TnT/CodeNet4Repair huggingface dataset:
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while True:
    f = input()
    _, op, _ = f.split()

    if op == '?':
        break

    print(eval(f))

Fixed, accepted submission:
while True:
    f = input()
    _, op, _ = f.split()

    if op == '?':
        break

    print(int(eval(f)))
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

Incorrect submission (verdict: Wrong Answer):
s = input()
t = reversed(input())
if(s == t):
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
s = input()
t = input()
if(s == t[::-1]):
  print("YES")
else:
  print("NO")
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):
from sys import stdin
input = stdin.readline

n = int(input())
S = list(input())
dic = {}

for d in S:
    if d not in dic:
        dic[d] = 1
    else:
        dic[d] += 1
tot = 1
for d in dic:
    i = dic[d] + 1
    tot *= i

print((tot-1) % (10**9+7))

Fixed, accepted submission:
n = int(input())
S = list(input())
dic = {}

for d in S:
    if d not in dic:
        dic[d] = 1
    else:
        dic[d] += 1
tot = 1
for d in dic:
    i = dic[d] + 1
    tot = tot*i % (10**9 + 7)

print((tot-1) % (10**9+7))
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

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

if (max(ABC) + ABC[0] + ABC[1] + ABC[2]) % 2 == 0:
    print((max(ABC) * 3 - ABC[0] - ABC[1] - ABC[2]) / 2)
else:
    print(((max(ABC) + 1) * 3 - ABC[0] - ABC[1] - ABC[2]) / 2)

Fixed, accepted submission:
import math

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

score = 0

if (max(ABC) + ABC[0] + ABC[1] + ABC[2]) % 2 == 0:
    score = (max(ABC) * 3 - ABC[0] - ABC[1] - ABC[2])
else:
    score = ((max(ABC) + 1) * 3 - ABC[0] - ABC[1] - ABC[2])

print(math.floor(score/2))
Problem:
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.   According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.   Determine if he is correct.

Incorrect submission (verdict: Wrong Answer):
grid = []
for i in range(3):
    grid.append([int(i) for i in input().split()])

for _ in range(100):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    if  grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3 and grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
        print('Yes')
        break

print('No')


Fixed, accepted submission:
grid = []
for i in range(3):
    grid.append([int(i) for i in input().split()])

for _ in range(100):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    if  grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3 and grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
        print('Yes')
        exit()
print('No')
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or a+b % 3 == 0:
    print("Possible")
else:
    print("Impossible")


Fixed, accepted submission:
a, b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Incorrect submission (verdict: Wrong Answer):
N = str(input())
if N[0]== 9 or N[1]==9:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
N = str(input())
if N[0]== "9" or N[1]=="9":
    print('Yes')
else:
    print('No')
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())

d = {}

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for key, val in d.items():
    print(key, 'x', val)

if 'AC' not in d:
    print('AC x 0')
if ('WA' not in d):
    print('WA x 0')
if('TLE' not in d):
    print('TLE x 0')
if 'RE' not in d:
    print('RE x 0')


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

d = {}
lst = ['AC', 'WA', 'TLE', 'RE']
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for i in lst:
    if i in d:
        print(i, 'x', d[i])
    else:
        print(i, 'x 0')
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
l=list(map(int,input().split()))
if l.count(5)==2 and l.count(1)==7:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
l=list(map(int,input().split()))
if l.count(5)==2 and l.count(7)==1:
  print("YES")
else:
  print("NO")
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):
print(sum(map(int,input().split()))//2+1)

Fixed, accepted submission:
print((sum(map(int,input().split()))+1)//2)
Problem:
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.  Assume that initially no person lives in the building.

Incorrect submission (verdict: Wrong Answer):
import sys

n = int(sys.stdin.readline())
values =[ [ int(val) for val in num[:-1].split() ] for num in sys.stdin.readlines() ]

nyukyo =[ [ [ 0 for _ in range(10) ] for _ in range(3) ] for _ in range(4) ]

for value in values:
    nyukyo[value[0]-1][value[1]-1][value[2]-1] = value[3]


for j in range(4):
    for n in range(3):
        for m in range(10):
            print(nyukyo[j][n][m], end=' ')
        print()
    print('#' * 20)


Fixed, accepted submission:
import sys

n = int(sys.stdin.readline())
values =[ [ int(val) for val in num[:-1].split() ] for num in sys.stdin.readlines() ]

nyukyo =[ [ [ 0 for _ in range(10) ] for _ in range(3) ] for _ in range(4) ]

for value in values:
    nyukyo[value[0]-1][value[1]-1][value[2]-1] += value[3]
    if nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] < 0:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 0
    elif nyukyo[value[0]-1][value[1]-1][value[2]-1] > 9:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 9

for j in range(4):
    for n in range(3):
        for m in range(10):
            print( ' ' + str(nyukyo[j][n][m]), end='')
        print('')
    if j < 3:
        print('#' * 20)
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
a,b,c=input().split()
d=[a,b,c]
print(d.count("5"))
if d.count("5")==2 and d.count("7")==1:
    print("YES")

else:
    print("NO")


Fixed, accepted submission:
a,b,c=input().split()
d=[a,b,c]

if d.count("5")==2 and d.count("7")==1:
    print("YES")

else:
    print("NO")
Problem:
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:    * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.  It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.

Incorrect submission (verdict: Wrong Answer):
n, m = map(int, input().split())
ans = max(1, n-2) * max(1, m-2)
print(ans)

Fixed, accepted submission:
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print((n-2) * (m-2))
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]

x, y = map(int, input().split())

if (x in g1 and y in g2) or (x in g2 and y in g2):
  print("Yes")
else:
  print("No")
  

Fixed, accepted submission:
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
 
x, y = map(int, input().split())
 
if (x in g1 and y in g1) or (x in g2 and y in g2):
  print("Yes")
else:
  print("No")
Problem:
Write a program which finds a pattern $p$ in a ring shaped text $s$.     

Incorrect submission (verdict: Wrong Answer):
str_list = input().rstrip()
str_search = input().rstrip()

str_list = str_list + str_list

print(str_search in str_list)

Fixed, accepted submission:
str_list = input().rstrip()
str_search = input().rstrip()

str_list = str_list + str_list

if str_search in str_list:
    print("Yes")
else:
    print("No")
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().split())
print(((a+b)//2)+1)

Fixed, accepted submission:
a,b = map(int,input().split())
print((a+b+1)//2)
Problem:
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.  The i-th operation is as follows:    1. Append a_i to the end of b.   2. Reverse the order of the elements in b.  Find the sequence b obtained after these n operations.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=[]
if n%2==0:
    x=a[::2]
    y=a[1::2]
    y.reverse()
    b=y+x
    print(b)
else:
    x=a[::2]
    y=a[1::2]
    x.reverse()
    b=x+y
    print(b)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
if n%2==0:
    x=a[::2]
    y=a[1::2]
    y.reverse()
    b=y+x
    print(*b)
else:
    x=a[::2]
    y=a[1::2]
    x.reverse()
    b=x+y
    print(*b)
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())
result = "No"
if V <= W:
    print(result)
else:
    for i in range(T):
        if A < B:
            A = A+V
            B = B+W
            if A == B:
                result = "Yes"
                break
        if A > B:
            A = A-V
            B = B-W
            if A == B:
                result = "Yes"
                break
    print(result) 

Fixed, accepted submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
result = "NO"
if V <= W:
    print(result)
else:
    D = abs(A-B)
    d = abs(V-W)
    if D > d*T:
        print(result)
    else:
        result = "YES"
        print(result)
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

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


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

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N-1:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))

print(sum(one)-sum(two))
Problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
X = list(map(int,input().split()))
for i in range(N):
  if i < N//2-1:
    print(X[(N)//2])
  elif i == N//2:
    print(X[(N)//2-1])
  elif i == N//2-1:
    print(X[(N)//2])
  elif i > N//2:
    print(X[(N)//2-1])

Fixed, accepted submission:
N = int(input())
X = list(map(int,input().split()))
X_ = sorted(X)
for x in X:
  if x <= X_[(N//2)-1]:
    print(X_[(N)//2])
  else:
    print(X_[(N)//2-1])
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()
s.replace('2017', '2018')
print(s)

Fixed, accepted submission:
print(input(2018)[4:])
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):
x = sorted(int(s) for s in input().split())
if x[0] + x[1] == x[2]:
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
x = sorted(int(s) for s in input().split())
if x[0] + x[1] == x[2]:
  print('Yes')
else:
  print('No')
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

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

t = ''.join(sorted(s))
print(t)

Fixed, accepted submission:
N, L = map(int, input().split())
s = [input() for _ in range(N)]

t = ''.join(sorted(s))
print(t)
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):
a = []
i = 1
n = 30
def checkNum():
    global a, i, x
    x = i
    if x%3 ==0:
        a.append(x)
        endCheck()
    include3()
    endCheck()

def include3():
    global a, i
    if x%10 == 3:
        a.append(x)
        endCheck()
        
def endCheck():
    global i
    i += 1
    if i <= n:
        print(i)
        checkNum()
        
checkNum()

print(*a)



Fixed, accepted submission:
n = int(input())
for i in range(1, n+1):
    if i%3 == 0 or  str(i).find('3') != -1:
        print(f" {i}", end = '')
print()
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
A,B,C=map(int,input().split())
print(['NO','YES'][A<=B<=C])

Fixed, accepted submission:
A,B,C=map(int,input().split())
print(['No','Yes'][A<=C and C<=B])
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):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(10000):
    for i in range(N-1):
        if A == sorted(A):
            print(ans)
            quit()
        a = A[i]
        ai = A[i+1]
        b = B[i]
        bi = B[i+1]
        if b > bi:
            if ai - a >= b - bi:
                A[i] = bi
                A[i+1] = b
                B[i] = ai
                B[i+1] = a
                ans += 1
        elif a > ai:
            if bi - b <= a - ai:
                A[i] = bi
                A[i+1] = b
                B[i] = ai
                B[i+1] = a
                ans += 1
print(-1)

Fixed, accepted submission:
H = int(input())
W = int(input())
m = max(H,W)
N = int(input())
ans = N//m
if N%m != 0:
    ans += 1
print(ans)
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
num=input()
moji=num.split(" ")

if int(moji[0])==7 or int(moji[0])==5:
    pass
else:
    print("NO")
    
    if moji[1]==7 or moji[1]==5:
        if int(moji[0])+int(moji[1])+int(moji[2])==19:
            print("YES")
    else:
        print("NO")

Fixed, accepted submission:
num=input()
moji=num.split(" ")

if int(moji[0])==7 or int(moji[0])==5:
    pass
else:
    print("NO")

if int(moji[1])==7 or int(moji[1])==5:
	if int(moji[0])+int(moji[1])+int(moji[2])==17:
		print("YES")
	else:
		print("NO")
else:
	print("NO")
Problem:
You are playing the following game with Joisino.    * Initially, you have a blank sheet of paper.   * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.   * Then, you are asked a question: How many numbers are written on the sheet now?  The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Incorrect submission (verdict: Wrong Answer):
import sys
import math

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(input())
cnt=0
li=[]

for _ in range(N):
	li.append(int(input()))
	
so=sorted(li)
ct=1
print(so)

for i in range(N-1):
	if so[i]==so[i+1]:
		ct+=1
	else:
		if ct%2==1:
			cnt+=1
		ct=1

if N==1:
	print(1)
else:	
	print(cnt)
			


Fixed, accepted submission:
import sys
import math

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(input())
cnt=0
li=[]

for _ in range(N):
	li.append(int(input()))
	
so=sorted(li)
ct=1

for i in range(N-1):
	if so[i]==so[i+1]:
		ct+=1
	else:
		cnt+=ct%2
		ct=1
		
cnt+=ct%2



if N==1:
	print(1)
else:	
	print(cnt)