TnT/CodeNet4Repair huggingface dataset:
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
from collections import deque

n, m = map(int, input().split())
ans_list = [0]*(n+1)

class Node:
    def __init__(self, x):
        self.val = x
        self.adj = []

for i in range(m):
    a, b = map(int, input().split())
    Node(a).adj.append(b)
    Node(b).adj.append(a)

q = deque()
q.append(Node(1).val)

while len(q) > 0:
    node = q.popleft()

    if node is not None:
        for i in Node(node).adj:
            if ans_list[i] == 0:
                ans_list[i] = Node(node).val

print('Yes')
for j in range(2, n + 1):
    print(ans_list[j])


Fixed, accepted submission:
from collections import deque

n, m = map(int, input().split())
ans_list = [0]*(n+1)

class Node:
    def __init__(self, x):
        self.val = x
        self.adj = []

nodelist = [Node(0)]
for i in range(1, n+1):
  nodelist.append(Node(i))

for i in range(m):
    a, b = map(int, input().split())
    nodelist[a].adj.append(b)
    nodelist[b].adj.append(a)

q = deque()
q.append(nodelist[1])

while len(q) > 0:
    node = q.popleft()

    if node is not None:
        for i in node.adj:
            if ans_list[i] == 0:
                ans_list[i] = node.val
                q.append(nodelist[i])

print('Yes')
for j in range(2, n + 1):
    print(ans_list[j])
Problem:
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = input()
m = int(input())
print(*['*' if x == s[m-1] else x for x in s])

Fixed, accepted submission:
n = int(input())
s = input()
m = int(input())
print(*['*' if x != s[m-1] else x for x in s], sep='')
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
s = input()
print(s[1::2])

Fixed, accepted submission:
s = input()
print(s[0::2])
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
import numpy as np

N = input(); A= input()
A,N = int(A), int(N)

if N % 500 <= A: print(N % 500); print('Yes')
else: print('No')


Fixed, accepted submission:
import numpy as np

N = input(); A= input()
A,N = int(A), int(N)

if N % 500 <= A:
    print('Yes')
else: print('No')
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Incorrect submission (verdict: Wrong Answer):
record = input()

wins = 0

for match in record:
    if(match == "o" or match =="O"):
        wins += 1

if(wins > 7):
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
record = input()

wins = 0

for match in record:
    if(match == "o" or match =="O"):
        wins += 1

matchesPlayed = len(record)

if(15 - matchesPlayed + wins > 7):
    print("YES")
else:
    print("NO")
Problem:
  The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.  One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one contestant to another, because judges with any relationship whatsoever with a specific contestant are temporarily excluded for scoring his/her performance.  Basically, scores given to a contestant's performance by the judges are averaged to decide his/her score. To avoid letting judges with eccentric viewpoints too much influence the score, the highest and the lowest scores are set aside in this calculation. If the same highest score is marked by two or more judges, only one of them is ignored. The same is with the lowest score. The average, which may contain fractions, are truncated down to obtain final score as an integer.  You are asked to write a program that computes the scores of performances, given the scores of all the judges, to speed up the event to be suited for a TV program.

Incorrect submission (verdict: Wrong Answer):
import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(s[1:-1])
    print(int(ave))

Fixed, accepted submission:
import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(sorted(s)[1:-1])
    print(int(ave))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
a=int(input()) 

ans = a % 1000

print(ans)

Fixed, accepted submission:
a=int(input()) 

ans = a % 1000

if ans != 0:
    print(1000-ans)
else:
    print(ans)
Problem:
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.  Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.  Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.                 void call(int n){   int i = 1;  CHECK_NUM:   int x = i;   if ( x % 3 == 0 ){     cout << " " << i;     goto END_CHECK_NUM;   }  INCLUDE3:   if ( x % 10 == 3 ){     cout << " " << i;     goto END_CHECK_NUM;   }   x /= 10;   if ( x ) goto INCLUDE3;  END_CHECK_NUM:   if ( ++i <= n ) goto CHECK_NUM;    cout << endl; }

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

import sys
import os



"""
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
"""

def call(n):
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(" ", end='')
            print(i, end='')
            i += 1
        else:
            while x > 0:
                if x % 10 == 3:
                    print(" ", end='')
                    print(i, end='')
                    i += 1
                    break
                else:
                    x //= 10
                    i += 1

n = int(input())
call(n)

Fixed, accepted submission:
# -*- coding: utf-8 -*-

import sys
import os



"""
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
"""

def include3(v):
    s = str(v)
    if '3' in s:
        return True
    else:
        return False

def call(n):
    for i in range(1, n + 1):
        if i % 3 == 0:
            print(" ", end='')
            print(i, end='')
        else:
            if include3(i):
                print(" ", end='')
                print(i, end='')

n = int(input())
call(n)
print()
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
x=int(input())
k=0
j=0
for i in range(x):
  if j<x:
    j+=i
    k+=1
  else:
    print(k)
    exit()
  

Fixed, accepted submission:
x=int(input())
k=0
j=0
if x==1:
  print("1")
  exit()
elif x==2:
  print("2")
  exit()
else:
  for i in range(x):
    if j<x:
      j+=i
      k+=1
    else:
      print(k-1)
      exit()
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
inputlist = [input() for i in range(4)]

n = 0

A,B,C= inputlist[0],inputlist[1],inputlist[2]

for i in range(int(A)+1):

    X = inputlist[3] 

    X = int(X) - i*500

    for j in range(int(B)+1):

        X = X - j*100

        for k in range(int(C)+1):

            X = X -k*50

            if X == 0:
                n += 1

print(n)

Fixed, accepted submission:
A,B,C,X = [int(input()) for i in range(4)]
X_original = X
n = 0

for i in range(int(A)+1):
    X = X_original
    X500 = X - i*500
    for j in range(int(B)+1):
        X100 = X500 - j*100
        for k in range(int(C)+1):
            X50 = X100-k*50
            if X50== 0:
                n += 1

print(n)
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
s = input()

if s.find('a') != -1 and s.find('b') != -1 and s.find('c') != -1:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
s = input()

if s.find('a') != -1 and s.find('b') != -1 and s.find('c') != -1:
    print("Yes")
else:
    print("No")
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())
print(X - (X - A) // B * B)

Fixed, accepted submission:
X = int(input())
A = int(input())
B = int(input())
print((X-A)%B)
Problem:
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.  Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.

Incorrect submission (verdict: Wrong Answer):
#coding: utf-8
N = int(input())
S = input()
mod = 1e9 + 7
alpha = list(map(chr,range(97,123)))
ans = 1
for i in alpha:
    ans *= S.count(i) + 1
    print(S.count(i))
print((ans-1) % mod)

Fixed, accepted submission:
#coding: utf-8
N = int(input())
S = input()
mod = 1000000000 + 7
alpha = list(map(chr,range(97,123)))
ans = 1
for i in alpha:
    ans *= S.count(i) + 1
print(int((ans-1) % mod))
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
# -*- coding:UTF-8 -*-
num = input().split()
print(int(num[0]) * int(num[1]), int(num[0])*2 + int(num[1]*2))

Fixed, accepted submission:
# -*- coding:UTF-8 -*-
num = input().split()
print(int(num[0]) * int(num[1]), int(num[0])*2 + int(num[1])*2)
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().split())
if a < b:
    print(a)
else:
    print(a-1)

Fixed, accepted submission:
a,b = map(int,input().split())
if a <= b:
    print(a)
else:
    print(a-1)
Problem:
Snuke loves puzzles.  Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below:    Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces.  Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.

Incorrect submission (verdict: Wrong Answer):
def solve(S, c):
    if S > c//2:
        return c//2
    elif S == c//2:
        return c//2
    if S < c//2:
        cnt = S
        c -= S * 2
        S -= S
        assert S == 0
        assert c > 0
        return cnt + c//4

S, c = [int(x) for x in input().split()]









Fixed, accepted submission:
def solve(S, c):
    if S > c//2:
        return c//2
    elif S == c//2:
        return c//2
    if S < c//2:
        cnt = S
        c -= S * 2
        S -= S
        assert S == 0
        assert c > 0
        return cnt + c//4


S, c = [int(x) for x in input().split()]
print(solve(S, c))
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V * T + A >= W * T + B:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V == W:
    print('NO')
    exit()

if 0 <= (abs(B - A) / (V - W)) <= T:
    print('YES')
else:
    print('NO')
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if (v-w)*t >= b-a:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if (v-w)*t >= abs(a-b):
  print('YES')
else:
  print('NO')
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
if __name__ == "__main__":
	a = [ i for i in input().split() ]
	a.sort(reverse=True)
	print(' '.join(a))

Fixed, accepted submission:
if __name__ == "__main__":
	a = [ i for i in input().split() ]
	a.sort()
	print(' '.join(a))
Problem:
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
t = [int(x) for x in input().split()]

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)
    
print(drink)
    
for i in range(m):
    score = sum(t) - t[drink[i][0]] + drink[i][1]
    print(score)

Fixed, accepted submission:
n = int(input())
t = [int(x) for x in input().split()]

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)

for i in range(m):
    score = sum(t) - t[drink[i][0]] + drink[i][1]
    print(score)
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
a = list(map(int,input().split()))
a.sort()
print(a)

Fixed, accepted submission:
a = list(map(int,input().split()))
a.sort()
print(a[0],a[1],a[2])
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
a=list(map(int,input().split()))
print (min(a),end=" ")
print (max(a),end=" ")
print (sum(a))

Fixed, accepted submission:
input()
a=list(map(int,input().split()))
print (min(a),end=" ")
print (max(a),end=" ")
print (sum(a))
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a_list = list(map(int,input().split()))
count = 0
for j in range(30):
  for a in a_list:
    frag = True
    if a % 2 !=0:
      frag = False
  if frag == False:
    print(count)
    break
  else:
    count += 1
    for i in range(n):
      a_list[i] = a_list[i]//2
      
    

  

Fixed, accepted submission:
n = int(input())
a_list = list(map(int,input().split()))
count = 0
for j in range(30):
  frag = True
  for a in a_list:
    if a % 2 !=0:
      frag = False
  if frag == False:
    print(count)
    break
  else:
    count += 1
    for i in range(n):
      a_list[i] = a_list[i]//2
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
s = input()
print(s[3])

Fixed, accepted submission:
s = input()
ss = s.replace('7','8',1)
print(ss)
Problem:
We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

res = A[0]
cnt = 1
use = []
for i in range(1, N):
    if A[i] == res:
        cnt += 1
    else:
        cnt = 1
        res = A[i]

    print(i, A[i], cnt, use)

    if cnt >= 2:
        use.append(A[i])
        cnt -= 2

    if len(use) >= 2:
        break

if len(use) >= 2:
    print(use[0]*use[1])
else:
    print(0)


Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

res = A[0]
cnt = 1
use = []
for i in range(1, N):
    if A[i] == res:
        cnt += 1
    else:
        cnt = 1
        res = A[i]

    if cnt >= 2:
        use.append(A[i])
        cnt -= 2

    if len(use) >= 2:
        break

if len(use) >= 2:
    print(use[0]*use[1])
else:
    print(0)
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
N, Y = tmp = list(map(int,input().split()))
ans = [-1]*3
for i in range(Y // 10000 + 1):
    tmp = Y - 10000 * i
    for j in range(tmp // 5000 + 1):
        if i + j <= N:
            if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
                ans = [i, j, N - i - j]
print(ans)

Fixed, accepted submission:
N, Y = tmp = list(map(int,input().split()))
ans = [-1]*3
for i in range(Y // 10000 + 1):
    tmp = Y - 10000 * i
    for j in range(tmp // 5000 + 1):
        if i + j <= N:
            if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
                ans = [i, j, N - i - j]
print(ans[0], ans[1], ans[2])
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
fee = 0
for i in range(N):
    fee = fee + 800 * N
    if N % 15 == 0:
        fee -= 200

print(fee)

Fixed, accepted submission:
N = int(input())
fee = 0
back = 0
fee = N * 800
back = N // 15 * 200

print(fee-back)