Dataset Viewer
Auto-converted to Parquet Duplicate
question
stringlengths
1.05k
4.11k
response1
stringlengths
736
6.57k
response2
stringlengths
685
6.06k
gt
int64
0
3
answer
listlengths
2
2
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a n...
\n```python\nimport sys\nfrom itertools import combinations\n\ndef can_split(available, target):\n if target == 0:\n return len(available) == 0\n available_sorted = sorted(available, reverse=True)\n for k in range(2, len(available_sorted) + 1):\n for comb in combinations(available_sorted, k):\n ...
\n```python\nimport sys\nfrom itertools import combinations\n\ndef can_split(available, target):\n if target == 0:\n return len(available) == 0\n available_sorted = sorted(available, reverse=True)\n for k in range(2, len(available_sorted) + 1):\n for comb in combinations(available_sorted, k):\n ...
0
[ 0, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFrog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ meters depth. Now Gorf is on the bottom of the well and has...
\nTo solve this problem, we need to determine the minimum number of jumps Gorf needs to escape from a well of depth `n` meters. Gorf can jump up from any depth `x` meters below ground level by any distance from 0 to `a_x` meters, and then he slips down by `b_x` meters. The goal is to find the shortest path for Gorf to ...
\nTo solve this problem, we need to determine the minimum number of jumps Gorf needs to escape from a well of depth `n` meters. Gorf can jump up from any depth `x` meters below ground level by any distance from 0 to `a_x` meters, and then he slips down by `b_x` meters. The goal is to find the shortest path for Gorf to ...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet x be an array of integers x = [x_1, x_2, ..., x_n]. Let\'s define B(x) as a minimal size of a partition of x into subsegments such that all elements in each subse...
\n```python\nimport sys\n\nMOD = 10**9 + 7\n\ndef main():\n input = sys.stdin.read().split()\n ptr = 0\n n = int(input[ptr])\n ptr += 1\n l = list(map(int, input[ptr:ptr+n]))\n ptr += n\n r = list(map(int, input[ptr:ptr+n]))\n ptr += n\n\n if n == 1:\n print(1 % MOD)\n return\n\...
\nTo solve this problem, we need to calculate the expected value of the square of the minimal number of partitions (B(x)) for an array of integers where each element can be any value within a given range. The result should be returned as a fraction modulo $10^9 + 7$.\n\n### Approach\n1. **Understanding B(x)**: The valu...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a set of points $x_1$, $x_2$, ..., $x_n$ on the number line.\n\nTwo points $i$ and $j$ can be matched with each other if the following conditions hold: ...
\nTo solve this problem, we aim to find the **maximum number of pairs** of points from a given list such that the absolute difference between the points in each pair is **at least `z`**. This is a classic **greedy algorithm** problem, and the optimal approach requires us to carefully and efficiently find valid pairs in...
\nTo solve the problem of finding the maximum number of pairs of points that can be matched such that the absolute difference between each pair is at least $ z $, we follow a structured and efficient approach using sorting and binary search.\n\n---\n\n### ✅ Key Steps:\n\n1. **Sorting**: \n - Sorting the array of poin...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is pos...
\n```python\nimport sys\nfrom collections import Counter\n\ndef main():\n n, m = map(int, sys.stdin.readline().split())\n y_left = list(map(int, sys.stdin.readline().split()))\n y_right = list(map(int, sys.stdin.readline().split()))\n \n right_freq = Counter(y_right)\n left_freq = Counter(y_left)\n ...
\n```python\nimport sys\n\ndef main():\n n, m = map(int, sys.stdin.readline().split())\n y_left = list(map(int, sys.stdin.readline().split()))\n y_right = list(map(int, sys.stdin.readline().split()))\n \n unique_left = set(y_left)\n unique_right = set(y_right)\n \n candidates = set()\n for y1...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou have a multiset containing several integers. Initially, it contains $a_1$ elements equal to $1$, $a_2$ elements equal to $2$, ..., $a_n$ elements equal to $n$.\n\...
\nTo solve the problem of determining the minimum number of operations required to delete all elements from a multiset, we follow a structured approach that efficiently groups and processes the counts of integers.\n\n---\n\n### 🧠 **Problem Understanding**\nWe are given a multiset with counts of integers from 1 to n. W...
\nTo solve this problem, we need to determine the minimum number of operations required to delete all elements from a multiset of integers. The operations allowed are either removing one occurrence of each number in a range (type 1) or removing multiple occurrences of a single number (type 2). The goal is to minimize t...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$).\n\nYou have to distribute salaries to your employe...
\n```python\nimport sys\n\ndef solve():\n input = sys.stdin.read().split()\n ptr = 0\n t = int(input[ptr])\n ptr += 1\n for _ in range(t):\n n, s = int(input[ptr]), int(input[ptr+1])\n ptr += 2\n employees = []\n sum_l = 0\n min_l = float(\'inf\')\n max_r = 0\n ...
\nTo solve the problem of maximizing the median salary that can be distributed to employees under given constraints, we use **binary search** to efficiently find the optimal solution. The key idea is to determine the highest possible median that can be achieved while staying within the budget and adhering to each emplo...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!\n\nIt was a battle between one hero operated by a rabbit and n ...
\n```python\nimport heapq\n\ndef main():\n import sys\n input = sys.stdin.read().split()\n ptr = 0\n n = int(input[ptr])\n ptr += 1\n hero_h = int(input[ptr])\n hero_a = int(input[ptr + 1])\n hero_d = int(input[ptr + 2])\n hero_s = int(input[ptr + 3])\n ptr += 4\n enemies = []\n for ...
\n```python\nimport heapq\n\ndef main():\n import sys\n input = sys.stdin.read().split()\n ptr = 0\n n = int(input[ptr])\n ptr += 1\n\n hero_h = int(input[ptr])\n hero_a = int(input[ptr+1])\n hero_d = int(input[ptr+2])\n hero_s = int(input[ptr+3])\n ptr +=4\n\n enemies = []\n for _ i...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nSuppose you had an array $A$ of $n$ elements, each of which is $0$ or $1$.\n\nLet us define a function $f(k,A)$ which returns another array $B$, the result of sorting...
\nTo solve this problem, we are given an array `C` which is derived from a binary array `A` by sorting the first `k` elements of `A` for each `k` from `1` to `n`, and then summing the resulting arrays. The goal is to reconstruct the original binary array `A` from the given array `C`.\n\n---\n\n### 🔍 Understanding the ...
\nTo solve the problem, we need to determine a binary array `A` given another array `C`, which is constructed from the element-wise sums of sorted subarrays of `A`. The challenge is to reverse-engineer `A` from `C` efficiently.\n\n---\n\n### 🔍 Key Insight\n\nEach element `C[j]` is the sum of the j-th elements of all s...
3
[ 1, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRecently personal training sessions have finished in the Berland State University Olympiad Programmer Training Centre. By the results of these training sessions teams...
\nTo solve this problem, we need to determine the lexicographically smallest priority list for a specific student `k` based on the given team formation process. The priority list of a student is a permutation of all other students, and it must be such that the student\'s teammates are chosen based on their priority lis...
\n```python\nimport sys\n\ndef main():\n import sys\n input = sys.stdin.read().split()\n ptr = 0\n n = int(input[ptr])\n ptr += 1\n results = list(map(int, input[ptr:ptr + 3 * n]))\n ptr += 3 * n\n teams = []\n for _ in range(n):\n team = list(map(int, input[ptr:ptr + 3]))\n tea...
0
[ 0, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIvan wants to have a good dinner. A good dinner should consist of a first course, a second course, a drink, and a dessert.\n\nThere are $n_1$ different types of first...
\nTo solve this problem, we need to determine the minimum cost of a dinner consisting of a first course, a second course, a drink, and a dessert, ensuring that all consecutive courses are compatible with each other. The solution involves efficiently checking compatibility and minimizing the total cost using precomputed...
\n```python\nimport sys\n\ndef main():\n input = sys.stdin.readline\n\n n1, n2, n3, n4 = map(int, input().split())\n\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n d = list(map(int, input().split()))\n\n forbidden_first = [set() f...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nToday, as a friendship gift, Bakry gave Badawy $n$ integers $a_1, a_2, \\dots, a_n$ and challenged him to choose an integer $X$ such that the value $\\underset{1 \\le...
\n```python\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n a = list(map(int, sys.stdin.readline().split()))\n \n if n == 0:\n print(0)\n return\n \n def is_possible(K):\n if K < 0:\n return False\n if n == 1:\n return True\n first ...
\nTo solve the problem of finding the **minimum possible value of the maximum XOR** between any number in an array and a chosen integer $ X $, we use a **binary search approach** combined with a **feasibility check**. This method efficiently narrows down the range of possible values for the maximum XOR and checks wheth...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water\'s temperature is t1, and the hot water...
\n```python\n# YOUR CODE HERE\nimport sys\n\ndef main():\n t1, t2, x1, x2, t0 = map(int, sys.stdin.read().split())\n \n best_diff = float(\'inf\')\n best_flow = 0\n best_y1 = 0\n best_y2 = 0\n \n for y1 in range(0, x1 + 1):\n if y1 == 0:\n # Handle y1 = 0 case\n curr...
\n```python\nimport sys\n\ndef main():\n t1, t2, x1, x2, t0 = map(int, sys.stdin.read().split())\n \n # Handle special cases where temperature is exactly t0\n if t0 == t1 and t0 == t2:\n print(x1, x2)\n return\n elif t0 == t1:\n print(x1, 0)\n return\n elif t0 == t2:\n ...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIn this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.\n\nYou are given an arithmetic expression consis...
\nTo solve the problem of generating a Brainfuck program that evaluates a given arithmetic expression and prints the result, we need to translate arithmetic operations into Brainfuck instructions. The core idea is to use the Brainfuck commands `+`, `-`, and `.` to compute the result of the expression and then print the...
\nTo solve the problem of generating a Brainfuck program that evaluates a given arithmetic expression and outputs the result, we follow a direct and efficient approach. The key insight is to recognize that each arithmetic operation in the input can be translated directly into Brainfuck commands using `+` and `-` to inc...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nADZEN is a popular advertising firm in your city that owns all $n$ billboard locations on Main street. The city council passed a new zoning ordinance mandating that n...
\nTo solve this problem, we need to maximize the revenue from billboards while ensuring that no more than `k` consecutive billboards are active at any given time. The solution uses dynamic programming combined with a sliding window maximum to efficiently track the maximum revenue achievable under these constraints.\n\n...
\nTo solve this problem, we must determine the **maximum revenue** ADZEN can generate while ensuring that **no more than `k` consecutive billboards** are active at any time. This is a classic **dynamic programming** problem where we carefully track the maximum revenue achievable by either **including** or **excluding**...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.\n\nGiven a number X,...
\n```python\nimport sys\nfrom functools import lru_cache\n\nMOD = 10**9 + 7\n\ndef main():\n X = sys.stdin.readline().strip()\n digits = [int(c) for c in X]\n n = len(digits)\n \n @lru_cache(maxsize=None)\n def dp(pos, tight, last_digit, leading_zero, count):\n if pos == n:\n if lead...
\n```python\nimport sys\nfrom functools import lru_cache\n\nMOD = 10**9 + 7\n\ndef main():\n X = sys.stdin.readline().strip()\n digits = [int(c) for c in X]\n n = len(digits)\n \n @lru_cache(maxsize=None)\n def dp(pos, tight, last_digit, leading_zero):\n if pos == n:\n return (0, 0) ...
0
[ 0, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarp is wondering about buying a new computer, which costs $c$ tugriks. To do this, he wants to get a job as a programmer in a big company.\n\nThere are $n$ posit...
\nTo solve the problem of determining the minimum number of days Polycarp needs to accumulate enough tugriks to buy a new computer, we simulate the process of working at each position and upgrading when beneficial. The key is to always choose the option (working at the current position or upgrading to the next) that le...
\nTo solve the problem, we need to determine the minimum number of days Polycarp needs to accumulate enough tugriks to buy a new computer. The strategy involves balancing between working at the current position and upgrading to a higher position if it leads to faster accumulation of the required amount.\n\n### Approach...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAfter years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is c...
\nTo solve the problem of finding the **minimum number of commands** needed to transform an initial all-white display into a specified black-and-white grid, we need to understand how each command affects the display.\n\n---\n\n### 🧠 **Problem Understanding**\n\nEach command `(x, y)` toggles the color of all pixels tha...
\nTo solve this problem, we need to determine the minimum number of commands required to transform an initially white display into a specified target configuration. Each command toggles a cross-shaped region on the display, affecting all cells in a row and column within a certain range.\n\n### Approach\n1. **Understand...
0
[ 0, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nSlime and his $n$ friends are at a party. Slime has designed a game for his friends to play.\n\nAt the beginning of the game, the $i$-th player has $a_i$ biscuits. At...
\nTo solve this problem, we need to determine the expected time for a game where players exchange biscuits until one player has all the biscuits. The solution involves calculating this expected time using modular arithmetic to handle large numbers efficiently.\n\n### Approach\n1. **Problem Analysis**: The game involves...
\nTo solve the problem of calculating the expected time for the game to end, we need to understand the dynamics of how biscuits are redistributed among players and use a mathematical approach to derive the expected time. \n\n---\n\n### 📌 Key Observations and Mathematical Insight\n\n- **Game Dynamics**: In each second,...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows...
\nTo solve this problem, we need to determine the maximum number of white lines (rows or columns without any black cells) that can be achieved after using an eraser tool exactly once on an n x n grid. The eraser tool turns a k x k square into white cells, and we need to find the optimal position to apply this tool to m...
\n```python\n# YOUR CODE HERE\nimport sys\n\ndef main():\n n, k = map(int, sys.stdin.readline().split())\n grid = [sys.stdin.readline().strip() for _ in range(n)]\n \n # Preprocess rows\n left_row = [n + 1] * (n + 1)\n right_row = [0] * (n + 1)\n row_white = [False] * (n + 1)\n \n for r in ra...
1
[ 1, 0 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRead problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.\n\nChefX showed ChefY his new pizza slice design. The design i...
\nTo solve this problem, we need to determine the angle between three points in a geometric figure formed by two rays from a common point, with specific constraints on the positions and distances of points along these rays. The solution involves understanding the geometric configuration and leveraging mathematical prop...
\nTo solve this problem, we need to determine the angle between three points in a geometric configuration defined by two rays from a common point. The points are placed such that all segments between them have equal lengths, and the angle between the rays is a fixed value. The solution involves understanding the geomet...
2
[ 0, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRead problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.\n\nChef and Chefu are working as gold miners. There are a tota...
\nTo solve this problem, we need to determine the optimal amount of gold that Chef and Chefu can mine from various gold mines, given that they can work on the same mine simultaneously but each can only work on one mine at a time. The goal is to calculate how much gold each miner will collect if they act optimally.\n\n#...
\n```python\nimport sys\n\ndef main():\n input = sys.stdin.read().split()\n ptr = 0\n T = int(input[ptr])\n ptr += 1\n for _ in range(T):\n N = int(input[ptr])\n ptr += 1\n chef_total = 0.0\n chefu_total = 0.0\n for _ in range(N):\n G = int(input[ptr])\n ...
3
[ 1, 1 ]
\nYou will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nSaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the...
\nTo solve this problem, we need to determine the minimum number of groups into which each contiguous subarray of a given array can be divided such that the product of any pair of integers in the same group is a perfect square. We then count how many subarrays have this minimum group count for each value from 1 to n.\n...
\n```python\n# YOUR CODE HERE\ndef main():\n import sys\n input = sys.stdin.read().split()\n n = int(input[0])\n a = list(map(int, input[1:n+1]))\n \n sf_list = [0] * n\n \n for i in range(n):\n x = a[i]\n if x == 0:\n sf_list[i] = 0\n continue\n sign =...
3
[ 1, 1 ]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
7