Dataset Viewer
Auto-converted to Parquet
question_title
stringlengths
3
34
question_content
stringlengths
713
3.03k
platform
stringclasses
1 value
question_id
stringlengths
12
45
contest_id
stringlengths
10
10
contest_date
timestamp[s]date
1011-01-01 00:00:00
2098-01-01 00:00:00
starter_code
stringclasses
1 value
difficulty
stringclasses
3 values
public_test_cases
stringlengths
160
7.6M
private_test_cases
stringlengths
172
35.8M
metadata
stringlengths
86
121
Good Bitstrings
For any two positive integers $a$ and $b$, define the function $\texttt{gen_string}(a,b)$ by the following Python code: def gen_string(a: int, b: int): res = "" ia, ib = 0, 0 while ia + ib < a + b: if ia * b <= ib * a: res += '0' ia += 1 else: res += '1' ib += 1 return res Equivalent C++ code: string gen_string(int64_t a, int64_t b) { string res; int ia = 0, ib = 0; while (ia + ib < a + b) { if ((__int128)ia * b <= (__int128)ib * a) { res += '0'; ia++; } else { res += '1'; ib++; } } return res; } $ia$ will equal $a$ and $ib$ will equal $b$ when the loop terminates, so this function returns a bitstring of length $a+b$ with exactly $a$ zeroes and $b$ ones. For example, $\texttt{gen_string}(4,10)=01110110111011$. Call a bitstring $s$ $\textbf{good}$ if there exist positive integers $x$ and $y$ such that $s=\texttt{gen_string}(x,y)$. Given two positive integers $A$ and $B$ ($1\le A,B\le 10^{18}$), your job is to compute the number of good prefixes of $\texttt{gen_string}(A,B)$. For example, there are $6$ good prefixes of $\texttt{gen_string}(4,10)$: x = 1 | y = 1 | gen_string(x, y) = 01 x = 1 | y = 2 | gen_string(x, y) = 011 x = 1 | y = 3 | gen_string(x, y) = 0111 x = 2 | y = 5 | gen_string(x, y) = 0111011 x = 3 | y = 7 | gen_string(x, y) = 0111011011 x = 4 | y = 10 | gen_string(x, y) = 01110110111011 INPUT FORMAT (input arrives from the terminal / stdin): The first line contains $T$ ($1\le T\le 10$), the number of independent test cases. Each of the next $T$ lines contains two integers $A$ and $B$. OUTPUT FORMAT (print output to the terminal / stdout): The answer for each test case on a new line.
codeforces
1333_platinum_good_bitstrings
usaco_1333
1333-01-01T00:00:00
# Read input and solve the problem
hard
[{"input": "6\n1 1\n3 5\n4 7\n8 20\n4 10\n27 21", "output": "1\n5\n7\n10\n6\n13", "testtype": "stdin"}, {"input": "10\n85 13\n71 66\n28 66\n29 71\n96 63\n38 31\n17 68\n36 58\n36 4\n63 33", "output": "20\n32\n12\n15\n27\n16\n36\n12\n15\n17", "testtype": "stdin"}, {"input": "10\n906 527\n608 244\n263 174\n839 281\n153 492\n987 849\n701 390\n195 518\n410 59\n48 971", "output": "23\n42\n50\n80\n19\n31\n28\n32\n30\n34", "testtype": "stdin"}]
eJyNmU2OrEcRRRmwDaRUjy2U/5nBSpBoZnjgSWPJ7YGFkFgEbI8Z++CcqPbgFUIqW++97vp+MjPixr03ov7x23/953e/yf/++G9++NPf3n74+PHnz7c/lLdW3z/aPLevclZfdbx/xK5ntrJab/W+f9xxopbbekR//xj9rrlKu2fXzaO3n9XKnaft4N52Yw9unrF406k7Zi3r3haTF/NPzHL3qfO8f/R5W+Xme+rlVau22XoZ9bR1374rb3/9+fNrk5dtbP+wgba49/Bnzu0refDr6q0+9fn9T5+fv/z4vc/99PmXHz7e/v5deTrwZoN1ljHG7NdDtL1q2fPUxdXeo/Zb9j2EhZvXmWsVzlkfq4245fDM5YRjr7lv6fOM7hHG6bXME+1wca09di299sFvhKIR5V4HL+bXxjln2S3Gqd8eN5Y5ab7dt0x/84zszUh0l7rcs/Z89cQctw/SNmv3xGeMekeJ2++Yvpmjt9Jv39Mct7uil7XP2Oz0zl3rNU9rNaMVbZ0yLzDhVeMQveDXWk3PrDfGLbPWMQDEOo2nyx5teJ5WZz3lnMk/35659a+0GrgZj5Our1ODPf5ytdbP60cGz61M1jarawbILXN8obredXuZc+w+XZHsltW/ktpm74VzLDN+zp6ckPvuNFhzBuBZLe89cUTtaWMeLvY1yW5xkb3cwwljtSmep/NOSy23svcXfufj39YOgeQNFtjMiy8De4+xBhte0QZJi21V1173Xvze67quFnOsvk87lHLfMfam7Gprc/YZcxOGsUKgU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qoDVLWUk9hF1LPXzZtHbsz01igc7s64AYGWPgxcVU9fZzfOFA8+N2p+bHJMHfOZau5chapeQVDEgHNjBb16uP0GtakLSTdL/1wh8jlzuvM1HkKbtmRW2hGm060qOkYHoiUNrehz98m9WiedD2OQJy1kIj0gdvZFk86OnD8wR0O9mZO8YCHnrA55rEogQNx7BQIFs3iwGY4nuIsfDBzmEz8nHURPggns65TRLNpx0CMAwCoCPWwfXKwl0Pf8frXKJASwTF13cEuiVv5BZIM6PvwNxafjtRxHz4Z90FewzkP6WDLcmPg8J1UTDgXUOcYREg2PGe3ZXPeSP3hdJ2lwQ5O4zV54ZwBO/ngO7wYlUFYESOQi+rtlMfrFGgY4OG4s0YJB/soN3unL+U+6h9JKPmlkrxLqdvTXKuriaDpzmGA4dt54dNXNmieUyOtfjbcksJZ6TTQkvzeJCcWQIKwdHuNZnQw+ifbAcmYNOFww8ZqZNrZIJ4dR2YDlP3KkQ1AQGjEHQCQxwWKMXWDtqdlA9js9f1KZySrgavXR1DbaT0EQ7m6Kg4mm88pzNQkmBkuRGa3qyOxoUuB4wkQHvigZlqHLA/HbLZkw/l8fVAjBybrjmDQDDogZM0qhUnxfcRF22x8lx+zg6rs9DS7294mv8xpDhsoOGCdHtPpf36ptnBoY/uFldVItcJiLT8HoYi+3T8BRE15Ja14OhmEwDHLk5oi52zy6Kpp+WVRhFWapaPFJ/u13CaD9MfHqdXIYRRyx0Ohgw3ZChdGf2dTSieRnpdNw6sAnDhn1p22d1sBDfR4fNOl1ZCHbdR2fuuVM1FNBM1IPvT/+pg///P3/wX+eu1W
{"problem_level": "platinum", "contest_year": 1333, "original_problem_id": "1333_platinum_good_bitstrings"}
Pareidolia
"\nPareidolia is the phenomenon where your eyes tend to see familiar patterns in\nimages where none (...TRUNCATED)
codeforces
1330_gold_pareidolia
usaco_1330
1330-01-01T00:00:00
# Read input and solve the problem
hard
"[{\"input\": \"besssie\\n1 1 5 4 6 1 1\", \"output\": \"1\\n4\", \"testtype\": \"stdin\"}, {\"input(...TRUNCATED)
"eJzsvcuO80qTteeBL6TQQ+MflM6Sb8C3YMD/hEkmqSTFY5IUJcOAr8VX6vVE1jYMAzbsidHdH6P72/t9qyQyMzJixYoDuf/X//Z(...TRUNCATED)
"{\"problem_level\": \"gold\", \"contest_year\": 1330, \"original_problem_id\": \"1330_gold_pareidol(...TRUNCATED)
Milk Sum
"\n**Note: The time limit for this problem is 4s, 2x the default.**\nFarmer John's $N$ cows ($1\\le (...TRUNCATED)
codeforces
1326_silver_milk_sum
usaco_1326
1326-01-01T00:00:00
# Read input and solve the problem
medium
"[{\"input\": \"5\\n1 10 4 2 6\\n3\\n2 1\\n2 8\\n4 5\", \"output\": \"55\\n81\\n98\", \"testtype\": (...TRUNCATED)
"eJxMnUmubUmTlSXEQLainQ2vC0aCRDTJRnaClPLPBkJIDIKBMSTWt8z8RCLgj/fevefs7W7FsmXV//nP//X//fP//U//7X/98S9(...TRUNCATED)
"{\"problem_level\": \"silver\", \"contest_year\": 1326, \"original_problem_id\": \"1326_silver_milk(...TRUNCATED)
Field Day
"\n**Note: The time limit for this problem in Python is 15s. Other languages have the default time (...TRUNCATED)
codeforces
1327_silver_field_day
usaco_1327
1327-01-01T00:00:00
# Read input and solve the problem
medium
"[{\"input\": \"5 3\\nGHGGH\\nGHHHH\\nHGHHG\", \"output\": \"5\\n3\\n5\", \"testtype\": \"stdin\"}, (...TRUNCATED)
"eJx8+UGuLcuubIlBgBqSyBZkVtUBsq6KAN0OqJJQIVVSRV1RT5XvbbdhgzHX130fH3HmjvCgk2aDDF//n//z/+3/+3/93/9P//f(...TRUNCATED)
"{\"problem_level\": \"silver\", \"contest_year\": 1327, \"original_problem_id\": \"1327_silver_fiel(...TRUNCATED)
Pareidolia
"\n**Note: The time limit for this problem is 4s, 2x the default.**\nPareidolia is the phenomenon wh(...TRUNCATED)
codeforces
1328_silver_pareidolia
usaco_1328
1328-01-01T00:00:00
# Read input and solve the problem
medium
"[{\"input\": \"bessiebessie\", \"output\": \"14\", \"testtype\": \"stdin\"}, {\"input\": \"abcdefgh(...TRUNCATED)
"eJyMvcmOJD20HuaFH+TirrWRrmQNTyLAK85zcB4NA350f4zMqu7/ygsDjc6qzMgI8vCcb2CQUf/P//4//8e//cv/9n/+X/9qntT(...TRUNCATED)
"{\"problem_level\": \"silver\", \"contest_year\": 1328, \"original_problem_id\": \"1328_silver_pare(...TRUNCATED)
Rotate and Shift
"\n**Note: The time limit for this problem is 4s, 2x the default.**\nTo celebrate the start of sprin(...TRUNCATED)
codeforces
1325_bronze_rotate_and_shift
usaco_1325
1325-01-01T00:00:00
# Read input and solve the problem
easy
"[{\"input\": \"5 3 4\\n0 2 3\", \"output\": \"1 2 3 4 0\", \"testtype\": \"stdin\"}, {\"input\": \"(...TRUNCATED)
"eJzMvc2OJbuSXqlBP0jgjmvgpPG3H6GfQED3sDXQpFRAXQ0EQYDmPelHlq1F3xE7dkZk5jn3VEGD+HInnU53J52k2WfmZv/z//i(...TRUNCATED)
"{\"problem_level\": \"bronze\", \"contest_year\": 1325, \"original_problem_id\": \"1325_bronze_rota(...TRUNCATED)
Bakery
"\nBessie has opened a bakery!\n\nIn her bakery, Bessie has an oven that can produce a cookie in $t_(...TRUNCATED)
codeforces
1302_silver_bakery
usaco_1302
1302-01-01T00:00:00
# Read input and solve the problem
medium
"[{\"input\": \"2\\n\\n3 7 9\\n4 3 18\\n2 4 19\\n1 1 6\\n\\n5 7 3\\n5 9 45\\n5 2 31\\n6 4 28\\n4 1 8(...TRUNCATED)
"eJxk3UvOLEuSJGYOuAQuwFHjHvjT3JwrIcAcsgc9STbQ1QOCaIAL4yq4IsonFn82AVYVsm7eEyfC3R76EBUV/b/+x//l//5//qf(...TRUNCATED)
"{\"problem_level\": \"silver\", \"contest_year\": 1302, \"original_problem_id\": \"1302_silver_bake(...TRUNCATED)
Cow-libi
"\n**Note: The time limit for this problem is 4s, two times the default.**\n\nSomebody has been graz(...TRUNCATED)
codeforces
1303_silver_cow-libi
usaco_1303
1303-01-01T00:00:00
# Read input and solve the problem
medium
"[{\"input\": \"2 4\\n0 0 100\\n50 0 200\\n0 50 50\\n1000 1000 0\\n50 0 200\\n10 0 170\", \"output\"(...TRUNCATED)
"eJxsfUuOdsmSlIRYSKrGpBTvBytBoof0oCeXlvr2AKGW2BQbYwW4+cM8TtUV4lL8mfl950R4+MPc3OL//Of/9n//33/8p//+v//(...TRUNCATED)
"{\"problem_level\": \"silver\", \"contest_year\": 1303, \"original_problem_id\": \"1303_silver_cow-(...TRUNCATED)
Hungry Cow
"\nBessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn,\nshe will eat on(...TRUNCATED)
codeforces
1299_bronze_hungry_cow
usaco_1299
1299-01-01T00:00:00
# Read input and solve the problem
easy
"[{\"input\": \"1 5\\n1 2\", \"output\": \"2\", \"testtype\": \"stdin\"}, {\"input\": \"2 5\\n1 2\\n(...TRUNCATED)
"eJxMvbuxLTuznHsFGjLiWNB4A9cBusAIHgeonKBASlRoES2kQHyZibn/LeyFnqPRjcajUKjKyvrf/+m//Of/83//v//6v/7tv/3(...TRUNCATED)
"{\"problem_level\": \"bronze\", \"contest_year\": 1299, \"original_problem_id\": \"1299_bronze_hung(...TRUNCATED)
Stamp Grid
"\nA stamp painting is a black and white painting on an $N \\times N$ canvas,\nwhere certain cells a(...TRUNCATED)
codeforces
1300_bronze_stamp_grid
usaco_1300
1300-01-01T00:00:00
# Read input and solve the problem
easy
"[{\"input\": \"4\\n\\n2\\n**\\n*.\\n1\\n*\\n\\n3\\n.**\\n.**\\n***\\n2\\n.*\\n**\\n\\n3\\n...\\n.*.(...TRUNCATED)
"eJzsvc3OLMltLXoHF7ivIfSQEIje+pfnntoDT45xemgNNGkLUGtgGAbOkx9c7crg4lokIzLr21u2GuhSa39VTCaDwZ9FRmRW1v/(...TRUNCATED)
"{\"problem_level\": \"bronze\", \"contest_year\": 1300, \"original_problem_id\": \"1300_bronze_stam(...TRUNCATED)
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
104