Dataset Viewer
Auto-converted to Parquet Duplicate
prompt
stringclasses
3 values
description
stringlengths
202
3.26k
constraints
stringclasses
46 values
input_format
stringlengths
4
2.04k
output_format
stringlengths
4
1.8k
note
stringlengths
0
5.27k
assistant
stringlengths
1.36k
70.7k
editorial
stringclasses
422 values
examples
listlengths
0
7
reasoning
stringlengths
0
66.1k
code
stringlengths
12
9.8k
language
stringclasses
2 values
num_tokens
int64
651
16.4k
id
int64
2
349k
dup_match
bool
1 class
dup_top_id
stringlengths
3
7
dup_top_score
float64
0.8
1
dup_top_pos
int64
0
2.14k
You will be given a competitive programming problem. Analyze the maximum input constraints and identify the optimal algorithmic approach and data structures needed to process the largest possible test cases within the time and memory limits, then explain why your chosen implementation strategy is the most efficient sol...
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them. Vasily decided to sort the cards. To do this, he repeatedly takes the top card from the deck, and if the number on...
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
The first line contains single integer n (1 ≤ n ≤ 100 000) — the number of cards in the deck. The second line contains a sequence of n integers a1, a2, ..., an (1 ≤ ai ≤ 100 000), where ai is the number written on the i-th from top card in the deck.
Print the total number of times Vasily takes the top card from the deck.
In the first example Vasily at first looks at the card with number 6 on it, puts it under the deck, then on the card with number 3, puts it under the deck, and then on the card with number 1. He places away the card with 1, because the number written on it is the minimum among the remaining cards. After that the cards ...
<think> Okay, let's see. The problem is about Vasily taking cards from the deck, and each time if the card is the current minimum, he removes it. Otherwise, he puts it under the deck. We need to count how many times he takes a card from the top. Hmm. The process continues until all cards are gone. The key is to find t...
[ { "input": "4\n6 3 1 2", "output": "7" }, { "input": "1\n1000", "output": "1" }, { "input": "7\n3 3 3 3 3 3 3", "output": "7" } ]
Okay, let's see. The problem is about Vasily taking cards from the deck, and each time if the card is the current minimum, he removes it. Otherwise, he puts it under the deck. We need to count how many times he takes a card from the top. Hmm. The process continues until all cards are gone. The key is to find the total...
import sys from collections import defaultdict class FenwickTree: def __init__(self, size): self.n = size self.tree = [0] * (self.n + 2) # 1-based indexing def update(self, idx, delta): while idx <= self.n: self.tree[idx] += delta idx += idx & -idx def que...
python
10,491
2
true
830/B
0.914323
135
You will be given a competitive programming problem. Analyze the maximum input constraints and identify the optimal algorithmic approach and data structures needed to process the largest possible test cases within the time and memory limits, then explain why your chosen implementation strategy is the most efficient sol...
Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule. A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number — the number of bonds the atom must form with other atoms. An atom can form one...
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
The single line of the input contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 106) — the valence numbers of the given atoms.
If such a molecule can be built, print three space-separated integers — the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If there are multiple solutions, output any of them. If there is no solution, print "Impossible" (without the quotes).
The first sample corresponds to the first figure. There are no bonds between atoms 1 and 2 in this case. The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms. The third sample corresponds to the third figure. There is no solution, because an atom cannot form bonds ...
<think> Okay, I need to solve this problem where three atoms have certain valence numbers, and I have to determine if it's possible to form a molecule by connecting them with bonds such that each atom's total bonds equal their valence. If possible, output the number of bonds between each pair. Let's think. The problem...
[ { "input": "1 1 2", "output": "0 1 1" }, { "input": "3 4 5", "output": "1 3 2" }, { "input": "4 1 1", "output": "Impossible" } ]
Okay, I need to solve this problem where three atoms have certain valence numbers, and I have to determine if it's possible to form a molecule by connecting them with bonds such that each atom's total bonds equal their valence. If possible, output the number of bonds between each pair. Let's think. The problem states ...
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int sum = a + b + c; if (sum % 2 != 0) { cout << "Impossible\n"; return 0; } int s = sum / 2; if (a + b < c || a + c < b || b + c < a) { cout << "Impossible\n"; ...
cpp
4,973
262,147
true
344/B
0.932529
1,551
You will be given a competitive programming problem. Analyze the maximum input constraints and identify the optimal algorithmic approach and data structures needed to process the largest possible test cases within the time and memory limits, then explain why your chosen implementation strategy is the most efficient sol...
Nikolay lives in a two-storied house. There are $$$n$$$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $$$1$$$ and $$$n$$$). If Nikolay is currently i...
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of two lines. The first line contains one integer $$$n$$$ $$$(1 \le n \le 1\,000)$$$ — the number of rooms on each floor. The second line contains o...
For each test case print one integer — the maximum number of rooms Nikolay can visit during his tour, if he can start in any room on any floor, and he won't visit the same room twice.
In the first test case Nikolay may start in the first room of the first floor. Then he moves to the second room on the first floor, and then — to the third room on the first floor. Then he uses a staircase to get to the third room on the second floor. Then he goes to the fourth room on the second floor, and then — to t...
<think> Okay, let's tackle this problem. So the goal is to find the maximum number of rooms Nikolay can visit without repeating any. The house has two floors, each with n rooms arranged in a row. He can move to adjacent rooms on the same floor or use a staircase to switch floors if there's one at the same room number. ...
[ { "input": "4\n5\n00100\n8\n00000000\n5\n11111\n3\n110", "output": "6\n8\n10\n6" } ]
Okay, let's tackle this problem. So the goal is to find the maximum number of rooms Nikolay can visit without repeating any. The house has two floors, each with n rooms arranged in a row. He can move to adjacent rooms on the same floor or use a staircase to switch floors if there's one at the same room number. Hmm. Le...
t = int(input()) for _ in range(t): n = int(input()) s = input().strip() if '1' not in s: print(n) else: first = s.find('1') last = s.rfind('1') l = first + 1 r = last + 1 left_gap = l - 1 right_gap = n - r min_val = min(left_gap, right_gap...
python
8,717
262,167
true
1244/B
1
1,283
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"Ivan is playing yet another roguelike computer game. He controls a single hero in the game. The her(...TRUNCATED)
Time limit per test: 3.0 seconds Memory limit per test: 256.0 megabytes
"The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 10$$$) — the number of equipm(...TRUNCATED)
"Print the build with the maximum strength that is not banned from the game. If there are multiple b(...TRUNCATED)
"<think>\nOkay, let's tackle this problem. So the goal is to find the maximum strength build that's (...TRUNCATED)
[{"input":"3\n3 1 2 3\n2 1 5\n3 2 4 6\n2\n3 2 3\n3 2 2","output":"2 2 3"},{"input":"3\n3 1 2 3\n2 1 (...TRUNCATED)
"Okay, let's tackle this problem. So the goal is to find the maximum strength build that's not banne(...TRUNCATED)
"import heapq\n\nn = int(input())\nslots = []\nfor _ in range(n):\n parts = list(map(int, input()(...TRUNCATED)
python
14,621
262,172
true
1574/D
0.970999
1,726
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one p(...TRUNCATED)
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
"The first line contains four integers a, b, c, d (250 ≤ a, b ≤ 3500, 0 ≤ c, d ≤ 180).\n\nIt(...TRUNCATED)
"Output on a single line:\n\n\"Misha\" (without the quotes), if Misha got more points than Vasya.\n\(...TRUNCATED)
"<think>\nOkay, let's see. The problem is about calculating the points Misha and Vasya got based on (...TRUNCATED)
[{"input":"500 1000 20 30","output":"Vasya"},{"input":"1000 1000 1 1","output":"Tie"},{"input":"1500(...TRUNCATED)
"Okay, let's see. The problem is about calculating the points Misha and Vasya got based on their sub(...TRUNCATED)
"#include <iostream>\n#include <algorithm>\n\nusing namespace std;\n\nint main() {\n int a, b, c,(...TRUNCATED)
cpp
3,378
262,181
true
501/A
0.927381
7
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"You are given two positive integers $$$x$$$ and $$$y$$$. You can perform the following operation wi(...TRUNCATED)
Time limit per test: 2.0 seconds Memory limit per test: 256.0 megabytes
"The only line of the input contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x, y \\le 10^{18}$$(...TRUNCATED)
Print YES if you can make $$$x$$$ equal to $$$y$$$ and NO if you can't.
"In the first example, you don't even need to do anything.\n\nThe fourth example is described in the(...TRUNCATED)
"<think>\nOkay, I need to solve this problem where I have to determine if x can be transformed into (...TRUNCATED)
[{"input":"3 3","output":"YES"},{"input":"7 4","output":"NO"},{"input":"2 8","output":"NO"},{"input"(...TRUNCATED)
"Okay, I need to solve this problem where I have to determine if x can be transformed into y through(...TRUNCATED)
"#include <iostream>\n#include <queue>\n#include <unordered_set>\n#include <algorithm>\n#include <st(...TRUNCATED)
cpp
13,201
39
true
1618/F
0.945326
1,647
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"You are given $$$q$$$ queries in the following form:\n\nGiven three integers $$$l_i$$$, $$$r_i$$$ a(...TRUNCATED)
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
"The first line contains one integer $$$q$$$ ($$$1 \\le q \\le 500$$$) — the number of queries.\n\(...TRUNCATED)
For each query print one integer: the answer to this query.
"<think>\nOkay, let's see. The problem is to find the smallest positive integer x that's divisible b(...TRUNCATED)
[ { "input": "5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5", "output": "6\n4\n1\n3\n10" } ]
"Okay, let's see. The problem is to find the smallest positive integer x that's divisible by d_i and(...TRUNCATED)
"#include <iostream>\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n ci(...TRUNCATED)
cpp
4,163
57
true
1101/A
0.943486
1,315
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"You have an array $$$a$$$ consisting of $$$n$$$ positive integers and you have to handle $$$q$$$ qu(...TRUNCATED)
Time limit per test: 3.0 seconds Memory limit per test: 256.0 megabytes
"The first line of the input contains two integers $$$n$$$ and $$$q$$$ ($$$1 \\le n , q \\le 3 \\cdo(...TRUNCATED)
"For each query of the second type, if answer of the query is yes, print \"YES\", otherwise print \"(...TRUNCATED)
"In the first query, requested subarray is $$$[1234, 2, 3, 3, 2, 1]$$$, and it's obvious that the nu(...TRUNCATED)
"<think>\nOkay, let's try to figure out how to solve this problem. The problem has two types of quer(...TRUNCATED)
"To solve this problem, we need to efficiently handle two types of queries on an array of integers: (...TRUNCATED)
[{"input":"10 8\n1234 2 3 3 2 1 1 2 3 4\n2 1 6 2\n1 1 1\n2 1 6 2\n2 1 9 2\n1 10 5\n2 1 9 3\n1 3 5\n2(...TRUNCATED)
"Okay, let's try to figure out how to solve this problem. The problem has two types of queries: upda(...TRUNCATED)
"import sys\nimport bisect\nfrom random import randint\n\ndef main():\n input = sys.stdin.read().(...TRUNCATED)
python
16,146
58
true
1746/F
0.845194
493
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"Permutation $$$p$$$ is a sequence of integers $$$p=[p_1, p_2, \\dots, p_n]$$$, consisting of $$$n$$(...TRUNCATED)
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
"The first line contains integer number $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test c(...TRUNCATED)
"For each test case, print:\n\n- If it's impossible to find such a permutation $$$p$$$, print \"-1\"(...TRUNCATED)
"In the first test case of the example answer $$$[1,3,4,5,2]$$$ is the only possible answer:\n\n- $$(...TRUNCATED)
"<think>\nOkay, let's see. The problem is to find a permutation p given the array q of prefix maxima(...TRUNCATED)
[ { "input": "4\n5\n1 3 4 5 5\n4\n1 1 3 4\n2\n2 2\n1\n1", "output": "1 3 4 5 2 \n-1\n2 1 \n1" } ]
"Okay, let's see. The problem is to find a permutation p given the array q of prefix maxima. If it's(...TRUNCATED)
"#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n ios_base::sync_with_stdio(false(...TRUNCATED)
cpp
9,424
83
true
1227/B
0.94602
209
"You will be given a competitive programming problem.\nAnalyze the maximum input constraints and ide(...TRUNCATED)
"Rudolf is going to visit Bernard, and he decided to take the metro to get to him. The ticket can be(...TRUNCATED)
Time limit per test: 1.0 seconds Memory limit per test: 256.0 megabytes
"The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$) — the number of test cases. (...TRUNCATED)
"For each testcase, output a single integer — the number of ways Rudolf can select two coins, taki(...TRUNCATED)
"Note that the pairs indicate the indices of the coins in the array, not their denominations.\n\nIn (...TRUNCATED)
"<think>\nOkay, let's see. The problem is to find the number of pairs of coins, one from each pocket(...TRUNCATED)
[{"input":"4\n4 4 8\n1 5 10 14\n2 1 8 1\n2 3 4\n4 8\n1 2 3\n4 2 7\n1 1 1 1\n2 7\n3 4 2000\n1 1 1\n1 (...TRUNCATED)
"Okay, let's see. The problem is to find the number of pairs of coins, one from each pocket, whose s(...TRUNCATED)
"import bisect\n\nt = int(input())\nfor _ in range(t):\n n, m, k = map(int, input().split())\n (...TRUNCATED)
python
4,260
262,242
true
1941/A
0.939044
1,157
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
19