Datasets:
data_source
stringclasses 4
values | prompt
listlengths 1
1
| ability
stringclasses 1
value | reward_model
dict | extra_info
dict |
|---|---|---|---|---|
taco
|
[
{
"role": "user",
"content": "One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by 1. For example, if there are seven teams with more balloons, you get the eight place. Ties are allowed.\n\nYou should know that it's important to eat before a contest. If the number of balloons of a team is greater than the weight of this team, the team starts to float in the air together with their workstation. They eventually touch the ceiling, what is strictly forbidden by the rules. The team is then disqualified and isn't considered in the standings.\n\nA contest has just finished. There are n teams, numbered 1 through n. The i-th team has t_{i} balloons and weight w_{i}. It's guaranteed that t_{i} doesn't exceed w_{i} so nobody floats initially.\n\nLimak is a member of the first team. He doesn't like cheating and he would never steal balloons from other teams. Instead, he can give his balloons away to other teams, possibly making them float. Limak can give away zero or more balloons of his team. Obviously, he can't give away more balloons than his team initially has.\n\nWhat is the best place Limak can get?\n\n\n-----Input-----\n\nThe first line of the standard input contains one integer n (2 ≤ n ≤ 300 000) — the number of teams.\n\nThe i-th of n following lines contains two integers t_{i} and w_{i} (0 ≤ t_{i} ≤ w_{i} ≤ 10^18) — respectively the number of balloons and the weight of the i-th team. Limak is a member of the first team.\n\n\n-----Output-----\n\nPrint one integer denoting the best place Limak can get.\n\n\n-----Examples-----\nInput\n8\n20 1000\n32 37\n40 1000\n45 50\n16 16\n16 16\n14 1000\n2 1000\n\nOutput\n3\n\nInput\n7\n4 4\n4 4\n4 4\n4 4\n4 4\n4 4\n5 5\n\nOutput\n2\n\nInput\n7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 7000000000\n15000000000 39000000000\n46000000000 51000000000\n0 1000000000\n0 0\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, Limak has 20 balloons initially. There are three teams with more balloons (32, 40 and 45 balloons), so Limak has the fourth place initially. One optimal strategy is: Limak gives 6 balloons away to a team with 32 balloons and weight 37, which is just enough to make them fly. Unfortunately, Limak has only 14 balloons now and he would get the fifth place. Limak gives 6 balloons away to a team with 45 balloons. Now they have 51 balloons and weight 50 so they fly and get disqualified. Limak gives 1 balloon to each of two teams with 16 balloons initially. Limak has 20 - 6 - 6 - 1 - 1 = 6 balloons. There are three other teams left and their numbers of balloons are 40, 14 and 2. Limak gets the third place because there are two teams with more balloons. \n\nIn the second sample, Limak has the second place and he can't improve it.\n\nIn the third sample, Limak has just enough balloons to get rid of teams 2, 3 and 5 (the teams with 81 000 000 000, 5 000 000 000 and 46 000 000 000 balloons respectively). With zero balloons left, he will get the second place (ex-aequo with team 6 and team 7).\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"8\\n20 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 1000\\n2 1000\\n\", \"7\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n5 5\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 7000000000\\n15000000000 39000000000\\n46000000000 51000000000\\n0 1000000000\\n0 0\\n\", \"2\\n100 150\\n5 100000\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 29\\n72 100\\n0 55\\n42 52\\n66 72\\n\", \"3\\n1 2\\n12 19\\n25 45\\n\", \"5\\n2 23\\n1 13\\n3 9\\n0 20\\n6 7\\n\", \"10\\n19 22\\n10 77\\n3 52\\n16 42\\n25 67\\n14 42\\n44 85\\n37 39\\n36 62\\n6 85\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n96 647\\n177 439\\n54 620\\n\", \"3\\n1000 1000\\n1001 1001\\n700 1000000\\n\", \"5\\n4 100\\n10 11\\n10 11\\n3 3\\n3 3\\n\", \"3\\n1 2\\n12 19\\n25 45\\n\", \"10\\n19 22\\n10 77\\n3 52\\n16 42\\n25 67\\n14 42\\n44 85\\n37 39\\n36 62\\n6 85\\n\", \"2\\n100 150\\n5 100000\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 29\\n72 100\\n0 55\\n42 52\\n66 72\\n\", \"5\\n4 100\\n10 11\\n10 11\\n3 3\\n3 3\\n\", \"5\\n2 23\\n1 13\\n3 9\\n0 20\\n6 7\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n96 647\\n177 439\\n54 620\\n\", \"3\\n1000 1000\\n1001 1001\\n700 1000000\\n\", \"2\\n100 150\\n2 100000\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 29\\n72 100\\n0 55\\n42 93\\n66 72\\n\", \"5\\n4 110\\n10 11\\n10 11\\n3 3\\n3 3\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n96 647\\n229 439\\n54 620\\n\", \"8\\n20 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 1000\\n2 1010\\n\", \"10\\n19 22\\n10 77\\n3 52\\n16 42\\n25 67\\n14 39\\n44 85\\n37 39\\n36 62\\n6 85\\n\", \"3\\n1000 0000\\n1001 1001\\n700 1000000\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 7000000000\\n15000000000 39000000000\\n46000000000 51000000000\\n0 0000000000\\n0 0\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 52\\n72 100\\n0 55\\n42 93\\n66 72\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n68 647\\n229 439\\n54 620\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 10778591928\\n15000000000 39000000000\\n46000000000 51000000000\\n0 0000000000\\n0 0\\n\", \"8\\n37 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 1000\\n2 1010\\n\", \"9\\n4 25\\n32 56\\n32 65\\n77 78\\n5 52\\n72 100\\n0 55\\n42 93\\n66 72\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n64 647\\n229 439\\n54 620\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 10778591928\\n15000000000 41827794041\\n46000000000 51000000000\\n0 0000000000\\n0 0\\n\", \"8\\n37 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 0000\\n2 1010\\n\", \"9\\n4 25\\n32 56\\n32 65\\n77 78\\n5 52\\n72 100\\n0 11\\n42 93\\n66 72\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n64 647\\n229 439\\n14 620\\n\", \"7\\n14000000003 1000000000000000001\\n81000000000 88000000000\\n5000000000 10778591928\\n15000000000 41827794041\\n46000000000 51000000000\\n0 0000000000\\n0 0\\n\", \"8\\n37 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 0000\\n2 1000\\n\", \"9\\n4 25\\n32 56\\n32 65\\n77 78\\n5 52\\n76 100\\n0 11\\n42 93\\n66 72\\n\", \"15\\n143 698\\n269 879\\n100 728\\n6 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n64 647\\n229 439\\n14 620\\n\", \"8\\n37 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n11 0000\\n2 1000\\n\", \"9\\n4 25\\n32 56\\n32 65\\n77 78\\n5 52\\n76 100\\n0 11\\n42 66\\n66 72\\n\", \"15\\n143 1050\\n269 879\\n100 728\\n6 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n64 647\\n229 439\\n14 620\\n\", \"9\\n4 25\\n32 56\\n32 65\\n77 78\\n5 52\\n76 100\\n0 11\\n42 121\\n66 72\\n\", \"15\\n143 427\\n269 879\\n100 728\\n6 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n64 647\\n229 439\\n14 620\\n\", \"9\\n4 25\\n32 56\\n54 65\\n77 78\\n5 52\\n76 100\\n0 11\\n42 121\\n66 72\\n\", \"9\\n4 25\\n32 56\\n54 65\\n77 78\\n5 52\\n76 100\\n0 11\\n42 121\\n53 72\\n\", \"3\\n2 2\\n12 19\\n25 45\\n\", \"2\\n100 150\\n3 100000\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 51\\n72 100\\n0 55\\n42 52\\n66 72\\n\", \"5\\n4 100\\n10 11\\n10 11\\n3 3\\n1 3\\n\", \"5\\n2 23\\n1 13\\n3 9\\n0 20\\n6 6\\n\", \"3\\n1000 1000\\n1001 1001\\n700 1010000\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 7000000000\\n15000000000 39000000000\\n46000000000 51000000000\\n0 1000010000\\n0 0\\n\", \"8\\n20 1000\\n32 37\\n40 1000\\n10 50\\n16 16\\n16 16\\n14 1000\\n2 1000\\n\", \"2\\n100 150\\n2 100010\\n\", \"9\\n4 70\\n32 56\\n32 65\\n77 78\\n5 29\\n72 101\\n0 55\\n42 93\\n66 72\\n\", \"15\\n143 698\\n269 879\\n100 728\\n86 855\\n368 478\\n174 368\\n442 980\\n812 825\\n121 220\\n137 198\\n599 706\\n423 586\\n96 647\\n229 439\\n54 51\\n\", \"7\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n5 5\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 7000000000\\n15000000000 39000000000\\n46000000000 51000000000\\n0 1000000000\\n0 0\\n\", \"8\\n20 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 1000\\n2 1000\\n\"], \"outputs\": [\"3\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"7\\n\", \"3\\n\", \"3\\n\", \"4\\n\", \"9\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"1\\n\", \"7\\n\", \"2\\n\", \"3\\n\", \"9\\n\", \"1\\n\", \"1\\n\", \"7\\n\", \"2\\n\", \"9\\n\", \"3\\n\", \"4\\n\", \"1\\n\", \"2\\n\", \"7\\n\", \"9\\n\", \"3\\n\", \"2\\n\", \"7\\n\", \"9\\n\", \"3\\n\", \"2\\n\", \"7\\n\", \"9\\n\", \"3\\n\", \"2\\n\", \"7\\n\", \"9\\n\", \"2\\n\", \"7\\n\", \"9\\n\", \"7\\n\", \"9\\n\", \"7\\n\", \"7\\n\", \"3\\n\", \"1\\n\", \"7\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"1\\n\", \"7\\n\", \"9\\n\", \"2\\n\", \"2\\n\", \"3\\n\"]}"
}
|
{
"index": 0
}
|
taco
|
[
{
"role": "user",
"content": "Problem\n\nGiven a natural number N less than or equal to 12, find the smallest natural number such that the number of divisors is exactly N.\n\nConstraints\n\n* 1 ≤ N ≤ 12\n\nInput\n\nOne natural number N is given in one line.\n\nOutput\n\nOutput the smallest natural number on a line so that the number of divisors is exactly N.\n\nExamples\n\nInput\n\n1\n\n\nOutput\n\n1\n\n\nInput\n\n2\n\n\nOutput\n\n2\n\n\nInput\n\n3\n\n\nOutput\n\n4\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"5\", \"4\", \"6\", \"11\", \"8\", \"7\", \"10\", \"9\", \"12\", \"001\", \"010\", \"011\", \"4\", \"6\", \"9\", \"8\", \"10\", \"5\", \"7\", \"11\", \"12\", \"001\", \"010\", \"011\", \"1\", \"3\", \"2\"], \"outputs\": [\"16\\n\", \"6\\n\", \"12\\n\", \"1024\\n\", \"24\\n\", \"64\\n\", \"48\\n\", \"36\\n\", \"60\\n\", \"1\\n\", \"48\\n\", \"1024\\n\", \"6\\n\", \"12\\n\", \"36\\n\", \"24\\n\", \"48\\n\", \"16\\n\", \"64\\n\", \"1024\\n\", \"60\\n\", \"1\\n\", \"48\\n\", \"1024\\n\", \"1\", \"4\", \"2\"]}"
}
|
{
"index": 1
}
|
codecontests
|
[
{
"role": "user",
"content": "Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets 11311 (475 = 1·162 + 13·161 + 11·160). Alexander lived calmly until he tried to convert the number back to the decimal number system.\n\nAlexander remembers that he worked with little numbers so he asks to find the minimum decimal number so that by converting it to the system with the base n he will get the number k.\n\nInput\n\nThe first line contains the integer n (2 ≤ n ≤ 109). The second line contains the integer k (0 ≤ k < 1060), it is guaranteed that the number k contains no more than 60 symbols. All digits in the second line are strictly less than n.\n\nAlexander guarantees that the answer exists and does not exceed 1018.\n\nThe number k doesn't contain leading zeros.\n\nOutput\n\nPrint the number x (0 ≤ x ≤ 1018) — the answer to the problem.\n\nExamples\n\nInput\n\n13\n12\n\n\nOutput\n\n12\n\nInput\n\n16\n11311\n\n\nOutput\n\n475\n\nInput\n\n20\n999\n\n\nOutput\n\n3789\n\nInput\n\n17\n2016\n\n\nOutput\n\n594\n\nNote\n\nIn the first example 12 could be obtained by converting two numbers to the system with base 13: 12 = 12·130 or 15 = 1·131 + 2·130.\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"16\\n11311\\n\", \"17\\n2016\\n\", \"13\\n12\\n\", \"20\\n999\\n\", \"7014809\\n73084644\\n\", \"7501\\n2542549323761022905\\n\", \"9\\n78\\n\", \"11\\n1107835458761401923\\n\", \"378135456\\n42831383491941211\\n\", \"3\\n1210020121011022121222022012121212020\\n\", \"23\\n12007622911918220\\n\", \"23156\\n27612518525717145\\n\", \"1000000000\\n17289468142098080\\n\", \"2\\n110111100000101101101011001110100111011001000000000000000000\\n\", \"10981\\n5149151039259677113\\n\", \"123\\n7719\\n\", \"467879\\n333380108424158040\\n\", \"10\\n996517375802030516\\n\", \"364\\n284155255182196\\n\", \"130\\n100\\n\", \"6\\n5543321344052\\n\", \"456\\n82103391245145170\\n\", \"10849219\\n65200749\\n\", \"13\\n9\\n\", \"2015054\\n30501583737\\n\", \"1000\\n1001\\n\", \"79\\n9653454753\\n\", \"7897\\n14412516641926184\\n\", \"1468\\n21107\\n\", \"7\\n441214552\\n\", \"378\\n1378\\n\", \"3\\n110021012201002100122001102110010002\\n\", \"5\\n4230423222300004320404110\\n\", \"3215\\n3\\n\", \"442020\\n13825031303078\\n\", \"500\\n29460456244280453288\\n\", \"13\\n41\\n\", \"98000000\\n19440834812\\n\", \"2\\n10000000000000000000000000\\n\", \"25\\n71610\\n\", \"8\\n17073735641412635372\\n\", \"20\\n905191218118181710131111\\n\", \"165726\\n465015206\\n\", \"9\\n1733607167155630041\\n\", \"7956123\\n6718643712272358\\n\", \"2707\\n11341512\\n\", \"4\\n32323300000100133222012211322\\n\", \"11346\\n573275516211238\\n\", \"145\\n357987665524124\\n\", \"5\\n22011100004310232330\\n\", \"1740798\\n321470190942028\\n\", \"2\\n0\\n\", \"251546\\n7278\\n\", \"1000000000\\n69204007\\n\", \"8\\n2670\\n\", \"9\\n3\\n\", \"6\\n20201051430024130310350\\n\", \"158\\n25832612364\\n\", \"2\\n10000000000000000000000000000\\n\", \"25\\n2172214240\\n\", \"46\\n342836241940392925\\n\", \"378\\n380378377\\n\", \"814730652\\n56899767577002\\n\", \"157137373\\n525141766938\\n\", \"215467\\n2082791630100848\\n\", \"1000000000\\n17289468142098026\\n\", \"789765212\\n1039927282755769\\n\", \"56132425\\n3102369282985322\\n\", \"123358\\n458270676485260235\\n\", \"1000000000\\n6\\n\", \"2\\n1110110101111000010001011110101001011001110000000010111010\\n\", \"2567853\\n5247911636981396703\\n\", \"124849\\n6172319\\n\", \"100\\n7226127039816418\\n\", \"7\\n325503632564034033331\\n\", \"98\\n11291073236468\\n\", \"5723\\n4907\\n\", \"25623752\\n25636131538378\\n\", \"57974\\n3619236326439503\\n\", \"67\\n29\\n\", \"21354646\\n47160699363858581\\n\", \"1000\\n1000\\n\", \"315464878\\n113635473256292967\\n\", \"1675\\n11480678916\\n\", \"294\\n2251151163\\n\", \"50\\n303521849112318129\\n\", \"1000\\n839105509657869885\\n\", \"1344\\n2498394521019605\\n\", \"1000000000\\n7289468142097485\\n\", \"905835986\\n371320\\n\", \"13568864\\n2513398972677784\\n\", \"76559\\n100147383\\n\", \"45\\n22\\n\", \"4\\n1\\n\", \"34\\n13\\n\", \"12650\\n25380755475\\n\", \"2\\n100000000000000000000000\\n\", \"1000000000\\n0\\n\", \"8742\\n111445644633405\\n\", \"2\\n1\\n\", \"4\\n200002312103012003212121020\\n\", \"7982154\\n129530518193255487\\n\", \"7014809\\n102879756\\n\", \"9\\n100\\n\", \"11\\n382510420288648924\\n\", \"378135456\\n12831895682456824\\n\", \"23156\\n7387536280256906\\n\", \"1000000000\\n24333639443276286\\n\", \"123\\n10484\\n\", \"467879\\n368527280835256600\\n\", \"10\\n222597981530852393\\n\", \"364\\n237322807863020\\n\", \"130\\n000\\n\", \"10849219\\n83330627\\n\", \"13\\n18\\n\", \"2015054\\n4444204328\\n\", \"1000\\n1100\\n\", \"79\\n2409245254\\n\", \"7897\\n20391270166292898\\n\", \"1468\\n13320\\n\", \"378\\n1359\\n\", \"3215\\n4\\n\", \"442020\\n13331873970659\\n\", \"13\\n69\\n\", \"98000000\\n27886076676\\n\", \"25\\n71634\\n\", \"165726\\n392874513\\n\", \"7956123\\n7010970922288651\\n\", \"2707\\n10290927\\n\", \"11346\\n454881953410771\\n\", \"145\\n685163412455292\\n\", \"1740798\\n206550076142979\\n\", \"251546\\n4165\\n\", \"1000000000\\n56918303\\n\", \"9\\n5\\n\", \"158\\n48951942645\\n\", \"2\\n10000000001000000000000000000\\n\", \"25\\n1266433760\\n\", \"378\\n21651093\\n\", \"814730652\\n34218876863132\\n\", \"157137373\\n852498899566\\n\", \"215467\\n2734642997696861\\n\", \"1000000000\\n4070176872309999\\n\", \"789765212\\n966952869089049\\n\", \"56132425\\n832614779118996\\n\", \"1000000000\\n10\\n\", \"2\\n1110110101111000010001011110101001011001110000000010110010\\n\", \"124849\\n2693618\\n\", \"100\\n8557506757619383\\n\", \"98\\n13317246402593\\n\", \"5723\\n4787\\n\", \"25623752\\n19355088993851\\n\", \"57974\\n2526384742158226\\n\", \"67\\n45\\n\", \"315464878\\n4109142007348631\\n\", \"1675\\n3311307412\\n\", \"294\\n4000058441\\n\", \"50\\n32628617953028826\\n\", \"1000\\n121339395177437420\\n\", \"1344\\n1071086767462405\\n\", \"1000000000\\n11480601458788363\\n\", \"905835986\\n721631\\n\", \"13568864\\n2286561798809748\\n\", \"76559\\n6941226\\n\", \"45\\n2\\n\", \"34\\n19\\n\", \"12650\\n20192706888\\n\", \"2\\n100000100000000000000000\\n\", \"1000000000\\n1\\n\", \"8742\\n6328802843819\\n\", \"16\\n3031\\n\", \"17\\n980\\n\", \"13\\n23\\n\", \"20\\n767\\n\", \"7014809\\n146215771\\n\", \"9\\n110\\n\", \"378135456\\n22515280329632668\\n\", \"23156\\n904228495782893\\n\", \"1000000000\\n19868108084509094\\n\", \"123\\n8496\\n\", \"10\\n318411305869679718\\n\", \"364\\n157382223219894\\n\", \"10849219\\n23657853\\n\", \"13\\n11\\n\", \"2015054\\n4563254260\\n\", \"1000\\n1110\\n\", \"79\\n4016215149\\n\", \"1468\\n6982\\n\", \"378\\n1944\\n\", \"442020\\n12020999027729\\n\", \"13\\n86\\n\", \"98000000\\n33788534326\\n\", \"25\\n88702\\n\", \"165726\\n228716695\\n\", \"7956123\\n11275466385049837\\n\", \"2707\\n10898456\\n\", \"11346\\n839931412664248\\n\", \"145\\n492646080219737\\n\", \"1740798\\n85593993242221\\n\", \"1000\\n0000\\n\", \"4\\n2\\n\", \"130\\n010\\n\"], \"outputs\": [\"475\", \"594\", \"12\", \"3789\", \"52188307\", \"805176557484307547\", \"71\", \"997343614685146644\", \"582652156959951259\", \"268193483524125978\", \"1781911903273803\", \"3433598652149101\", \"17289468142098080\", \"1000000000000000000\", \"748054672922159638\", \"9490\", \"72980519445207316\", \"996517375802030516\", \"4993183241788\", \"100\", \"12975669536\", \"1621222691867186\", \"70296063\", \"9\", \"6147498437\", \"100001\", \"27953623755\", \"6062228032315859\", \"4043\", \"26508694\", \"4992\", \"68193483524125904\", \"269845965585325530\", \"3\", \"26973736400898\", \"467528530570226788\", \"53\", \"19052834812\", \"33554432\", \"4785\", \"272324690824608506\", \"738505167292405431\", \"770641106\", \"273150934002691930\", \"4255926011071634\", \"3071250\", \"269019726702209402\", \"83675287784142\", \"330396354354854\", \"45965585242840\", \"99531390411376\", \"0\", \"7278\", \"69204007\", \"1464\", \"3\", \"270672213058376250\", \"15908078858\", \"268435456\", \"26524975\", \"694167817136539\", \"65568783041\", \"46358126945150\", \"82638887763\", \"966934630351661\", \"17289468142098026\", \"821298450375293\", \"10027171005317597\", \"860152492903254335\", \"6\", \"267367244641009850\", \"346042641011647808\", \"7688108\", \"7226127039816418\", \"271498451941492378\", \"10007394522984\", \"4907\", \"65689385274354\", \"7079242212325439\", \"29\", \"21776150370291089\", \"100000\", \"35848000882710261\", \"8852883441\", \"72564361\", \"59962796634170079\", \"839105509657869885\", \"814487257688093\", \"7289468142097485\", \"371320\", \"4621032639107192\", \"76682942\", \"22\", \"1\", \"13\", \"40587846725\", \"8388608\", \"0\", \"74498130012303\", \"1\", \"9019726702208584\", \"82535003403725833\", \"73027846\\n\", \"81\\n\", \"172231866179050935\\n\", \"48521947022960760\\n\", \"91721750832368430\\n\", \"24333639443276286\\n\", \"12876\\n\", \"80674656546747372\\n\", \"222597981530852393\\n\", \"551469610812821084\\n\", \"0\\n\", \"90124379\\n\", \"21\\n\", \"8955104304\\n\", \"1100\\n\", \"7716707335\\n\", \"77974627231096383\\n\", \"19404\\n\", \"737\\n\", \"4\\n\", \"26126652576639\\n\", \"87\\n\", \"27330076676\\n\", \"119454\\n\", \"651046241\\n\", \"4439721124561997\\n\", \"74064447\\n\", \"66354999927451\\n\", \"8876919867755382\\n\", \"625215372765251\\n\", \"4165\\n\", \"56918303\\n\", \"5\\n\", \"449531645097\\n\", \"268697600\\n\", \"1869180910775\\n\", \"131600037\\n\", \"278791129209708\\n\", \"1339537867018\\n\", \"23417202174971075\\n\", \"4070176872309999\\n\", \"7636656899948985\\n\", \"25389867713255721\\n\", \"10\\n\", \"267367244641009842\\n\", \"3339692\\n\", \"8557506757619383\\n\", \"11802851130527\\n\", \"4787\\n\", \"49594985979867\\n\", \"492203336834244232\\n\", \"45\\n\", \"401515403785035767\\n\", \"930851512\\n\", \"25831163826451157\\n\", \"344848705972570426\\n\", \"121339395177437420\\n\", \"351762807909141\\n\", \"11480601458788363\\n\", \"721631\\n\", \"4167964069931316\\n\", \"5323797\\n\", \"2\\n\", \"19\\n\", \"32281794888\\n\", \"8519680\\n\", \"1\\n\", \"42309520903611\\n\", \"12337\\n\", \"2737\\n\", \"29\\n\", \"2927\\n\", \"104423097\\n\", \"90\\n\", \"8513825999400348\\n\", \"11225519405654549\\n\", \"198681080084509094\\n\", \"10428\\n\", \"318411305869679718\\n\", \"1003912188094182\\n\", \"25356291\\n\", \"11\\n\", \"9194945662\\n\", \"1110\\n\", \"1566027003\\n\", \"9790\\n\", \"7226\\n\", \"23538621455529\\n\", \"110\\n\", \"33114534326\\n\", \"3254377\\n\", \"379032057\\n\", \"7149630022620759\\n\", \"75709832\\n\", \"1226634073299612\\n\", \"6249773867683127\\n\", \"258616124596975\\n\", \"0\\n\", \"2\\n\", \"10\\n\"]}"
}
|
{
"index": 2
}
|
codecontests
|
[
{
"role": "user",
"content": "Snuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller. Find the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n* 4 \\leq N \\leq 2 \\times 10^5\n* 1 \\leq A_i \\leq 10^9\n* All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN\nA_1 A_2 ... A_N\n\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nExamples\n\nInput\n\n5\n3 2 4 1 2\n\n\nOutput\n\n2\n\n\nInput\n\n10\n10 71 84 33 6 47 23 25 52 64\n\n\nOutput\n\n36\n\n\nInput\n\n7\n1 2 3 1000000000 4 5 6\n\n\nOutput\n\n999999994\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"10\\n10 71 84 33 6 47 23 25 52 64\", \"7\\n1 2 3 1000000000 4 5 6\", \"5\\n3 2 4 1 2\", \"10\\n10 71 113 33 6 47 23 25 52 64\", \"7\\n1 2 3 1100000000 4 5 6\", \"5\\n3 2 4 2 2\", \"10\\n10 102 113 33 6 47 23 25 52 64\", \"7\\n1 2 3 1100000000 4 5 2\", \"10\\n10 102 113 60 6 47 23 25 52 64\", \"5\\n5 2 4 2 1\", \"10\\n10 102 113 60 6 47 23 25 52 118\", \"7\\n1 2 3 1100000000 1 20 2\", \"5\\n4 3 4 2 1\", \"10\\n10 102 113 60 6 90 16 25 52 118\", \"10\\n19 102 113 60 6 90 16 6 52 118\", \"10\\n19 102 113 60 6 10 16 6 52 118\", \"7\\n1 2 3 1101000000 1 2 3\", \"7\\n1 2 3 1101000100 1 2 3\", \"5\\n2 1 6 0 2\", \"7\\n1 1 3 1101000100 1 5 0\", \"7\\n1 1 3 1101000100 0 0 0\", \"7\\n1 0 3 1101000100 0 0 0\", \"10\\n10 71 84 33 6 47 8 25 52 64\", \"7\\n1 2 4 1000000000 4 5 6\", \"10\\n11 102 113 33 6 47 23 25 52 64\", \"10\\n10 102 113 60 6 47 23 25 74 64\", \"7\\n1 2 3 1100000010 1 20 2\", \"10\\n10 102 113 72 6 90 16 25 52 118\", \"7\\n0 2 3 1100000000 1 37 2\", \"5\\n2 3 6 2 1\", \"10\\n19 102 113 60 6 97 16 6 52 118\", \"10\\n19 102 113 69 6 10 16 6 52 118\", \"5\\n2 1 12 0 2\", \"7\\n1 2 3 1101000110 1 3 3\", \"10\\n10 71 84 33 6 47 8 8 52 64\", \"10\\n10 13 113 33 8 47 23 25 52 64\", \"10\\n11 102 45 33 6 47 23 25 52 64\", \"7\\n1 2 2 1100001000 4 5 2\", \"10\\n10 102 113 60 7 47 23 25 74 64\", \"7\\n1 2 3 1100000100 6 20 2\", \"7\\n1 2 3 1100100010 1 20 2\", \"10\\n10 102 113 72 6 90 16 25 89 118\", \"10\\n10 102 203 60 6 90 16 8 52 118\", \"5\\n2 1 7 0 2\", \"7\\n1 2 3 1101010100 1 0 0\", \"7\\n1 1 3 0101000100 0 0 1\", \"10\\n10 18 84 33 6 47 8 8 52 64\", \"7\\n1 2 0 1100000100 4 5 6\", \"10\\n11 102 45 33 6 47 4 25 52 64\", \"10\\n0 102 113 60 7 47 23 25 74 64\", \"10\\n10 102 113 60 6 6 19 25 52 118\", \"7\\n1 2 0 1100100010 1 20 2\", \"7\\n0 2 3 1000000000 2 37 2\", \"10\\n19 183 113 60 6 194 16 6 52 118\", \"10\\n19 102 57 69 11 10 16 6 52 118\", \"7\\n2 2 5 1101000100 1 2 5\", \"5\\n2 1 7 0 0\", \"7\\n1 2 3 1111000100 2 5 0\", \"7\\n0 1 3 1101000101 0 0 0\", \"10\\n10 18 84 33 6 6 8 8 52 64\", \"10\\n10 20 113 33 8 47 23 25 92 64\", \"10\\n11 102 45 33 6 47 4 15 52 64\", \"10\\n10 102 33 60 6 6 19 25 52 118\", \"7\\n0 2 3 1100000100 6 20 3\", \"5\\n8 0 2 2 0\", \"10\\n17 155 70 60 6 47 27 25 52 118\", \"7\\n0 2 3 1001000000 2 37 2\", \"10\\n19 183 113 60 6 194 16 6 52 38\", \"7\\n1 4 3 1100010000 2 2 5\", \"7\\n2 2 5 1101100100 1 2 5\", \"7\\n1 1 0 0101000100 0 0 0\", \"7\\n1 1 4 1001000000 3 7 6\", \"10\\n10 26 113 33 8 47 23 25 92 64\", \"10\\n11 102 45 33 6 47 4 15 49 64\", \"10\\n-1 83 113 60 7 47 23 25 74 64\", \"7\\n0 4 0 1100000100 4 10 2\", \"7\\n0 2 3 1001010000 2 37 2\", \"10\\n19 183 113 60 6 273 16 6 52 38\", \"7\\n1 4 3 1100010000 2 1 5\", \"7\\n2 0 3 1101000000 0 4 0\", \"7\\n0 2 5 1101100100 1 2 5\", \"7\\n1 2 1 1111000100 2 6 0\", \"7\\n1 0 5 1101010100 1 0 -1\", \"7\\n0 2 3 1001010000 4 37 2\", \"10\\n10 102 236 60 1 90 16 8 52 56\", \"10\\n19 183 40 60 6 273 16 6 52 38\", \"10\\n19 102 10 69 19 10 16 6 62 118\", \"7\\n2 -1 3 1101000000 0 4 0\", \"7\\n1 2 1 0111000100 2 6 0\", \"7\\n1 1 3 1101010100 2 1 0\", \"10\\n10 18 115 33 6 6 8 6 52 90\", \"10\\n-1 83 225 60 7 39 23 25 74 64\", \"7\\n1 4 1 1000001000 2 1 2\", \"10\\n19 102 10 9 19 10 16 6 62 118\", \"7\\n1 0 0 0101001100 0 1 0\", \"10\\n10 26 146 33 8 47 23 26 92 64\", \"10\\n10 102 21 72 6 138 36 25 21 14\", \"5\\n2 10 8 1 0\", \"10\\n8 102 236 60 1 90 16 8 55 56\", \"7\\n2 -1 3 1101000001 1 4 0\", \"7\\n1 0 0 0101011100 0 1 0\", \"7\\n0 4 3 1100001010 4 4 4\", \"7\\n-1 4 1 1100000100 1 7 2\"], \"outputs\": [\"36\", \"999999994\", \"2\", \"53\\n\", \"1099999994\\n\", \"2\\n\", \"22\\n\", \"1099999996\\n\", \"29\\n\", \"3\\n\", \"58\\n\", \"1099999997\\n\", \"1\\n\", \"61\\n\", \"55\\n\", \"37\\n\", \"1100999997\\n\", \"1101000097\\n\", \"5\\n\", \"1101000098\\n\", \"1101000099\\n\", \"1101000100\\n\", \"36\\n\", \"999999994\\n\", \"21\\n\", \"49\\n\", \"1100000007\\n\", \"73\\n\", \"1099999998\\n\", \"4\\n\", \"52\\n\", \"46\\n\", \"11\\n\", \"1101000107\\n\", \"35\\n\", \"72\\n\", \"32\\n\", \"1100000996\\n\", \"50\\n\", \"1100000094\\n\", \"1100100007\\n\", \"95\\n\", \"91\\n\", \"6\\n\", \"1101010099\\n\", \"101000099\\n\", \"48\\n\", \"1100000097\\n\", \"38\\n\", \"60\\n\", \"56\\n\", \"1100100008\\n\", \"999999998\\n\", \"23\\n\", \"31\\n\", \"1101000096\\n\", \"7\\n\", \"1111000097\\n\", \"1101000101\\n\", \"59\\n\", \"79\\n\", \"44\\n\", \"19\\n\", \"1100000095\\n\", \"8\\n\", \"54\\n\", \"1000999998\\n\", \"90\\n\", \"1100009996\\n\", \"1101100096\\n\", \"101000100\\n\", \"1000999994\\n\", \"85\\n\", \"41\\n\", \"80\\n\", \"1100000096\\n\", \"1001009998\\n\", \"161\\n\", \"1100009997\\n\", \"1100999998\\n\", \"1101100097\\n\", \"1111000098\\n\", \"1101010100\\n\", \"1001009996\\n\", \"124\\n\", \"167\\n\", \"27\\n\", \"1100999999\\n\", \"111000098\\n\", \"1101010098\\n\", \"87\\n\", \"143\\n\", \"1000000998\\n\", \"57\\n\", \"101001100\\n\", \"118\\n\", \"42\\n\", \"9\\n\", \"126\\n\", \"1101000000\\n\", \"101011100\\n\", \"1100001006\\n\", \"1100000098\\n\"]}"
}
|
{
"index": 3
}
|
codecontests
|
[
{
"role": "user",
"content": "You are given a permutation p_1, p_2, …, p_n.\n\nIn one move you can swap two adjacent values.\n\nYou want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≤ i ≤ n-k+1 such that p_i = 1, p_{i+1} = 2, …, p_{i+k-1}=k.\n\nLet f(k) be the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation.\n\nYou need to find f(1), f(2), …, f(n).\n\nInput\n\nThe first line of input contains one integer n (1 ≤ n ≤ 200 000): the number of elements in the permutation.\n\nThe next line of input contains n integers p_1, p_2, …, p_n: given permutation (1 ≤ p_i ≤ n).\n\nOutput\n\nPrint n integers, the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation, for k=1, 2, …, n.\n\nExamples\n\nInput\n\n\n5\n5 4 3 2 1\n\n\nOutput\n\n\n0 1 3 6 10 \n\n\nInput\n\n\n3\n1 2 3\n\n\nOutput\n\n\n0 0 0 \n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"3\\n1 2 3\\n\", \"5\\n5 4 3 2 1\\n\", \"1\\n1\\n\", \"100\\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\\n\", \"10\\n5 1 6 2 8 3 4 10 9 7\\n\", \"5\\n5 4 3 1 2\\n\", \"3\\n3 2 1\\n\", \"3\\n2 3 1\\n\", \"10\\n5 1 6 2 8 4 3 10 9 7\\n\", \"3\\n3 1 2\\n\", \"3\\n2 1 3\\n\", \"5\\n5 4 1 2 3\\n\", \"3\\n1 3 2\\n\"], \"outputs\": [\"0 0 0\\n\", \"0 1 3 6 10\\n\", \"0\\n\", \"0 42 52 101 101 117 146 166 166 188 194 197 249 258 294 298 345 415 445 492 522 529 540 562 569 628 628 644 684 699 765 766 768 774 791 812 828 844 863 931 996 1011 1036 1040 1105 1166 1175 1232 1237 1251 1282 1364 1377 1409 1445 1455 1461 1534 1553 1565 1572 1581 1664 1706 1715 1779 1787 1837 1841 1847 1909 1919 1973 1976 2010 2060 2063 2087 2125 2133 2192 2193 2196 2276 2305 2305 2324 2327 2352 2361 2417 2418 2467 2468 2510 2598 2599 2697 2697 2770\\n\", \"0 1 2 3 8 9 12 12 13 13\\n\", \"0 0 2 5 9\\n\", \"0 1 3\\n\", \"0 2 2\\n\", \"0 1 3 4 9 10 13 13 14 14\\n\", \"0 0 2\\n\", \"0 1 1\\n\", \"0 0 0 3 7\\n\", \"0 1 1\\n\"]}"
}
|
{
"index": 4
}
|
taco
|
[
{
"role": "user",
"content": "Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive. The files must be saved in the order they appear in the queue. \n\n### Input:\n\n* Array of file sizes `(0 <= s <= 100)`\n* Capacity of the HD `(0 <= c <= 500)`\n\n### Output:\n\n* Number of files that can be fully saved in the HD. \n\n### Examples:\n\n```\nsave([4,4,4,3,3], 12) -> 3\n# 4+4+4 <= 12, but 4+4+4+3 > 12\n```\n\n```\nsave([4,4,4,3,3], 11) -> 2\n# 4+4 <= 11, but 4+4+4 > 11\n```\n\nDo not expect any negative or invalid inputs.\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"fn_name\": \"save\", \"inputs\": [[[4, 4, 4, 3, 3], 12], [[4, 4, 4, 3, 3], 11], [[4, 8, 15, 16, 23, 42], 108], [[13], 13], [[1, 2, 3, 4], 250], [[100], 500], [[11, 13, 15, 17, 19], 8], [[45], 12]], \"outputs\": [[3], [2], [6], [1], [4], [1], [0], [0]]}"
}
|
{
"index": 5
}
|
codecontests
|
[
{
"role": "user",
"content": "You are playing a game with a bag of red and black balls. Initially, you are told that the bag has n balls total. In addition, you are also told that the bag has probability pi / 106 of containing exactly i red balls.\n\nYou now would like to buy balls from this bag. You really like the color red, so red balls are worth a unit of 1, while black balls are worth nothing. To buy a ball, if there are still balls in the bag, you pay a cost c with 0 ≤ c ≤ 1, and draw a ball randomly from the bag. You can choose to stop buying at any point (and you can even choose to not buy anything at all).\n\nGiven that you buy optimally to maximize the expected profit (i.e. # red balls - cost needed to obtain them), print the maximum expected profit.\n\nInput\n\nThe first line of input will contain two integers n, X (1 ≤ n ≤ 10 000, 0 ≤ X ≤ 106).\n\nThe next line of input will contain n + 1 integers p0, p1, ... pn (0 ≤ pi ≤ 106, <image>)\n\nThe value of c can be computed as <image>.\n\nOutput\n\nPrint a single floating point number representing the optimal expected value.\n\nYour answer will be accepted if it has absolute or relative error at most 10 - 9. More specifically, if your answer is a and the jury answer is b, your answer will be accepted if <image>.\n\nExample\n\nInput\n\n3 200000\n250000 250000 250000 250000\n\n\nOutput\n\n0.9000000000\n\nNote\n\nHere, there is equal probability for the bag to contain 0,1,2,3 red balls. Also, it costs 0.2 to draw a ball from the bag.\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"3 200000\\n250000 250000 250000 250000\\n\", \"6 202020\\n100000 10000 100000 10000 670000 10000 100000\\n\", \"5 999999\\n0 0 0 0 1 999999\\n\", \"1 499999\\n500000 500000\\n\", \"20 123123\\n1682 7 254283 3077 0 0 62970 31538 847 13907 136 114786 8896 21735 366 197843 34 5405 85982 151831 44675\\n\", \"1 0\\n1000000 0\\n\", \"1 1000000\\n0 1000000\\n\", \"10 234567\\n200000 0 0 0 200000 0 200000 0 200000 0 200000\\n\", \"20 539824\\n89 745 2051 4086 6484 9638 13708 18398 23681 29010 35616 43101 50384 59257 68339 77831 88430 99269 110714 122979 136190\\n\", \"3 590909\\n250000 250000 250000 250000\\n\", \"20 432432\\n819 6 114860 85975 254174 31601 21342 5378 0 9060 44688 41 1 14140 133 62548 3175 352 1727 152041 197939\\n\", \"6 202020\\n100000 10000 100000 10000 670000 10010 100000\\n\", \"5 999999\\n0 0 -1 0 1 999999\\n\", \"1 499999\\n115576 500000\\n\", \"20 123123\\n1682 7 254283 3077 0 0 62970 31538 847 13907 136 114786 8896 21735 366 197843 34 5405 85982 8318 44675\\n\", \"1 0\\n1001000 0\\n\", \"10 234567\\n200000 0 0 0 200000 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 745 2051 4086 6484 9638 1603 18398 23681 29010 35616 43101 50384 59257 68339 77831 88430 99269 110714 122979 136190\\n\", \"3 590909\\n228542 250000 250000 250000\\n\", \"7 432432\\n819 6 114860 85975 254174 31601 21342 5378 0 9060 44688 41 1 14140 133 62548 3175 352 1727 152041 197939\\n\", \"3 200000\\n250000 250000 250000 397262\\n\", \"5 999999\\n0 0 -1 0 2 999999\\n\", \"1 499999\\n213407 500000\\n\", \"20 123123\\n1682 7 254283 3077 0 0 62970 31538 847 13907 136 114786 8896 21735 366 197843 34 5405 85982 8318 81415\\n\", \"10 234567\\n200000 0 0 0 372503 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 232 2051 4086 6484 9638 1603 18398 23681 29010 35616 43101 50384 59257 68339 77831 88430 99269 110714 122979 136190\\n\", \"3 200000\\n250000 250000 250000 367997\\n\", \"5 999999\\n1 0 -1 0 2 999999\\n\", \"20 123123\\n1682 7 254283 3077 0 0 62970 31538 847 26513 136 114786 8896 21735 366 197843 34 5405 85982 8318 81415\\n\", \"5 234567\\n200000 0 0 0 372503 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 232 2051 4086 6484 9638 1603 12499 23681 29010 35616 43101 50384 59257 68339 77831 88430 99269 110714 122979 136190\\n\", \"3 200000\\n250000 250000 16477 367997\\n\", \"5 999999\\n1 0 -1 0 4 999999\\n\", \"20 123123\\n1682 10 254283 3077 0 0 62970 31538 847 26513 136 114786 8896 21735 366 197843 34 5405 85982 8318 81415\\n\", \"5 234567\\n200000 0 1 0 372503 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 232 2051 4086 6484 9638 1603 12499 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 110714 122979 136190\\n\", \"7 252582\\n819 6 114860 85975 254174 31601 21342 5378 0 9060 44688 41 1 14140 133 62548 1273 352 1727 152041 196806\\n\", \"3 289595\\n250000 250000 16477 367997\\n\", \"20 123123\\n1682 10 254283 3077 0 0 62970 31538 847 26513 136 114786 8896 21735 484 197843 34 5405 85982 8318 81415\\n\", \"5 234567\\n200000 0 1 0 447710 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 232 2051 4086 6484 9638 1603 14800 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 110714 122979 136190\\n\", \"7 252582\\n819 6 114860 85975 254174 31601 34809 5378 0 9060 44688 41 1 14140 133 62548 1273 352 1727 152041 196806\\n\", \"3 289595\\n250000 250000 7702 367997\\n\", \"5 999999\\n1 0 -1 0 4 1433939\\n\", \"20 123123\\n1682 10 254283 3077 0 0 62970 31538 847 26513 136 114786 3347 21735 484 197843 34 5405 85982 8318 81415\\n\", \"5 120377\\n200000 0 1 0 447710 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 232 2051 4086 6484 9638 1603 14800 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 110714 122979 85118\\n\", \"7 134694\\n819 6 114860 85975 254174 31601 34809 5378 0 9060 44688 41 1 14140 133 62548 1273 352 1727 152041 196806\\n\", \"5 999999\\n1 0 -2 0 4 1433939\\n\", \"20 123123\\n1682 2 254283 3077 0 0 62970 31538 847 26513 136 114786 3347 21735 484 197843 34 5405 85982 8318 81415\\n\", \"5 120377\\n144884 0 1 0 447710 0 200000 0 200000 0 12191\\n\", \"20 539824\\n89 201 2051 4086 6484 9638 1603 14800 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 110714 122979 85118\\n\", \"5 999999\\n0 0 -2 0 4 1433939\\n\", \"20 123123\\n1682 2 73202 3077 0 0 62970 31538 847 26513 136 114786 3347 21735 484 197843 34 5405 85982 8318 81415\\n\", \"20 539824\\n89 201 2051 4086 6484 18428 1603 14800 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 110714 122979 85118\\n\", \"7 134694\\n819 6 162889 85975 254174 31601 34809 5378 0 9060 44688 41 1 14140 133 62548 1273 352 2984 152041 196806\\n\", \"20 123123\\n1682 2 73202 3077 0 0 62970 31538 847 26513 136 114786 3347 21735 484 197843 34 5405 43293 8318 81415\\n\", \"5 120377\\n26622 0 1 0 447710 0 200000 0 200000 -1 12191\\n\", \"20 539824\\n89 201 2051 4086 6484 18428 1603 14800 23681 29010 35616 43101 50384 95017 68339 77831 88430 99269 44013 122979 85118\\n\", \"7 134694\\n819 6 162889 85975 254174 31601 34809 1068 0 9060 44688 41 1 14140 133 62548 1273 352 2984 152041 196806\\n\", \"20 123123\\n1682 2 73202 3077 0 0 62970 31538 847 26513 136 114786 3347 21735 902 197843 34 5405 43293 8318 81415\\n\", \"20 539824\\n89 201 2051 4086 6484 18428 1603 14800 23681 29010 35616 43101 50384 44776 68339 77831 88430 99269 44013 122979 85118\\n\", \"20 123123\\n1682 2 73202 3077 0 0 94795 31538 847 26513 136 114786 3347 21735 902 197843 34 5405 43293 8318 81415\\n\", \"20 539824\\n89 201 2051 4086 6484 18428 1603 14800 23681 29010 35616 43101 50384 44776 68339 77831 88430 99269 44013 171823 85118\\n\", \"7 134694\\n819 6 262706 85975 254174 31601 34809 1068 0 9060 44688 41 1 14140 133 62548 1273 352 2984 249563 196806\\n\", \"20 123123\\n1682 2 143095 3077 0 0 94795 31538 847 26513 136 114786 3347 21735 902 197843 34 5405 43293 8318 81415\\n\", \"20 539824\\n89 201 2051 4086 6484 6233 1603 14800 23681 29010 35616 43101 50384 44776 68339 77831 88430 99269 44013 171823 85118\\n\", \"20 123123\\n1682 2 143095 3077 0 0 94795 31538 847 26513 136 114786 3347 21735 902 62243 34 5405 43293 8318 81415\\n\", \"20 539824\\n36 201 2051 4086 6484 6233 1603 14800 23681 29010 35616 43101 50384 44776 68339 77831 88430 99269 44013 171823 85118\\n\", \"7 134694\\n25 6 262706 85975 254174 31601 34809 1068 0 9060 44688 67 1 14140 133 62548 1273 352 2984 249563 196806\\n\", \"20 109932\\n1682 2 143095 3077 0 0 94795 31538 847 26513 136 114786 3347 21735 902 62243 34 5405 43293 8318 81415\\n\", \"20 539824\\n38 201 2051 4086 6484 6233 1603 14800 23681 29010 35616 43101 50384 44776 68339 77831 88430 99269 44013 171823 85118\\n\", \"20 109932\\n1682 2 143095 3077 0 0 94795 31538 847 26513 136 114786 3347 21735 902 62243 34 5405 43293 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 6484 6233 1603 14800 23681 29010 35616 43101 50384 44776 68339 129625 88430 99269 44013 171823 85118\\n\", \"7 134694\\n25 12 262706 85975 254174 31601 34809 1068 0 9060 85979 67 1 14140 133 62548 1273 352 2984 249563 196806\\n\", \"20 109932\\n1682 2 143095 3077 0 1 94795 31538 847 26513 136 114786 3347 21735 902 62243 34 5405 43293 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 6484 6233 1603 21789 23681 29010 35616 43101 50384 44776 68339 129625 88430 99269 44013 171823 85118\\n\", \"7 134694\\n25 12 262706 73604 254174 31601 34809 1068 0 9060 85979 67 1 14140 133 62548 1273 352 2984 249563 196806\\n\", \"20 109932\\n1682 2 143095 3077 0 1 94795 31538 847 26513 136 114786 3347 21735 1705 62243 34 5405 43293 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 6484 6233 1603 21789 23681 29010 35616 43101 50384 44776 51314 129625 88430 99269 44013 171823 85118\\n\", \"20 109932\\n1682 2 143095 3077 0 1 94795 31538 847 26513 136 114786 3347 21735 1705 114039 34 5405 43293 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 44776 51314 129625 88430 99269 44013 171823 85118\\n\", \"20 109932\\n1682 2 143095 3077 0 1 94795 31538 847 26513 136 114786 3347 21735 1705 114039 34 5405 34847 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 41341 51314 129625 88430 99269 44013 171823 85118\\n\", \"20 109932\\n1682 2 147476 3077 0 1 94795 31538 847 26513 136 114786 3347 21735 1705 114039 34 5405 34847 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 46144 51314 129625 88430 99269 44013 171823 85118\\n\", \"7 134694\\n28 12 262706 73604 254174 31601 34809 1068 0 9060 693 67 1 14140 239 62548 1273 352 2984 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 94795 31538 847 791 136 114786 3347 21735 1705 114039 34 5405 34847 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 46144 51314 129625 88430 99269 44013 259948 85118\\n\", \"7 134694\\n28 12 262706 13791 254174 31601 34809 1068 0 9060 693 67 1 14140 239 62548 1273 352 2984 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 94795 31538 847 791 136 114786 3347 21735 1705 114039 34 4504 34847 11967 81415\\n\", \"20 539824\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 46144 51314 41529 88430 99269 44013 259948 85118\\n\", \"20 109932\\n1682 2 147476 3077 0 1 94795 31538 847 791 136 114786 3347 21735 1705 114039 34 4504 34847 11967 23004\\n\", \"20 343968\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 35616 43101 50384 46144 51314 41529 88430 99269 44013 259948 85118\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 3347 21735 1705 114039 34 4504 34847 11967 23004\\n\", \"20 343968\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 88430 99269 44013 259948 85118\\n\", \"7 134694\\n28 12 262706 18394 254174 31601 34809 1068 1 9060 693 78 1 14140 239 62548 1273 352 2984 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 3347 21735 1705 59294 34 4504 34847 11967 23004\\n\", \"20 343968\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 72745 99269 44013 259948 85118\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 6122 21735 1705 59294 34 4504 34847 11967 23004\\n\", \"20 585786\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 72745 99269 44013 259948 85118\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 6122 21735 1705 59294 34 4504 34847 12411 23004\\n\", \"20 585786\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 72745 99269 44013 415649 85118\\n\", \"7 134694\\n28 12 262706 18394 254174 31601 19564 1068 1 9060 693 78 1 14140 239 62548 1794 352 5790 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 6122 40451 1705 59294 34 4504 34847 12411 23004\\n\", \"20 585786\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 72745 99269 85318 415649 85118\\n\", \"7 199153\\n28 12 262706 18394 254174 31601 19564 1068 1 9060 693 78 1 14140 239 62548 1794 352 5790 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 6122 40451 1705 59294 34 4504 34847 12411 26754\\n\", \"20 585786\\n38 201 2051 4086 9622 6233 1603 21789 23681 29010 68355 43101 50384 46144 51314 41529 72745 99269 85318 110920 85118\\n\", \"7 199153\\n28 22 262706 18394 254174 31601 19564 1068 1 9060 693 78 1 14140 239 62548 1794 352 5790 329070 196806\\n\", \"20 109932\\n1682 2 147476 3077 0 1 24580 31538 847 791 136 114786 6122 40451 1705 59294 34 4504 34847 7350 26754\\n\"], \"outputs\": [\"0.9000000000\", \"2.4344387867\", \"0.0000040000\", \"0.0000010000\", \"8.9640029962\", \"0.0000000000\", \"0.0000000000\", \"3.5495784771\", \"4.5786473969\", \"0.0000001667\", \"3.8973078653\", \"2.4344456712\", \"0.0000051000\", \"0.3122483911\", \"7.6949807973\", \"0.0000000000\", \"2.6004060796\", \"4.6598402374\", \"0.0129579435\", \"0.6253716710\", \"1.0925392805\", \"0.0000044000\", \"0.2008632007\", \"8.0998225958\", \"2.4289834895\", \"4.6633914352\", \"1.0583148255\", \"0.0000034000\", \"8.0789838546\", \"1.7061500573\", \"4.7042631165\", \"0.9958531285\", \"0.0000014000\", \"8.0789521095\", \"1.7061480475\", \"4.6140664656\", \"1.8084731276\", \"0.7977818787\", \"8.0793226397\", \"1.8417587412\", \"4.5986397265\", \"1.8703292288\", \"0.8015593505\", \"0.0000024894\", \"8.0735783648\", \"2.2911437827\", \"4.3558031289\", \"2.6751897173\", \"0.0000036052\", \"8.0736634817\", \"2.5266302080\", \"4.3560121885\", \"0.0000041631\", \"10.0932169299\", \"4.2966520367\", \"2.5401891461\", \"9.7497297390\", \"3.2166020025\", \"4.0837090254\", \"2.5136584634\", \"9.7504545512\", \"4.1992730782\", \"9.4694042901\", \"4.4144048979\", \"2.2970401651\", \"8.6185795585\", \"4.5032173207\", \"7.7858436804\", \"4.5036110314\", \"2.3007180656\", \"8.0355120804\", \"4.5035961735\", \"8.0849647483\", \"4.4867640317\", \"2.3006968786\", \"8.0849562227\", \"4.4388944289\", \"2.3052759394\", \"8.0891407719\", \"4.4618951062\", \"8.4401464975\", \"4.4398873931\", \"8.3501669483\", \"4.4485630102\", \"8.2988026871\", \"4.4364498953\", \"2.3052617444\", \"8.3562447068\", \"4.7583550428\", \"2.3637740227\", \"8.3475609316\", \"4.8114616062\", \"7.4427696895\", \"8.6227300538\", \"7.9346728087\", \"8.4381302464\", \"2.3586007146\", \"7.3826388311\", \"8.4269817498\", \"7.3933532093\", \"3.8031146388\", \"7.4019029318\", \"4.2888247634\", \"2.2885820405\", \"7.5282972938\", \"4.3600479138\", \"1.8649801880\", \"7.6036810914\", \"3.3147847800\", \"1.8649397926\", \"7.5116819433\"]}"
}
|
{
"index": 6
}
|
codeforces
|
[
{
"role": "user",
"content": "Title: Hot Days\n\nTime Limit: None seconds\n\nMemory Limit: None megabytes\n\nProblem Description:\nThe official capital and the cultural capital of Berland are connected by a single road running through *n* regions. Each region has a unique climate, so the *i*-th (1<=≤<=*i*<=≤<=*n*) region has a stable temperature of *t**i* degrees in summer.\n\nThis summer a group of *m* schoolchildren wants to get from the official capital to the cultural capital to visit museums and sights. The trip organizers transport the children between the cities in buses, but sometimes it is very hot. Specifically, if the bus is driving through the *i*-th region and has *k* schoolchildren, then the temperature inside the bus is *t**i*<=+<=*k* degrees.\n\nOf course, nobody likes it when the bus is hot. So, when the bus drives through the *i*-th region, if it has more than *T**i* degrees inside, each of the schoolchild in the bus demands compensation for the uncomfortable conditions. The compensation is as large as *x**i* rubles and it is charged in each region where the temperature in the bus exceeds the limit.\n\nTo save money, the organizers of the trip may arbitrarily add or remove extra buses in the beginning of the trip, and between regions (of course, they need at least one bus to pass any region). The organizers can also arbitrarily sort the children into buses, however, each of buses in the *i*-th region will cost the organizers *cost**i* rubles. Please note that sorting children into buses takes no money.\n\nYour task is to find the minimum number of rubles, which the organizers will have to spend to transport all schoolchildren.\n\nInput Specification:\nThe first input line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=105; 1<=≤<=*m*<=≤<=106) — the number of regions on the way and the number of schoolchildren in the group, correspondingly. Next *n* lines contain four integers each: the *i*-th line contains *t**i*, *T**i*, *x**i* and *cost**i* (1<=≤<=*t**i*,<=*T**i*,<=*x**i*,<=*cost**i*<=≤<=106). The numbers in the lines are separated by single spaces.\n\nOutput Specification:\nPrint the only integer — the minimum number of roubles the organizers will have to spend to transport all schoolchildren.\n\nPlease, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.\n\nDemo Input:\n['2 10\\n30 35 1 100\\n20 35 10 10\\n', '3 100\\n10 30 1000 1\\n5 10 1000 3\\n10 40 1000 100000\\n']\n\nDemo Output:\n['120\\n', '200065\\n']\n\nNote:\nIn the first sample the organizers will use only one bus to travel through the first region. However, the temperature in the bus will equal 30 + 10 = 40 degrees and each of 10 schoolchildren will ask for compensation. Only one bus will transport the group through the second region too, but the temperature inside won't exceed the limit. Overall, the organizers will spend 100 + 10 + 10 = 120 rubles.\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"2 10\\n30 35 1 100\\n20 35 10 10\", \"3 100\\n10 30 1000 1\\n5 10 1000 3\\n10 40 1000 100000\", \"10 1\\n8 6 3 4\\n9 10 7 7\\n1 3 9 5\\n10 9 4 2\\n1 10 2 10\\n1 1 8 5\\n5 5 9 2\\n5 8 4 3\\n4 4 9 7\\n5 7 5 10\", \"5 5\\n100 29 49 77\\n34 74 41 8\\n32 21 24 91\\n45 52 16 51\\n50 87 90 94\", \"1 1000000\\n4 4 6 2\", \"20 102\\n73 79 75 27\\n13 15 62 47\\n74 75 85 86\\n49 81 23 69\\n43 17 45 27\\n35 14 90 35\\n51 74 35 33\\n54 66 46 24\\n33 76 49 3\\n34 53 25 76\\n69 72 76 31\\n41 31 8 48\\n49 48 85 24\\n19 2 59 83\\n19 31 51 86\\n31 10 45 76\\n56 47 79 86\\n49 33 15 1\\n77 89 26 64\\n7 52 76 77\"], \"outputs\": [\"120\", \"200065\", \"88\", \"686\", \"6000002\", \"59201\"]}"
}
|
{
"index": 7
}
|
taco
|
[
{
"role": "user",
"content": "You’re playing hopscotch! You start at the origin and your goal is to hop to the lattice point $(N, N)$. A hop consists of going from lattice point $(x_1, y_1)$ to $(x_2, y_2)$, where $x_1 < x_2$ and $y_1 < y_2$.\n\nYou dislike making small hops though. You’ve decided that for every hop you make between two lattice points, the x-coordinate must increase by at least $X$ and the y-coordinate must increase by at least $Y$.\n\nCompute the number of distinct paths you can take between $(0, 0)$ and $(N, N)$ that respect the above constraints. Two paths are distinct if there is some lattice point that you visit in one path which you don’t visit in the other.\n\nHint: The output involves arithmetic mod $10^9+7$. Note that with $p$ a prime like $10^9+7$, and $x$ an integer not equal to $0$ mod $p$, then $x(x^{p-2})$ mod $p$ equals $1$ mod $p$.\n\n-----Input-----\nThe input consists of a line of three integers, $N$ $X$ $Y$. You may assume $1 \\le X, Y \\le N \\le 10^{6}$.\n\n-----Output-----\nThe number of distinct paths you can take between the two lattice points can be very large. Hence output this number modulo 1 000 000 007 ($10^9 + 7$).\n\n-----Examples-----\nSample Input:\n2 1 1\nSample Output:\n2\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"2 1 1\\n\", \"7 2 3\\n\"], \"outputs\": [\"2\\n\", \"9\\n\"]}"
}
|
{
"index": 8
}
|
codecontests
|
[
{
"role": "user",
"content": "Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out).\n\nFor $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.\n\n* enqueue($t$, $x$): Insert an integer $x$ to $Q_t$.\n* front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing.\n* dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing.\n\n\n\nIn the initial state, all queues are empty.\n\nConstraints\n\n* $1 \\leq n \\leq 1,000$\n* $1 \\leq q \\leq 200,000$\n* $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$n \\; q$\n$query_1$\n$query_2$\n:\n$query_q$\n\n\nEach query $query_i$ is given by\n\n\n0 $t$ $x$\n\n\nor\n\n\n1 $t$\n\n\nor\n\n\n2 $t$\n\n\nwhere the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively.\n\nOutput\n\nFor each front operation, print an integer in a line.\n\nExample\n\nInput\n\n3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n\n\nOutput\n\n1\n4\n2\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"3 9\\n0 0 1\\n0 0 2\\n0 0 3\\n0 2 4\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 4\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 1 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 1 3\\n0 2 6\\n0 2 5\\n1 1\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 1 3\\n0 0 6\\n0 2 5\\n1 1\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 0\\n0 0 2\\n0 1 3\\n0 0 6\\n0 2 5\\n1 1\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 0\\n0 0 2\\n0 0 3\\n0 0 6\\n0 2 5\\n1 1\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 0 1\\n0 0 2\\n0 0 3\\n0 2 4\\n0 2 10\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 4\\n0 2 4\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n1 0\\n1 0\", \"3 9\\n0 1 1\\n0 0 0\\n0 1 3\\n0 2 6\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\", \"3 9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\\n0 2 5\\n1 1\\n1 2\\n0 0\\n1 1\", \"5 9\\n0 1 0\\n0 0 2\\n0 0 3\\n0 0 6\\n0 2 0\\n1 1\\n1 2\\n2 0\\n1 0\", \"4 9\\n0 1 1\\n0 0 2\\n0 0 3\\n0 2 8\\n0 2 5\\n1 0\\n1 2\\n2 0\\n1 0\"], \"outputs\": [\"1\\n4\\n2\", \"2\\n4\\n3\\n\", \"2\\n6\\n3\\n\", \"2\\n6\\n\", \"1\\n6\\n\", \"1\\n5\\n6\\n\", \"0\\n5\\n6\\n\", \"0\\n5\\n3\\n\", \"1\\n4\\n2\\n\", \"2\\n4\\n4\\n\", \"2\\n6\\n2\\n2\\n\", \"0\\n6\\n\", \"2\\n7\\n3\\n\", \"6\\n5\\n\", \"1\\n5\\n1\\n\", \"5\\n5\\n6\\n\", \"0\\n2\\n3\\n\", \"3\\n7\\n3\\n\", \"1\\n5\\n\", \"1\\n5\\n2\\n\", \"3\\n5\\n3\\n\", \"1\\n10\\n\", \"2\\n1\\n3\\n\", \"3\\n6\\n3\\n\", \"1\\n4\\n\", \"0\\n\", \"3\\n5\\n\", \"5\\n5\\n10\\n\", \"0\\n3\\n\", \"3\\n11\\n3\\n\", \"0\\n6\\n2\\n2\\n\", \"3\\n5\\n7\\n\", \"3\\n3\\n\", \"1\\n3\\n6\\n\", \"1\\n\", \"3\\n3\\n3\\n\", \"0\\n6\\n1\\n1\\n\", \"3\\n3\\n7\\n\", \"1\\n6\\n1\\n1\\n\", \"0\\n6\\n3\\n3\\n\", \"10\\n\", \"1\\n6\\n2\\n1\\n\", \"2\\n\", \"2\\n2\\n3\\n\", \"2\\n5\\n3\\n\", \"0\\n5\\n3\\n3\\n3\\n3\\n3\\n3\\n\", \"1\\n0\\n1\\n\", \"2\\n6\\n0\\n2\\n\", \"0\\n5\\n2\\n\", \"0\\n2\\n4\\n\", \"0\\n6\\n0\\n0\\n\", \"2\\n10\\n\", \"1\\n4\\n3\\n\", \"2\\n0\\n3\\n\", \"2\\n3\\n\", \"1\\n4\\n10\\n\", \"4\\n5\\n\", \"1\\n2\\n\", \"2\\n4\\n5\\n\", \"0\\n3\\n3\\n3\\n3\\n3\\n3\\n3\\n\", \"0\\n10\\n1\\n1\\n\", \"2\\n2\\n2\\n\", \"2\\n6\\n2\\n\", \"-1\\n5\\n2\\n\", \"0\\n2\\n6\\n\", \"2\\n-1\\n3\\n\", \"0\\n12\\n\", \"0\\n6\\n4\\n4\\n\", \"3\\n9\\n7\\n\", \"1\\n2\\n3\\n\", \"5\\n\", \"6\\n3\\n3\\n3\\n3\\n3\\n3\\n3\\n\", \"2\\n2\\n6\\n\", \"2\\n-1\\n\", \"0\\n17\\n\", \"3\\n9\\n\", \"6\\n0\\n3\\n3\\n3\\n3\\n3\\n3\\n3\\n\", \"3\\n6\\n\", \"0\\n2\\n2\\n\", \"4\\n-1\\n\", \"3\\n2\\n\", \"1\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n\", \"3\\n\", \"0\\n2\\n0\\n2\\n\", \"4\\n-1\\n6\\n\", \"17\\n\", \"4\\n\", \"0\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n\", \"1\\n0\\n6\\n6\\n6\\n6\\n6\\n6\\n6\\n\", \"5\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n4\\n\", \"-1\\n2\\n4\\n\", \"1\\n0\\n\", \"2\\n4\\n3\\n3\\n3\\n3\\n3\\n3\\n3\\n3\\n\", \"1\\n6\\n2\\n\", \"3\\n1\\n3\\n\", \"5\\n5\\n6\\n6\\n6\\n6\\n6\\n6\\n6\\n6\\n\", \"2\\n6\\n2\\n2\\n2\\n2\\n\", \"4\\n7\\n3\\n\", \"2\\n5\\n2\\n\", \"0\\n0\\n3\\n\", \"2\\n8\\n3\\n\"]}"
}
|
{
"index": 9
}
|
taco
|
[
{
"role": "user",
"content": "Garry is looking at the sky. Such a beautiful day! He notices that the clouds are particularly beautiful today, and wishes to record the current state of the sky. He has no camera, so he begins writing down coordinate points. Fortunately for Garry, the current cloud cover can be represented as the union of non-intersecting, non-degenerate triangles where each vertex is at a coordinate point on the $xy$-plane. Two triangles are considered non-intersecting if their intersection has area $0$. A triangle is degenerate if its area is $0$.\n\nThe next day, Garry’s friend Jerry goes to look at the sky. Jerry also wishes to record the current state of the sky. He follows the same protocol as Garry, and writes down the cloud cover as a set of non-intersecting triangles.\n\nGarry and Jerry want to determine if they saw the same cloud cover. Unfortunately, there are multiple possible ways to represent the same cloud cover! Given Garry and Jerry’s notes, did they see the same cloud cover in the sky?\n\n-----Input-----\nThe first line of input contains the integer $n$, $(0 \\le n \\le 100000)$, the number of triangles Garry wrote down. Each of the next $n$ lines contains $6$ space separated integers, $x_1$, $y_1$, $x_2$, $y_2$, $x_3$, and $y_3$. These are Garry’s triangles. The next line contains the integer $m$, $(0 \\le m \\le 100000)$, the number of triangles Jerry wrote down. Each of the next $m$ lines contains $6$ space separated integers, $x_1$, $y_1$, $x_2$, $y_2$, $x_3$, and $y_3$. These are Jerry’s triangles. The absolute value of the $x$ and $y$ coordinates are at most $10^9$. (That’s as far as Garry and Jerry can see.)\n\n-----Output-----\nPrint “yes” if Garry and Jerry saw the same cloud cover, or “no” if they did not.\n\n-----Examples-----\nSample Input 1:\n1\n10000 0 10000 10000 0 10000\n3\n10000 0 10000 10000 5000 5000\n5000 5000 10000 10000 0 10000\n0 0 0 1000 1000 0\nSample Output 1:\nno\n\nSample Input 2:\n2\n9996 0 9997 0 0 1\n9999 0 10000 0 0 1\n2\n9997 0 9998 0 0 1\n9998 0 9999 0 0 1\nSample Output 2:\nno\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"1\\n10000 0 10000 10000 0 10000\\n3\\n10000 0 10000 10000 5000 5000\\n5000 5000 10000 10000 0 10000\\n0 0 0 1000 1000 0\\n\", \"2\\n9996 0 9997 0 0 1\\n9999 0 10000 0 0 1\\n2\\n9997 0 9998 0 0 1\\n9998 0 9999 0 0 1\\n\", \"1\\n2 0 2 4 4 2\\n2\\n2 0 2 2 4 2\\n2 2 4 2 2 4\\n\"], \"outputs\": [\"no\\n\", \"no\\n\", \"yes\\n\"]}"
}
|
{
"index": 10
}
|
taco
|
[
{
"role": "user",
"content": "Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation $a + 1 = b$ with positive integers $a$ and $b$, but Kolya forgot the numbers $a$ and $b$. He does, however, remember that the first (leftmost) digit of $a$ was $d_a$, and the first (leftmost) digit of $b$ was $d_b$.\n\nCan you reconstruct any equation $a + 1 = b$ that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.\n\n\n-----Input-----\n\nThe only line contains two space-separated digits $d_a$ and $d_b$ ($1 \\leq d_a, d_b \\leq 9$).\n\n\n-----Output-----\n\nIf there is no equation $a + 1 = b$ with positive integers $a$ and $b$ such that the first digit of $a$ is $d_a$, and the first digit of $b$ is $d_b$, print a single number $-1$.\n\nOtherwise, print any suitable $a$ and $b$ that both are positive and do not exceed $10^9$. It is guaranteed that if a solution exists, there also exists a solution with both numbers not exceeding $10^9$.\n\n\n-----Examples-----\nInput\n1 2\n\nOutput\n199 200\n\nInput\n4 4\n\nOutput\n412 413\n\nInput\n5 7\n\nOutput\n-1\n\nInput\n6 2\n\nOutput\n-1\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"1 2\\n\", \"4 4\\n\", \"5 7\\n\", \"6 2\\n\", \"9 1\\n\", \"1 1\\n\", \"8 9\\n\", \"9 8\\n\", \"9 9\\n\", \"2 4\\n\", \"1 9\\n\", \"6 5\\n\", \"9 2\\n\", \"3 3\\n\", \"8 8\\n\", \"8 1\\n\", \"6 7\\n\", \"9 2\\n\", \"3 2\\n\", \"2 1\\n\", \"1 9\\n\", \"7 6\\n\", \"5 4\\n\", \"6 5\\n\", \"9 9\\n\", \"3 1\\n\", \"9 5\\n\", \"4 3\\n\", \"9 6\\n\", \"8 7\\n\", \"9 8\\n\", \"9 7\\n\", \"8 8\\n\", \"8 1\\n\", \"9 3\\n\", \"2 9\\n\", \"9 2\\n\", \"2 4\\n\", \"1 2\\n\", \"6 5\\n\", \"1 1\\n\", \"3 2\\n\", \"3 3\\n\", \"8 1\\n\", \"4 4\\n\", \"9 1\\n\", \"9 6\\n\", \"2 9\\n\", \"9 7\\n\", \"8 9\\n\", \"9 8\\n\", \"3 1\\n\", \"9 3\\n\", \"8 8\\n\", \"9 5\\n\", \"7 6\\n\", \"1 9\\n\", \"5 4\\n\", \"8 7\\n\", \"4 3\\n\", \"9 9\\n\", \"6 7\\n\", \"2 1\\n\", \"17 1\\n\", \"3 4\\n\", \"2 2\\n\", \"2 3\\n\", \"4 5\\n\", \"12 13\\n\", \"0 5\\n\", \"1 3\\n\", \"16 1\\n\", \"1 4\\n\", \"11 1\\n\", \"2 6\\n\", \"0 9\\n\", \"3 7\\n\", \"8 4\\n\", \"12 8\\n\", \"6 1\\n\", \"13 3\\n\", \"5 8\\n\", \"9 0\\n\", \"2 5\\n\", \"1 14\\n\", \"6 4\\n\", \"10 7\\n\", \"4 2\\n\", \"12 9\\n\", \"1 7\\n\", \"6 0\\n\", \"0 2\\n\", \"5 2\\n\", \"10 2\\n\", \"27 1\\n\", \"3 6\\n\", \"0 4\\n\", \"-1 1\\n\", \"0 6\\n\", \"-1 2\\n\", \"28 1\\n\", \"1 8\\n\", \"11 2\\n\", \"2 0\\n\", \"0 8\\n\", \"6 3\\n\", \"8 2\\n\", \"17 8\\n\", \"7 1\\n\", \"14 3\\n\", \"1 0\\n\", \"9 -1\\n\", \"0 3\\n\", \"4 1\\n\", \"17 7\\n\", \"10 4\\n\", \"12 11\\n\", \"1 11\\n\", \"6 -1\\n\", \"0 7\\n\", \"5 3\\n\", \"10 3\\n\", \"4 7\\n\", \"28 0\\n\", \"3 11\\n\", \"0 12\\n\", \"-1 4\\n\", \"1 -1\\n\", \"7 0\\n\", \"2 8\\n\", \"11 3\\n\", \"-2 1\\n\", \"-1 8\\n\", \"11 5\\n\", \"13 2\\n\", \"17 0\\n\", \"5 1\\n\", \"13 0\\n\", \"1 5\\n\", \"10 1\\n\", \"4 8\\n\", \"7 4\\n\", \"2 7\\n\", \"10 6\\n\", \"1 15\\n\", \"6 -2\\n\", \"0 13\\n\", \"1 6\\n\", \"10 0\\n\", \"4 9\\n\", \"51 0\\n\", \"3 17\\n\", \"0 10\\n\", \"-1 7\\n\", \"2 -1\\n\", \"4 0\\n\", \"1 2\\n\", \"5 7\\n\", \"6 2\\n\", \"4 4\\n\"], \"outputs\": [\"1 2\\n\", \"40 41\\n\", \"-1\\n\", \"-1\\n\", \"9 10\\n\", \"10 11\\n\", \"8 9\\n\", \"-1\\n\", \"90 91\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"30 31\\n\", \"80 81\\n\", \"-1\\n\", \"6 7\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"90 91\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"80 81\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"19 20\", \"-1\\n\", \"10 11\\n\", \"-1\\n\", \"30 31\\n\", \"-1\\n\", \"40 41\\n\", \"9 10\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"89 90\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"80 81\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"90 91\\n\", \"69 70\", \"-1\\n\", \"-1\", \"39 40\", \"20 21\", \"29 30\", \"49 50\", \"129 130\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"19 20\", \"-1\\n\", \"-1\\n\", \"40 41\\n\"]}"
}
|
{
"index": 11
}
|
codecontests
|
[
{
"role": "user",
"content": "WARNING Large input/output files. Use faster I/O.\nIt's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy (say N). Teams like Snow Kids, Shadows, Xenons, Red Tigers, Wambas, Pirates, etc. are in total enthusiasm and are practising hard to win the cup using their talent and flux.\nEach planet of the galaxy has a government. Some governments have a mutual agreement between them. If planet A has mutual agreement with planet B, then there is a bidirectional spaceway between A and B using which anybody can go from A to B and vice-versa. People can use these spaceways to travel from one planet to another, if there exists a path between them using some of the spaceways.\nEach planet has it's own football ground. The GFA has planned the matches in such a way that a team can have a match at any of these grounds. The GFA has come across some problems in the execution of their plan. They have found out that there are many pairs of planets between which there does not exist any path, so the football team of one of those planets can't reach the other planet. They requested the corresponding governments to make a spaceway between them, but because of absense of mutual agreement (duhhh.. Politics!), these goverment did not agree. So the GFA suggested that they will make teleports between some pairs of planets which will be used only by the football teams to travel.\nBut there are two types of governments in the galaxy\n1. Some of the governments are greedy (duhhh..). They want to make money (You don't say!) throught the GFA. So each of these government has asked the GFA for a tax value which it has to pay if it wants to make a teleport ending at their planet.\n2. Others want to sponser the event, so they will give money to the GFA if they make a teleport ending at their planet (That's new..). The GFA would always avoid such governments no matter what the consequences are, because these kind of governments have always some dirty plans in their minds for the GFA.\nNow, the GFA wants to make bi-directional teleports between planets such that the football teams of any planet can reach any other planet to play a football match, using spaceways between the planets and/or teleports made by the GFA.\nThe GFA also has financial problems and want to spend as little money as possible. They have come to you so that you can help them calculate the minimum ammount of money needed to fulfill their plan.\n\nInput\nThe first line of the input consists of two integers - N and M. N is number of planets and M is number of pairs of planets which have a mutual agreement, i.e they have a spaceway between them. Then, M lines follow, each containing two space separated integers A and B, denoting a mutual agreement and hence a spaceway to travel, between plenet A and planet B. Then, N lines follow. The i^th line has an integer C. If C ≥ 0, then it represents the tax value which the GFA has to pay to the government of planet i (it's a type 1 government). If C < 0, then it represents the money the ith government will pay to the GFA (it's a type 2 government).\n\nOutput\nPrint the minimum amount needed for the GFA to fulfill their plan if it can be fulfilled, else print \"-1\" (without quotes).\n\nConstraints\n\n1 ≤ N ≤ 100,000\n0 ≤ M ≤ 1,000,000\n0 ≤ |C| ≤ 10,000\n1 ≤ A,B ≤ N\nA ≠ B\n\nSample\n\nInput 1\n6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6\n\nOutput 1\n3\n\n\nInput 2\n3 1\n2 3\n1\n-1\n-1\n\nOutput 2\n-1\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"6 6\\n1 2\\n2 3\\n1 3\\n4 5\\n5 6\\n4 6\\n1\\n3\\n5\\n2\\n4\\n6\", \"3 1\\n2 3\\n1\\n-1\\n-1\", \"6 6\\n1 2\\n2 5\\n1 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\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"3\\n\", \"4\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"4\\n\", \"0\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"2\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"3\\n\", \"4\\n\", \"-1\\n\", \"1\\n\", \"-1\\n\", \"-1\\n\", \"2\\n\", \"3\\n\", \"-1\\n\", \"1\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"-1\\n\", \"3\\n\", \"0\\n\", \"4\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"3\\n\", \"0\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"-1\\n\", \"2\\n\", \"-1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"0\\n\"]}"
}
|
{
"index": 12
}
|
taco
|
[
{
"role": "user",
"content": "Example\n\nInput\n\n4 5 3\n-10 -10\n10 -10\n10 10\n-10 10\n1 2\n1 3\n1 4\n2 3\n3 4\n-20 0\n1 0\n20 0\n\n\nOutput\n\nNo\nYes\nNo\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"4 5 3\\n-10 -10\\n10 -10\\n10 10\\n-10 10\\n1 2\\n1 3\\n1 4\\n2 3\\n3 4\\n-20 0\\n1 0\\n20 0\"], \"outputs\": [\"No\\nYes\\nNo\"]}"
}
|
{
"index": 13
}
|
codeforces
|
[
{
"role": "user",
"content": "Title: Willem, Chtholly and Seniorious\n\nTime Limit: None seconds\n\nMemory Limit: None megabytes\n\nProblem Description:\n— Willem...\n\n— What's the matter?\n\n— It seems that there's something wrong with Seniorious...\n\n— I'll have a look...\n\n\n\nSeniorious is made by linking special talismans in particular order.\n\nAfter over 500 years, the carillon is now in bad condition, so Willem decides to examine it thoroughly.\n\nSeniorious has *n* pieces of talisman. Willem puts them in a line, the *i*-th of which is an integer *a**i*.\n\nIn order to maintain it, Willem needs to perform *m* operations.\n\nThere are four types of operations:\n- 1 *l* *r* *x*: For each *i* such that *l*<=≤<=*i*<=≤<=*r*, assign *a**i*<=+<=*x* to *a**i*.- 2 *l* *r* *x*: For each *i* such that *l*<=≤<=*i*<=≤<=*r*, assign *x* to *a**i*.- 3 *l* *r* *x*: Print the *x*-th smallest number in the index range [*l*,<=*r*], i.e. the element at the *x*-th position if all the elements *a**i* such that *l*<=≤<=*i*<=≤<=*r* are taken and sorted into an array of non-decreasing integers. It's guaranteed that 1<=≤<=*x*<=≤<=*r*<=-<=*l*<=+<=1.- 4 *l* *r* *x* *y*: Print the sum of the *x*-th power of *a**i* such that *l*<=≤<=*i*<=≤<=*r*, modulo *y*, i.e. .\n\nInput Specification:\nThe only line contains four integers *n*,<=*m*,<=*seed*,<=*v**max* (1<=≤<=*n*,<=*m*<=≤<=105,<=0<=≤<=*seed*<=<<=109<=+<=7,<=1<=≤<=*vmax*<=≤<=109).\n\nThe initial values and operations are generated using following pseudo code:\n\nHere *op* is the type of the operation mentioned in the legend.\n\nOutput Specification:\nFor each operation of types 3 or 4, output a line containing the answer.\n\nDemo Input:\n['10 10 7 9\\n', '10 10 9 9\\n']\n\nDemo Output:\n['2\\n1\\n0\\n3\\n', '1\\n1\\n3\\n3\\n']\n\nNote:\nIn the first example, the initial array is {8, 9, 7, 2, 3, 1, 5, 6, 4, 8}.\n\nThe operations are:\n - 2 6 7 9 - 1 3 10 8 - 4 4 6 2 4 - 1 4 5 8 - 2 1 7 1 - 4 7 9 4 4 - 1 2 7 9 - 4 5 8 1 1 - 2 5 7 5 - 4 3 10 8 5\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"10 10 7 9\", \"10 10 9 9\", \"1000 1000 658073485 946088556\", \"1000 1000 663001819 921338426\", \"1000 1000 811605498 961464625\", \"100000 100000 585767874 969488314\", \"100000 100000 456616815 974410294\", \"35293 65394 377702722 965499399\", \"96334 53956 282409557 989731155\", \"34281 4646 305421312 941787985\", \"65410 84158 299309076 977599182\", \"75424 85046 913047528 985636135\", \"96011 69484 952656656 949837239\", \"69971 85577 806771998 978710230\", \"53834 13558 705236852 914473856\", \"92855 38088 901131679 905998083\", \"48858 21838 231460178 954692031\", \"32475 84541 799815170 924502267\", \"56021 2857 942001819 920619100\", \"83662 39961 277703709 950449724\", \"34134 37276 316383536 923096494\", \"34736 88419 280789856 941687084\", \"65839 45757 768591103 998790277\", \"92582 97744 474444887 902071104\", \"46031 42537 451207636 982647444\", \"64909 20063 18579507 927481501\", \"90798 73851 189131066 992703032\", \"72580 68306 62781726 916636983\", \"1924 16436 604734001 960651460\", \"41309 15973 780671431 932433911\", \"100000 100000 1000000006 1\", \"100000 100000 1000000006 1000000000\", \"100000 100000 0 1000000000\"], \"outputs\": [\"2\\n1\\n0\\n3\", \"1\\n1\\n3\\n3\", \"375432604\\n52885108\\n732131239\\n335583873\\n375432604\\n582199284\\n235058938\\n682619432\\n62026709\\n631048460\\n51394660\\n25596188\\n244696891\\n1009575922\\n9787768\\n9787768\\n618642640\\n278237785\\n251668359\\n321813234\\n563194827\\n101752810\\n208858224\\n262327445\\n11344020\\n907542692\\n275574805\\n1182618779\\n20489113\\n1215012508\\n838060601\\n15849943\\n168527462\\n537661946\\n301301341\\n838060601\\n46928748\\n656331376\\n1656165287\\n181551648\\n31803656\\n1136481\\n836554656\\n836554656\\n836554656\\n487461834\\n653789051\\n24729...\", \"549050815\\n1494447218\\n123274718\\n949106303\\n363391514\\n1550246060\\n107855794\\n206930179\\n462058384\\n167101179\\n858273570\\n356404756\\n156657135\\n591408459\\n315837577\\n277556562\\n423807049\\n57871554\\n207585345\\n207585345\\n711053606\\n62414948\\n736991621\\n141019877\\n15668980\\n1659611655\\n39231619\\n202790129\\n3196038\\n236864151\\n56524932\\n313582670\\n72493924\\n535770507\\n88995537\\n194484599\\n539736025\\n273631024\\n149972180\\n416123619\\n323570345\\n695471102\\n71796515\\n66127408\\n1269337883\\n296472622\\n72864255\\n42...\", \"230231691\\n50907792\\n772872116\\n28726758\\n20957398\\n48216401\\n564116048\\n70658978\\n9545021\\n789851575\\n993564693\\n754556313\\n1407453357\\n281963589\\n624055178\\n50804159\\n50804159\\n894467226\\n24436906\\n209344702\\n583604216\\n545435223\\n399103514\\n286455036\\n672601056\\n112440928\\n28906651\\n285384887\\n437165549\\n672601056\\n672601056\\n672601056\\n418317887\\n1156656565\\n123389163\\n939398850\\n323019445\\n1040606872\\n181812742\\n631705944\\n1252601229\\n1270982340\\n2020261282\\n209344702\\n661730192\\n61860166\\n140819245\\n...\", \"488773319\\n425485657\\n31451411\\n125354121\\n198709192\\n1297027050\\n915846188\\n865847922\\n865847922\\n495955788\\n430259012\\n38112058\\n655555207\\n269554140\\n655555207\\n655555207\\n865847922\\n655555207\\n330862299\\n257742484\\n881124869\\n278870276\\n623597474\\n530082948\\n1127525850\\n1204398738\\n1730577047\\n37072555\\n694048\\n31371749\\n9135760\\n33463298\\n1057194805\\n770383482\\n565637501\\n520029864\\n991846906\\n1371315075\\n97454049\\n300044161\\n1305967176\\n519456769\\n74989894\\n519456769\\n14719300\\n880742495\\n196109958\\n...\", \"29694410\\n114810283\\n27479618\\n509651935\\n1377955711\\n1853568141\\n48591174\\n550185772\\n1377733875\\n3188073431\\n552494826\\n162623392\\n119629080\\n961540301\\n13098980\\n961540301\\n73386869\\n81666310\\n556381646\\n556381646\\n16557046\\n585391759\\n513708058\\n835481600\\n835481600\\n196542142\\n155864374\\n390537976\\n556381646\\n272417853\\n2018159187\\n36749272\\n123046338\\n556381646\\n292126506\\n292126506\\n292126506\\n438730662\\n15137105\\n292126506\\n138122700\\n231556955\\n119940584\\n118400300\\n851007817\\n551381231\\n41556221\\n...\", \"239665146\\n662971035\\n63311606\\n197632809\\n411726834\\n310795966\\n240415864\\n2536670\\n5613\\n202237164\\n104440580\\n72640017\\n570409322\\n114470532\\n15706744\\n576574650\\n495809922\\n2202598461\\n230071751\\n131974040\\n921695668\\n2206028955\\n142512706\\n154685285\\n921695668\\n439798074\\n3278435837\\n206871252\\n611644713\\n150614106\\n24485187\\n3485714729\\n2523738028\\n3485714729\\n247403172\\n215325649\\n590457343\\n3485714729\\n1729280554\\n25140341\\n351532943\\n1729280554\\n252624780\\n1083769695\\n188669787\\n332592766\\n4313876...\", \"264424564\\n831132059\\n72908436\\n368090942\\n227423644\\n311506102\\n194783295\\n206318770\\n56695549\\n211863709\\n56695549\\n214634804\\n297831496\\n365649379\\n247715382\\n293899239\\n635203088\\n137366134\\n24683564\\n1445257517\\n98960586\\n325902360\\n114187617\\n292648787\\n431543187\\n46443921\\n716759516\\n1430137540\\n1430137540\\n431543187\\n574046806\\n248546906\\n1126047236\\n2649836\\n759894053\\n706270467\\n223031249\\n759894053\\n316507989\\n119726966\\n1213065175\\n68123952\\n68123952\\n13792714\\n331483558\\n446844394\\n446844394\\n...\", \"29743039\\n480172415\\n140640480\\n856939452\\n98074616\\n3035375\\n644241474\\n644241474\\n279358712\\n279358712\\n17376223\\n182274578\\n333883463\\n509541754\\n310952850\\n685788527\\n223266725\\n253520950\\n26530950\\n501280346\\n24526068\\n117438324\\n5300076\\n117438324\\n117438324\\n313193846\\n9007832\\n305109765\\n1728525074\\n28677313\\n28506441\\n363836046\\n28677313\\n810490379\\n630323845\\n303089169\\n211750693\\n20586044\\n1727991144\\n13537401\\n789731968\\n789731968\\n71774445\\n430486019\\n456241150\\n430486019\\n99829885\\n106821794\\n...\", \"685446942\\n701897521\\n809216029\\n455806624\\n249004690\\n273488789\\n92895066\\n971005418\\n127013721\\n1249277917\\n147217558\\n139154621\\n821049631\\n1375797794\\n157402634\\n1198902618\\n1620738977\\n24571589\\n1481406668\\n1459610003\\n98342934\\n98342934\\n2238344471\\n190638960\\n971005418\\n347261832\\n804800693\\n561476144\\n804800693\\n804800693\\n1238964356\\n220043336\\n1238964356\\n350972540\\n54846606\\n444625629\\n186497410\\n435072732\\n105203033\\n609625024\\n435072732\\n609625024\\n67644091\\n609625024\\n367494\\n609625024\\n53480...\", \"452443538\\n919821162\\n214758190\\n538602859\\n599290738\\n1380479354\\n91\\n30402955\\n313667506\\n46450616\\n430822033\\n1064551056\\n1589735072\\n885640637\\n53728070\\n4773196\\n1622583932\\n195603732\\n72827616\\n61957289\\n2299040254\\n75818259\\n642736943\\n507230783\\n241032135\\n373689191\\n1460529968\\n1253584727\\n65126128\\n24852939\\n137801751\\n318674322\\n60000306\\n318674322\\n1253584727\\n1253584727\\n318674322\\n579230242\\n982770772\\n398108613\\n694874412\\n6896765\\n30216757\\n10782747\\n694874412\\n450833972\\n654671372\\n6546713...\", \"32539942\\n221637648\\n6685807\\n221637648\\n130499111\\n749816296\\n749816296\\n465720281\\n169837107\\n434579635\\n434579635\\n434579635\\n140347135\\n80756745\\n917825533\\n176391976\\n388876628\\n24154597\\n52986937\\n749816296\\n143381298\\n115970301\\n8487472\\n578697326\\n129033564\\n129033564\\n342075018\\n129033564\\n129033564\\n215260680\\n62781742\\n377703498\\n215260680\\n215260680\\n823964653\\n229054709\\n215260680\\n543738340\\n377703498\\n215260680\\n288700027\\n839891288\\n823964653\\n148164475\\n215260680\\n868684479\\n868684479\\n308...\", \"129329933\\n68385719\\n540565769\\n56655160\\n1686967476\\n1541942367\\n503262086\\n1262717021\\n1917927442\\n89532045\\n331110012\\n285803527\\n214266325\\n622411716\\n501726093\\n418940034\\n501726093\\n119341174\\n514438082\\n288349614\\n574659327\\n312054790\\n2954052\\n1519871905\\n1519871905\\n148270297\\n285803527\\n2141292212\\n2644011758\\n952023412\\n211365450\\n101906015\\n952023412\\n81336979\\n1142528136\\n1124663438\\n623313617\\n328980988\\n73743051\\n734701813\\n8348685\\n792032598\\n167646751\\n1079261493\\n546235003\\n500693783\\n792...\", \"227634968\\n75533466\\n692001026\\n372458402\\n4199748\\n372458402\\n1011605540\\n148163245\\n1082313030\\n1876361538\\n252764794\\n1082313030\\n213855976\\n20679522\\n213855976\\n39289356\\n227865875\\n2316098912\\n767062628\\n485927680\\n767062628\\n266488539\\n745842201\\n22734895\\n609911878\\n111182647\\n100331484\\n1753687996\\n167171744\\n485927680\\n3238342\\n65048581\\n675400107\\n102847960\\n79627523\\n99751245\\n75065723\\n446974685\\n69768843\\n234926533\\n1346413189\\n268814655\\n99751245\\n113231745\\n123381304\\n52895998\\n162960402\\n13...\", \"55981088\\n160365879\\n198841463\\n16748732\\n1486157\\n940679842\\n90710681\\n324660985\\n166529288\\n535567417\\n151558952\\n218974486\\n331522181\\n760674601\\n760674601\\n332166026\\n246407870\\n79818860\\n5979574\\n536221952\\n50773637\\n79818860\\n519436559\\n331522181\\n127744454\\n98592365\\n83358985\\n275931666\\n732449614\\n405457829\\n1353659460\\n11058078\\n729708778\\n342000739\\n1162214\\n1162214\\n1162214\\n310867040\\n148135539\\n574118370\\n928983682\\n524479467\\n41969224\\n511281496\\n649137291\\n285473957\\n285473957\\n300759177\\n10...\", \"370847937\\n463563365\\n367380589\\n341817660\\n106844349\\n631218936\\n1903253855\\n152677346\\n2122059099\\n527292097\\n3519900\\n13012943\\n84734828\\n1520810540\\n226192657\\n1978951417\\n1386685276\\n1682768810\\n9119707\\n1521671071\\n2776435178\\n33398758\\n1528015541\\n226489528\\n571104910\\n243497460\\n400780750\\n420100208\\n1043989628\\n1451057360\\n434594375\\n327308470\\n16499992\\n901126852\\n1453786073\\n268548975\\n901126852\\n327308470\\n118609516\\n447919118\\n555690825\\n1092279693\\n3750710219\\n3709774734\\n5866129199\\n53198154...\", \"1476622863\\n620575616\\n620575616\\n78358606\\n438229787\\n864343294\\n12338748\\n1533951174\\n22149457\\n225899435\\n116727262\\n2363454966\\n23802028\\n126121524\\n47524507\\n360201478\\n58493311\\n58493311\\n363006653\\n1659243219\\n1898547080\\n111467637\\n151197193\\n17047098\\n481900146\\n523981654\\n667787844\\n193996944\\n906407106\\n5613772\\n561747384\\n355019510\\n755462348\\n45612357\\n552152736\\n467700213\\n133377364\\n667678683\\n523981654\\n1041743225\\n25175667\\n689741016\\n689741016\\n27813939\\n118945345\\n577631414\\n928133446\\n2...\", \"220073701\\n727295171\\n403209389\\n57913378\\n533442531\\n590064935\\n219334821\\n934651827\\n1276456256\\n367157678\\n123336941\\n385398504\\n957948763\\n205735222\\n1299753192\\n456943243\\n366180607\\n435417349\\n607104570\\n56298134\\n193843556\\n300856292\\n173076391\\n636606525\\n313268237\\n677092026\\n172995482\\n412475584\\n20029368\\n32735150\\n467452356\\n210066452\\n210066452\\n210066452\\n136919226\\n1382145697\\n914945606\\n194540184\\n624906162\\n624906162\\n588138580\\n624906162\\n115762671\\n122995130\\n602863059\\n473714412\\n187136...\", \"126252222\\n849892280\\n167866056\\n127364128\\n127364128\\n450004640\\n458130870\\n127364128\\n585334262\\n14475851\\n127364128\\n38910263\\n224539282\\n825993384\\n127364128\\n96652010\\n18604923\\n47266399\\n906040086\\n46391759\\n318595826\\n127364128\\n318595826\\n104497172\\n318595826\\n841837314\\n119474015\\n202909906\\n186683697\\n161340425\\n890054689\\n207667046\\n186683697\\n186683697\\n982483372\\n982483372\\n970578805\\n1509014350\\n169911047\\n399527384\\n148321924\\n260202217\\n1079582546\\n341511245\\n1704702615\\n206165042\\n30995511...\", \"870247680\\n35828540\\n10693546\\n198698070\\n8284050\\n7996330\\n184167090\\n211946972\\n581355602\\n413509769\\n238825775\\n288191626\\n120306907\\n784563961\\n695255246\\n173030372\\n322425686\\n987458693\\n1047783977\\n7655871\\n695255246\\n1273433928\\n1574983481\\n151640495\\n227480251\\n224928429\\n227480251\\n42411840\\n232624919\\n224928429\\n189372927\\n224928429\\n194449043\\n906749416\\n258234237\\n3253928010\\n43269307\\n218951276\\n474442785\\n421639939\\n18679100\\n51715037\\n421639939\\n474442785\\n389762766\\n3176639\\n39619784\\n16759...\", \"183818278\\n205903405\\n163799308\\n114262258\\n473958519\\n374203788\\n7412532\\n789150889\\n339153118\\n133450986\\n339153118\\n355870030\\n213438639\\n72371912\\n897178997\\n567245519\\n9226262\\n61273072\\n482571152\\n61273072\\n25069173\\n26289124\\n157227437\\n9064234\\n91919653\\n769517395\\n392022677\\n138881826\\n482961641\\n276680584\\n513335054\\n16319149\\n513335054\\n513335054\\n513335054\\n484706460\\n90429697\\n265064608\\n274690262\\n264818705\\n117287263\\n1131988503\\n329064115\\n1074580206\\n596447015\\n9064234\\n596447015\\n1233496\\n...\", \"678126807\\n1032303763\\n443892850\\n2900162\\n359867860\\n909321721\\n282237191\\n32476392\\n909321721\\n909321721\\n909321721\\n395833688\\n909321721\\n111393833\\n1862877827\\n9657375\\n1841936689\\n200749704\\n112435038\\n736555479\\n1206250982\\n9356050\\n736555479\\n297818932\\n290875157\\n322725717\\n206227944\\n932542054\\n630169903\\n1206250982\\n1206250982\\n311006658\\n966119600\\n966119600\\n381477\\n326255604\\n85400943\\n3891748251\\n98327387\\n120588804\\n480537833\\n16411381\\n924545423\\n618680484\\n442365821\\n186723124\\n1570384675\\n...\", \"615962324\\n871938501\\n46758368\\n771582484\\n23362941\\n483737060\\n645934514\\n360312782\\n143955012\\n37888632\\n87503654\\n24280201\\n380445709\\n558574575\\n29583810\\n56351351\\n20177884\\n3763903\\n20652\\n225045569\\n139842734\\n34921510\\n76167018\\n62940058\\n202172786\\n675330569\\n856736574\\n17852626\\n1348761106\\n1348761106\\n151879079\\n59349419\\n1479504273\\n675524105\\n30936840\\n246296399\\n1647188865\\n151010160\\n448224904\\n1647188865\\n44525093\\n2262297944\\n625076927\\n244983906\\n60408560\\n534966611\\n534966611\\n42959560\\n...\", \"20264423\\n153434450\\n164995661\\n577060066\\n564247456\\n260347857\\n720604311\\n329587356\\n351913053\\n1412130719\\n962683528\\n7311281\\n1488665438\\n1419729339\\n46949459\\n1488665438\\n124051366\\n1488665438\\n8135269\\n1159282\\n239565871\\n229564151\\n18448464\\n1426435681\\n46900807\\n644262799\\n268629120\\n56343862\\n163559110\\n73270721\\n59427856\\n644262799\\n644262799\\n644262799\\n1426435681\\n644262799\\n644262799\\n1538104637\\n1427165695\\n416453692\\n579373083\\n40662989\\n149471664\\n873195434\\n11027753\\n606249189\\n1302016003\\n...\", \"269516549\\n642864303\\n25032469\\n115372744\\n46740774\\n422004558\\n308450120\\n292670932\\n1225114614\\n308450120\\n586984082\\n308450120\\n831925309\\n782629281\\n195873104\\n1338669052\\n831925309\\n846888619\\n3593834\\n979073\\n4143263\\n71565650\\n339206737\\n869962395\\n272554744\\n394452983\\n80076701\\n219349564\\n236647603\\n95367812\\n189131938\\n15570719\\n5499337\\n813294149\\n96253960\\n178177637\\n339136655\\n64762330\\n2444408353\\n3311130099\\n181458657\\n2208828278\\n252557929\\n223375980\\n3447406493\\n163783624\\n181458657\\n32068...\", \"82268803\\n823120145\\n22437793\\n79305058\\n141058630\\n454513528\\n50278331\\n286975891\\n71675090\\n1280701409\\n199601434\\n1224942235\\n145318910\\n145318910\\n175299998\\n413619613\\n33333661\\n356101636\\n15085552\\n88093049\\n660604153\\n69342898\\n9661704\\n41141377\\n825929676\\n1661301459\\n62218513\\n1993966592\\n281100568\\n532143708\\n514062254\\n81371299\\n73984632\\n849331146\\n42454875\\n812612262\\n236025988\\n376131279\\n981695252\\n129041988\\n2959698729\\n1655673084\\n81054581\\n1655673084\\n206317887\\n1529748115\\n828696819\\n587...\", \"955231872\\n1345938897\\n37809236\\n1023745536\\n193327830\\n436196190\\n1390545560\\n981804553\\n1045391793\\n851876301\\n687402477\\n687402477\\n42268493\\n328559844\\n24034514\\n252182937\\n279807511\\n106057230\\n1039492777\\n7502068\\n511880431\\n2318324125\\n45502261\\n563695247\\n462332546\\n672588582\\n624384702\\n672588582\\n31449928\\n72203770\\n684180552\\n709466604\\n709466604\\n684180552\\n759166137\\n67435990\\n405911259\\n277606868\\n1076032126\\n759166137\\n21671606\\n1980595676\\n843191728\\n61650249\\n612025245\\n472605762\\n61202524...\", \"224407039\\n21629501\\n51671061\\n618123933\\n66618374\\n349548646\\n1707651063\\n21984485\\n745056175\\n66017917\\n294185410\\n519710292\\n513436148\\n24316769\\n158658898\\n612865248\\n225546641\\n368908923\\n1127927911\\n209356404\\n583748672\\n607372677\\n718946905\\n722922265\\n8318377\\n299512174\\n918433001\\n50651876\\n324485498\\n415234261\\n17609483\\n82606475\\n184620922\\n5720471\\n1287572969\\n1080877827\\n86077625\\n1660997030\\n479967009\\n389354602\\n159084510\\n639166732\\n766227609\\n1940884570\\n521559131\\n1304554719\\n2296012179\\n...\", \"75563798\\n403789976\\n6393139\\n254976448\\n805601247\\n6393139\\n254976448\\n175939840\\n1389369508\\n922395878\\n61632625\\n1686490793\\n23750495\\n625527070\\n434310777\\n113496156\\n460480347\\n261196051\\n2583744434\\n505830077\\n280326977\\n77318221\\n430992600\\n410525376\\n902799147\\n132626784\\n851717663\\n476352311\\n545543140\\n9677235\\n849072777\\n1496482050\\n150578755\\n55426222\\n815693999\\n1369752719\\n2326528906\\n7493896\\n50909437\\n808378541\\n313315600\\n808378541\\n91608487\\n2649723\\n683362929\\n42620542\\n818196368\\n648192...\", \"1\\n0\\n1\\n1\\n1\\n1\\n0\\n2\\n0\\n2\\n0\\n2\\n3\\n0\\n1\\n2\\n1\\n0\\n1\\n0\\n0\\n0\\n1\\n0\\n1\\n0\\n0\\n0\\n0\\n1\\n2\\n0\\n0\\n0\\n0\\n1\\n0\\n0\\n2\\n2\\n0\\n0\\n0\\n3\\n0\\n0\\n1\\n3\\n1\\n0\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n2\\n1\\n0\\n2\\n2\\n0\\n1\\n0\\n0\\n1\\n1\\n1\\n0\\n0\\n0\\n2\\n1\\n1\\n1\\n1\\n0\\n2\\n1\\n2\\n2\\n1\\n0\\n0\\n0\\n0\\n1\\n1\\n0\\n2\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n1\\n0\\n1\\n0\\n0\\n0\\n0\\n1\\n2\\n2\\n0\\n0\\n2\\n2\\n0\\n2\\n2\\n0\\n2\\n2\\n0\\n0\\n1\\n0\\n3\\n0\\n0\\n3\\n5\\n1\\n4\\n0\\n0\\n0\\n0\\n1\\n0\\n1\\n2\\n0\\n0\\n3\\n1\\n1\\n2\\n0\\n0\\n0\\n1\\n1\\n2\\n0\\n0\\n0\\n5\\n0\\n0\\n0\\n0\\n0\\n0\\n3\\n1\\n0\\n0\\n4\\n0\\n0\\n1\\n1\\n0\\n0...\", \"882118768\\n227532426\\n982370702\\n89007427\\n485790874\\n634312928\\n49251089\\n627764763\\n80706419\\n1397244924\\n272967282\\n1397244924\\n1350824337\\n670835165\\n760200096\\n767082446\\n172014978\\n293563707\\n338455390\\n326300712\\n148951496\\n883219864\\n966553744\\n159024974\\n174268768\\n150366372\\n11996640\\n444249353\\n142162688\\n467511457\\n696083115\\n204657135\\n284818568\\n44568313\\n262909776\\n594416395\\n202008512\\n519417095\\n337769547\\n337769547\\n28098864\\n35755678\\n326275262\\n2694086723\\n569314771\\n221615842\\n16755104...\", \"10169893\\n16014934\\n817242366\\n909155662\\n909155662\\n64934185\\n63188268\\n294217675\\n78389509\\n71850126\\n71850126\\n100243750\\n898699956\\n133848650\\n1054178187\\n133848650\\n22516864\\n62515496\\n537279455\\n124507892\\n440708118\\n124507892\\n217708272\\n133848650\\n125674761\\n458997492\\n253085860\\n377119511\\n1595531354\\n377119511\\n455176528\\n621245765\\n1268020473\\n1268020473\\n1471497703\\n2437200935\\n612553989\\n244788470\\n1503454951\\n313339152\\n565198602\\n585007836\\n861854621\\n98979356\\n570051021\\n681628204\\n48341592...\"]}"
}
|
{
"index": 14
}
|
codecontests
|
[
{
"role": "user",
"content": "There is a board with a grid consisting of n rows and m columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number i and column number j as (i, j).\n\nA group of six numbers (a, b, c, d, x0, y0), where 0 ≤ a, b, c, d, is a cross, and there is a set of cells that are assigned to it. Cell (x, y) belongs to this set if at least one of two conditions are fulfilled:\n\n * |x0 - x| ≤ a and |y0 - y| ≤ b\n * |x0 - x| ≤ c and |y0 - y| ≤ d\n\n<image> The picture shows the cross (0, 1, 1, 0, 2, 3) on the grid 3 × 4. \n\nYour task is to find the number of different groups of six numbers, (a, b, c, d, x0, y0) that determine the crosses of an area equal to s, which are placed entirely on the grid. The cross is placed entirely on the grid, if any of its cells is in the range of the grid (that is for each cell (x, y) of the cross 1 ≤ x ≤ n; 1 ≤ y ≤ m holds). The area of the cross is the number of cells it has.\n\nNote that two crosses are considered distinct if the ordered groups of six numbers that denote them are distinct, even if these crosses coincide as sets of points.\n\nInput\n\nThe input consists of a single line containing three integers n, m and s (1 ≤ n, m ≤ 500, 1 ≤ s ≤ n·m). The integers are separated by a space.\n\nOutput\n\nPrint a single integer — the number of distinct groups of six integers that denote crosses with area s and that are fully placed on the n × m grid.\n\nPlease, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.\n\nExamples\n\nInput\n\n2 2 1\n\n\nOutput\n\n4\n\n\nInput\n\n3 4 5\n\n\nOutput\n\n4\n\nNote\n\nIn the first sample the sought groups of six numbers are: (0, 0, 0, 0, 1, 1), (0, 0, 0, 0, 1, 2), (0, 0, 0, 0, 2, 1), (0, 0, 0, 0, 2, 2).\n\nIn the second sample the sought groups of six numbers are: (0, 1, 1, 0, 2, 2), (0, 1, 1, 0, 2, 3), (1, 0, 0, 1, 2, 2), (1, 0, 0, 1, 2, 3).\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"2 2 1\\n\", \"3 4 5\\n\", \"2 2 3\\n\", \"2 20 37\\n\", \"500 500 250000\\n\", \"500 500 249995\\n\", \"1 1 1\\n\", \"2 1 1\\n\", \"32 71 297\\n\", \"20 20 8\\n\", \"6 14 23\\n\", \"2 78 117\\n\", \"500 500 9997\\n\", \"500 500 6913\\n\", \"2 1 2\\n\", \"3 3 5\\n\", \"5 1 3\\n\", \"5 10 25\\n\", \"74 99 5057\\n\", \"500 499 3\\n\", \"30 90 29\\n\", \"2 55 9\\n\", \"21 10 155\\n\", \"500 499 93\\n\", \"500 500 249999\\n\", \"27 9 57\\n\", \"500 500 249993\\n\", \"10 4 33\\n\", \"499 498 7\\n\", \"500 500 9\\n\", \"48 81 2573\\n\", \"1 2 1\\n\", \"500 500 1\\n\", \"500 500 2431\\n\", \"72 65 2843\\n\", \"9 10 5\\n\", \"499 499 5\\n\", \"100 100 199\\n\", \"100 100 19\\n\", \"9 7 55\\n\", \"500 500 2639\\n\", \"100 100 5\\n\", \"10 14 47\\n\", \"48 76 2921\\n\", \"49 7 105\\n\", \"498 500 13\\n\", \"500 500 9999\\n\", \"499 500 5\\n\", \"20 17 319\\n\", \"500 500 249998\\n\", \"100 100 3421\\n\", \"20 12 101\\n\", \"56 54 2639\\n\", \"500 500 9001\\n\", \"500 500 249997\\n\", \"1 2 2\\n\", \"500 500 11025\\n\", \"497 498 45\\n\", \"30 8 53\\n\", \"500 498 11\\n\", \"500 500 4755\\n\", \"2 4 3\\n\", \"500 145 250000\\n\", \"57 71 297\\n\", \"20 20 1\\n\", \"2 146 117\\n\", \"500 298 6913\\n\", \"5 1 1\\n\", \"6 10 25\\n\", \"21 15 155\\n\", \"500 285 93\\n\", \"22 9 57\\n\", \"48 85 2573\\n\", \"500 344 2431\\n\", \"72 124 2843\\n\", \"167 499 5\\n\", \"101 100 199\\n\", \"100 110 19\\n\", \"9 13 55\\n\", \"6 14 47\\n\", \"49 9 105\\n\", \"100 101 3421\\n\", \"36 12 101\\n\", \"500 371 11025\\n\", \"24 8 53\\n\", \"2 7 3\\n\", \"17 71 297\\n\", \"6 2 5\\n\", \"2 208 117\\n\", \"500 298 12325\\n\", \"1 1 0\\n\", \"2 2 0\\n\", \"6 2 23\\n\", \"2 2 2\\n\", \"0 3 5\\n\", \"500 500 449162\\n\", \"6 4 33\\n\", \"2 2 4\\n\", \"48 76 2682\\n\", \"20 17 594\\n\", \"156 500 249998\\n\", \"1 1 2\\n\", \"2 4 5\\n\", \"323 145 250000\\n\", \"0 1 0\\n\", \"1 2 3\\n\", \"2 0 0\\n\"], \"outputs\": [\" 4\\n\", \" 4\\n\", \" 0\\n\", \" 0\\n\", \"0\\n\", \" 0\\n\", \" 1\\n\", \" 2\\n\", \" 507408\\n\", \"0\\n\", \" 112\\n\", \" 0\\n\", \" 1380438648\\n\", \" 2147074656\\n\", \"0\\n\", \" 2\\n\", \" 9\\n\", \" 102\\n\", \" 20000\\n\", \" 1491006\\n\", \" 145304\\n\", \" 846\\n\", \" 36\\n\", \" 143189600\\n\", \" 0\\n\", \" 3435\\n\", \" 0\\n\", \" 0\\n\", \" 4419230\\n\", \" 7640108\\n\", \" 9380\\n\", \" 2\\n\", \" 250000\\n\", \" 2137019440\\n\", \" 25704\\n\", \" 632\\n\", \" 2964068\\n\", \" 1788896\\n\", \" 550416\\n\", \" 4\\n\", \" 2141188528\\n\", \" 115208\\n\", \" 256\\n\", \" 1288\\n\", \" 14229\\n\", \" 9728792\\n\", \"4540761776\", \" 2970032\\n\", \" 4\\n\", \"0\\n\", \" 723136\\n\", \" 424\\n\", \" 392\\n\", \" 1254836160\\n\", \" 0\\n\", \"0\\n\", \"10736521384\\n\", \" 74632432\\n\", \" 896\\n\", \" 8304516\\n\", \" 2145363424\\n\", \"12\\n\", \"0\\n\", \"1701784\\n\", \"400\\n\", \"7020\\n\", \"871391088\\n\", \"5\\n\", \"204\\n\", \"410\\n\", \"77428256\\n\", \"1640\\n\", \"86238\\n\", \"1239895992\\n\", \"644640\\n\", \"984020\\n\", \"1818540\\n\", \"610876\\n\", \"619\\n\", \"32\\n\", \"26041\\n\", \"752936\\n\", \"3000\\n\", \"6487160460\\n\", \"440\\n\", \"30\\n\", \"132510\\n\", \"20\\n\", \"21528\\n\", \"1620057168\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\"]}"
}
|
{
"index": 15
}
|
taco
|
[
{
"role": "user",
"content": "Given the value of n, print the n'th prime number.\n\nInput : A single integer n. \nOutput : A single number which is the n'th prime number.\nConstraints : \n1 ≤ n ≤ 1000\n\nSAMPLE INPUT\n2\n\nSAMPLE OUTPUT\n3\n\nExplanation\n\nThe first few prime numbers are:\n2,3,5,7. So, the answer is 3.\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
] |
code
|
{
"style": "rule",
"ground_truth": "{\"inputs\": [\"1000\", \"1\", \"17\", \"100\"], \"outputs\": [\"541\", \"7919\", \"2\", \"59\"]}"
}
|
{
"index": 16
}
|
Eurus-2-Code-RL (VERL Format)
This dataset contains 25,276 competitive programming problems from the Eurus-2-RL-Data dataset, filtered and converted to VERL format for reinforcement learning training workflows.
Source: PRIME-RL/Eurus-2-RL-Data
License: MIT
Note (Updated 2025-10-27): System prompts have been removed from all examples for better compatibility with other code datasets. The dataset now contains only user messages with the coding problems. See changelog for details.
Dataset Description
Eurus-2-Code-RL is a curated collection of competitive programming problems specifically designed for training language models using reinforcement learning. The problems are sourced from various high-quality coding challenge platforms and include:
- CodeContests problems
- TACO (Text-Assisted Coding with Objectives) problems
- APPS (Automated Programming Progress Standard) problems
- Codeforces problems
Dataset Structure
The dataset follows the VERL format with the following fields:
data_source(string): Original source identifier (e.g., "taco", "codecontests", "apps", "codeforces")prompt(list): Chat template format with role/content structure- User message with the coding problem
ability(string): Task category ("code")reward_model(dict): Evaluation informationstyle: Evaluation method ("rule" for test-based evaluation)ground_truth: Test cases for evaluation
extra_info(dict): Additional metadatasplit: Data split ("train" or "dummy")index: Example index
Data Quality
High-Quality Problems:
- ✅ Diverse sources - Problems from competitive programming platforms
- ✅ RL-focused - Specifically designed for reinforcement learning training
- ✅ Verified solutions - Ground truth test cases for reward model evaluation
- ✅ Compatible format - Matches structure of other VERL code datasets
Sample Problem
{
"data_source": "taco",
"prompt": [
{
"role": "user",
"content": "One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by 1...\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
}
],
"ability": "code",
"reward_model": {
"style": "rule",
"ground_truth": "{\"inputs\": [...], \"outputs\": [...]}"
},
"extra_info": {
"split": "train",
"index": 0
}
}
Usage
from datasets import load_dataset
# Load the dataset
dataset = load_dataset("sungyub/eurus-2-code-verl")
# Access an example
example = dataset['train'][0]
print(example['prompt'][0]['content']) # Coding problem
print(example['reward_model']['ground_truth']) # Test cases
print(example['data_source']) # Source dataset
# Stream the dataset for memory efficiency
dataset = load_dataset("sungyub/eurus-2-code-verl", streaming=True)
for example in dataset['train']:
# Process examples one at a time
pass
Statistics
- Total examples: 25,276
- Format: 1 Parquet file with Git LFS
- File size: ~1.54 GB
- File: train-00000-of-00001.parquet
- Filter rate: 5.3% of total Eurus-2 dataset
Source Datasets
The problems are sourced from multiple high-quality competitive programming datasets:
- codecontests: CodeContests problems (9,639 problems)
- taco: Text-Assisted Coding with Objectives (9,579 problems)
- apps: Automated Programming Progress Standard (3,462 problems)
- codeforces: Codeforces problems (2,596 problems)
Problem Types
The dataset covers a wide range of programming challenges including:
- Algorithm design and implementation
- Data structures
- Dynamic programming
- Graph algorithms
- String processing
- Mathematical problems
- And more...
File Structure
The dataset is contained in a single parquet file:
- File name:
train-00000-of-00001.parquet - Contains all 25,276 examples
- HuggingFace datasets library automatically handles file loading
Conversion
The dataset was converted using a streaming approach:
# Install dependencies
pip install datasets pyarrow
# Run conversion
python convert_to_verl.py
# Features:
# - Streaming processing for memory efficiency
# - ParquetWriter for efficient output
# - Progress tracking and resume capability
# - Filters only code problems (ability='code')
Use Cases
This dataset is ideal for:
- Reinforcement Learning: Training code generation models with RL
- Fine-tuning: Improving competitive programming capabilities
- Code Generation: Training models to solve algorithmic problems
- Dataset Merging: Compatible with other VERL code datasets (e.g., skywork-or1-code-verl)
Technical Details
Conversion Process
- Loaded source dataset from HuggingFace in streaming mode
- Filtered examples where ability='code'
- Removed system prompts for compatibility (2025-10-27)
- Output to single parquet file
- Total conversion time: ~2.4 minutes
- Filter rate: 5.3% (25,276 code problems from 480,537 total)
VERL Format Benefits
- Standardized structure: Consistent across all VERL datasets
- Rich metadata: Includes source and split information
- Chat template: Ready for instruction-tuned models
- Reward model integration: Test cases for RL training
- Dataset compatibility: Works seamlessly with other VERL code datasets
Original System Prompt (Removed)
The original dataset included a structured reasoning system prompt with the following actions:
- [ASSESS]: Evaluate the current state
- [ADVANCE]: Take a concrete step forward
- [VERIFY]: Check validity of steps
- [SIMPLIFY]: Break down complex parts
- [SYNTHESIZE]: Combine insights
- [PIVOT]: Change approach if needed
- [OUTPUT]: Present the final answer
This prompt has been removed from all examples to ensure compatibility with other code datasets that use simple user-only prompts. Users who wish to use structured reasoning can add their own system prompts at training time.
Additional Information
For more information about VERL format, see the VERL documentation.
Citation
If you use this dataset, please cite the original Eurus-2-RL-Data:
@misc{eurus-2-rl-data,
title={Eurus-2-RL-Data},
author={PRIME-RL},
year={2024},
publisher={HuggingFace},
url={https://huggingface.co/datasets/PRIME-RL/Eurus-2-RL-Data}
}
Changelog
2025-10-27 - System Prompt Removal
- Removed system prompts from all 25,276 examples
- Improved compatibility with other VERL code datasets (e.g., skywork-or1-code-verl)
- Prompt structure now:
[{"role": "user", "content": "..."}]instead of[{"role": "system", ...}, {"role": "user", ...}] - All other fields (data_source, ability, reward_model, extra_info) preserved
- Original system prompt content documented above for reference
- File size remains ~1.54GB
2025-10-14 - Initial Release
- Filtered and converted 25,276 code problems from Eurus-2-RL-Data
- Single file for efficient loading
- Preserved original source information and metadata
- Included structured reasoning system prompt
- Total size: 1.54GB
- Downloads last month
- 63