record_id stringlengths 7 7 | source stringclasses 5
values | title stringlengths 6 30 | statement stringlengths 17 223 | answer stringlengths 0 25 | reference_solution stringlengths 29 736 | unit_tests listlengths 0 7 | collected_at timestamp[s]date 2025-05-04 00:00:00 2025-10-08 00:00:00 |
|---|---|---|---|---|---|---|---|
CR-0001 | kattis | Sum of Squared Digits | What is the sum of the squares of the decimal digits of 9999? | 324 | def solve(n):
return sum(int(ch) ** 2 for ch in str(n)) | [
"assert solve(9999) == 324",
"assert solve(0) == 0",
"assert solve(123) == 14",
"assert solve(1000000) == 1"
] | 2025-06-14T00:00:00 |
CR-0002 | codeforces | Set Bit Count | How many bits are set to one in the binary representation of 255? | 8 | def solve(n):
return bin(n).count('1') | [
"assert solve(255) == 8",
"assert solve(0) == 0",
"assert solve(1) == 1",
"assert solve(1023) == 10",
"assert solve(1000000) == 7",
"assert solve(4095) == 12"
] | 2025-10-06T00:00:00 |
CR-0003 | kattis | Hamming Distance | How many bit positions differ between the binary representations of 117 and 15? | 5 | def solve(pair):
return bin(pair[0] ^ pair[1]).count('1') | [
"assert solve((117, 15)) == 5",
"assert solve((1, 4)) == 2"
] | 2025-05-24T00:00:00 |
CR-0004 | codeforces | Multiples of Seven | What is the sum of every positive integer no greater than 1000 that is divisible by 7? | 71071 | def solve(n):
return sum(i for i in range(1, n + 1) if i % 7 == 0) | [
"assert solve(1000) == 71071",
"assert solve(100) == 735",
"assert solve(7) == 7",
"assert solve(2000) == 285285",
"assert solve(49) == 196",
"assert solve(1) == 0"
] | 2025-08-04T00:00:00 |
CR-0005 | leetcode | Second Largest | What is the second largest distinct value in [5, 1, 9, 9, 7]? Return -1 if no such value exists. | 7 | def solve(arr):
uniq = sorted(set(arr), reverse=True)
return uniq[1] if len(uniq) > 1 else -1 | [
"assert solve([5, 1, 9, 9, 7]) == 7",
"assert solve([1, 2]) == 1",
"assert solve([4]) == -1",
"assert solve([8, 8, 8]) == -1",
"assert solve([10, 3, 3, 7]) == 7"
] | 2025-05-28T00:00:00 |
CR-0006 | leetcode | Days Between Dates | HOW MANY DAYS LIE BETWEEN 2024-02-27 AND 2024-03-05 (BOTH ISO DATES, COUNTING THE DIFFERENCE IN CALENDAR DAYS)? | 7 | from datetime import date
def solve(pair):
y1, m1, d1 = (int(x) for x in pair[0].split('-'))
y2, m2, d2 = (int(x) for x in pair[1].split('-'))
return (date(y2, m2, d2) - date(y1, m1, d1)).days | [
"assert solve(('2024-02-27', '2024-03-05')) == 7",
"assert solve(('2023-01-01', '2024-01-01')) == 365"
] | 2025-10-07T00:00:00 |
CR-0007 | kattis | Digital Root | What is the single-digit digital root of 987654321? | 9 | def solve(n):
return 0 if n == 0 else 1 + (n - 1) % 9 | [
"assert solve(987654321) == 9",
"assert solve(0) == 0",
"assert solve(9) == 9",
"assert solve(12345) == 6",
"assert solve(999999999) == 9",
"assert solve(7) == 7"
] | 2025-07-11T00:00:00 |
CR-0008 | kattis | Fibonacci Residue | What is F(50) modulo 1000, where F(0) = 0, F(1) = 1 and each later term is the sum of the previous two?. | 25 | def solve(pair):
n, m = pair
a, b = 0, 1
for _ in range(n):
a, b = b, (a + b) % m
return a | [
"assert solve((50, 1000)) == 25",
"assert solve((10, 100)) == 55",
"assert solve((0, 7)) == 0",
"assert solve((100, 97)) == 96",
"assert solve((25, 10)) == 5"
] | 2025-10-03T00:00:00 |
CR-0009 | leetcode | Two Sum Positions | For the list [2, 7, 11, 15] and target 9, give the two 0-based indices (smaller first) of the pair of entries that add up to the target. Exactly one such pair exists. | [0, 1] | def solve(pair):
arr, target = pair
seen = {}
for i, x in enumerate(arr):
if target - x in seen:
return [seen[target - x], i]
seen[x] = i
return [] | [
"assert solve(([2, 7, 11, 15], 9)) == [0, 1]",
"assert solve(([3, 2, 4], 6)) == [1, 2]",
"assert solve(([3, 3], 6)) == [0, 1]",
"assert solve(([1, 5, 9, 12], 21)) == [2, 3]"
] | 2025-09-23T00:00:00 |
CR-0010 | codeforces | Smaller Of Two | Which is smaller, 14 or 27? | TODO | def solve(pair):
return min(pair) | [
"assert solve((14, 27)) == 14",
"assert solve((5, 3)) == 3"
] | 2025-06-05T00:00:00 |
CR-0011 | internal | String Length | How many characters does 'toolathlon' have? | 10 | def solve(s):
return len(s) | [
"assert solve('toolathlon') == 10",
"assert solve('x') == 1"
] | 2025-07-23T00:00:00 |
CR-0012 | kattis | Digital Root | what is the single-digit digital root of 987654321? | 9 | def solve(n):
return 0 if n == 0 else 1 + (n - 1) % 9 | [
"assert solve(987654321) == 9",
"assert solve(0) == 0",
"assert solve(9) == 9",
"assert solve(12345) == 6",
"assert solve(999999999) == 9",
"assert solve(7) == 7"
] | 2025-10-01T00:00:00 |
CR-0013 | atcoder | Run Length Encoding | Encode 'aaabccccdd' as character-count pairs, for example 'aab' becomes 'a2b1'. | a3b1c4d2 | def solve(s):
if not s:
return ''
out, cur, count = [], s[0], 1
for ch in s[1:]:
if ch == cur:
count += 1
else:
out.append(cur + str(count))
cur, count = ch, 1
out.append(cur + str(count))
return ''.join(out) | [
"assert solve('aaabccccdd') == 'a3b1c4d2'",
"assert solve('abc') == 'a1b1c1'",
"assert solve('wwwwwwwwwwww') == 'w12'",
"assert solve('aabbaa') == 'a2b2a2'"
] | 2025-05-13T00:00:00 |
CR-0014 | internal | String Reversal | Reverse the characters of 'verl'. | lrev | def solve(s):
return s[::-1] | [
"assert solve('verl') == 'lrev'",
"assert solve('ab') == 'ba'"
] | 2025-05-04T00:00:00 |
CR-0015 | leetcode | Count A Letter | How many times does the letter a appear in 'banana'? | 3 | def solve(s):
return s.count('a') | [
"assert solve('banana') == 3"
] | 2025-08-10T00:00:00 |
CR-0016 | leetcode | Island Count | Treating 1 cells as land and 0 cells as water, and connecting land cells only up and down and left and right, how many islands does the grid [[1, 1, 0, 0], [0, 1, 0, 1], [0, 0, 1, 1], [1, 0, 0, 0]] contain? | 3 | def solve(grid):
if not grid:
return 0
rows, cols = len(grid), len(grid[0])
seen = set()
count = 0
for r in range(rows):
for c in range(cols):
if grid[r][c] == 1 and (r, c) not in seen:
count += 1
stack = [(r, c)]
seen.add((... | [
"assert solve([[1, 1, 0, 0], [0, 1, 0, 1], [0, 0, 1, 1], [1, 0, 0, 0]]) == 3",
"assert solve([[1]]) == 1",
"assert solve([[0, 0], [0, 0]]) == 0"
] | 2025-09-26T00:00:00 |
CR-0017 | atcoder | Binomial Residue | What is the remainder of the binomial coefficient C(20, 10) when divided by 1000? | 756 | import math
def solve(triple):
n, k, m = triple
return math.comb(n, k) % m | [
"assert solve((20, 10, 1000)) == 756",
"assert solve((10, 5, 7)) == 0",
"assert solve((50, 25, 97)) == 24"
] | 2025-05-26T00:00:00 |
CR-0018 | leetcode | List GCD | What is the greatest common divisor of every number in [24, 36, 60]? | 12 | def solve(arr):
g = 0
for x in arr:
a, b = g, x
while b:
a, b = b, a % b
g = a
return g | [
"assert solve([24, 36, 60]) == 12",
"assert solve([7]) == 7"
] | 2025-08-23T00:00:00 |
CR-0019 | kattis | Fibonacci Residue | What is F(50) modulo 1000, where F(0) = 0, F(1) = 1 and each later term is the sum of the previous two? | 25 | def solve(pair):
n, m = pair
a, b = 0, 1
for _ in range(n):
a, b = b, (a + b) % m
return a | [
"assert solve((50, 1000)) == 25",
"assert solve((10, 100)) == 55",
"assert solve((0, 7)) == 0",
"assert solve((100, 97)) == 96",
"assert solve((25, 10)) == 5"
] | 2025-05-20T00:00:00 |
CR-0020 | kattis | Base Conversion | Write 255 in base 16 using lowercase digits, without any prefix. | ff | def solve(pair):
n, b = pair
if n == 0:
return '0'
digits = '0123456789abcdefghijklmnopqrstuvwxyz'
out = []
while n:
out.append(digits[n % b])
n //= b
return ''.join(reversed(out)) | [
"assert solve((255, 16)) == 'ff'",
"assert solve((10, 2)) == '1010'",
"assert solve((0, 8)) == '0'",
"assert solve((4095, 16)) == 'fff'",
"assert solve((100, 7)) == '202'"
] | 2025-06-18T00:00:00 |
CR-0021 | atcoder | Right Rotation | Rotate the list [1, 2, 3, 4, 5] to the right by 2 positions and give the resulting list. | [4, 5, 1, 2, 3] | def solve(pair):
arr, k = pair
k %= len(arr)
return arr[-k:] + arr[:-k] if k else list(arr) | [
"assert solve(([1, 2, 3, 4, 5], 2)) == [4, 5, 1, 2, 3]",
"assert solve(([1, 2], 3)) == [2, 1]",
"assert solve(([7], 0)) == [7]"
] | 2025-06-08T00:00:00 |
CR-0022 | atcoder | Right Rotation | rotate the list [1, 2, 3, 4, 5] to the right by 2 positions and give the resulting list. | [4, 5, 1, 2, 3] | def solve(pair):
arr, k = pair
k %= len(arr)
return arr[-k:] + arr[:-k] if k else list(arr) | [
"assert solve(([1, 2, 3, 4, 5], 2)) == [4, 5, 1, 2, 3]",
"assert solve(([1, 2], 3)) == [2, 1]",
"assert solve(([7], 0)) == [7]"
] | 2025-10-05T00:00:00 |
CR-0023 | codeforces | Matrix Trace | What is the trace (sum of the main diagonal) of the matrix [[3, 1, 4], [1, 5, 9], [2, 6, 5]]? | 13 | def solve(grid):
return sum(grid[i][i] for i in range(len(grid))) | [
"assert solve([[3, 1, 4], [1, 5, 9], [2, 6, 5]]) == 13",
"assert solve([[1, 2], [3, 4]]) == 5",
"assert solve([[7]]) == 7",
"assert solve([[1, 0, 0], [0, 2, 0], [0, 0, 3]]) == 6"
] | 2025-05-23T00:00:00 |
CR-0024 | atcoder | Least Common Multiple | What is the least common multiple of 21 and 6? | 42 | def solve(pair):
a, b = pair
x, y = a, b
while y:
x, y = y, x % y
return abs(a * b) // x | [
"assert solve((21, 6)) == 42",
"assert solve((4, 6)) == 12"
] | 2025-05-21T00:00:00 |
CR-0025 | codeforces | Longest Character Run | What is the length of the longest run of one repeated character in 'aaabccccdd'? | 4 | def solve(s):
best = cur = 0
prev = None
for ch in s:
if ch == prev:
cur += 1
else:
prev, cur = ch, 1
best = max(best, cur)
return best | [
"assert solve('aaabccccdd') == 4",
"assert solve('abc') == 1"
] | 2025-10-02T00:00:00 |
CR-0026 | leetcode | Merged Interval Count | After merging every pair of overlapping closed intervals in [(1, 3), (2, 6), (8, 10), (15, 18)], how many disjoint intervals remain? | 3 | def solve(intervals):
intervals = sorted(intervals)
count = 0
end = None
for s, e in intervals:
if end is None or s > end:
count += 1
end = e
else:
end = max(end, e)
return count | [
"assert solve([(1, 3), (2, 6), (8, 10), (15, 18)]) == 3",
"assert solve([(1, 4), (4, 5)]) == 1",
"assert solve([(1, 2), (3, 4)]) == 2",
"assert solve([(1, 10)]) == 1",
"assert solve([(2, 3), (2, 4), (5, 6)]) == 2"
] | 2025-07-26T00:00:00 |
CR-0027 | leetcode | Sort Ascending | Sort the numbers [5, 2, 9] in ascending order. | ? | def solve(arr):
return sorted(arr) | [
"assert solve([5, 2, 9]) == [2, 5, 9]",
"assert solve([1]) == [1]"
] | 2025-09-12T00:00:00 |
CR-0028 | kattis | List Total | What is the total of the numbers in [4, 8, 15, 16]? | TBD | def solve(arr):
return sum(arr) | [
"assert solve([4, 8, 15, 16]) == 43",
"assert solve([1]) == 1"
] | 2025-07-15T00:00:00 |
CR-0029 | leetcode | Insert Position | The list [1, 3, 5, 6] is sorted ascending. If 5 were inserted while keeping the list sorted, at which 0-based index would it go? Return the leftmost valid index. | 2 | def solve(pair):
arr, target = pair
lo, hi = 0, len(arr)
while lo < hi:
mid = (lo + hi) // 2
if arr[mid] < target:
lo = mid + 1
else:
hi = mid
return lo | [
"assert solve(([1, 3, 5, 6], 5)) == 2",
"assert solve(([1, 3, 5, 6], 2)) == 1",
"assert solve(([1, 3, 5, 6], 7)) == 4",
"assert solve(([1], 0)) == 0"
] | 2025-07-22T00:00:00 |
CR-0030 | leetcode | Trailing Zeros of a Factorial | How many trailing zeros does 100! have in base ten? | 24 | def solve(n):
count, power = 0, 5
while power <= n:
count += n // power
power *= 5
return count | [
"assert solve(100) == 24",
"assert solve(25) == 6",
"assert solve(5) == 1",
"assert solve(1000) == 249",
"assert solve(3) == 0",
"assert solve(200) == 49"
] | 2025-05-22T00:00:00 |
CR-0031 | atcoder | First Character | Give the first character of 'curriculum'. | c | def solve(s):
return s[0] | [] | 2025-08-08T00:00:00 |
CR-0032 | internal | Absolute Value | What is the absolute value of -45? | TODO | def solve(n):
return abs(n) | [
"assert solve(-45) == 45",
"assert solve(0) == 0",
"assert solve(9) == 9"
] | 2025-07-28T00:00:00 |
CR-0033 | kattis | Caesar Cipher | Shift every lowercase letter of 'attackatdawn' forward by 3 positions in the alphabet, wrapping at z. | dwwdfndwgdzq | def solve(pair):
s, k = pair
out = []
for ch in s:
if 'a' <= ch <= 'z':
out.append(chr((ord(ch) - 97 + k) % 26 + 97))
else:
out.append(ch)
return ''.join(out) | [
"assert solve(('attackatdawn', 3)) == 'dwwdfndwgdzq'",
"assert solve(('abc', 1)) == 'bcd'",
"assert solve(('xyz', 3)) == 'abc'",
"assert solve(('hello world', 5)) == 'mjqqt btwqi'"
] | 2025-08-27T00:00:00 |
CR-0034 | codeforces | Greatest Common Divisor | What is the greatest common divisor of 1071 and 462? | 21 | def solve(pair):
a, b = pair
while b:
a, b = b, a % b
return a | [
"assert solve((1071, 462)) == 21",
"assert solve((48, 18)) == 6",
"assert solve((17, 5)) == 1",
"assert solve((1000, 250)) == 250",
"assert solve((0, 9)) == 9",
"assert solve((270, 192)) == 6"
] | 2025-05-12T00:00:00 |
CR-0035 | atcoder | Armstrong Number | Is 153 an Armstrong number, meaning it equals the sum of its own digits each raised to the power of the digit count? | True | def solve(n):
s = str(n)
p = len(s)
return sum(int(ch) ** p for ch in s) == n | [
"assert solve(153) == True",
"assert solve(9474) == True",
"assert solve(100) == False"
] | 2025-05-18T00:00:00 |
CR-0036 | codeforces | Divisor Count | How many positive divisors does 720 have? | 30 | def solve(n):
count, i = 0, 1
while i * i <= n:
if n % i == 0:
count += 2 if i * i != n else 1
i += 1
return count | [
"assert solve(720) == 30",
"assert solve(1) == 1"
] | 2025-09-16T00:00:00 |
CR-0037 | codeforces | Integer To Roman | Write 1987 as a Roman numeral using the standard subtractive notation. | MCMLXXXVII | def solve(n):
table = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'),
(90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'),
(5, 'V'), (4, 'IV'), (1, 'I')]
out = []
for value, sym in table:
while n >= value:
out.append(sym)
n -= val... | [
"assert solve(1987) == 'MCMLXXXVII'",
"assert solve(4) == 'IV'",
"assert solve(58) == 'LVIII'",
"assert solve(2024) == 'MMXXIV'",
"assert solve(9) == 'IX'",
"assert solve(3999) == 'MMMCMXCIX'"
] | 2025-07-07T00:00:00 |
CR-0038 | atcoder | Leap Years In Range | How many leap years are there from 1900 through 2000 inclusive, using the Gregorian rule (divisible by 4, except centuries not divisible by 400)? | 25 | def solve(pair):
lo, hi = pair
return sum(1 for y in range(lo, hi + 1) if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0) | [
"assert solve((1900, 2000)) == 25",
"assert solve((2000, 2010)) == 3",
"assert solve((1896, 1903)) == 1"
] | 2025-09-07T00:00:00 |
CR-0039 | codeforces | Set Bit Count | How many bits are set to one in the binary representation of 255? | 8 | def solve(n):
return bin(n).count('1') | [
"assert solve(255) == 8",
"assert solve(0) == 0",
"assert solve(1) == 1",
"assert solve(1023) == 10",
"assert solve(1000000) == 7",
"assert solve(4095) == 12"
] | 2025-09-09T00:00:00 |
CR-0040 | kattis | Uppercase | Convert 'verl' to upper case. | VERL | def solve(s):
return s.upper() | [
"assert solve('verl') == 'VERL'"
] | 2025-09-05T00:00:00 |
CR-0041 | leetcode | Word Order Reversal | Reverse the order of the space-separated words in 'the quick brown fox jumps', then join them with single spaces. | jumps fox brown quick the | def solve(s):
return ' '.join(s.split()[::-1]) | [
"assert solve('the quick brown fox jumps') == 'jumps fox brown quick the'",
"assert solve('verl rule reward') == 'reward rule verl'",
"assert solve('one') == 'one'"
] | 2025-07-05T00:00:00 |
CR-0042 | kattis | Roman Numeral Value | What is the integer value of the Roman numeral 'MCMXCIV'? | 1994 | def solve(s):
values = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
total = 0
for i, ch in enumerate(s):
v = values[ch]
if i + 1 < len(s) and values[s[i + 1]] > v:
total -= v
else:
total += v
return total | [
"assert solve('MCMXCIV') == 1994",
"assert solve('III') == 3"
] | 2025-07-27T00:00:00 |
CR-0043 | leetcode | Edit Distance | What is the minimum number of single-character insertions, deletions or substitutions needed to turn 'kitten' into 'sitting'? | 3 | def solve(pair):
a, b = pair
prev = list(range(len(b) + 1))
for i, ca in enumerate(a, 1):
cur = [i]
for j, cb in enumerate(b, 1):
cur.append(min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (ca != cb)))
prev = cur
return prev[-1] | [
"assert solve(('kitten', 'sitting')) == 3",
"assert solve(('abc', 'abc')) == 0",
"assert solve(('', 'abc')) == 3"
] | 2025-07-20T00:00:00 |
CR-0044 | internal | Cube Of A Number | What is 12 cubed? | N/A | def solve(n):
return n ** 3 | [
"assert solve(12) == 1728",
"assert solve(2) == 8"
] | 2025-05-06T00:00:00 |
CR-0045 | kattis | Hamming Distance | How many bit positions differ between the binary representations of 117 and 15? | 5 | def solve(pair):
return bin(pair[0] ^ pair[1]).count('1') | [
"assert solve((117, 15)) == 5",
"assert solve((1, 4)) == 2"
] | 2025-10-04T00:00:00 |
CR-0046 | internal | Square Of A Number | What is 23 squared? | def solve(n):
return n * n | [
"assert solve(23) == 529",
"assert solve(1) == 1"
] | 2025-06-10T00:00:00 | |
CR-0047 | atcoder | Pascal Row Sum | What is the sum of all entries in row 20 of Pascal's triangle, where the top row is row 0? | 1048576 | def solve(n):
return 2 ** n | [
"assert solve(20) == 1048576",
"assert solve(0) == 1",
"assert solve(1) == 2",
"assert solve(10) == 1024",
"assert solve(30) == 1073741824"
] | 2025-09-22T00:00:00 |
CR-0048 | leetcode | Balanced Parentheses | Is the parenthesis string '(()())' balanced, that is, does every opening bracket have a matching closing bracket in the right order? | True | def solve(s):
depth = 0
for ch in s:
depth += 1 if ch == '(' else -1
if depth < 0:
return False
return depth == 0 | [
"assert solve('(()())') == True",
"assert solve('(())') == True",
"assert solve(')(') == False",
"assert solve('') == True",
"assert solve('((()))') == True",
"assert solve('(()') == False"
] | 2025-06-09T00:00:00 |
CR-0049 | codeforces | Frequency Ordering | Order the characters of 'tree' by decreasing frequency; break ties by ascending character code, and concatenate the result. | eert | from collections import Counter
def solve(s):
counts = Counter(s)
return ''.join(sorted(s, key=lambda ch: (-counts[ch], ch))) | [
"assert solve('tree') == 'eert'",
"assert solve('aabbcc') == 'aabbcc'",
"assert solve('leetcode') == 'eeecdlot'"
] | 2025-08-26T00:00:00 |
CR-0050 | codeforces | Distinct Count | How many distinct values are in [1, 1, 2, 3]? | 3 | def solve(arr):
return len(set(arr)) | [] | 2025-08-17T00:00:00 |
CR-0051 | leetcode | Word Count | How many whitespace-separated words does the sentence 'the quick brown fox jumps over the lazy dog' contain? | 9 | def solve(s):
return len(s.split()) | [
"assert solve('the quick brown fox jumps over the lazy dog') == 9",
"assert solve('verl') == 1",
"assert solve(' a b ') == 2",
"assert solve('') == 0"
] | 2025-09-03T00:00:00 |
CR-0052 | leetcode | Vowel Census | How many vowels (a, e, i, o and u, in either case) occur in the string 'Reinforcement Learning From Verifiable Rewards'? | 16 | def solve(s):
return sum(1 for ch in s.lower() if ch in 'aeiou') | [
"assert solve('Reinforcement Learning From Verifiable Rewards') == 16",
"assert solve('Verl') == 1",
"assert solve('abcde') == 2",
"assert solve('') == 0",
"assert solve('rhythm') == 0",
"assert solve('AEIOU xyz') == 5",
"assert solve('Queueing') == 5"
] | 2025-07-06T00:00:00 |
CR-0053 | leetcode | Fewest Coins | What is the smallest number of coins from the denominations [1, 2, 5] that add up to exactly 11? Coins may be reused. | 3 | def solve(pair):
coins, amount = pair
inf = float('inf')
dp = [0] + [inf] * amount
for a in range(1, amount + 1):
for c in coins:
if c <= a:
dp[a] = min(dp[a], dp[a - c] + 1)
return dp[amount] if dp[amount] != inf else -1 | [
"assert solve(([1, 2, 5], 11)) == 3",
"assert solve(([2], 3)) == -1",
"assert solve(([1], 0)) == 0",
"assert solve(([3, 7], 20)) == 4"
] | 2025-08-20T00:00:00 |
CR-0054 | atcoder | List Product | What is the product of the numbers in [2, 3, 4]? | N/A | def solve(arr):
out = 1
for x in arr:
out *= x
return out | [
"assert solve([2, 3, 4]) == 24",
"assert solve([5]) == 5"
] | 2025-08-15T00:00:00 |
CR-0055 | internal | Parity Check | Is 17 an odd number? | True | def solve(n):
return n % 2 == 1 | [
"assert solve(17) == True",
"assert solve(4) == False"
] | 2025-06-24T00:00:00 |
CR-0056 | atcoder | Collatz Length | Starting from 27, how many steps does the Collatz map need before it first reaches 1? | 111 | def solve(n):
steps = 0
while n != 1:
n = n // 2 if n % 2 == 0 else 3 * n + 1
steps += 1
return steps | [
"assert solve(27) == 111",
"assert solve(1) == 0",
"assert solve(6) == 8",
"assert solve(19) == 20",
"assert solve(97) == 118",
"assert solve(2) == 1",
"assert solve(871) == 178"
] | 2025-09-20T00:00:00 |
CR-0057 | internal | Larger Of Two | Which is larger, 14 or 27? | TBD | def solve(pair):
return max(pair) | [
"assert solve((14, 27)) == 27",
"assert solve((5, 3)) == 5"
] | 2025-05-08T00:00:00 |
CR-0058 | codeforces | Anagram Groups | How many groups of mutual anagrams are there in the list ['eat', 'tea', 'tan', 'ate', 'nat', 'bat']? Two words belong to the same group when one can be rearranged into the other, and every word belongs to exactly one group. | 3 | def solve(words):
return len({''.join(sorted(w)) for w in words}) | [
"assert solve(['eat', 'tea', 'tan', 'ate', 'nat', 'bat']) == 3",
"assert solve(['abc']) == 1"
] | 2025-06-23T00:00:00 |
CR-0059 | atcoder | Median | What is the median of the numbers in [3, 1, 4, 1, 5, 9, 2, 6]? For an even count, average the two middle values. | 3.5 | def solve(arr):
s = sorted(arr)
n = len(s)
if n % 2:
return s[n // 2]
return round((s[n // 2 - 1] + s[n // 2]) / 2, 2) | [
"assert solve([3, 1, 4, 1, 5, 9, 2, 6]) == 3.5",
"assert solve([1, 2, 3]) == 2",
"assert solve([4, 4]) == 4.0",
"assert solve([10, 2, 8, 6]) == 7.0",
"assert solve([7]) == 7"
] | 2025-07-10T00:00:00 |
CR-0060 | codeforces | Longest Increasing Subsequence | What is the length of the longest strictly increasing subsequence of [10, 9, 2, 5, 3, 7, 101, 18]? | 4 | def solve(arr):
tails = []
for x in arr:
lo, hi = 0, len(tails)
while lo < hi:
mid = (lo + hi) // 2
if tails[mid] < x:
lo = mid + 1
else:
hi = mid
if lo == len(tails):
tails.append(x)
else:
... | [
"assert solve([10, 9, 2, 5, 3, 7, 101, 18]) == 4",
"assert solve([1, 2, 3]) == 3"
] | 2025-06-22T00:00:00 |
CR-0061 | atcoder | Binary Gap | In the binary representation of 529, what is the longest run of zeros that is surrounded by ones on both sides? | 4 | def solve(n):
bits = bin(n)[2:]
gaps, cur = [], 0
for ch in bits:
if ch == '0':
cur += 1
else:
gaps.append(cur)
cur = 0
return max(gaps) if gaps else 0 | [
"assert solve(529) == 4",
"assert solve(9) == 2",
"assert solve(15) == 0",
"assert solve(20) == 1",
"assert solve(1041) == 5",
"assert solve(1) == 0"
] | 2025-05-16T00:00:00 |
CR-0062 | kattis | Weighted Mean | Given the scores [80, 90, 70] and the integer weights [1, 2, 3], what is the weighted average, rounded to two decimal places? | 78.33 | def solve(pair):
scores, weights = pair
total = sum(s * w for s, w in zip(scores, weights))
return round(total / sum(weights), 2) | [
"assert solve(([80, 90, 70], [1, 2, 3])) == 78.33",
"assert solve(([100], [1])) == 100.0",
"assert solve(([60, 80], [1, 1])) == 70.0",
"assert solve(([50, 75, 90], [2, 1, 1])) == 66.25"
] | 2025-09-18T00:00:00 |
CR-0063 | internal | Sum Of First Integers | What is the sum of the first 37 positive integers? | 703 | def solve(n):
return n * (n + 1) // 2 | [
"assert solve(37) == 703",
"assert solve(10) == 55"
] | 2025-07-14T00:00:00 |
CR-0064 | leetcode | Palindromic Integer | Is the integer 12321 the same when its digits are read in reverse? | True | def solve(n):
s = str(n)
return s == s[::-1] | [
"assert solve(12321) == True",
"assert solve(1234) == False",
"assert solve(7) == True",
"assert solve(1000021) == False",
"assert solve(123321) == True"
] | 2025-08-16T00:00:00 |
CR-0065 | leetcode | Days Between Dates | How many days lie between 2024-02-27 and 2024-03-05 (both ISO dates, counting the difference in calendar days)? | 7 | from datetime import date
def solve(pair):
y1, m1, d1 = (int(x) for x in pair[0].split('-'))
y2, m2, d2 = (int(x) for x in pair[1].split('-'))
return (date(y2, m2, d2) - date(y1, m1, d1)).days | [
"assert solve(('2024-02-27', '2024-03-05')) == 7",
"assert solve(('2023-01-01', '2024-01-01')) == 365"
] | 2025-08-02T00:00:00 |
CR-0066 | kattis | Modular Exponentiation | What is 3 raised to the power 200, reduced modulo 13? | 9 | def solve(triple):
b, e, m = triple
return pow(b, e, m) | [
"assert solve((3, 200, 13)) == 9",
"assert solve((2, 10, 1000)) == 24",
"assert solve((7, 0, 5)) == 1",
"assert solve((5, 117, 19)) == 1"
] | 2025-07-21T00:00:00 |
CR-0067 | codeforces | Prime Count | How many primes are strictly below 100? | 25 | def solve(n):
if n < 3:
return 0
sieve = [True] * n
sieve[0] = sieve[1] = False
for i in range(2, int(n ** 0.5) + 1):
if sieve[i]:
for j in range(i * i, n, i):
sieve[j] = False
return sum(sieve) | [
"assert solve(100) == 25",
"assert solve(30) == 10",
"assert solve(2) == 0",
"assert solve(1000) == 168",
"assert solve(10) == 4",
"assert solve(500) == 95"
] | 2025-06-25T00:00:00 |
CR-0068 | atcoder | Zero One Knapsack | With capacity 5 and items given as (weight, value) pairs [(2, 3), (3, 4), (4, 5), (5, 6)], what is the maximum total value of a subset whose weights fit the capacity? Each item may be taken at most once. | 7 | def solve(pair):
items, cap = pair
dp = [0] * (cap + 1)
for w, v in items:
for c in range(cap, w - 1, -1):
dp[c] = max(dp[c], dp[c - w] + v)
return dp[cap] | [
"assert solve(([(2, 3), (3, 4), (4, 5), (5, 6)], 5)) == 7",
"assert solve(([(1, 1), (2, 2), (3, 3)], 3)) == 3",
"assert solve(([(5, 10)], 4)) == 0",
"assert solve(([(1, 5), (1, 6), (1, 7)], 2)) == 13"
] | 2025-09-13T00:00:00 |
CR-0069 | codeforces | Longest Character Run | What is the length of the longest run of one repeated character in 'aaabccccdd'? | 4 | def solve(s):
best = cur = 0
prev = None
for ch in s:
if ch == prev:
cur += 1
else:
prev, cur = ch, 1
best = max(best, cur)
return best | [
"assert solve('aaabccccdd') == 4",
"assert solve('abc') == 1"
] | 2025-06-20T00:00:00 |
CR-0070 | codeforces | Most Frequent Value | Which value occurs most often in [4, 1, 4, 2, 4, 1]? If several values tie for the highest count, give the smallest of them. | 4 | from collections import Counter
def solve(arr):
counts = Counter(arr)
best = max(counts.values())
return min(x for x, c in counts.items() if c == best) | [
"assert solve([4, 1, 4, 2, 4, 1]) == 4",
"assert solve([1, 2, 3]) == 1",
"assert solve([5, 5, 3, 3]) == 3"
] | 2025-05-09T00:00:00 |
CR-0071 | leetcode | Maximum Subarray | What is the largest sum of any non-empty contiguous subarray of [-2, 1, -3, 4, -1, 2, 1, -5, 4]? | 6 | def solve(arr):
best = cur = arr[0]
for x in arr[1:]:
cur = max(x, cur + x)
best = max(best, cur)
return best | [
"assert solve([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6",
"assert solve([1]) == 1"
] | 2025-07-18T00:00:00 |
CR-0072 | atcoder | Armstrong Number | is 153 an armstrong number, meaning it equals the sum of its own digits each raised to the power of the digit count? | True | def solve(n):
s = str(n)
p = len(s)
return sum(int(ch) ** p for ch in s) == n | [
"assert solve(153) == True",
"assert solve(9474) == True",
"assert solve(100) == False"
] | 2025-10-08T00:00:00 |
Verl code curriculum - candidate pool
Raw candidate pool backing this run's code-reasoning curriculum.
raw_pool.jsonl holds one JSON object per line with the fields record_id,
source, title, statement, answer, reference_solution, unit_tests
and collected_at. Statements are collected from public competitive-programming
archives and each row carries a reference solution plus assertion strings.
Rows whose source is internal are not cleared for redistribution and are kept
in the file only so the curation audit can account for them.
Licence: cc-by-4.0
- Downloads last month
- 35