question
stringlengths 58
4.29k
| label
class label 3
classes |
---|---|
the academic year begin lesson olympiad occupy free time it surprise today Olga fall asleep Literature she dream stair the stair consist n step the step number mean low step number 1 high step number n Above pointer direction Olga step as soon Olga go step direction pointer step leave change it mean direction change direction direction upolga move step direction show pointer step if Olga move stair fall wake move stair move step move mean nth step in second Olga move step accord direction pointer locate step Olga begin second for step find duration dream Olga step begin dreamOlgas fall take second step go wake second | 2string
|
there epidemic Monstropolis monster sick to recover monster line queue appointment doctor citysoon monster hungry begin eat one monster eat monster weight strictly great weight monster eat stand queue monster eat instantly there monster eat moment after monster a eat monster b weight monster a increase weight eat monster b in result eat length queue decrease monster eat step forward place queue a monster eat monster initially n monster queue ith weight aiFor example weight 122212 order queue monster number 1 6 leave right option monster can not eat second monster a11 great a22 second monster can not eat monst a22 great a32 second monster can not eat fifth monster neighbor second monster eat monster queue transform 32212 after time say good joke monster recover at moment k kn monster queue jth weight bj both sequences b contain weight monster order lastYou require provide possible order eat monster lead current queue determine happen assume doctor do not appointment monster eat | 1graph
|
one day Grasshopper jumping lawn find piece paper string Grasshopper interested minimum jump ability order able reach far end string jumping vowel english alphabet jump ability maximum possible length jump formally consider begginne Grasshopper locate directly leftmost character stre his goal reach position right rightmost character string in jump Grasshopper jump right distance 1 value jump ability the picture correspond example the follow letter vowel a e I o u Y | 1graph
|
Little Vlad fond popular computer game Bota2 recently developer announce new addon name Bota3 of course Vlad immediately buy find computer old new game need updatedThere n video card shop power ith video card equal integer value ai as Vlad want sure new game work want buy video card unite power cuttingedge technology to use technology card choose lead video card attach secondary for new technology work require power secondary video card divisible power lead video card in order achieve power secondary video card reduce integer value equal current power however power lead video card remain unchanged ie can not reducedvlad infinite money buy set video card help determine video card buy pick lead video card reduce power work maximum total value video power | 1graph
|
arseniy grownup independent his mother decide leave m day leave vacation she prepare lot food leave money wash Arseniys clothe ten minute leave realize useful prepare instruction particular clothe wear day absent Arseniys family bit weird clothe enumerate for example Arseniys n sock assign unique integer 1 n thus thing mother write integers li ri days index sock wear day obviously li stand leave foot ri right each sock paint k colorsWhen mother leave Arseniy notice accord instruction wear sock different color day of course terrible mistake cause rush arseniy smart boy magical coincidence posse k jar paint k colorsArseniy want repaint sock way m day follow mother instruction wear sock color as go busy day time change color sock finalize color nowthe new computer game Bota3 realise Arseniy can not wait play what minimum number sock need color change order possible follow mother instruction wear sock color m day | 2string
|
Grigoriy like hero famous comedy film find job night security guard museum at night receive embosser stock expositionembosser special devise allow print text plastic tape Text print sequentially character character the device consist wheel lowercase English letter write circle static pointer current letter button print choose letter at allow rotate alphabetic wheel step clockwise counterclockwise Initially static pointer point letter other letter locate show picture after Grigoriy add new item base print plastic tape attach correspond exhibit its require return wheel initial position pointer letter aOur hero afraid exhibit alive start attack want print name fast possible help give string find minimum number rotation wheel require print | 2string
|
polycarp start business tomorrow work day car repair shop for car repair shop small car repair give timepolycarp good marketing collect n request client the request number 1 n order camethe ith request characterize value si day client want start repair car di duration day repair car the day enumerate 1 day tomorrow second day day tomorrow onpolycarp make schedule processing request order nth request he schedule ith request follow if car repair shop idle di day start si sisi1sidi1 day repair car ith client Otherwise Polycarp find day x 1 di subsequent day repair schedule start x in word choose small positive x day xx1xdi1 schedule repair car so car ith client repair range xxdi1 it possible day x repair schedule start si give n request ask help polycarp schedule accord rule | 1graph
|
theater stage rectangular field size nm the director give stage plan actor follow for cell state plan actor cell notYou place spotlight stage good position the spotlight project light direction look stage leave right thus spotlight position cell place direction shinesA position good condition hold actor cell spotlight place actor direction spotlight project Count number good position place spotlight two position spotlight consider different location cell projection direction differ | 1graph
|
this interactive problem you use flush operation print line for example C use fflushstdout Java use Systemoutflush Pascal flushoutputin problem guess array unknown the information initially length n array aThe allow action ask sum element index formally print index j index distinct then program read response single integer equal aiajIt easy prove possible guess array n requestsWrite program guess array make n request | 1graph
|
Vasily exit store want recheck total price purchase bill the bill string name purchase price print row space check format name1price1name2price2namenpricen namei ith purchase nonempty string length 10 consist lowercase English letter pricei price ith purchase nonempty string consist digit dot decimal point it possible purchase equal name different pricesthe price purchase write follow format if price integer number dollar cent writtenotherwise number dollar dot decimal point write follow cent twodigit format number cent 1 9 inclusively lead zeroalso digit significant dollar separate dot decimal point no extra lead zero allow the price start digit end digitfor example 234 1544 14943110 099 12305 valid price 333 33311 1200 33 01234 12 valid Write program find total price purchase give bill | 1graph
|
you give table consist n row m columnsnumber row form permutation integer 1 mYou allow pick element row swap row also allow pick column swap thus allow perform 0 n1 action total Operations perform orderyou check possible obtain identity permutation 12 m row in word check perform operation follow give rule row sort increase order | 1graph
|
you give text consist n line each line contain spaceseparate word consist lowercase English lettersWe define syllable string contain exactly vowel arbitrary number possibly consonant in english alphabet follow letter consider vowel e o u yEach word text contain vowel divided syllable each character exactly syllable for example word mamma divide syllable ma mma mam ma mamm Words consist consonant ignoredthe verse pattern give text sequence n integer p1p2pn Text match give verse pattern 1 n divide word ith line syllable way total number syllable equal piYou give text verse pattern check give text match give verse pattern | 0array
|
Misha array integer length n he wants choose k different continuous subarray element array belongs choose subarraysMisha wants choose subarray way calculate sum element subarray add sum result value maximum possible | 2string
|
anatoly live university dorm student as know cockroache live student cockroache color black red there n cockroache live Anatolys roomanatoly cockroach form single line as perfectionist like color cockroache line alternate he black paint red paint in turn swap cockroache single cockroach change colorhelp Anatoly find minimum number turn need color cockroache line alternate | 1graph
|
during chemistry lesson Andrew learn saturate hydrocarbon alkane enter radical chlorination reaction Andrew curious boy wonder different product reaction form give alkane he manage solve task small molecule large one face difficulty ask helpformally give tree consist n vertex degree vertex do not exceed 4 you count number distinct nonisomorphic tree obtain add tree new vertex new edge graph tree degree vertex do not exceed 4two tree isomorphic exist bijection fv vertex u v connect edge vertex fv fu connect edge | 1graph
|
Cowboy Beblop funny little boy like sit computer he obtain elastic hoop shape 2D polygon necessarily convex since there s gravity spaceship hoop stand air since hoop elastic Cowboy Beblop stretch rotate translate shorten edge wantsfor hoop give number vertex position vertex define x Y Z coordinate the vertex give order they re connect 1stvertex connect 2nd connect 3rd etc vertex connect two hoop connect impossible pull infinity different direction manipulate edge have edge vertex intersect point like link chain connect the polygon edge intersect overlap to thing easy polygon wellconnecte edges polygon cross area polygon different direction upper low side plane define polygon different number timescowboy Beblop fascinated hoop obtain like know wellconnecte since he s busy play dog Zwei he d like figure he promise sweet help | 2string
|
welcome world Pokermon yellow little mouselike creature absolutely love playing poker yeah right in ensue Pokermon League n register Pokermon trainer t exist trainer team belong conference since lot jealousy trainer e pair trainer hate their hate mutual identical pair trainer hate world Pokermon joyful place each trainer wishlist length li team he d like joinYour task divide player team team conference trainer belong exactly team team conference total hate conference e2 trainer team wishlist total hate conference calculate number pair trainer team different conference hate | 1graph
|
Dexterina Womandark archrival they ve know since superintelligent teenage girl they ve try solve dispute peaceful nonviolent way after god know different challenge they ve give score equal they re desperately try good game wit this time Dexterina challenge Womandark game NimNim twoplayer game player turn remove object distinct heap on turn player remove object remove number object single heap the player can not turn lose by agreement size pile select randomly range 0x each pile size take independently probability distribution know start gamewomandark come brand new evil idea thwart Dexterinas plan have not get spare time she offer tip look fabulous exchange help win Nim your task tell probability player play win give rule | 1graph
|
ZS Coder code crazy computer if do not type word c consecutive second type disappear more formally type word second word second b bac new word append word screen if bac screen disappear word type appear screenfor example c5 type word second 138141920 second 8 3 word screen after disappear second 13 type at second 14 19 word type finally second 20 word type total 3 word remain screenyoure give time ZS Coder type word determine word remain screen finish type | 2string
|
ZS Coder love maze your job create play a maze consist nm room room arrange n row number start 1 m column number leave right start 1 the room ith row jth column denote ij a player start room 11 want reach room nmeach room door one maze border wall adjacent wall room share door some door lock mean impossible pass door for example door connect ij ij1 lock can not ij ij1 also travel room downwards room ij room i1j rightward room ij room ij1 provide corresponding door lock this image represent maze door lock the colored arrow denote possible path red cross denote lock door ZS Coder consider maze difficulty x exactly x way travel room 11 room nm two way consider different differ sequence room visit travellingyour task create maze difficulty exactly equal t in addition ZS Coder do not like large maze size maze number lock door limit sound simple right | 1graph
|
today hedgehog Filya go school time teacher give homework Filya unable complete helpfilya give array nonnegative integer a1a2an first pick integer x add x element array subtract x element change element he want element array equalnow wonder possible pick integer x change element array x order element equal | 2string
|
Owl Sonya decide partymaker to train role gather owl friend country house there m chair locate circle consequently number integer 1 m thus chair i1 neighbour 1 m1 Chairs 1 m neighbour some chair occupy friend there n friend total no friend occupy chair rule follow each participant remove game chair currently sit each participant choose direction follow clockwise index increase m go 1 counterclockwise index decrease 1 go m this direction coincide different pair owl each turn guest step choose direction if guest position chair remove chair game Game end chair leave game owl busy want rid game soon possible they cooperate pick direction your goal find minimum number o move require finish game | 1graph
|
Sonya unable think story problem come formal descriptionyou give array contain n positive integer at turn pick element increase decrease 1 the goal array strictly increase make minimum possible number operation you allow change element way negative equal 0 | 1graph
|
there n integer b1b2bn write row for 1 n value ai define crow perform follow procedure the crow set ai initially 0 the crow add bi ai subtract bi1 add bi2 number nth number thus aibibi1bi2bi3 memory give value a1a2an wants find initial number b1b2bn write row can | 1graph
|
ZS Coder Chris Baboon arrive Udayland they walk park n tree grow they decide naughty color tree park the tree number integer 1 n leave rightinitially tree color ci ZS Coder Chris Baboon recognize m different color 0cim ci0 mean tree uncoloredZS Coder Chris Baboon decide color uncolore tree ie tree ci0 they color m color 1 m color ith tree color j require exactly pij litre paintthe friend define beauty color tree minimum number contiguous group group contain subsegment tree split n tree group contain tree color for example color tree leave right 2111322313 beauty color 7 partition tree 7 contiguous group color 2111322313 ZS Coder Chris Baboon want color uncolored tree beauty color exactly k they need help determine minimum paint litre need finish jobPlease note friend can not color tree color | 2string
|
ZS Coder Chris Baboon travel Udayland to special ioi bus the IOI bus n row seat there 4 seat row seat separate pair walkway when ZS Chris come places bus occupiedZS Chris good friend they insist pair neighbouring seat two seat consider neighbouring row pair give configuration bus help ZS Chris determine sit | 2string
|
the king stand standard chess board you give position format cd c column h d row 1 8 find number move permit kingCheck king move httpsenwikipediaorgwikiking_chess King move position e4 | 1graph
|
Masha want open bakery bake muffin n city number 1 n there m bidirectional road connect pair citiesTo bake muffin bakery Masha need establish flour supply storage there k storage locate different city number a1a2akunforunately law country Masha live prohibit open bakery city storage locate she open nk city course flour delivery pay kilometer path storage bakery Masha pay 1 rubleformally Masha pay x rouble open bakery city b aib 1ik choose storage city s saj 1jk b s connect path road summary length x path Masha able choose usedMasha thrifty rational she interested city open bakery choose k storage path city bakery city storage pay minimum possible ruble flour delivery please help Masha find | 1graph
|
Vasiliy like rest hard work meet bar nearby as programmer love famous drink Beecola buy n different shop city its know price bottle shop equal xi coinsVasiliy plan buy favorite drink q consecutive day he know ith day able spend mi coin now day want know different shop buy bottle Beecola | 1graph
|
Vasiliy live point ab coordinate plane he hurry work want house soon possible New app suggest n available Berutaxi nearby the ith taxi locate point xiyi move speed vi consider n driver directly vasiliy maximum possible speed Compute minimum time Vasiliy Berutaxi car | 1graph
|
you give functional graph it direct graph vertex go exactly arc the vertex numerate 0 n1graph give array f0f1fn1 fi number vertex go arc vertex besides give array weight arcs w0w1wn1 wi arc weight fi the graph sample test also give integer k length path need find vertex number si mi si sum weight arcs path length equal k starts vertex mi minimal weight arc path length k start vertex the length path number arc path | 1graph
|
on vacation n pupil decide excursion gather they need overcome path length l meter each pupil speed equal v1 to excursion quickly decide rent bus seat k people mean can not fit k people time speed equal v2 in order avoid seasick pupil want bus oncedetermine minimum time require n pupil reach place excursion consider embarkation disembarkation passenger reversal bus place immediately time neglect | 0array
|
a tree undirecte connect graph cycleslet consider root undirected tree n vertex number 1 n there way represent tree one way create array n integer p1p2pn pi denote parent vertex convenience root consider parent for rooted tree array p 2332 give sequence p1p2pn able restore tree there exactly index r prr a vertex r root tree for n1 vertex edge vertex vertex pi a sequence p1p2pn call valid describe procedure generate rooted tree for example n3 sequence 122 231 213 validYou give sequence a1a2an necessarily valid your task change minimum number element order valid sequence print minimum number change example valid sequence number change if valid sequence achievable minimum number change print | 2string
|
Barney hang Nora think feeling Barney wants send cheesy text message want happy possible initially happiness level Nora 0 Nora love pickup line like I m fall stuff totally know n pickup line consist lowercase English letter equal write different pronouncing meaning every time Nora see ith pickup line consecutive subsequence Barneys text message happiness level increase ai these substring overlap example Nora pickup line aa twice pickup line ab text message aaabdue texte app limit Barneys text l charactersbarney ask help Nora happy possible go to legen | 1graph
|
barney live NYC NYC infinite number intersection number positive integer start 1 there exist bidirectional road intersection 2i road 2i1 positive integer you clearly exist unique short path intersection initially pass road free but slapsgive ahead q consecutive event happen soon there type events1 government make new rule a rule denote integer v u w as result action pass fee road short path u v increase w dollar 2 Barney start move intersection v go intersection u there s girl want cuddle fake Lorenzo Von Matterhorn he use short path visit minimum number intersection road intersectionsgovernment need calculation for time Barney go cuddle girl need tell government money pay sum passing fee road pass | 1graph
|
you give permutation number 12n m pair position ajbjAt step choose pair give position swap number position what lexicographically maximal permutation getLet p q permutation number 12n p lexicographically small q number 1 in exist pkqk 1ki piqi | 2string
|
you give positive decimal number xYour task convert simple exponential notationlet xa10b 1a10 general case simple exponential notation look like aeb if b equal zero Eb skip if integer write decimal point also extra zero b | 1graph
|
Heidi get tired decipher prophecy hide Tree Life decide headquarters rest little try of course uproot tree draw Tree piece paper on second thought identical drawing n total n number vertex Tree Life know happenindee way Heidi ambush group zombie while manage fend damage drawing peculiar way ith copy vertex number remove adjacent edge in picture zombie erase vertex number relabele remain n1 vertex arbitrarily number 1 n fortunately vertex distinct number what s drawing arbitrarily shuffledreorderedNow Heidi want recover Tree Life description drawing list edge | 1graph
|
Heidi Cow aghast crack northern Wall Zombies gather outside form group prepare assault this happen quickly fetch HC2 Handbook Crazy Constructions look right chapterHow build wall take set brick Select possible wall design computing number possible design leave exercise reader Place brick accord choose design this easy but Heidi Coding cow construct cow her mind keep come point 2b despite imminent danger zombie onslaught wonder possible wall build n bricksA wall set wall segment define easy version how different wall construct wall consist 1 n brick two wall different exist column c row r wall brick spot notalong n give C width wall define easy version return number different wall modulo 1063 | 2string
|
break news zombie neurology it turn contrary previous belief zombie bear single brain later evolve complicated brain structure in fact zombie consume brain new brain appear nervous system gets immediately connect exist brain single brain connector researcher interest monitoring brain latency zombie your task write program give history evolution zombie nervous system compute brain latency stage | 1graph
|
now Heidi sure Zombie Contamination level checker work time strike this time zombie lair strictly convex polygon lattice each vertex polygon occupy point lattice for cell lattice Heidi know level Zombie Contamination number corner cell inside border lairGiven information Heidi want know exact shape lair rain destruction zombie help | 2string
|
Heidi get brain thumb but evening is not challenge await dauntless agent dinner precisely midnight n attendee love play risky gameevery zombie get number ni 1nin write forehead although zombie number number write forehead N1 fellow note number unique from point communication zombie allow observation key success when cuckoo clock strike midnight attendee simultaneously guess number forehead if guess number correctly zombie survive home happily on hand single attendee manage guess number correctly doom diezombie are not bright creature Heidi act fast want jeopardize life she single option perform quick surgery brain manage chest ability remotely reprogram decisionmake strategy attendee upcoming midnight game can suggest sound strategy Heidi give rule game ensure attendee guess number correctly possible sequence number foreheadsGiven zombie rank R n1 number ni attendee forehead program return number zombie rank r shall guess those answer define strategy check flawless | 1graph
|
tonight brain dinner night zombie gather scarf delicious brain the artful Heidi plan crash party incognito disguise her objective away brain analyze zombie mindset home gain strategic advantagethey n guest tonight n1 real zombie fake Heidi the livingdead love hierarchy love brain unique rank range 1 n1 Heidi appear slightly different attribute high rank N tonight chest brain display attendee see these split attendee accord follow procedureThe zombie high rank make suggestion get brain brain indivisible entity a vote follow if half attendee accept offer brain share suggest way feast begin but majority reach highestranke zombie kill zombie hierarchy suggestion if kill highestranke make etc its exactly half vote case tie vote highestranke alive zombie count twice course vote favor suggestion order stay aliveyou know zombie greedy sly know basically zombie brain alike Consequently zombie accept offer suboptimal that offer strictly well potential late offer vote and mistake zombie normally dull tonight intellect perfect each zombie priority tonight descend order survive event experience death know fun brain possible Heidi go offer half attendee accept allocate brain Heidi herselfwhat small number brain chest possible | 1graph
|
Arya n opponent school each day fight opponent present day his opponent fight plan guarantee win implement plan require presence that mean day Aryas opponent absent school Arya beat present opponent Otherwise opponent present beat AryaFor opponent Arya know schedule go present particular day tell maximum number consecutive day beat present opponentsnote day opponent present Arya consider beat present opponent | 1graph
|
Pari want buy expensive chocolate Arya she n coin value ith coin ci the price chocolate k Pari subset coin sum equal k AryaLooking coin question come mind give coin Arya value Arya she jealous do not want Arya lot value so want know value x Arya able x subset coin sum kFormally Pari want know value x exist subset coin sum k subset subset sum x ie exist way pay chocolate Arya able sum x coin | 2string
|
recently Pari Arya research NPHard problem find minimum vertex cover problem interestingsuppose graph g give Subset a vertex call vertex cover graph edge uv endpoint set ie bothpari Arya win great undirected graph award team contest now split part want part graph vertex coverthey agree graph need find disjoint subset vertex a B A b vertex cover claim impossible each vertex give friend | 2string
|
after piece devilish mirror hit Kays eye long interested beauty rose now like watch snowflakesonce time find huge snowflake form tree connect acyclic graph consist n node the root tree index 1 Kay interested structure treeAfter research form q query interested the ith query ask find centroid subtree node vi your goal answer queriesSubtree node tree consist node descendant direct in word subtree node v form node u node v present path u rootCentroid tree subtree node erase tree maximum size connect component time small size initial tree subtree | 1graph
|
on coordinate plane square side parallel coordinate axis the length square equal the low left corner square coincide point 00 point origin the upper right corner square positive coordinatesyou give point coordinate x y your task determine point locate strictly inside square strictly outside square | 1graph
|
after finish eat bun Alyona come integer n m she decide write column integer column contain integer 1 n second contain integer 1 m now girl want count pair integer choose column second column sum divisible 5formally Alyona want count number pair integer xy 1xn 1ym equal 0As usual Alyona trouble ask help | 1graph
|
Dima live dormitory cockroachesAt moment 0 Dima see cockroach running table decide kill Dima need exactly t second aim precisely strike cockroach finish itTo survive cockroach run shadow cast round plate stand table T second Shadow casted plate shape circle Shadow circle intersect nest overlap arbitrarilythe cockroach use follow strategy equiprobably pick direction run run constant speed v if moment tt reach shadow circle immediately stop shadow stay alive Otherwise cockroach kill Dimas precise strike consider Dimas precise strike instantdetermine probability cockroach stay alive | 1graph
|
consider linear function fxAxB Lets define g0xx gnxfgn1x n0 for give integer value A B n x find value gnx modulo 1097 | 1graph
|
Mary graduate wellknown University attend celebration party student like dream beautiful life champagne glass construct small pyramid the height pyramid n the level consist 1 glass stand 2 glass second level count 3 glass level onthe level consist n glassesvlad see movie time champagne beautifully flow level one fill glass simultaneously so take bottle start pour glass locate pyramidEach second Vlad pour glass champagne equal size exactly glass if glass champagne flow pour edge glass equally distribute glass stand if overflow glass level champagne pour table for purpose problem consider champagne distribute pyramid glass immediately Vlad interested number completely glass stop pour champagne t secondspicture illustrate pyramid consist level | 0array
|
there n problem prepare Codeforces round they arrange ascending order difficulty problem difficulty moreover m pair similar problem author want split problem division accord follow rule Problemset division nonempty each problem exactly division yes unusual requirement each problem division 1 hard problem division 2 if problem similar different division your goal count number way split problem division satisfy rule two way split problem consider different problem belong division 1 division 2 otherNote relation similarity transitive that problem similar problem j problem j similar problem k do not follow similar k | 2string
|
Yasin array contain n integer Yasin 5 year old love ultimate weird thingsyasin denote weirdness array maximum gcdaiaj value 1ijn for n1 weirdness equal 0 gcdxy great common divisor integer x yHe define ultimate weirdness array Ultimate weirdness fij weirdness new array obtain remove element j inclusive new array a1 ai1aj1 ansince 5 year old boy can not code Yasin ask help find value ultimate weirdness give array | 1graph
|
Vasya decide pass large integer n Kate First write number string append right integer k number digit n Magically number shuffle arbitrary order note pass Kate the thing Vasya remember nonempty substre n substre n sequence consecutive digit number nVasya know way restore number n your task find small possible initial integer n note decimal representation number n contain lead zeroes case integer n equal zero case single digit 0 | 1graph
|
this problem give version differ constraint if solve problem large constraint write single solution version if find problem difficult large constraint write solution simplify version onlywake morning Apollinaria decide bake cookie to bake cookie need n ingredient ingredient know value ai grams ingredient need bake cookie to prepare cookie Apollinaria need use n ingredientsapollinaria bi gram ith ingredient also k gram magic powder each gram magic powder turn exactly 1 gram n ingredient bake cookiesyour task determine maximum number cookie Apollinaria able bake ingredient magic powder | 2string
|
Moscow host major international conference attend n scientist different country each scientist know exactly language for convenience enumerate language world integer 1 109in evening conference n scientist decide cinema there m movie cinema come each movie characterize distinct number index audio language index subtitle language the scientist come movie pleased know audio language movie satisfied know language subtitle satisfied know note audio language subtitle language movie different scientist decide movie you help choose movie number please scientist maximum possible if movie select maximize number satisfied scientist | 1graph
|
as know cubism trend art problem construct volumetrical shape plane combination threedimensional geometric shape come fore a famous sculptor Cicasso selfportrait contemplate hate cubism he impress idea transmit twodimensional object threedimensional object magnificent sculpture and new project connect Cicasso want coat hater anticubism to want create sculpture depict wellknown geometric primitive convex polygoncicasso prepared blank rod integer length wants bring the ith rod segment length liThe sculptor plan convex polygon nonzero area rod side each rod length it forbid cut break bend rod however side form straight angle Cicasso know impossible convex polygon nonzero area rod length choose Cicasso want leave unused rod sculptor decide rodblank integer length problem solvable of course want short possible material expensive improper deed spend money help sculptor | 1graph
|
a famous sculptor Cicasso go world tourwell actually worldwide but opportunity work sculptor should not otherwise exclusivity so Cicasso entirely hold world tour native country BerlandCicasso devoted work want distract little possible therefore visit city these city different think favourite of course save money choose short path city but probably guess Cicasso weird person although do not like organize exhibition like travel country enjoy scenery so want total distance travel large possible however sculptor bad planning ask help there n city m oneway road Berland you choose different city Cicasso visit determine order visit so total distance travel visit city order start city list end choose time short route pair city large note intermediate route pass city assign tour pass twice city for example tour look like four city order visit marked overline 1524note Berland hightech country so nanotechnology road alter length for reason move regular car popular country happen pair city generally reach car however Cicasso conservative travel car Choose city sculptor tour automobile it guarantee possible | 2string
|
if integer divisible integer b b call divisor aFor example 12 positive 6 divisor they 1 2 3 4 6 12lets define function Dn number integer 1 n inclusive exactly positive divisorsbetween 1 10 integer 6 8 10 exactly positive divisor so d103you give integer n you calculate Dn | 1graph
|
Ayush cashier shopping center recently department start click collect service allow user shop online the store contain k item n customer service each user pay m item let aij denote jth item ith person orderdue space limitation item arrange single row when Ayush receive ith order find item aij 1jm row Let posx denote position item x row moment collection then Ayush take time equal posai1posai2posaim ith customerwhen Ayush access xth element keep new stock row take away xth element Thus value updatingyour task calculate total time take Ayush process ordersyou assume market endless stock | 2string
|
great common divisor GCDab positive integer b equal big integer d integers b divisible d there efficient algorithm find great common divisor GCDab example Euclid algorithm Formally find big integer d integer aa1a2b divisible d to problem complicate allow b googol 10100 number fit 64bit integer type | 1graph
|
consider regular Codeforces round consist problem use dynamic scoringyou give final scoreboard for participant include time accept submission problem give also solution know able hack the change scoreboard happen end round challengeswhat good place endmore formally n people participate include for problem solve exactly k people end round maximum score problem define if n2k2n maximum possible score 500 if n4k2n maximum possible score 1000 if n8k2n maximum possible score 1500 if n16k2n maximum possible score 2000 if n32k2n maximum possible score 2500 if 32kn maximum possible score 3000 let maximum possible score problem equal s then contestant do not manage accepted solution hack earn 0 point problem if got solution accept t minute begin round solution was not hack earn point problemthe overall score participant equal sum point earn problem plus 100 point successful hack hacksthe result place equal plus number participant who s overall score strictly great | 1graph
|
you give integer b ab how prime number interval b inclusive | 1graph
|
lazy caterer sequence define maximum number piece form slice convex pancake n cut cut straight line the formula Cnnn121 you give n calculate nth element sequence | 2string
|
you give array n element coprime array move possibleIn insert positive integral number want great 109 place arrayAn array coprime adjacent number coprimein number theory integer b say coprime positive integer divide 1 | 1graph
|
you give complete undirected graph for pair vertex give length edge connect find short path pair vertex graph return length long | 1graph
|
Pussycat Sonya array consist n positive integer there 2n possible subsequence array for subsequence count minimum number operation element equal each operation choose element subsequence multiply prime number Choose element subsequence divide prime number the choose element divisible choose prime number what sum minimum number operation 2n possible subsequence find print sum modulo 1097 | 1graph
|
Alex programming Valentina toddler daughter got start ask question round bracket parenthesis code he explain bit got give task order finish code timeFor purpose problem consider string consist opening close round bracket character the sequence bracket call correct correct sequence bracket enclose pair open closing bracket concatenation correct sequence bracket for example sequence correct notAlex take piece paper write string s consist bracket ask Valentina count number distinct nonempty substring s correct sequence bracket in word task count number nonempty correct sequence bracket occur stre s substring do not mix subsequenceswhen Valentina finish task Alex notice do not know answer help do not loose face Valentina solve problem | 1graph
|
my James diGriz I m clever robber treasure hunter galaxy there book write adventure song operation able catch pretty awkward momentI able hide camera outsmart guard pass numerous trap I finally reach treasure box open I accidentally start clockwork bomb luckily I meet kind bomb I know clockwork mechanism stop connect contact wire control panel bomb certain mannerI n contact connect n1 wire contact number integer 1 n Bomb security mechanism ensure follow condition exist k2 contact c1c2ck form circuit e exist k distinct wire contact c1 c2 c2 c3 ck c1 bomb immediately explode story end in particular contact connect wire form circuit length 2 it prohibit connect contact itselfon hand I disconnect wire e moment n2 wire scheme security check fail bomb explode so thing I unplug wire plug new place ensure fact circuit appearI know I wire order stop clockwork but time run help alive find sequence operation consist unplug wire put place bomb defuse | 1graph
|
there website accessible different address for example long time codeforce accessible hostname codeforcescom codeforcesruYou give list page address query for simplicity consider address form httphostnamepath hostname server consist word maybe dot separate path optional path consist word separate slash we consider hostname correspond website query hostname exactly query second vice versa query second hostname query take look sample clarificationsyour goal determine group server name correspond website Ignore group consist server nameplease note accord definition query httphostname httphostname different | 0array
|
radewoosh play computer game there n level number 1 n Levels divide k region group each region contain positive number consecutive levelsthe game repeat follow process if region beat game end immediately Otherwise system find region nonbeaten level Let x denote region the system create bag token each token represent level token represent level for beat level region x system add ti tokens bag token represent ith level let j denote nonbeaten level region x the system add tj tokens bag Finally system take uniformly random token bag player start level represent token a player spend hour beat level beat past Given n k value t1t2tn task split level region each level belong exactly region region contain nonempty consecutive set level what minimum possible expect number hour require finish game | 2string
|
Little Artyom decide study probability theory he find book lot nice exercise want help themconsider dice when throw dice show integer 1 n inclusive for dice probability outcome give course sum 1 different dice different probability distributionsWe throw dice simultaneously calculate value maxab minab equal outcome dice b equal outcome second dice you do not know probability distribution particular value dice know probability distribution maxab minab that x 1 n know probability maxab equal x probability minab equal x find valid probability distribution value dice its guarantee input datum consistent solution exist | 1graph
|
Little Artem find grasshopper he bring house construct jumping area himThe area look like strip cell 1n each cell contain direction jump length jump Grasshopper start cell follow instruction write cell Grasshopper stop immediately jump strip now Artem wants find happen | 1graph
|
codeforce wonderful platform feature show contribute community every register user contribution integer number necessarily positive there n register user ith contribution tilimak little polar bear he s new competitive programming he do not account Codeforces able upvote exist blog comment we assume register user infinitely blogs comment Limak spend b minute read blog upvote Authors contribution increase 5 Limak spend c minute read comment upvote Authors contribution increase 1 note possible Limak read blog fast commentslimak like tie he think awesome tie k register user to happen go spend time read upvote after exist integer value x k register user contribution exactly xHow time Limak need achieve goal | 2string
|
Limak little polar bear he do not toy play polynomialshe consider polynomial valid degree n coefficient integer exceed k absolute value More formallylet a0a1an denote coefficient then polynomial Px valid follow condition satisfied ai integer aik an0 Limak recently get valid polynomial p coefficient a0a1a2an he notice P20 want change he go change coefficient valid polynomial Q degree n Q20 Count number way you count way distinct coefficient target polynom differ | 1graph
|
in Berland n city n1 bidirectional road each road connect pair city city give roadsIn city exactly repair brigade to repair road need team base city connect road work simultaneously day both brigade repair road day repair road day but repair brigade daydetermine minimum number day need repair road the brigade change city initially | 1graph
|
polycarp big lover kill time social network a page chatlist favourite network message send friend friend chat rise page the relative order chat do not change if chat friend new chat simply insert listassume chat list initially give sequence Polycaprus message list chat message process Assume friend write message Polycarpus | 2string
|
Paul orchestra the string section arrange rc rectangular grid fill violinist exception n violist Paul like viola like picture include k Paul picture axisparallel rectangle orchestra Count number possible picture Paul taketwo picture consider different coordinate correspond rectangle different | 1graph
|
Alice Bob tree undirecte acyclic connect graph there ai chocolate waiting pick ith vertex tree first choose different vertex start position Alice choose chocolate contain themThen alternate move select vertex time collect chocolate node to thing interesting decide select vertex heshe select vertex adjacent hisher previous turn vertex choose moveif moment able select node satisfy rule heshe skip turn let person pick chocolate long heshe this go pick chocolate furtherDue greed chocolate want collect chocolate possible however friend care total number chocolate obtain what maximum total number chocolate pick | 2string
|
Yash recently learn Fibonacci sequence excite he call sequence Fibonacciish sequence consist element f0 f1 arbitrary fn2fn1fn n0 you give sequence integer a1a2an your task rearrange element sequence way long possible prefix fibonacciish sequence | 1graph
|
Mr Santa ask great programmer world solve trivial problem he give integer m ask number positive integer n factorial n end exactly m zero Are great programmer solve problem | 1graph
|
Grandma Laura come market sell apple during day sell apple but grandma old forgot apple bring marketshe precisely remember n buyer buy exactly half apple moment purchase give half apple gift number apple moment purchase odd sell apple hadSo buyer take integral positive number apple maybe do not pay half apple number apple moment purchase oddfor buyer grandma remember give half apple gift the cost apple p number p evenprint total money grandma end day check buyer cheat | 1graph
|
each month Blake get report contain main economic indicator company Blake Technologies there n commodity produce company for exactly integ final report denote correspond revenue before report get Blake pass hand m manager each reorder element order Namely ith manager sort ri number nondescende nonascending order pass report manager i1 directly Blake manager number imemployee Blake Technologies prepare report right you know initial sequence ai length n description manager value ri favourite order you ask speed process determine final report look like | 2string
|
Blake CEO large company call Blake Technologies he love company think company well that candidate need pass interview consist follow problemWe define function fxlr bitwise or integer xlxl1xr xi ith element array x you give array b length n you need determine maximum value sum falrfblr possible 1lrn | 2string
|
Vasya start work machine vision company IT City Vasyas team create software hardware identification people faceOne project knowhow camera rotate optical axis shoot People eyecatche gadget rotate camera come well look and camera take photo time what well high quality identificationBut simple the picture camera appear rotate clockwise camera rotation frame content rotate counterclockwise but identification algorithm work face slightly deviate verticalVasya entrust correct situation rotate capture image image minimally deviate vertical Requirements severe Firstly picture rotate angle divisible 90 degree lose bit information image secondly frame camera huge FPS big adequate rotation speed provide hardware fpga solution and solution rotate 90 degree clockwise of course apply 90 degree turn times sake performance number turn minimizedhelp Vasya implement program give rotation angle camera determine minimum number 90 degree clockwise turn necessary picture direction deviation vertical minimumthe figure contain frame take unrotated camera rotate 90 degree clockwise rotate 90 degree counterclockwise Arrows direction true the figure show 90 degree clockwise turn FPGA hardware | 1graph
|
the city administration IT City decide fix symbol scientific technical progress city main square indicator board show effect Moores law real timemoore law observation number transistor dense integrate circuit double approximately 24 month the implication Moores law computer performance function time increase exponentially wellyou prepare information change second display indicator board Lets assume second number transistor increase exactly 1000000011 time | 1graph
|
Famil Door want celebrate birthday friend Far far away he n friend come party specific range day year ai bi of course Famil Door want friend celebrate possiblefar car weird far far away citizen carry people opposite gender exactly male female however far far transportation partyfamil Door select day year invite friend available moment number male friend invite equal number female friend invite Find maximum number friend present party | 1graph
|
door family go celebrate Famil Doorss birthday party they love Famil Door plan birthday cake weirdThe cake nn square consist equal square length 1 each square consist single chocolate they buy cake randomly start chocolate cake the value Famil door happiness equal number pair cell chocolate row column cake Famil Doorss family wonder happiness Famil go beplease note pair count different cell can not share row column | 1graph
|
there n student class work group project the student divide group student group work independent piece discuss result it take ith student ai minute finish hisher independent pieceif student work different pace frustrating fast student stressful slow one in particular imbalance group define maximum ai group minus minimum ai group Note group contain single student imbalance 0 how way student divide group total imbalance group kTwo division consider distinct exist pair student work group division different group | 1graph
|
Luke Skywalker got lock rubbish shredder press r2d2 work rescue Luke need stay alive long possible for simplicity assume happen straight line press initially coordinate 0 l speed v1 v2 respectively Luke width d able choose position press Luke die soon distance press width your task determine long Luke stay alive | 0array
|
tree connected graph cycle a leaf tree vertex connect exactly vertexyou give tree n vertex root vertex 1 there ant leaf tree in second ant simultaneously parent vertex vertex no ant vertex simultaneously root treefind minimal time require ant root tree note start ant leave tree | 2string
|
Wet Shark ask Rat Kwesh generate positive real number x y z 01 2000 inclusive Wet Krash want impress Wet Shark generate number exactly digit decimal pointwet Shark know Rat Kwesh want lot cheese so Rat opportunity earn lot cheese he hand number x y z Rat Kwesh Rat Kwesh pick option a1xyz a2xzy a3xyz a4xzy a5yxz a6yzx a7yxz a8yzx a9zxy a10zyx a11zxy a12zyx let m maximum ai c small index 1 12 acm rat goal find c ask help Rat Kwesh want cheese get print expression corresponding ac | 1graph
|
today Wet Shark give n integer use integer Wet Shark want maximum possible divisible 2 sum please calculate value Wet Shark Note Wet Shark use integer n integer sum integer 0 | 1graph
|
Professor GukiZ array integer b Professor want sum element array sa close possible sum element array b sb so want minimize value vsasbIn operation professor swap element array element array b for example array 51324 array b 332 professor swap element 5 array element 2 array b new array 21324 new array b 335professor do not want swap find minimal value v sequence swap lead value v Professor make swap new swap make new array b | 2string
|
there n pearl row Lets enumerate integer 1 n leave right the pearl number type ailet sequence consecutive pearl segment Lets segment good contain pearl typesplit row pearl maximal number good segment note pearl appear exactly segment partitionAs inputoutput reach huge size recommend use fast inputoutput method example prefer use scanfprintf instead cincout c prefer use bufferedreaderprintwrit instead ScannerSystemout Java | 1graph
|
you give multiset a b each multiset exactly n integer 1 n inclusive Multisets contain multiple copy numberyou like find nonempty subset a nonempty subset b sum element subset equal Subsets multiset ie contain element equal valuesif solution exist print 1 otherwise print index element subset a b sum | 1graph
|
your friend recently give slime birthday you n slime initially value 1you go play game slime initially single slime row then add n1 slime when add slime place right place slime then slime row value v combine create slime value v1you like final state row you ve add n slime please print value slimes row leave right | 2string
|
there point mark coordinate plane the goal simple polyline selfintersection selftouche pass point also polyline consist segment parallel coordinate axis you find minimum number segment polyline consist | 1graph
|
you give n string ti each string cost cilet define function stre psi number occurrence s ti s length string s find maximal value function fs stringsnote string s necessarily stre t | 2string
|