Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
32
32
problem
stringlengths
28
2.84k
output
stringlengths
800
95.3k
source
stringclasses
5 values
license
stringclasses
1 value
dataset
stringclasses
1 value
split
stringclasses
1 value
difficulty
stringclasses
30 values
Answer
stringlengths
8
12.3k
wrong_cot
stringlengths
109
615k
⌀
wrong_plan
stringlengths
525
65.3k
wrong_answer
stringlengths
0
84.7k
⌀
8be667fb42682957580ebc058aeceb7a
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * 0 ≤ wi ≤ 10,000 * G has arborescence(s) with the root r Input |V| |E| r s0 t0 w0 s1 t1 w1 : s|E|-1 t|E|-1 w|E|-1 , where |V| is the ...
<think> Okay, I need to find the minimum-cost arborescence for a given directed graph with a specified root. Hmm, arborescence is like a directed tree where all edges point away from the root, and there's exactly one path from the root to every other node. Right, so the problem is to compute the sum of the weights of t...
aizu
cc-by-4.0
code_contests
train
UNKNOWN_DIFFICULTY
def find_min_cost_arborescence(V, E, root): if len(V) == 1: return 0 min_in_edges = {} for node in V: if node == root: continue min_edge = None min_weight = float('inf') for e in E: if e['to'] == node and e['weight'] < min_weight: ...
I need to find the minimum-cost arborescence rooted at `r`. An arborescence is a directed tree where all edges point away from the root, and every node except the root has exactly one incoming edge. My first idea: For each node (except the root), pick the incoming edge with the smallest weight. That should give me the...
The correct approach to finding the minimum-cost arborescence (directed minimum spanning tree rooted at a given node) involves Edmonds' algorithm, which iteratively contracts cycles formed by selecting the minimum-weight incoming edge for each non-root vertex, then recursively solving on a contracted graph. The key ins...
def solve(): n, m, r = map(int, input().split()) edges = [] for _ in range(m): s, t, w = map(int, input().split()) edges.append((s, t, w)) # For each node except root, find the minimum incoming edge min_in_weight = {} min_in_edge = {} for node in range(n): i...
0cb6b310e716e5df4a6b6d4eb076a6e3
Today, as usual, Jerry comes up with a new puzzle for Tom. Jerry knows very well that Tom is well aware of the concepts of fibonacci series. So he intends to present the problem with a twist. By choosing any random integer Jerry asks Tom to tell whether the given number is a fibonacci number. Input The first line of t...
<think> Okay, let's see. The problem is to determine if a given number is a Fibonacci number. Hmm. So, how do I check that efficiently, especially considering the constraints where N can be up to 1e9? First, I remember that a number is part of the Fibonacci sequence if and only if 5*N^2 +4 or 5*N^2 -4 is a perfect squ...
codechef
cc-by-4.0
code_contests
train
UNKNOWN_DIFFICULTY
import math def is_perfect_square(x): s = math.isqrt(x) return s * s == x t = int(input()) for _ in range(t): n = int(input()) x = 5 * n * n if is_perfect_square(x + 4) or is_perfect_square(x - 4): print("is fibo") else: print("not fibo")
I need to check if a given number is a Fibonacci number. I know the Fibonacci sequence goes: 1, 1, 2, 3, 5, 8, 13, 21, ... and so on. So, one way is to generate Fibonacci numbers one by one and see if the input number appears in the sequence. But wait — the input can be as large as $ 10^9 $. How many Fibonacci numbers...
The correct solution leverages a mathematical property: a positive integer $ n $ is a Fibonacci number if and only if one of $ 5n^2 + 4 $ or $ 5n^2 - 4 $ is a perfect square. This is a well-known identity derived from Binet’s formula and properties of Fibonacci numbers. The key insight is to avoid generating Fibonacci ...
t = int(input()) for _ in range(t): n = int(input()) a, b = 1, 1 found = False while b <= n: if b == n: found = True break c = a + b a = b b = c if found: print("is fibo") else: print("not fibo")
b1c1c912ac90e98b2b001e4fd8e658ef
This is yet another problem on regular bracket sequences. A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequenc...
<think> Okay, I need to solve this problem where I have to replace the question marks in a bracket sequence with '(' or ')' such that the resulting sequence is regular, and the total cost is minimized. Let's think about how to approach this. First, a regular bracket sequence must be balanced. That means the number of ...
codeforces
cc-by-4.0
code_contests
train
VERY_HARD
import heapq def main(): import sys input = sys.stdin.read().split() ptr = 0 s = input[ptr] ptr +=1 m = s.count('?') q_list = [] for _ in range(m): a = int(input[ptr]) b = int(input[ptr+1]) ptr +=2 q_list.append((a, b)) open_count = s.count('(') ...
I need to make a valid bracket sequence from a pattern with `(`, `)`, and `?`. Each `?` can become `(` or `)` with given costs. I want the cheapest valid sequence. First, I think: I can try to simulate the sequence from left to right, keeping track of the current balance. Whenever I see a `?`, I should choose the chea...
The correct solution hinges on a greedy strategy with a priority queue: we initially assume all `?` are replaced with `)` (to minimize early balance), then whenever the running balance goes negative, we flip the most cost-effective `?` (i.e., the one with the smallest `a - b`) to `(` to restore balance. After processin...
import sys def main(): data = sys.stdin.read().split() if not data: return s = data[0] m = s.count('?') q_list = [] ptr = 1 for _ in range(m): a = int(data[ptr]) b = int(data[ptr+1]) ptr += 2 q_list.append((a, b)) # Greedy assignment: as...
e21b0e5fc03c44fb2dec67e730d79e14
"There are two cameras which observe the up line and the down line respectively on the double lane ((...TRUNCATED)
"<think>\nOkay, let's see. The problem is to find the maximum time interval where no cars passed thr(...TRUNCATED)
aizu
cc-by-4.0
code_contests
train
UNKNOWN_DIFFICULTY
"def main():\n import sys\n input = sys.stdin.read().split()\n ptr = 0\n while True:\n (...TRUNCATED)
"I need to find the maximum time interval where no car passed through the monitoring line. Since the(...TRUNCATED)
"The correct solution hinges on recognizing that the maximum time interval with **no cars passing on(...TRUNCATED)
"import sys\n\ndef main():\n input = sys.stdin.read().split()\n ptr = 0\n while True:\n (...TRUNCATED)
880ac66e82396460e68d79e9ccf4bf84
"Adilbek's house is located on a street which can be represented as the OX axis. This street is real(...TRUNCATED)
"<think>\nOkay, let's see. The problem is about Adilbek wanting to install lamps along a street to i(...TRUNCATED)
codeforces
cc-by-4.0
code_contests
train
11
"def main():\n import sys\n input = sys.stdin.read().split()\n idx = 0\n n = int(input[i(...TRUNCATED)
"Okay, so we have a street from 0 to n, and some positions are blocked. We need to cover the whole s(...TRUNCATED)
"The correct solution hinges on two key insights: \n1. **The minimum lamp power required** is deter(...TRUNCATED)
"def main():\n import sys\n input = sys.stdin.read().split()\n idx = 0\n n = int(input[i(...TRUNCATED)
2854c700caeb36aead0d056e349ee840
"Simple Factorial\nYou are asked to calculate factorials of some small positive integers.\nInput\n (...TRUNCATED)
"<think>\nOkay, I need to write a Python program that calculates the factorial of several numbers gi(...TRUNCATED)
codechef
cc-by-4.0
code_contests
train
UNKNOWN_DIFFICULTY
"t = int(input())\nfor _ in range(t):\n n = int(input())\n fact = 1\n for i in range(1, n+1(...TRUNCATED)
"I need to compute factorials for multiple test cases. Since N can be up to 100, and T up to 100, I (...TRUNCATED)
"The correct approach requires computing the factorial of each input number using a simple loop that(...TRUNCATED)
"def factorial(n, memo={0: 1, 1: 1}):\n if n in memo:\n return memo[n]\n memo[n] = n * (...TRUNCATED)
01ad6a2182b351828053ede3c800073c
"In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning (...TRUNCATED)
"<think>\nOkay, so I need to solve this programming problem. Let me read the problem statement caref(...TRUNCATED)
codeforces
cc-by-4.0
code_contests
train
VERY_HARD
"import sys\nMOD = 10**9 + 7\n\nmax_d_phi = 10**6\nmax_fact = 2 * 10**5 + 10\n\n# Precompute smalles(...TRUNCATED)
"I need to compute, after each day, the sum over all possible choices of `k` species of the maximum (...TRUNCATED)
"The correct solution hinges on a deep insight: for a fixed number of gardens `g`, the maximum numbe(...TRUNCATED)
"import sys\nMOD = 10**9 + 7\n\ndef mod_pow(base, exp, mod):\n result = 1\n base %= mod\n w(...TRUNCATED)
a72176885daf756ec29facc18b89c1f7
"The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its (...TRUNCATED)
"<think>\nOkay, let's see. I need to solve this problem where I have to determine if a given input s(...TRUNCATED)
codeforces
cc-by-4.0
code_contests
train
interview
s = input().strip() h_count = s.count('H') print("Yes" if h_count % 2 == 0 else "No")
"Okay, so I need to figure out whether a given string in the HQ... language is valid. The examples s(...TRUNCATED)
"The correct solution hinges on the observation that the language HQ... only accepts programs where (...TRUNCATED)
"s = input().strip()\nsegments = s.split('Q')\nfor segment in segments:\n h_count = 0\n for ch(...TRUNCATED)
21c0161e37c8619015e0b515ce1311f1
"Valera loves to participate in competitions. Especially in programming contests. Today he has parti(...TRUNCATED)
"<think>\nOkay, let's tackle this problem. Hmm. So the task is to find a distribution of points for (...TRUNCATED)
codeforces
cc-by-4.0
code_contests
train
MEDIUM
"n, k, l, r, sall, sk = map(int, input().split())\n\n# Compute the top k scores\nx = sk // k\nremain(...TRUNCATED)
"I need to assign scores to *n* students such that:\n- Each student scores between *l* and *r*.\n- T(...TRUNCATED)
"The correct approach involves constructing a valid score distribution by first assigning scores to (...TRUNCATED)
"n, k, l, r, sall, sk = map(int, input().split())\n\n# Assign top k scores as evenly as possible\nx (...TRUNCATED)
820e1759338c48d99aeb0d14a3948729
"Raju has a very pretty girlfriend. He chats with her all day and night through his phone. His phone(...TRUNCATED)
"<think>\nOkay, I need to solve this programming problem. Let's read the problem carefully.\n\nThe p(...TRUNCATED)
hackerearth
cc-by-4.0
code_contests
train
UNKNOWN_DIFFICULTY
"# Precompute the character to (key, presses) mapping\nmapping = {}\n\n# Key 0\nkey0 = ['_', '0']\nf(...TRUNCATED)
"I see that Raju is typing on a T9 keypad with limited keys, and each key has multiple letters. I re(...TRUNCATED)
"The correct solution requires mapping each character to its corresponding key and number of presses(...TRUNCATED)
"# Precompute the character to (key, presses) mapping\nmapping = {}\n\n# Key 0\nkey0 = ['_', '0']\nf(...TRUNCATED)
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
316