Dataset Viewer (First 5GB)
Auto-converted to Parquet Duplicate
id
stringlengths
3
8
aliases
stringlengths
0
152
contest_id
stringlengths
1
4
contest_name
stringlengths
10
125
contest_type
stringclasses
3 values
contest_start
stringlengths
10
10
contest_start_year
stringdate
2010-01-01 00:00:00
2024-01-01 00:00:00
index
stringclasses
56 values
time_limit
stringclasses
29 values
memory_limit
stringclasses
17 values
title
stringlengths
2
64
description
stringlengths
0
7.25k
input_format
stringlengths
0
2.72k
output_format
stringlengths
0
2.22k
interaction_format
stringclasses
179 values
note
stringlengths
0
5.36k
examples
stringlengths
0
1.22k
editorial
stringlengths
0
22.2k
rating
stringclasses
29 values
tags
stringlengths
0
139
testset_size
stringclasses
255 values
official_tests
stringlengths
0
393M
official_tests_complete
stringclasses
2 values
input_mode
stringclasses
2 values
generated_checker
stringlengths
0
9.75k
executable
stringclasses
2 values
solution_o3
stringlengths
0
20.2k
explanation
stringlengths
0
4.51k
solution_o3_length
int64
0
5.67k
852/A
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
A
1.0
256.0
Digits
John gave Jack a very hard problem. He wrote a very big positive integer A0 on a piece of paper. The number is less than 10200000 . In each step, Jack is allowed to put ' + ' signs in between some of the digits (maybe none) of the current number and calculate the sum of the expression. He can perform the same procedure...
First line contains a positive integer N (1 ≤ N ≤ 200000), representing the number of digits of A0. Second line contains a string of length N representing positive integer number A0. Each character is digit. There will be no leading zeros.
Output exactly three lines, the steps Jack needs to perform to solve the problem. You can output any sequence of steps which results in a single digit number (and is logically consistent). Every step consists of digits and ' + ' signs. Steps should not contain several ' + ' signs in a row, whitespaces, or ' + ' signs ...
In the first sample, Jack can't put ' + ' signs anywhere, so he just writes 1 in each line and solves the problem. Here, solution is unique. In the second sample, Jack first puts ' + ' between every two consecutive digits, thus getting the result 5 + 8 + 0 + 6 = 19. He does the same on the second step, getting 1 + 9 =...
{'input': '1\n1', 'output': '1\n1\n1'}, {'input': '4\n5806', 'output': '5+8+0+6\n1+9\n1+0'}
2500
brute force, implementation, math
46
{'input': '1\r\n1\r\n', 'output': '1\r\n1\r\n1\r\n'}, {'input': '4\r\n5806\r\n', 'output': '5+8+0+6\r\n1+9\r\n1+0\r\n'}, {'input': '3\r\n199\r\n', 'output': '1+9+9\r\n1+9\r\n1+0\r\n'}, {'input': '3\r\n289\r\n', 'output': '2+8+9\r\n1+9\r\n1+0\r\n'}, {'input': '23\r\n99999999999991999999999\r\n', 'output': '9+9+9+9+9+9+9...
False
stdio
import sys def main(input_path, output_path, submission_path): with open(input_path, 'r') as f: n = int(f.readline().strip()) a0 = f.readline().strip() with open(submission_path, 'r') as f: steps = [line.strip() for line in f.readlines()] if len(steps) != 3: print(0) ...
True
#!/usr/bin/env python3 import sys def step(expr_str): # If the current number has more than one digit, # we insert '+' between every digit. # If it is a single digit, we just use it as is. if len(expr_str) > 1: expr = '+'.join(expr_str) else: expr = expr_str # Evaluate the expre...
The code reads the initial number A0 (as a string) and defines a helper function "step" that performs one allowed move: if the number has multiple digits, it joins all the digits with a '+' (which is valid since each summand is a single digit and thus has no leading zeros); otherwise it simply returns the number itself...
511
852/B
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
B
2.0
256.0
Neural Network country
Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with many layers, each layer possibly having many cities. They also have one entry, and one exit point. There are exactly L layers, each having N cities. Let us look at...
The first line of input contains N (1 ≤ N ≤ 106), L (2 ≤ L ≤ 105) and M (2 ≤ M ≤ 100), the number of cities in each layer, the number of layers and the number that travelling cost should be divisible by, respectively. Second, third and fourth line contain N integers each denoting costs 0 ≤ cost ≤ M from entry point to...
Output a single integer, the number of paths Doctor G. can take which have total cost divisible by M, modulo 109 + 7.
This is a country with 3 layers, each layer having 2 cities. Paths $$6 \rightarrow 2 \rightarrow 2 \rightarrow 3$$, and $$6 \rightarrow 2 \rightarrow 1 \rightarrow 4$$ are the only paths having total cost divisible by 13. Notice that input edges for layer cities have the same cost, and that they are same for all layers...
{'input': '2 3 13\n4 6\n2 1\n3 4', 'output': '2'}
2000
dp, matrices
20
{'input': '2 3 13\r\n4 6\r\n2 1\r\n3 4\r\n', 'output': '2'}, {'input': '2 4 5\r\n1 1\r\n1 1\r\n1 1\r\n', 'output': '16'}, {'input': '1 1234 5\r\n1\r\n1\r\n1\r\n', 'output': '1'}, {'input': '3 2 2\r\n0 1 0\r\n0 0 1\r\n1 1 0\r\n', 'output': '3'}, {'input': '5 4 3\r\n2 1 0 1 2\r\n0 1 2 1 0\r\n1 2 1 0 2\r\n', 'output': '20...
False
stdio
True
#!/usr/bin/env python3 import sys mod = 10**9 + 7 def main(): data = sys.stdin.read().split() if not data: return it = iter(data) N = int(next(it)) L = int(next(it)) M = int(next(it)) # Frequency arrays for remainder counts modulo M. F_A = [0] * M # For costs from entry t...
# The problem asks for the number of paths through L layers (each with N cities) such that the total traveling # cost is divisible by a given number M. The journey is divided as follows: # # 1. From the entry point to the first layer, the cost is determined by the A array. # 2. Traveling from one layer to the next (for...
1,294
852/C
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
C
0.5
256.0
Property
Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on time, court decided to punish Bill by making him lose a part of his property. Bill’s property can be observed as a convex...
The first line contains one integer number n (2 ≤ n ≤ 50000), representing number of edges of 2n-sided polygon. The second line contains n distinct integer numbers B2k (0 ≤ B2k ≤ n - 1, k = 0... n - 1) separated by a single space, representing points the court chose. If B2k = i, the court chose point Pi on side A2k A...
Output contains n distinct integers separated by a single space representing points B1, B3, ..., B2n - 1 Bill should choose in order to maximize the property area. If there are multiple solutions that maximize the area, return any of them.
To maximize area Bill should choose points: B1 = P0, B3 = P2, B5 = P1
{'input': '3\n0 1 2', 'output': '0 2 1'}
2100
greedy, sortings
29
{'input': '3\r\n0 1 2\r\n', 'output': '0 2 1\r\n'}, {'input': '10\r\n0 1 2 3 4 5 6 7 8 9\r\n', 'output': '0 1 2 3 5 6 7 8 9 4\r\n'}, {'input': '10\r\n1 7 3 6 8 2 4 5 0 9\r\n', 'output': '2 6 5 9 7 1 4 0 3 8\r\n'}, {'input': '10\r\n4 9 7 2 3 5 6 1 8 0\r\n', 'output': '8 9 6 1 4 7 2 5 3 0\r\n'}, {'input': '5\r\n1 2 3 0 4...
False
stdio
import sys def main(): input_path = sys.argv[1] submission_path = sys.argv[3] with open(input_path, 'r') as f: n = int(f.readline().strip()) court = list(map(int, f.readline().split())) with open(submission_path, 'r') as f: submission = list(map(int, f.readline().split...
True
#!/usr/bin/env python3 def main(): import sys data = sys.stdin.read().split() if not data: return n = int(data[0]) # even[k] is the court‐chosen index for edge A_{2k}A_{2k+1} (k=0..n-1) even = list(map(int, data[1:1+n])) # For each odd edge A_{2k+1}A_{2k+2} (k=0..n-1), Bill can ...
The code first reads the integer n and the list of the n distinct court–chosen values for even–indexed edges. Each even vertex B_{2k} lies on edge A_{2k}A_{2k+1} and its “position” on the circle is determined by its fixed vertex A_{2k} plus an offset proportional to the chosen number divided by n. For each odd–indexed ...
1,444
852/D
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
D
2.0
256.0
Exploration plan
The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities. After exploring the map of Serbia for a while, the competitors came up with the following facts: the country has V cities which are indexed with numbers from 1 to V, and the...
The first line contains four integers: V, E, N and K (1 ≤ V ≤ 600, 1 ≤ E ≤ 20000, 1 ≤ N ≤ min(V, 200), 1 ≤ K ≤ N), number of cities, number of roads, number of teams and the smallest number of different cities they need to end up in, respectively. The second line contains N integers, the cities where...
Output a single integer that represents the minimal time the teams can move for, such that they end up in at least K different cities or output -1 if there is no solution. If the solution exists, result will be no greater than 1731311.
Three teams start from city 5, and two teams start from city 2. If they agree to move for 3 minutes, one possible situation would be the following: Two teams in city 2, one team in city 5, one team in city 3 , and one team in city 1. And we see that there are four different cities the teams end their journey at.
{'input': '6 7 5 4\n5 5 2 2 5\n1 3 3\n1 5 2\n1 6 5\n2 5 4\n2 6 7\n3 4 11\n3 5 3', 'output': '3'}
2100
binary search, flows, graph matchings, shortest paths
44
{'input': '6 7 5 4\r\n5 5 2 2 5\r\n1 3 3\r\n1 5 2\r\n1 6 5\r\n2 5 4\r\n2 6 7\r\n3 4 11\r\n3 5 3\r\n', 'output': '3'}, {'input': '5 6 4 1\r\n4 4 4 4\r\n5 4 40\r\n3 2 989\r\n1 2 29\r\n4 3 18\r\n2 5 697\r\n4 3 51\r\n', 'output': '0'}, {'input': '15 6 9 8\r\n3 4 2 7 7 4 3 3 2\r\n13 2 9569\r\n15 1 8936\r\n12 5 3842\r\n13 4 ...
False
stdio
True
import sys import heapq def solve(): data = sys.stdin.read().split() if not data: return it = iter(data) V = int(next(it)) E = int(next(it)) N = int(next(it)) K = int(next(it)) # Convert team starting cities (1-indexed) to 0-indexed. team_starts = [int(next(it)) - 1 for...
# The problem requires us to determine the minimal time T such that each team starting from its given city # can travel up to time T and the teams can be assigned to at least K distinct cities. # # Step 1: We compute the shortest distances from each team's starting city to all other cities using Dijkstra's # algorithm....
1,024
852/E
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
E
1.0
256.0
Casinos and travel
John has just bought a new car and is planning a journey around the country. Country has N cities, some of which are connected by bidirectional roads. There are N - 1 roads and every city is reachable from any other city. Cities are labeled from 1 to N. John first has to select from which city he will start his journe...
In the first line, a positive integer N (1 ≤ N ≤ 100000), the number of cities. In the next N - 1 lines, two numbers a, b (1 ≤ a, b ≤ N) separated by a single space meaning that cities a and b are connected by a bidirectional road.
Output one number, the answer to the problem modulo 109 + 7.
Example 1: If Jack selects city 1 as John's starting city, he can either build 0 casinos, so John will be happy all the time, or build a casino in both cities, so John would visit a casino in city 1, become unhappy, then go to city 2, visit a casino there and become happy and his journey ends there because he can't go ...
{'input': '2\n1 2', 'output': '4'}, {'input': '3\n1 2\n2 3', 'output': '10'}
2100
dp
12
{'input': '2\r\n1 2\r\n', 'output': '4\r\n'}, {'input': '3\r\n1 2\r\n2 3\r\n', 'output': '10\r\n'}, {'input': '4\r\n1 2\r\n2 3\r\n3 4\r\n', 'output': '24\r\n'}
False
stdio
True
#!/usr/bin/env python3 import sys def main(): data = sys.stdin.read().split() if not data: return n = int(data[0]) mod = 1000000007 if n == 1: # Only one city. John’s journey is just that city. # The only valid assignment is to have no casino (because his mood must remain go...
# The problem asks for counting the number of pairs (starting city, casino placement) # for which no matter how John travels his journey through the tree, he ends in a good mood. # # We observe that when John starts from a city u, his journey always is a simple path (without revisiting vertices) # from u to one of the ...
1,467
852/F
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
F
3.0
256.0
Product transformation
"Consider an array A with N elements, all being the same integer a.\n\nDefine the product transforma(...TRUNCATED)
"The first and only line of input contains four integers N, M, a, Q (7 ≤ Q ≤ 109 + 123, 2 ≤ a (...TRUNCATED)
You should output the array A from left to right.
"The multiplicative order of a number a modulo Q $$\\phi(a,Q)$$, is the smallest natural number x su(...TRUNCATED)
{'input': '2 2 2 7', 'output': '1 2'}
2200
combinatorics, math, number theory
18
"{'input': '2 2 2 7\\r\\n', 'output': '1 2 '}, {'input': '1 1 19 1877058\\r\\n', 'output': '19 '}, {(...TRUNCATED)
True
stdio
True
"#!/usr/bin/env python3\ndef main():\n import sys\n data = sys.stdin.read().split()\n if no(...TRUNCATED)
"# 1. We first notice that if we write each array element as A[i] = a^(E[i]),\n# then the update (...TRUNCATED)
1,510
852/G
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
G
2.0
256.0
Bathroom terminal
"Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is(...TRUNCATED)
"The first line of input contains two integers N and M (1 ≤ N ≤ 100 000, 1 ≤ M ≤ 5000), re(...TRUNCATED)
"Output contains M lines and each line consists of one integer, representing the number of words tha(...TRUNCATED)
"If we switch '?' with 'b', 'e' and with empty character, we get 'abc', 'aec' and 'ac' respectively.(...TRUNCATED)
{'input': '3 1\nabc\naec\nac\na?c', 'output': '3'}
1700
implementation
15
"{'input': '3 1\\r\\nabc\\r\\naec\\r\\nac\\r\\na?c\\r\\n', 'output': '3\\r\\n'}, {'input': '22 2\\r\(...TRUNCATED)
False
stdio
True
"import sys\nfrom collections import defaultdict\nimport sys\nsys.setrecursionlimit(10000)\n\n# Buil(...TRUNCATED)
"The solution first builds a separate trie for each group of words by their length. Each word (which(...TRUNCATED)
1,450
852/H
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
H
2.0
256.0
Bob and stages
"The citizens of BubbleLand are celebrating their 10th anniversary so they decided to organize a big(...TRUNCATED)
"The first line of input contains two integers N (3 ≤ N ≤ 200) and K (3 ≤ K ≤ min(N, 50)), s(...TRUNCATED)
"Output contains only one line with one number, rounded to exactly two decimal places: the maximal f(...TRUNCATED)
"Example explanation: From all possible convex polygon with 4 vertices and no other vertex inside, t(...TRUNCATED)
{'input': '5 4\n0 0\n3 0\n2 1\n4 4\n1 5', 'output': '10.00'}
3000
dp, geometry
32
"{'input': '5 4\\r\\n0 0\\r\\n3 0\\r\\n2 1\\r\\n4 4\\r\\n1 5\\r\\n', 'output': '10.00\\r\\n'}, {'inp(...TRUNCATED)
False
stdio
True
"#!/usr/bin/env python3\nimport sys, math\nfrom decimal import Decimal, ROUND_HALF_UP\n\n# Precomput(...TRUNCATED)
"# \n# 1. Precomputation of “left” matrix:\n# For every ordered pair (i, j) of stage indices (...TRUNCATED)
1,799
852/I
852
Bubble Cup X - Finals [Online Mirror]
ICPC
1504432800
2017
I
2.0
64.0
Dating
"This story is happening in a town named BubbleLand. There are n houses in BubbleLand. In each of th(...TRUNCATED)
"The first line contains an integer n (1 ≤ n ≤ 105), the number of houses in the town.\n\nThe se(...TRUNCATED)
For each of the q questions output a single number, the answer to the citizens question.
"In the first question from house 1 to house 3, the potential couples are (1, 3) and (6, 3).\n\nIn t(...TRUNCATED)
"{'input': '7\\n1 0 0 1 0 1 0\\n9 2 9 2 2 9 9\\n2 6\\n1 2\\n4 2\\n6 5\\n3 6\\n7 4\\n2\\n1 3\\n7 5', (...TRUNCATED)
2300
brute force, dfs and similar, graphs, trees
27
"{'input': '7\\r\\n1 0 0 1 0 1 0\\r\\n9 2 9 2 2 9 9\\r\\n2 6\\r\\n1 2\\r\\n4 2\\r\\n6 5\\r\\n3 6\\r\(...TRUNCATED)
False
stdio
True
"#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\ndef main():\n data = sys.std(...TRUNCATED)
"# The solution first reads input and compresses the favorite numbers to use them as indices.\n# It (...TRUNCATED)
1,627
1268/A
1269/C
1268
Codeforces Round 609 (Div. 1)
CF
1576926300
2019
A
3.0
256.0
Long Beautiful Integer
"You are given an integer $$$x$$$ of $$$n$$$ digits $$$a_1, a_2, \\ldots, a_n$$$, which make up its (...TRUNCATED)
"The first line of input contains two integers $$$n, k$$$ ($$$2 \\leq n \\leq 200\\,000, 1 \\leq k <(...TRUNCATED)
"In the first line print one integer $$$m$$$: the number of digits in $$$y$$$.\n\nIn the next line p(...TRUNCATED)
{'input': '3 2\n353', 'output': '3\n353'}, {'input': '4 2\n1234', 'output': '4\n1313'}
"At first, let's set $$$a_i=a_{i-k}$$$ for all $$$i>k$$$.\nIf it is at least the initial $$$a$$$, th(...TRUNCATED)
1700
constructive algorithms, greedy, implementation, strings
197
"{'input': '3 2\\r\\n353\\r\\n', 'output': '3\\r\\n353\\r\\n'}, {'input': '4 2\\r\\n1234\\r\\n', 'ou(...TRUNCATED)
False
stdio
True
"#!/usr/bin/env python3\nimport sys\n\ndef main():\n data = sys.stdin.read().strip().split()\n (...TRUNCATED)
"# The solution works as follows:\n#\n# 1. The program reads n (number of digits) and k, then the n (...TRUNCATED)
717
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
37