TnT/CodeNet4Repair huggingface dataset:
Problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.  In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.  When activated, each type of robot will operate as follows.    * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.    * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.  Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
K = int(input())
x = list(map(int,input().split()))

length = 0

for i in x:
    length += min(i,K-i)

print(length)

Fixed, accepted submission:
N = int(input())
K = int(input())
x = list(map(int,input().split()))

length = 0

for i in x:
    length += min(i,K-i)*2

print(length)
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):
n = int(input())
print(n % 1000)

Fixed, accepted submission:
n = int(input())
n = n % 1000
if n == 0:
    print(0)
else:
    print(1000 - n)
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
words = []
for _ in range(N):
  words.append(('plus', input()))
M = int(input())
for _ in range(M):
  words.append(('minus', input()))
ans = 0
for i in range(N):
  point = 1
  for j in range(N+M):
    if words[i][1] == words[j][1]:
      if words[j][0] == 'plus':
        point += 1
      else:
        point -= 1
  ans = max(ans, point)

Fixed, accepted submission:
N = int(input())
words = []
for _ in range(N):
  words.append(('plus', input()))
M = int(input())
for _ in range(M):
  words.append(('minus', input()))
ans = 0
for i in range(N):
  point = 1
  for j in range(N+M):
    if words[i][1] == words[j][1] and i != j:
      if words[j][0] == 'plus':
        point += 1
      else:
        point -= 1
  ans = max(ans, point)
print(ans)
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):
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

Fixed, accepted submission:
n = int(input())
a = list(map(int,input().split()))
kaisuu = 0
while a[0]%2 == 0:
    for i in range(n):
        if a[i]%2 == 0:
            a[i] /= 2
            if i == n-1:
                kaisuu += 1
        else:
            break
else:
    print(kaisuu)
Problem:
We have a grid with H rows and W columns, where all the squares are initially white.  You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:    * Choose one row, then paint all the squares in that row black.   * Choose one column, then paint all the squares in that column black.  At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.

Incorrect submission (verdict: Wrong Answer):
h = int(input())
w = int(input())
n = int(input())
print(n % max(h,w))

Fixed, accepted submission:
h = int(input())
w = int(input())
n = int(input())
if n % max(h,w) == 0:
  print(n // max(h,w))
else:
  print(n // max(h,w) + 1)
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())
graph = [deque([]) for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)


def bfs(u):
    ans = [None] * (N+1)
    queue = deque([u])
    d = [None] * (N+1) 
    d[u] = 0 
    while queue:
        v = queue.popleft()
        for i in graph[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                ans[i] = v
                queue.append(i)
    return ans
d = bfs(1)
for i in range(2,N+1):
    print(d[i])

Fixed, accepted submission:
from collections import deque
N,M = map(int,input().split())
graph = [deque([]) for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)


def bfs(u):
    ans = [None] * (N+1)
    queue = deque([u])
    d = [None] * (N+1) 
    d[u] = 0 
    while queue:
        v = queue.popleft()
        for i in graph[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                ans[i] = v
                queue.append(i)
    return ans
d = bfs(1)
print("Yes")
for i in range(2,N+1):
    print(d[i])
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
S = []
S = list(input())
JS = 0
AS = 0
OT = 0

for i in range(N):
  print(S[i])
  if S[i] == 'a':
    JS += 1
  elif S[i] == 'b':
    AS += 1
  elif S[i] == 'c':
    OT += 1
  
  if S[i] == 'a' and A + B >= (JS + AS):
    print('Yes')
  elif S[i] == 'b' and A + B >= (JS + AS) and AS <= B:
    print('Yes')
  else:
    print('No') 

Fixed, accepted submission:
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
S = []
S = list(input())
JS = 0
AS = 0
OT = 0

for i in range(N):
  if S[i] == 'a' and A+B > JS+AS:
    print('Yes')
    JS += 1
  elif S[i] == 'b' and A+B > JS+AS and AS < B:
    print('Yes')
    AS += 1
  else:
    print('No')
Problem:
There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
# Your code here!

N = int(input())

A = list(map(int,input().split()))

A = sorted(A)

print(sum(A[N//2:]) - sum(A[:N//2]))
l = 0
r = N - 1
if N % 2 == 0:
    for i in range(N-1):
        if i % 2 == 0:
            print(A[r],A[l])
            A[r] = A[r] - A[l]
            l += 1
        else:
            print(A[l],A[r])
            A[l] = A[l] - A[r]
            r -= 1
        
else:
    for i in range(N-1):
        if i % 2 == 1:
            print(A[r],A[l])
            A[r] = A[r] - A[l]
            l += 1
        else:
            print(A[l],A[r])
            A[l] = A[l] - A[r]
            r -= 1

Fixed, accepted submission:
# coding: utf-8
# Your code here!

N = int(input())

A = list(map(int,input().split()))


A = sorted(A)
ans = A[-1] - A[0]
A_nashi = A[1:-1]

plus = len(A_nashi)
for i in range(len(A_nashi)):
    if A_nashi[i] >= 0:
        plus = i
        break

ans += sum(A_nashi[plus:]) - sum(A_nashi[:plus])

print(ans)

res = A[0]
for i in range(len(A_nashi) - plus):
    print(res,A_nashi[-i-1])
    res -= A_nashi[-i-1]
    
print(A[-1], res)
res = A[-1] - res

for i in range(plus):
    print(res,A_nashi[i])
    res -= A_nashi[i]
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
import math

n = int(input())
o = n / 1.08

o_int = math.floor(o)


print(math.floor(o_int * 1.08))


if (math.floor(o_int * 1.08) == n):
    print(o_int)

else:
    print(":(")

Fixed, accepted submission:
import math


n = int(input())
o = n / 1.080

o_floor = math.floor(o)
o_ceil = math.ceil(o)

if math.floor(o_floor * 1.08) == n:
    print(o_floor)

elif math.floor(o_ceil * 1.08) == n:
    print(o_ceil)

else:
    print(':(')
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n= int(input())
ac=str("AC X")
wa=str("WA X")
tle=str("TLE X")
re=str("RE X")
a=0;b=0;c=0;d=0
for i in range(n):
    p=input()
    if(p=="AC"):
        a+=1
    if(p=="WA"):
        b+=1
    if (p == "TLE"):
        c += 1
    if (p == "RE"):
        d += 1
print(ac,a)
print(wa,b)
print(tle,c)
print(re,d)

Fixed, accepted submission:
n= int(input())
ac=str("AC x")
wa=str("WA x")
tle=str("TLE x")
re=str("RE x")
a=0;b=0;c=0;d=0
for i in range(n):
    p=input()
    if(p=="AC"):
        a+=1
    if(p=="WA"):
        b+=1
    if (p == "TLE"):
        c += 1
    if (p == "RE"):
        d += 1
print(ac,a)
print(wa,b)
print(tle,c)
print(re,d)
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):
print('Yes' if sorted(input())=='abc' else 'No')

Fixed, accepted submission:
print('Yes' if ''.join(sorted(input()))=='abc' else 'No')
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())
List = list(map(int,input().split()))
count = 1
while all(li % 2 == 0 for li in List):
    List = [i // 2 for i in List]
    count += 1
print(count)

Fixed, accepted submission:
N = int(input())
List = list(map(int,input().split()))
count = 0
while all(li % 2 == 0 for li in List):
    List = [li // 2 for li in List]
    count += 1
print(count)
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 queue import Queue

n,m = map(int,input().split())

grafo = [[] for i in range(n)]

for x in range(m):
    a,b = map(int,input().split())
    grafo[a-1].append(b)
    grafo[b-1].append(a)


placas = [0] * (n)

def bfs(a):
    q = Queue(maxsize = n)
    placas[1] = 1
    q.put(a)
    while not q.empty():
        popado = q.get()
        for adj in grafo[popado-1]:
            if not placas[adj-1]:
                placas[adj-1] = popado
                q.put(adj)

    if placas.count(0) == 0:
        print("Yes")
        for x in placas[1::]:
            print(x)
    else:
        print("No")

bfs(1)


Fixed, accepted submission:
from queue import Queue

n,m = map(int,input().split())

grafo = [[] for i in range(n)]

for x in range(m):
    a,b = map(int,input().split())
    grafo[a-1].append(b)
    grafo[b-1].append(a)


placas = [0] * (n)

def bfs(a):
    q = Queue(maxsize = n)
    placas[0] = 1
    q.put(a)
    while not q.empty():
        popado = q.get()
        for adj in grafo[popado-1]:
            if not placas[adj-1]:
                placas[adj-1] = popado
                q.put(adj)

    if placas.count(0) == 0:
        print("Yes")
        for x in placas[1::]:
            print(x)
    else:
        print("No")

bfs(1)
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

Incorrect submission (verdict: Wrong Answer):
a = input().split()
if a[0] < a[1] < a[0]:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a = input().split()
if a[0] < a[1] < a[2]:
  print('Yes')
else:
  print('No')
Problem:
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.  Write a program which computes the amount of the debt in n weeks.

Incorrect submission (verdict: Wrong Answer):
n = 10 ** 2
for i in range(int(input())) :
    n = float(n) * 1.05
    if n - int(n) > 0 : n = int(n) + 1
    else : n = int(n)
print(n * (10 ** 4))

Fixed, accepted submission:
n = 10 ** 2
for i in range(int(input())) :
    n = float(n) * 1.05
    if n - int(n) > 0 : n = int(n) + 1
    else : n = int(n)
print(n * (10 ** 3))
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):


Z = list(map(int, input().split()))
S, T = Z[:2], Z[2:]
dy, dx = [abs(T[i] - S[i]) for i in range(2)]
# first
result = ""
result += "U"*dy
result += "R"*dx
result += "D"*dy
result += "L"*dx
result += "L"
result += "U"*(dy + 1)
result += "R"*(dx + 1)
result += "D"
result += "R"
result += "D"*(dy + 1)
result += "L"*(dx + 1)
result += "U"
print(result)

Fixed, accepted submission:


Z = list(map(int, input().split()))
S, T = Z[:2], Z[2:]
dx, dy = [abs(T[i] - S[i]) for i in range(2)]
# first
result = ""
result += "U"*dy
result += "R"*dx
result += "D"*dy
result += "L"*dx
result += "L"
result += "U"*(dy + 1)
result += "R"*(dx + 1)
result += "D"
result += "R"
result += "D"*(dy + 1)
result += "L"*(dx + 1)
result += "U"
print(result)
Problem:
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.  He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.  Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

Incorrect submission (verdict: Wrong Answer):
N,K=map(int,input().split())
A={}
for i in input().split():
  A[i]=A.get(i,0)+1
A=sorted(A.values())
print(A)
print(sum(A[0:len(A)-K]))

Fixed, accepted submission:
N,K=map(int,input().split())
A={}
for i in input().split():
  A[i]=A.get(i,0)+1
A=sorted(A.values())
print(sum(A[0:len(A)-K]))
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
s=a+b+c
if s%2==0:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
a,b,c=map(int,input().split())
s=a+b+c

if s%2==0:
    if a+b==c:
        print("Yes")
    elif a+c==b:
        print("Yes")
    elif c+b==a:
        print("Yes")
    else:
        print("No")
else:
    print("No")
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())

print(800 * n - 200 * n // 15)

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

print(800 * n - 200 * (n // 15))
Problem:
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:                 this is a pen   is would become:                 uijt jt b qfo   Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".

Incorrect submission (verdict: Wrong Answer):
d= dict(zip([chr(i) for i in range(97, 123)], [chr(i) for i in range(119,123)]+[chr(i) for i in range(97, 119)]))
while 1:
    try:
        text= input()
        for i in input():
            t= d.get(i)
            print(i if t== None else t, end='')
        print()
    except:
        break

Fixed, accepted submission:
import string
strings = string.ascii_lowercase
clues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)]
while True:
    try:
        data = input()
    except:
        break
    for word in data.split():
        if len(word) == 4 or 3:
            dif = 19 - (ord(word[0]) - 97)
            enc = ["" for _ in range(26)]
            for k, v in zip([i for i in range(dif, dif+26)], strings):
                enc[k%26] = v
            candidate = tuple(enc.index(c) for c in word)
            try:
                clues.index(candidate)
            except:
                continue
            break
    ans = ""
    for c in data:
        try:
            ans += strings[enc.index(c)]
        except:
            ans = ans + "." if c == "." else ans + " "
    print(ans)
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

Incorrect submission (verdict: Wrong Answer):
str_line = input()
str_line = list(str_line)
str_line.sort()
#print(str_line)
temp = 0
stnum_list = []

for i in range(1,len(str_line)-1):
    if str_line[i] == str_line[i-1]:
        temp += 1
        
    else:
        stnum_list.append(temp)
        temp = 0
        
rsult = 1        
for i in range(len(stnum_list)):
    rsult *= stnum_list[i]

if rsult%2 == 1:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
str_line = input()
str_line = list(str_line)
str_line.sort()
#print(str_line)
temp = 0
stnum_list = []

for i in range(1,len(str_line)-1):
    if str_line[i] == str_line[i-1]:
        temp += 1
        
    else:
        stnum_list.append(temp)
        temp = 0
        

rsult = 1
#print(len(str_line))

if len(str_line) == 1:
    rsult = 0
else:
    for i in range(len(stnum_list)):
        rsult *= stnum_list[i]

if rsult%2 == 1:
    print("Yes")
else:
    print("No")