question
stringlengths 58
4.29k
| label
class label 3
classes |
---|---|
let define string x opening tag x small letter latin alphabet each opening tag match closing tag type x x letterTegs nest case open closing tag pair locate inside pairlet define notion XMLtext string XMLtext s XMLtext sasa XMLtext small latin letter s1 s2 XMLtexts s1s2 XMLtext you give XMLtext guarantee text valid task print follow form tag opening closing locate single line print tag 2h space h level tag nestedness | 1graph
|
Petr stand line n people do not know exactly position occupy he people stand b people stand find number different position Petr occupy | 2string
|
you give stre s each pair number l r fulfill condition 1lrs correspond substre string s start position l end position r inclusivelet define function string Fxy like well find list pair number correspond substring string x equal string y Lets sort list pair accord pair number increase the value function Fxy equal number nonempty continuous sequence listfor example Fbabbabbababbabbabb6 the list pair follows1447912its continuous sequence 14 47 912 1447 47912 1447912 your task calculate give string s sum Fsx x x belong set substring string s | 2string
|
petya love lucky number everybody know lucky number positive integer decimal representation contain lucky digit 4 7 for example number 47 744 4 lucky 5 17 467 notPetya array consist n number he want perform m operation type add l r d add integer d element index belong interval l r inclusive 1lrn1d104 count l r find print screen lucky number element index belong interval l r inclusive 1lrn each lucky number count times appear interval petya list operation the operation addition array will not number exceed 104 help Petya write program perform operation | 1graph
|
three son inherit father rectangular corn fiend divide nm square for square know ton corn grow the father old farmer love son equally bequeath divide field part contain a b c ton cornthe field divide parallel line the line parallel field the line strictly square field each result field consist square your task find number way divide field describe mark line divide field part result part grow a ton corn b c remain | 1graph
|
let s string length equal n its character number 0 n1 j integer 0ijn Lets define function f followsfsijsi1 j1rsj n1rs0 iHere sp q substre string s start position p end position q inclusive string concatenation operator rx string result write character x string reverse order if ji1 substre si1 j1 consider emptyyou give string b find value j faijb Number maximally possible if exist valid value j choose minimal j | 1graph
|
yet education system reform carry Berland recently the innovation followsan academic year consist n day each day pupil study exactly m subject subject study day after lesson ith subject pupil home task contain ai bi exercise besides subject special attribute complexity ci a school timetable consider follow condition satisfied timetable contain subject order complexity strict increase day task contain k times exercise k compare previous day formally let number home task exercise ith day xi 1 in xikxi1 xikxi1 true total number exercise home task maximal possible all limitation separately set schoolIt turn case ai bi reach 1016 Berland Minister Education famous love halfmeasure value biai do not exceed 100 that happen Berland School 256 nevertheless school principal work timetable academic year | 1graph
|
Linear Kingdom exactly tram line it n stop number 1 n order trams movement at ith stop ai passenger exit tram bi passenger enter the tram arrive stop also tram arrive stop passenger exit emptyyour task calculate tram minimum capacity number people inside tram time exceed capacity note stop exit passenger exit enter passenger enter tram | 1graph
|
petya get interested grammar year school he invent language call Petyas Petya wanted create maximally simple language chat friend that s language grammar describe follow set rule there part speech adjective noun verb each word language adjective noun verb There gender masculine feminine each word language gender masculine feminine masculine adjective end lios feminine adjective end liala Masculine noun end etr feminime noun end etra Masculine verb end initis feminime verb end inite thus word Petyas language ending give there ending Petyas language it accept word consist end that word lio liala etr belong Petyas language there are not punctuation mark grammatical tense singularplural form language complication a sentence exactly valid language word exactly statement Statement sequence Petyas language satisfy condition words statement follow follow order leave right zero adjective follow exactly noun follow zero verb all word statement genderafter Petyas friend Vasya write instant messenger instant messaging program support Petyas language Petya want add spelling grammar checking program as Vasya country Petya do not feel like wait ask help problem your task define give sequence word true give text represent exactly sentence Petyas language | 0array
|
little Petya love inequation help find n positive integer a1a2an follow condition satisfy a12a22an2x a1a2any | 2string
|
petya love lucky number we know lucky number positive integer decimal representation contain lucky digit 4 7 for example number 47 744 4 lucky 5 17 467 notPetya friend Vasya play interesting game Petya randomly choose integer p interval plpr Vasya choose integer v interval vlvr randomly both player choose integer equiprobably find probability interval minvpmaxvp contain exactly k lucky number | 1graph
|
Tattah asleep Tattah attend lecture this wellknown formula Tattahs colleagueson Wednesday afternoon Tattah attend Professor HHs lecture at 1221 right fall asleep stare digital watch Sahers wrist he notice digit clock read direction ie palindromein sleep start dream rare moment day time display digital clock palindrome as soon wake felt destine write program find momentHowever have not master skill programming sleep task help | 1graph
|
in year 2500 annual graduation ceremony German University Cairo GUC run smoothly 500 year farthe important ceremony relate arrangement professor ceremonial halltraditionally GUC n professor each professor seniority level all seniority different Lets enumerate professor 1 n 1 senior professor n junior professorthe ceremonial hall n seat seat professor some place hall mean senior professor more specifically m pair seat seniorjunior relation tradition require m pair seat aibi professor seat senior position ai senior professor seat junior position biGUC strict tradition carefully observe start year 2001 the tradition require the seat professor change year Year 2001 ceremony lexicographically arrangement professor ceremonial hall each consecutive year lexicographically arrangement professor the arrangement professor list n integer integer seniority professor seat position number second integer seniority professor seat position number etcGiven n number professor y current year m pair restriction output arrangement professor year | 2string
|
as German University Cairo GUC student basketball player Herr Wafa delight hear news GUC finally participate Annual Basketball Competition ABC a team form n player guc student however team player belong different department there m department GUC number 1 m Herr Wafas department number h for department Herr Wafa know number si student play basketball belong departmentHerr wafa able guarantee spot team special power but hate floatingpoint number need help find probability teammate belong department Note possible team contain Herr Wafa equally probable consider student different | 1graph
|
lavrenty baker go bun stuffings sell themLavrenty n gram dough m different stuffing type the stuffing type numerate 1 m Lavrenty know ai gram leave ith stuff it take exactly bi gram stuff ci gram dough cook bun ith stuff such bun sell di tugriksalso bun stuffings each bun require c0 gram dough sell d0 tugrik so Lavrenty cook number bun different stuffing run dough stuffing Lavrenty throw away excess material leave bakingfind maximum number tugriks Lavrenty earn | 1graph
|
each item game level the high level high basic parameter item we shall consider follow basic parameter attack atk defense def resistance different type impact resEach item belong class in problem consider class weapon armor orbbesides there s new world hide inside item we increase item level travel world we capture socalle resident Item WorldResidents creature live inside item each resident give bonus item currently locate we consider resident type gladiator improve item atk sentry improve def physician improve reseach item size parameter the parameter limit maximum number resident live inside item we resident item within moment time resident item item free place new resident we remove resident item leave outside inside item moment timeLaharl certain number item he want resident item equip weapon armor defensive orb the weapon atk large possible end among equip pattern contain weapon maximum atk parameter choose one armor def parameter large possible among equipment pattern choose defensive orb large possible res parameter Values parameter def re weapon atk re armor atk def orb indifferent LaharlFind optimal equipment pattern Laharl | 2string
|
in Disgaea roleplaying game character skill determine character ability use certain weapon spell if character necessary skill use the skill level represent integer increase use skill different character class characterize different skill unfortunately skill uncommon give character class difficult obtain to avoid limitation socalle transmigration Transmigration reincarnation character new creature his soul shift new body retain experience previous life as result transmigration new character get skill old character skill level reduce accord k coefficient skill level equal x transmigration equal kx y integral y if skill level strictly 100 skill forget character after new character gain skill specific class new the level additional skill set 0 thus create character skill specific completely different character class transmigration for example create mage archer thief warrior possible you suggest solve follow problem skill character transmigration level skill | 1graph
|
after event Orlando know Sasha Roma decide find team big loser Thankfully Masha find revolver rotate cylinder n bullet slot able contain exactly k bullet boy chance resolve problem Sasha select k n slot wish put bullet Roma spin cylinder n possible cylinder shift equiprobable then game start player turn Sasha start put gun head shoot if bullet trigger cylinder shifts position weapon give Roma the game continue shot survivor winner Sasha want lose choose slot bullet way minimize probability loss of possible variant want select lexicographically minimal slot lexicographically charge More formally cylinder n bullet slot able contain k bullet represent string n character exactly k X charge slot uncharged slot let describe process shot suppose trigger character string slot if shot do not kill cylinder shift string shift leave so character second character but trigger do not it character result stringAmong string minimal probability loss Sasha choose lexicographically minimal accord string charge gun you help Sasha charge gun for xi query answer bullet position xi | 2string
|
the average miner Vaganych take refresher course as soon miner complete course exam the hard computer test call Testing Pants SadnessThe test consist n question question answer strictly order give question 1 question n question contain ai answer variant exactly correct a click regard select answer question the goal select correct answer n question if Vaganych select wrong answer question select answer unselected test start begin question 1 but Vaganych remember the order answer question order question remain unchanged question answer themselvesvaganych smart memory superb unbelievably unlucky know whatsoever test theme how click perform bad case | 1graph
|
a little boy Gerald enter clothe shop find unpleasant clothe turn match for example Gerald notice look ridiculous smoking suit baseball capOverall shop sell n clothing item exactly m pair clothing item match each item price represent integer number ruble Gerald want buy clothing item match besides want spend little money possible find possible sum spend | 1graph
|
Ehsan love geometry especially like rotate pointsGiven point plane Ehsan like rotate k degree counterclockwise origin what result rotation | 1graph
|
you give polynom form pxxa1xa2 xan Write Pike program print standard form pxxnb1xn1bn1xbn you write addend form CXK example 5x8please write polynom short way skip unnecessary term term CXK reduce omit Look sample clarification | 2string
|
there lot rumor medium day one day Aida decide find rumor madeshe ask n friend help they form circle Aida tell person right piece news simple string then person tell string person hisher right but do not tell stre exactly they d hear each person type change remove character end hear string add character end hear string finally rumor pass exactly n move complete cycle Aida hear different expect person leave she think cheated change explain now wants write pike piece code get initial final string tell Aida possible final string initial rule describe | 2string
|
shrek Donkey guess live far away kingdom decide play card game call YAGame the rule simple initially Shrek hold m card Donkey hold n card player card card lie table face player thus begin game overall mn1 card besides player know card pack card consist card know card lie table one player the player turn shrek start during player try guess card lie table if guess correctly game end win if guess wrong game end time player win Name card pack if player card aside card long game if player do not card say recently Donkey start take yellow pill win Shrek now Shrek want evaluate chance win start take pillshelp Shrek assume pill good quality player start play optimal manner | 1graph
|
petya love football one day watch football match write player current position piece paper to simplify situation depict string consist zeroes one a zero correspond player team correspond player team if 7 player team stand situation consider dangerous for example situation 00100110111111101 dangerous 11110111011101 you give current situation determine dangerous | 1graph
|
petya love hockey one day watch hockey match fall asleep Petya dreamt appoint change hockey team thus Petya give original team w collection forbid substring s1s2sn all string consist uppercase lowercase latin letter String w length w character number 1 wFirst Petya find occurrence forbidden substring w string during search substring case letter should not taken consideration that string abc ABc consider equalafter Petya perform replacement letter cover occurrence More formally letter position replace position string w exist pair index lr 1lirw substre wlr contain collection s1s2sn case insensitive comparison during replacement letter case remain Petya allow replace letter are not cover forbid substringletter letter uppercase lowercase consider lucky hockey player that s petya perform change letter occur result string time possible help Petya find result string if string find come lexicographicallynote process replacement repeat occur that Petyas replacement string start contain new occurrence bad substring Petya pay attention | 1graph
|
one day Igor K stop programming take math one late autumn evening sit table read book think the follow statement catch attention among people pairwise acquaint people pairwise unacquainted peopleigor could not require minimum 6 people well that s people keep repeat mind Lets Max Ilya Vova know and let add Dima Oleg Vova acquaint now math rubbishIgor K take 5 friend write friend now want check true people pairwise acquaint pairwise acquaint people | 1graph
|
an african crossword rectangular table nm size each cell table contain exactly letter this table refer grid contain encrypted word need decodedTo solve crossword cross repeat letter row column in word letter cross corresponding column row contain letter exactly besides letter cross simultaneouslywhen repeat letter cross write remain letter stre the letter occupy high position follow letter occupy low position if letter locate row letter leave go the result word answer problemyou suggest solve african crossword print word encrypt | 1graph
|
Programmer Vasya study new programming language K the K language resemble language C family syntax however powerful rule actual Clike language unapplicable to fully understand statement read language description carefully follow similar rule real programming languagesThere powerful system pointer K add asterisk right exist type x result new type x that call pointerdefinition operation also operation opposite type x pointer add ampersand result type x refer x that call dereference operationThe K language basic datum type void errtype also language operator typedef typeof the operator typedef a b define new datum type b equivalent a a asterisk ampersand b for example operator typedef void ptptvoid create new type ptptvoid void the operator typeof a return type a bring void return type void equivalent necessary number asterisk number possibly zero that having define ptptvoid type show typeof ptptvoid operator return voidan attempt dereference void type lead error special datum type errtype for errtype follow equation hold true errtypeerrtypeerrtype an attempt use data type have not define lead errtypeuse typedef define type time of definition valid however type define early type changeLet note dereference operation low priority pointer operation word T equal TNote operator execute consecutively if operator typedef void typedef b errtype b errtype errtype void void sample 2Vasya fully understand powerful technology that s ask help write program analyze operator | 0array
|
in far away kingdom live greedy king to defend land build n guard tower Apart tower kingdom army head tyrannical narcissistic general the general can not stand specifically let soldier army present towerdure defence operation manage guard tower general send army tower each general ask fee king manage tower as live far away kingdom general evaluate fee follow weird manner find remotest distant tower soldier army situate ask fee equal distance each tower represent point plane coordinate xy distance point coordinate x1y1 x2y2 determined kingdom x1x2y1y2The greedy king exactly satisfied requirement general that s agree pay fee general equal maximum demand fee however king green greed way arrange tower army wants find cheapest each tower occupy soldier exactly armyHe hire you find minimum money pay fee and king scrupulous count number arrangement cost money as number large king know remainder divide 1097two arrangement distinct set tower occupy soldier general distinct | 2string
|
the hero story Valera good friend arcady school spend free time play turnbase strategy GAGA go and go again the gameplay follow there army play field consist n man n the current player specify soldier enemys soldier shoot target player soldier shoot simultaneously this game world soldier shoot perfectly absolutely hit specify target if enemy soldier hit surely die it happen soldier indicate target kill soldier participate game anymore the game GAGA consist step Valera make Arcady Valera game end you ask calculate maximum total number soldier kill game | 1graph
|
you know Valerys favorite sport biathlon due help learn shoot miss skill unmatched shooting range but small task perform learn complete path fastestThe track map represent rectangle nm size divide square each square mark lowercase latin letter mean type plot exception start square mark capital Latin letter S terminate square mark capital latin letter t the time movement square equal 1 minute the time movement cell neglect we cell sideadjacent one forbid map edge also follow restriction impose path allow visit k different type square squares type visit infinite number time square mark S T type count but S visit exactly begin t visit exactly endYour task find path square S square T take minimum time among short path choose lexicographically minimal when compare path lexicographically represent sequence character plot type | 1graph
|
consider house plan let house represented infinite horizontal strip define inequality hyh strictly outside house light source point 0f 0f Windows locate wall window represent segment line yh yh also window arrange symmetrically line y0your task find area floor home light source light | 2string
|
Vasya recently develop new algorithm optimize reception customer flow consider follow problemLet queue cashier contain n people characterize positive integer ai time need work customer what special cashier serve customer simultaneously however customer need ai aj time serve time need work customer equal maxaiaj please note work customer uninterruptable process people simultaneously come cashier mean begin serve simultaneously finish simultaneously possible waitvasya algorithm ingenious heuristic long queue person wait people stand queue send simultaneously if queue customer number go cashier serve ai time note total number phase serve customer equal n2Vasya think method help cope queue hate that s ask work program determine minimum time queue serve algorithm | 1graph
|
there n student Polycarps class include a day ago student write essay my good friend each student essay dedicated student class hisher good friend Note student bs good friend necessarily student good friend bAnd teacher lead class museum history sport programming exciting story legendary hero await student tourist Petr tomek SnapDragon that s hear aboutthe teacher decide divide student pair pair consist student good friend she able split student pair problem wants pick maximum number pair if variant want pick pair boygirl pair possible of course student include pair | 1graph
|
do remember kind cartoon Beauty Beast no firing machine gun radiation mutant timetravelsthere beauty name Belle once violate beast order visit West Wing after banished castle everybody upset the beautiful Belle upset Beast Lumiere candlestick but bad thing Cogsworth upset Cogsworth human mantel clock alarm clockdue Cogsworths frustration inhabitant castle trouble determine time drink morning tea time evening stroll fortunately deep basement lie digital clock show time format HHMM Now resident castle face difficult task they turn Cogsworths hour minute mustache hand way Cogsworth begin correct time moreover need find turn angle degree mustache hand the initial time show Cogsworth 1200you rotate hand forward show picture as way select angle rotation choose small angle right nonnegative directionNote Cogsworths hour minute mustache hand evenly continuously hand move independently turn hand hand remain stand | 2string
|
Fox Ciel safely return castle wrong security system castle sensor attach castle cover herCiel point 11 castle want point nn position room by step Ciel point xy x1y rightward xy1 upwardIn castle c2 sensor set point aibj integer j 0ic0jcEach sensor count value decrease count value time Ciel move initially count value sensor t every time Ciel move point xy count value sensor point uv decrease uxvy when count value sensor strictly 0 sensor catch Ciel suspicious individualDetermine Ciel 11 nn catch sensor possible output step Assume Ciel point censor point | 1graph
|
after Fox Ciel win onsite round programming contest take bus return castle the fee bus 220 yen she meet Rabbit Hanako bus they decide play follow game get bored bus Initially pile contain x 100yen coin y 10yen coin they turn alternatively Ciel take turn in turn exactly 220 yen pile in Ciels turn multiple way 220 yen choose way contain maximal number 100yen coin in Hanakos turn multiple way 220 yen choose way contain maximal number 10yen coin if Ciel Hanako can not exactly 220 yen pile lose Determine winner game | 2string
|
a breakthrough computer game Civilization XIII striking scale elaborate detail Lets close look themthe play area game split congruent cell regular hexagon the cell equal 1 each unit occupy exactly cell playing field the field consider infinite Lets look battle unit call Archer each archer parameter shoot range its positive integer determine radius circle archer hit target the center circle coincide center cell archer stay a cell consider archer fire point cell include border point locate inside circle borderThe picture show border shoot range equal 3 4 5 the archer depict a Find number cell fire archer | 1graph
|
the Easter Rabbit lay n egg circle paint each egg paint color 7 red orange yellow green blue indigo violet also follow condition satisfy each seven color paint egg any egg lie sequentially paint different color help Easter rabbit paint egg require manner we know possible | 1graph
|
tourist walk x axi he choose direction speed exceed V he stand move he know newspaper time t1 point coordinate x1 interesting event occur time t2 point coordinate x2 xntn interesting event short assume immediate event count visit time ti tourist point coordinate xiWrite program tourist find maximum number event tourist begin time equal 0 tourist appear point 0 tourist choose initial point yes answer similar different question | 1graph
|
scientist planet Olympia conduct experiment mutation primitive organism Genome organism planet represent string K capital english letter for pair type gene assign aij risk disease occurence organism provide gene type adjacent genome 1based index gene j index second gene the gene a index 1 b index 2 for example a32 stand risk cb fragment Risk disease occurence organism equal sum risk pair adjacent gene genomescientist obtain base organism some new organism obtain mutation organism Mutation involve removal gene particular type such removal increase total risk disease occurence additionally for type gene scientist determine ti increasement total risk disease occurence provide removal gene have type index for example t4 stands value additional total risk increasement case remove D genesscientist want find number different organism obtain give total risk disease occurence great t they use process mutation describe two organism consider different string represent genome different Genome contain gene | 2string
|
the kingdom Olympia consist N city M bidirectional road each road connect exactly city city connect road also possible road connect city make loopall road constantly plunder bandit after bandit bore waste time road robbery suggest king Olympia pay accord offer bandit want gift consist gold silver coin Offer contain list restriction road know gi small gold si small silver coin gift stop robbery road that gift contain gold b silver coin bandit stop robbery road gia sibunfortunately kingdom treasury do not contain gold silver coin olympian tugrik the cost gold coin tugrik g cost silver coin tugrik S King wants send bandit gift city exist safe path your task find minimal cost olympian tugrik require gift | 2string
|
there square box 66 size it contain 36 chip 11 size those chip contain 36 different character 09 AZ there exactly chip characteryou allow follow operation choose 6 row 6 column cyclically shift chip position leave right row upwards downward column those operation allow perform time to solve puzzle shift chip describe operation write increase order exactly equal right picture an example solve puzzle show picture Write program find sequence operation solve puzzle that sequence necessarily short exceed limit 10000 operation it guarantee solution exist | 1graph
|
the nonnegative integer divisor nonnegative integer b exist positive integer c acb some number interesting Commander Surena define interesting property nonnegative integer an integer happy divisible digit an integer happy divisible digit an integer upset divisible digit Surena ask find give number happy happy upset | 1graph
|
two good friend try new programming language call PersescriptThe important language string a string Persescript character so example hello string but Hello variable keyword consider problemPersescript functionbase so operator language for example sum number write sumab abThere function work string these include concatxy function get string x y put y end x return result for example concathelloworld return HelloWorld reversex get single string x reverse for example reversehello return olleH substrxab get string x integer b 1abn n length x and return substre x index b inclusive for example substrHello24 return ell substrxabc version substr work like c step add c positive for example substrhelloworld1102 return Hlool this substr mean ath character cth character reach bYoure go manipulate string Persescript give string expression print result it guarantee expression contain string show character functionscommand Persescript caseinsensitive so substr function write SUBsTr but can not print result hello instead print HelloSee sample information | 1graph
|
the positive integer divisor positive integer b exist positive integer c acb King Astyages think positive integer x extraordinarily nice number divisor equal number odd divisorsfor example 3 positive divisor 3 1 odd 3 extraordinarily nice on hand 2 divisible 2 1 odd divisor therefore 2 extraordinarily nicegiven positive integer x determine extraordinarily nice | 1graph
|
Anton Dasha like play different game break checker paper by 11th grade manage play game type ask Vova programmer come new game Vova suggest play game code dot follow rule on checker paper coordinate system draw a dot initially position xy a shift dot preselecte vector also player game symmetrically reflect dot relatively line yx Anton Dasha turn Anton go the player distance dot coordinate origin exceed d lose help determine winner | 1graph
|
let aa1a2an permutation n natural number 12n you give positive integer k sequence Bb1b2bn bi number element aj a left element ati ajikfor example n5 possible a 51423 for k2 B give 12100 but k3 b11000for sequence Xx1x2xn Yy1y2yn let ith element element xiyi if xiyi X lexicographically small Y xiyi X lexicographically great YGiven n k B need determine lexicographically small a | 0array
|
Harry Potter lose Invisibility Cloak run school caretaker Filch Finding invisible object easy task fortunately Harry friend willing help Hermione Granger read the Invisibility cloak everything they volume the Encyclopedia Quick Search Shortest Paths Graphs Network Flows Maximal increase Subsequences other Magical Objects she develop search algorithm invisibility cloak complex dynamic system Hogwarts themhogwart consist n floor number integer 1 n some pair floor connect staircase the staircase change position move exactly end Formally situation like staircase connect floor b modify position connect floor c b c c floor different b under circumstance staircase connect floor at time multiple stair pair floorsinitially Harry floor number 1 he remember floor lose cloak want look floor therefore goal visit n floor Harry visit floor order finish search floornowadays staircase rarely however Ron Hermione willing spell help Harry find cloak to cause suspicion friend plan staircase staircase in shift staircase Harry able floor reachable moment staircase look Invisibility Cloak it assume time staircase spontaneouslyhelp friend compose search plan if variant solve problem valid option necessarily optimal accept | 2string
|
table bowling tournament participant complete competition accord give final standing table the table give sequence line line format score your task prepare table consist line form place Sort participant score desc lexicographically case tie place numerate 1 if participant score share place output like 1214 johnplease look sample clarification | 1graph
|
positive integer number x call prime exactly positive integer divisor for example 2 3 17 97 prime 1 10 120 notyou give integer number n find short segment ab contain n ie anb ab prime | 1graph
|
you give line nm n m digit sign Print value give expression | 2string
|
in strategic computer game Settlers II build defense structure expand protect territory Lets building at moment defense structure accommodate exactly n soldier within task assume number soldier defense structure will not increase decreaseevery soldier rank natural number 1 k 1 stand private k stand general the high rank soldier well fight therefore player profit have soldier highest possible rankto increase rank soldier need train but soldier will not train free training session require golden coin on training session n soldier presentAt end training session soldier rank increase follow first soldier divide group rank possible number group form then group soldier rank k present exactly soldier increase rank oneYou know rank n soldier moment determine number golden coin need increase rank soldier rank k | 1graph
|
Tyndex ahead rival the reaction release Zoozle Chrome browser release new browser tyndexbromethe popularity new browser grow daily and secret TyndexBar instal TyndexBar automatically fill glass fine 1664 cognac buy TyndexBottles insert usb port it highly popular wellthought interaction userlet example system automatic address correction have enter codehorse instead codeforce the gloomy Zoozle Chrome sadly address exist TyndexBrome time automatically find close address send that s brillianthow splendid function work that s simple for potential address function F error calculate follow rule letter ci potential address c close position j letter ci address s enter user find the absolute difference ij position add F so 1ic position j choose cisj ij minimal possible letter ci exist address enter user length potential address c add F after value error function calculate potential address suitable find to understand special feature describe method well recommend realize algorithm calculate F function address give user set potential address good luck | 2string
|
the Romans attack this time Persians Shapur ready defeat he say a lion afraid sheep Nevertheless Shapur find weakness roman army defeat so give army weakness numberIn Shapurs opinion weakness army equal number triplet ijk ijk aiajak ax power man stand position x the roman army special trait power people distincthelp Shapur find weak Romans | 1graph
|
Shapur extremely gifted student he great include Combinatorics Algebra Number Theory Geometry Calculus etc he smart extraordinarily fast he manage sum 1018 number single secondone day 230 ad Shapur try find possibly calculation fast as result great contest ask come partIn contest give contestant different pair number each number digit 0 1 the contestant write new number corresponding give pair number the rule simple the ith digit answer 1 ith digit give number differ in case ith digit answer 0shapur number try speed he see perform operation number length length number number digit glance he give correct answer expect contestant correct answer he good fellow will not big number give person number lengthnow go Shapurs contest see fast accurate | 2string
|
Misha decide help Pasha Akim friend he cunning plan destroy laughy mushroom he know laughy mushroom easily burst laugh Mushrooms grow lawn there mushroom tth lawnMisha know lawn mushroom grow unique ability a lawn transfer laugh lawn j exist integer b permutation number aiaj b beautiful triple ij a beautiful triple pairwise coprime number xyz satisfy follow condition x2y2z2Misha want know minimal number lawn laugh laughy mushroom burst | 1graph
|
the Cereal Guys friend Serial Guy like watch soap opera an episode start have not wash plate but decide tap fill water the plate represent parallelepipe knm k layer layer upper rectangle nm square obstacle the water present square the tap position square xy layer guarantee square every minute cubical unit water fall plate find minute Serial Guy unglue soap opera turn water overfill plate that find moment time plate absolutely going overfill momentnote water fill area reach sample 4 water flow 6 direction face 111 cube | 1graph
|
one day Vasya solve arithmetical problem he write expression abc notebook when teacher check Vasyas work turn Vasya solve problem incorrectly now Vasya tries find excuse he say simply forgot write digits number b c can not remember number actually help Vasya find number x y z follow condition meet xyz expression xyz digit erase way result abc expression xyz minimal length | 1graph
|
in Berland money reform prepare new coin introduce after long economic calculation decide expensive coin possess denomination exactly n Berland dollar also follow restriction introduce comfort denomination coin divisible denomination cheap coin it know possible variant variant large number new coin choose find variant print order decrease coin denomination | 2string
|
Brian Rabbit adore chess not long ago argue Stewie Rabbit knight well king to prove point try knight fast Stewie do not accept statement evidence he construct infinite chessboard Brian delete square add interest game Brian need count different board square knight stand square coordinate 00 reach k move naturally forbid delete squaresbrian do not like exact science acquaint programming that s hardly able ahead Stewie start solve problem help Brian solve problem fast Stewie | 2string
|
there stre s consist capital latin letter let denote current length s during allow apply follow operation insert pos ch insert letter ch string s position pos 1poss1achz the letter ch posth symbol string s letter shift aside length string increase 1 delete pos delete character number pos 1poss string s at letter shift length string decrease 1 replace pos ch letter position pos line s replace ch 1possachz at length string change your task find minimal number move t string s string you find sequence action lead require result | 1graph
|
in probability theory follow paradox call Benfords law know in list random number take real source number start digit 1 occur number start digit that s simple form lawhaving read Codeforces Hedgehog got intrigue statement wishes thoroughly explore he find follow similar problem interesting particular N random variable ith integer value segment LiRi number segment equiprobable it mean value ith quantity equal integer number give interval LiRi probability 1RiLi1The Hedgehog want know probability event digit K value equal in word let consider set fix value random variable leave digit MSD significant digit value then let count time digit 1 encounter encounter K cent n value set value call good you find probability set value give random variable good | 1graph
|
once time little frog Vasya decide travel home swamp Overall n mound swamp locate line the distance neighboring mound meter Vasya want visit mounds day wants visit exactly for make route plan decide order jump mound Vasya pick mound he think boring jump time distance that s want jump route different length help Vasya Frog plan | 1graph
|
one popular blog site edit upload photo like it cut rectangular area ratio height width ie heightwidth quotient vary 08 125 inclusively besides cut area size equal power number 2 2x integer x if rule do not indicate size cut clearly way cut possess large area choose of course side cut area integer if answer problem choose answer maximal height | 1graph
|
there give stre S consist N symbol your task find number order pair integer j that1 1ijn2 SiSj ith symbol string S equal jth | 1graph
|
every year race take place motorway city a B this year Vanya decide race drive car bear noble the HuffpufferSo Vasya leave city a Huffpuffer beginning fill petrol tank α liter petrol α10 Vanyas favorite number necessarily integer petrol station locate motorway interval 100 kilometer ie station locate 100 kilometer away city a second 200 kilometer away city a 300 kilometer away city A the huffpuffer spend 10 liter petrol 100 kilometer Vanya check petrol tank time pass petrol station if petrol leave tank station Vanya fill tank α liter petrol otherwise do not stop station drive for example α4321 car fuel time station number 4 there ll 321 petrol liter leave after fuel car 4642 liter then Vanya stop station number 8 end 64243214963 liter the stop station number 12 96343215284 the stop station number 17 you will not believe huffpuffer lead race perhaps unexpected snow perhaps video camera instal motorway register speed limit breaking perhaps fact Vanya threaten junk huffpuffer car win whatever reason huffpuffer lead jealous people contestant wrack brain trying think way stop outrageone way petrol station Vanya stop your task calculate station happen warn Vanya you do not know α number give succession number station Vanya stop Find number station stop | 0array
|
a triangular number number dot equilateral triangle uniformly fill dot for example dot arrange triangle triangular number the nth triangular number number dot triangle n dot you learn number Wikipedia httpenwikipediaorgwikiTriangular_numberYour task find give integer triangular number | 2string
|
one day wellknown sponsor wellknown contest decide participant contest Tshirt present a natural problem occur hand clear tshirt size order hand do not want order tshirt exactly paper wall oversupply after considerable brain rack preestimate sponsor representative order certain number tshirt size S M L XL XXL the Tshirts turn bring good luck that s contest day build line K participant willing every contestant characterize hisher desire Tshirt size happen participant size S M L XL XXL the participant come Tshirt try choose suitable choosing like if Tshirt optimal size leave heshe take ado otherwise contestant prefer choose Tshirt size close optimal possible distance neighboring size consider equal if variant choice unique contestant Tshirt big size case heshe grow for example person optimal size L preference list look like L XL M XXL S use datum tshirt size order organizer size contestant line determine get Tshirt size | 1graph
|
Vasya get interested programming contest TCMCF rule on contest n problem suggest problem cost certain integral number point negative equal zero accord TCMCF rule accept problem earn point overall number point contestant equal product cost problem heshe complete if person do not solve heshe do not appear final standing was not consider participant Vasya understand maximal number point useful solve problem unfortunately understand contest finish now ask help find problem solve earn maximal number point | 1graph
|
once Vasya need transport m goat m wolf riverbank quickly possible the boat hold n animal Vasya addition permit n animal boat if place bank boat wolf happen strictly outnumber goat wolf eat goat Vasya get upset when Vasya swim boat shore animal accompany bored feel upset when boat reach bank animal simultaneously animal choose Vasya simultaneously boat that mean moment animal arrive get animal go leave have not get somebody eat Vasya need transport animal river bank eat Vasya do not upset what minimal number times cross river | 2string
|
Vasya bear Berland film director currently work new blockbuster the Unexpected Vasya know experience important choose main character name surname wisely he list n name n surname wants use Vasya have not decide character free match surname now list main character follow format Name1 Surname1 name2 surname2 Namen Surnamen ie namesurname pair separate exactly comma exactly space separate surname exactly space First Vasya want maximize number pair surname start letter if variant Vasya want lexicographically minimal help himan answer verify line format show include need commas space its lexicographical minimality line need ensure the output line should not end space comma | 1graph
|
today Vasya visit widely know site learn continuation favourite game Codecraft II appear exactly k month he look calendar learn moment month number s Vasya immediately get interested month Codecraft III appear help understand thatall month Vasyas calendar name usual english name January February March April May June July August September October November December | 1graph
|
Anfisa monkey get disappoint word processor are not good reflect range emotion that s decide switch graphic editor having open BerPaint see white rectangle WH size paint First Anfisa learn navigate drawing tool paint segment quickly paint rectangle certain number blackcolore segment the result picture do not bright Anfisa that s turn attention fill tool find point rectangle paint choose color area color point contain completely paint choose color having apply fill time Anfisa express emotion completely stop paint your task information paint segment apply fill find color total area area paint color fill | 2string
|
in far away galaxy n inhabit planet number number 1 n they locate large distance that s communication difficult planet number 1 hyperdrive invent as soon significant event take place n1 spaceship build planet number 1 ship send planet inform revolutionary invention Paradoxical think hyperspace represent simple threedimensional euclidean space the inhabit planet consider fix point point coincide point lie straight line the movement ship hyperdrive planet perform straight line constant speed ship that s distance hyperspace measure hyperyear ship hyperdrive cover distance s hyperyear s yearsWhen ship reach inhabited planet inhabitant planet dissemble n2 identical ship hyperdrive send n2 planet ship arrive the time new ship compare time planet small disregard new ship absolutely identical one send initially constant speed straight line trajectory having reach planet perform mission ie dissemble build new n2 ship send planet ship arrive thus process spread important news galaxy continueshowever hyperdrive creator hurry spread news invention do not study completely go ship collide hyperspace if move ship find point provoke explosion colossal power lead destruction galaxyyour task find time galaxy continue exist moment ship launch planet | 1graph
|
today s kilometer long auto race take place Berland the track represent straight line long s kilometer there n car take race start simultaneously begin track for car know behavior system segment speed car constant the jth segment ith car pair vijtij vij car speed segment kilometer hour tij hour car drive speed the segment give order drive carsyour task find times race car manage lead car a lead consider situation car appear car it know lead happen instantly e time segment positive length car drive at moment time point lead appear in case take individually meeting car start finish consider count lead | 2string
|
Vasya think lucky ticket ticket number divisible 3 he gather large collection ticket day young brother Leonid have sulk decide destroy collection first tear ticket exactly do not think Leonid throw piece away having see Vasya got terrify tried restore collection he choose piece pair glue pair pair form lucky ticket the rest piece Vasya throw away reluctantly thus glue 2 t piece end t ticket luckyWhen Leonid tear ticket piece piece contain letter number second piece contain restvasya glue pair piece way like important get lucky ticket end for example piece 123 99 glue way 12399 99123what maximum number ticket Vasya | 1graph
|
one day Vasya decide look result Berland 1910 Football Championships final unfortunately do not find overall score match got hold profound description matchs process on n line description describe goal every goal mark team score Help Vasya learn team win final it guarantee match end tie | 1graph
|
on square low row chessboard stand pawn it variant move upwards leftward upwards rightward the pawn choose square low row start journey on square lie 0 9 pea the pawn wants reach uppermost row having collect pea possible as divide pea k brother number peas divisible k1 find maximal number pea able collect move itthe pawn throw pea away leave board when pawn appear square board include square way necessarily take pea | 1graph
|
the translation Berland language Birland language easy task those language similar berlandish word differ birlandish word mean little spell pronounce reversely for example berlandish word code correspond birlandish word edoc however easy mistake translation Vasya translate word s Berlandish Birlandish t help find translate word correctly | 2string
|
Berland scientist notice long ago world depend Berland population due persistent research area scientist manage find Berland chronology start moment people come land consider happen year after Berland year start chronology population equal 13 people second year however trace population number follow year ultimately difficult task find di number people Berland year di12di2 di13di112di2 of course know people live Berland moment tell possibly year country population equal A that s ask determine also possible find year begin Berland chronology Lets suppose year a1a2ak then define resident country year apart a variant look example explanation | 2string
|
in Berland city S tram engine house tram three people work house tram driver conductor head engine house the tram leave engine house morning drive loop route the tram need exactly c minute complete route the head engine house control trams movement go outside c minute tram drive engine house head leave driver bonus second lateIt Afterwards Berland Federal Budget give money tramline S happen mean plan the tramline rebuild result turn huge network the previous loop route destroy S n crossroad m tramline link pair crossroad the traffic Berland way tram tramline direction there tramline crossroad way opposite way every tramline link different crossroad crossroad outgoing tramlineSo tramline build reason gave think increase number tram S the tram continue ride driver excellent opportunity rid unending control engine house head for tramline network choose route freely now crossroad driver arbitrarily choose way the tram part S return way traffic the driver afraid challenge night city asleep return engine house safely drive tramline opposite directionthe city people rejoice wait tram appear street year however driver behavior enrage engine house head now tries carry insidious plan instal camera look rebellious tramthe plan go follow the head engine house want install camera crossroad choose period time t t minute turn away favourite tv check tram also head engine house want moment time divisible t moment tram appear crossroad camera There camera crossroad engine house prevent possible terrorist attack engine house head among possible plan engine house head choose plan large possible value t hate distract favourite tv if plan unique pick plan require minimal possible number camera find plan | 1graph
|
once Petya Vasya invent new game call Smart boy they locate certain set word dictionary game it admissible dictionary contain similar word the rule game follow player choose letter word long 1 word dictionary write piece paper the second player add letter one initial final position make word long 2 player turn add letter begin end make word long 3 but player must not break condition newly create word substre word dictionary the player can not add letter current word break condition losesalso end turn certain string s write paper player turn get number point accord formulawhere sequence number symbol c latin alphabet number start 1 for example number word dictionary line s occur substre your task learn win game final score every player play optimally try win maximize number point minimize number point opponent | 1graph
|
the Berland Armed Forces System consist n rank number natural number 1 n 1 low rank n high rankOne need exactly di year rise rank rank i1 reach certain rank having reach previous i1 rank impossibleVasya reach new rank dream hold rank b find year Vasya serve army finally realize dream | 1graph
|
having unravel Berland Dictionary scientist manage read note chronicler time for example learn chief ancient Berland tribe chosenAs soon pretender pick follow test take place chief tribe take slab divide horizontal vertical stripe identical square slab consist N line M column paint square black white then pretender give slab size paint entirely white within day pretender paint sidelinke set square slab color the set call link square belong set path belong set neighboring square share the aim pretender paint slab exactly way chiefs slab paint the paint slab like new chiefscientist find slab paint ancient Berland tribe chief help determine minimal day need find new chief paint slab give way | 1graph
|
today z city resident enjoy shell game competition the resident gather main square watch breathtaking performance the performer put 3 nontransparent cup upside row then openly put small ball cup start shuffle cup quickly make exactly 3 shuffle after spectator exactly attempt guess cup think ball answer correct prize maybe try find ball | 1graph
|
a star map Berland check field nm square in square star the favourite constellation Berlands astronomer constellation Cross this constellation form 5 star integer x radius constellation follow true 2nd vertical line 1st x square 3rd vertical line 1st x square 4th horizontal line 1st x square leave 5th horizontal line 1st x square right such constellation numerous that s number integer 1 follow principle constellation compare small radius get small index radius equal central star high central star central star level central star leave central star oneYour task find constellation index k give Berlands star map | 0array
|
email address Berland string form AB A b arbitrary string consist small latin letter Bob system administrator Bersoft company he keep list email address companys staff this list large string address write arbitrary order separate comma the address write oncesuddenly unknown reason commas Bobs list disappear now Bob string address write separator impossible determine boundary address unfortunately day chief ask bring initial list address now Bob want disjoin address valid way help | 2string
|
a long time ago far country live king Copa after recent king reform get large power start book himselfthe total income a kingdom 0th year know total income b nth year number negative mean loss correspondent year King want financial stability to need find common coefficient x coefficient income growth year this coefficient satisfy equationaxnbsurely king go job demand find number XIt necessary point fractional number kingdom economy that s input number coefficient x integer the number x zero negative | 1graph
|
one day Bob get letter envelope Bob know Berlands post officer send letter directly city a city b stamp a b b a unfortunately impossible send letter directly city sender city receiver that s letter send intermediate city Post officer send letter way route letter contain city Bob sure post officer stamp letter accuratelythere n stamp envelope Bobs letter he understand possible route letter but stamp numerous Bob can not determine route that s ask help find possible route letter | 1graph
|
how horrible the empire galactic chicken try conquer beautiful city Z build huge incubator produce million chicken soldier day fence the huge incubator look like polygon plane Oxy n vertex naturally DravDe can not want destroy chicken empire for sure start incubatorDravDe strictly outside incubator territory point Axaya want inside kill chicken work but take lot the problem recently DravDe go roller skate break leg he incubator territory jet airplane LEVAP41LEVAP41 fly speed Vxvyvzv DravDe plane point a fly time air drop DravDe heavy that s fall vertically speed fdown point free fall DravDe open parachute moment starts fall wind speed Uxuyuzu land unfortunately DravDe is not good mathematic would help poor world saviour find air dropping plan allow land incubator territory if answer unique DravDe want find plan minimum time flight plane if answer multiple want find minimum time free fall opening parachute | 2string
|
a motorcade n truck drive city z city З approach tunnel know Tunnel Horror among truck driver rumour monster DravDe hunt driver tunnel some driver fear let consider general case each truck describe number v value truck passanger cargo c passanger truck driver include l total people tunnel truck driver overcome fear monster appear motorcade hell eat r total people follow truck driver overcome fear monster appear motorcade hell eat since road narrow impossible escape DravDe appear moreover motorcade can not rearrange the order truck can not change possible truck motorcade leave near tunnel indefinite period you head motorcade remove truck rest motorcade tunnel total left truck value maximal | 1graph
|
give number n find small positive integer exactly n divisor it guarantee give n answer exceed 1018 | 1graph
|
you give follow concurrent program there n process ith process follow pseudocode repeat ni time yi y y yi1end repeathere y share variable everything local process all action give row atomic ie process start execute row interrupt beyond interleaving possible ie process work grant right execute row in begin y0 you give integer W ni i1 N Determine possible process terminate yw possible output arbitrary schedule produce final value | 2string
|
once Bob decide lay parquet floor living room the living room size nm metre Bob plank type plank 12 meter b plank 21 meter c plank 22 meter help Bob find possible parquet living room set plank possible find possible way Bob do not use plank | 1graph
|
Berland Government decide improve relation neighboring country first decide build new road city Berland neighboring country possible reach there n city Berland neighboring country total exactly n1 twoway road because recent financial crisis Berland Government strongly press money build new road close exist one every day possible close exist road immediately build new your task determine day need rebuild road city possible reach draw plan closure old road build new one | 2string
|
phone number Berland sequence n digit often easier memorize number divide group digit for example phone number 1198733 easy remember 1198733 your task find give phone number division group digit | 1graph
|
recently construction Berland collider complete collider represent long narrow tunnel contain n particle we associate collider 1dimensional coordinate system going leave right for particle know coordinate velocity moment start collider the velocity particle do not change launch collider Berland scientist think big bang happen collision particle velocity differ direction help determine time elapse launch collider big bang happen | 1graph
|
in 2n1 box apple orange your task choose n box contain half apple half orange | 1graph
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.