TnT/CodeNet4Repair huggingface dataset:
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):
house = [[[0] * 10 for _ in range(3)] for __ in range(4)]

n = int(input())

while n:
    b, f, r, v = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v
    n -= 1

for b in house:
    for f in b:
        print(*f)
    print('#' * 20)

Fixed, accepted submission:
house = [[[0] * 10 for _ in range(3)] for __ in range(4)]

n = int(input())

while n:
    b, f, r, v = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v
    n -= 1

for i, b in enumerate(house):
    for f in b:
        print(' ', end='')
        print(*f)
    if i < 3:
        print('#' * 20)
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
c=0
i=0
list1=[]
list2=[]


S = input('')
char_list = list(S)
c = len (char_list)
c= c-1
print(c)

while c>1:
	if c % 2 == 0:
		d=int(c/2)
		print (d)
		for i in range(d):
			list1.append(char_list[i]) 
			list2.append(char_list[i+d])
		print (list1)
		print(list2)

		if list1 == list2:
			print (len (list1))
			break

		list1=[]
		list2=[]
	c=c-1

Fixed, accepted submission:
c=0
i=0
list1=[]
list2=[]


S = input('')
char_list = list(S)
c = len (char_list)
c= c-1
#print(c)

while c>1:
	if c % 2 == 0:
		d=int(c/2)
		#print (d)
		for i in range(d):
			list1.append(char_list[i]) 
			list2.append(char_list[i+d])
		#print (list1)
		#print(list2)

		if list1 == list2:
			print (len (list1)*2)
			break

		list1=[]
		list2=[]
	c=c-1
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):
n = int(input())
a = [0] * n
print (n)
a = list(map(int, input().split()))

print (min(a))
print (max(a))
print (sum(a))

Fixed, accepted submission:
n = int(input())
a = [0] * n
a = list(map(int, input().split()))
print (min(a),max(a),sum(a))
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

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

if n[0] % 2 == 0:
    print((n[0]*n[1])/2)
    sys.exit()
else:
    if n[1] % 2 == 0:
        print((n[0]*n[1])/2)
        sys.exit()
    else:
        b = int((n[0]*n[1])/2)
        print((n[0]*n[1])-b)
        sys.exit()
    


Fixed, accepted submission:
from decimal import Decimal
import sys
n = list(map(int, input().split()))

if n[0] == 1 or n[1] == 1:
    print(1)
    sys.exit()

if n[0] % 2 == 0:
    print(Decimal(int((n[0]/2)*n[1])))
    sys.exit()
else:
    if n[1] % 2 == 0:
        print(Decimal(int(n[0]*(n[1]/2))))
        sys.exit()
    else:
        a = ((n[0]-1)*n[1])/2
        b = n[1] - int(n[1]/2)
        print(Decimal(int(a+b)))
        sys.exit()
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 = input()
if "9" in n :
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
n = input()
if "9" in n :
    print("Yes")
else:
    print("No")
Problem:
An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.  You can assume that +, - and * are given as the operator and an operand is a positive integer less than 106

Incorrect submission (verdict: Wrong Answer):
a = input().split()
b = []
for i in a:
    if i.isdigit():
        b.append(i)
    else:
        c = b.pop()
        d = b.pop()
        ans = eval(str(d)+i+str(c))
        b.append(ans)
print(b)



Fixed, accepted submission:
a = input().split()
b = []
for i in a:
    if i.isdigit():
        b.append(i)
    else:
        c = b.pop()
        d = b.pop()
        ans = eval(str(d)+i+str(c))
        b.append(ans)
print(b[0])
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().split())

if(b-a == c-b):
  print("Yes")
else:
  print("No")

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

if b - a == c - b:
    print("YES")
else:
    print("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: Time Limit Exceeded):
N = input()
A = list(map(int,input().split()))
count = 0
exist_odd = False

while (exist_odd == False):
  for x in A:
    x = int(x)
    if x % 2 != 0:
      exist_odd = True
      
  if exist_odd == True:
    break
  else:
    for x in A:
      x /= 2
      count += 1
print(count)
        

Fixed, accepted submission:
N = int(input())
A = list(map(int,input().split()))
count = 0
flag = True
while(flag):
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i]/2
        else:
            flag = False
            break
    if flag == True:
        count+=1
print(count)
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())

i = 0
while i*1000<=n:
    i += 1

print(n-(i-1)*1000)

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

i = 0
while i*1000<n:
    i += 1

print((i)*1000-n)
Problem:
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.  Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan.  Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.

Incorrect submission (verdict: Wrong Answer):
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print('Left')
if a+b==c+d:
  print('Balanced')
else:
  print('Right')

Fixed, accepted submission:
a,b,c,d=map(int,input().split())
if (a+b)>(c+d):
  print('Left')
if (a+b)==(c+d):
  print('Balanced')
if (a+b)<(c+d):
  print('Right')
Problem:
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?

Incorrect submission (verdict: Wrong Answer):
def main():
    n,m=map(int,input().split(' '))
    print((n-1)*(m-1))

if __name__ == '__main__':
    print(main())


Fixed, accepted submission:
def main():
    n,m=map(int,input().split(' '))
    print((n-1)*(m-1))

if __name__ == '__main__':
    main()
Problem:
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).  The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Incorrect submission (verdict: Wrong Answer):
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for _ in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Fixed, accepted submission:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)
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):
import sys

input = sys.stdin.readline

#N
#t1 x1 y1t1 x1 y1
#t2 x2 y2t2 x2 y2

#tN xN yNtN xN yN
N = 3
x = [0 for i in range(N)]
y = [0 for i in range(N)]
c =[[0 for i in range(N)] for i in range(N)]

for i in range(N):
    c1, c2, c3 = map(int, input().split())
    c[i][0] = c1
    c[i][1] = c2
    c[i][2] = c3


x[0] = 0
for i in range(N):
    y[i] = c[0][i] - x[0]
x[1] = c[1][0] - y[1]
x[2] = c[2][0] - y[2]


flag = True
for i in range(N):
   for j in range(N):
       numx = x[i]
       numy = y[j]
       if not numx + numy == c[i][j]:
           flag = False
if flag:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
import sys

input = sys.stdin.readline

#N
#t1 x1 y1t1 x1 y1
#t2 x2 y2t2 x2 y2

#tN xN yNtN xN yN
N = 3
x = [0 for i in range(N)]
y = [0 for i in range(N)]
c =[[0 for i in range(N)] for i in range(N)]

for i in range(N):
    c1, c2, c3 = map(int, input().split())
    c[i][0] = c1
    c[i][1] = c2
    c[i][2] = c3


x[0] = 0
for i in range(N):
    y[i] = c[0][i] - x[0]
x[1] = c[1][0] - y[0]
x[2] = c[2][0] - y[0]

flag = True
for i in range(N):
   for j in range(N):
       numx = x[i]
       numy = y[j]
       if not numx + numy == c[i][j]:
           flag = False
if flag:
    print("Yes")
else:
    print("No")
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):
n = int(input())
count = 0
room = [int(0) for i in range(4) for j in range(3) for k in range(10)]
while count < n:
    x = list(map(lambda k: int(k), input().split(" ")))
    room[(x[0]-1)*30+(x[1]-1)*10+(x[2]-1)] += x[3]
    count += 1
for i in range(4):
    for j in range(3):
        for k in range(10):
            if k == 0:
                print("%d" % room[30*i+10*j+k], end="")
            else:
                print(" %d" % room[30*i+10*j+k], end="")
        print("")
    print("####################")

Fixed, accepted submission:
n = int(input())
count = 0
room = [int(0) for i in range(4) for j in range(3) for k in range(10)]
while count < n:
    x = list(map(lambda k: int(k), input().split(" ")))
    room[(x[0]-1)*30+(x[1]-1)*10+(x[2]-1)] += x[3]
    count += 1
for i in range(4):
    if i != 0:
        print("####################")
    for j in range(3):
        for k in range(10):
            print(" %d" % room[30*i+10*j+k], end="")
        print("")
Problem:
In programming, hexadecimal notation is often used.  In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.  In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`.  When X and Y are seen as hexadecimal numbers, which is larger?

Incorrect submission (verdict: Wrong Answer):
x,y=input().split()

if(x<y):
  print(x+"<"+y)
elif (x==y):
  print(x+"="+y)
else:
  print(x+">"+y)

Fixed, accepted submission:
x,y=input().split()

if(x<y):
  print("<")
elif (x==y):
  print("=")
else:
  print(">")
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Incorrect submission (verdict: Wrong Answer):
A,B,C=map(int,input().split())
if A+B<=C:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
A,B,C=map(int,input().split())
if A+B>=C:
    print("Yes")
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())
power = 1
for i in range(1,n+1):
    power += i%(10**9+7)
print(power % (10**9 + 7))


Fixed, accepted submission:
n = int(input())
print(n*800-(n//15)*200)
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):
C1 = [c1 for c1 in input()]
C2 = [c2 for c2 in input()]
if C1 == reversed(C2):
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
C1 = [c1 for c1 in input()]
C2 = [c2 for c2 in input()]
C2.reverse()
if C1 == C2:
  print("YES")
else:
  print("NO")
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

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

li.sort
print (li[0] + li[1] + li[2] ** K)


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

print (li[0] + li[1] + li[2] + max(li) * (2 ** K - 1))
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 = list(map(int, input().split()))
if a.sort() == [5, 5, 7]:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
I = list(map(int, input().split()))
I.sort()
if I == [5, 5, 7]:
    print("YES")
else:
    print("NO")
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s = list(input())
s.reverse()
s=''.join(s)

arr = ['dream', 'dreamer', 'erase', 'eraser']

tmp = []
arr2 = []
for i in range(4):
	tmp += list(arr[i])
	tmp.reverse()
	arr2.append(''.join(tmp))
	tmp = []

for y in arr2:
	if y in s:
		s = s.replace(y,'')
		

if s =='':
	print('Yes')
else:
	print('No')

	

Fixed, accepted submission:
s = input()

while len(s)>4:
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    else:
        break
if len(s)>0 :
    print('NO')
else:
    print('YES')
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):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for K in range(C+1):
            if A*500 + B*100 + C*50 == X:
                count += 1

print(count)

Fixed, accepted submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                count += 1

print(count)
Problem:
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`.  Consider doing the following operation:    * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.  You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Incorrect submission (verdict: Wrong Answer):
H, W, K = map(int, input().split())
C = []
for i in range(H):
    c = list(input().strip())
    C.append(c)

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h >> i & 1:
                    continue
                if w >> j & 1:
                    continue
                cnt += 1
        if cnt == K:
            ans += 1

print(ans)


Fixed, accepted submission:
H, W, K = map(int, input().split())
C = []
for i in range(H):
    c = list(input().strip())
    C.append(c)

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h >> i & 1:
                    continue
                if w >> j & 1:
                    continue
                if C[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int,input().split())
sum = a+b
if sum % 2 ==0:
  print("Even")
else:
  print("Odd")
  


Fixed, accepted submission:
a, b = map(int,input().split())
cal = a*b
if cal % 2 == 0:
  print("Even")
else:
  print("Odd")
Problem:
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.

Incorrect submission (verdict: Wrong Answer):
from heapq import heappop,heappush
N,Q = map(int,input().split())
route = [[] for _ in range(N)]
ans = [0] * N
for i in range(N - 1):
    a,b = map(int,input().split())
    route[a - 1].append(b)
    route[b - 1].append(a)
for i in range(Q):
    p,x = map(int,input().split())
    ans[p - 1] = x
W = [(0,1)]
A = [1] * N
while W:
    de,nod = heappop(W)
    A[nod - 1] = 0
    for i in route[nod - 1]:
        if A[i - 1] == 1:
            heappush(W,(de + 1,i))
            ans[i - 1] += ans[nod - 1]
for j in ans:
    print(j)

Fixed, accepted submission:
from heapq import heappop,heappush
N,Q = map(int,input().split())
route = [[] for _ in range(N)]
ans = [0] * N
for i in range(N - 1):
    a,b = map(int,input().split())
    route[a - 1].append(b)
    route[b - 1].append(a)
for i in range(Q):
    p,x = map(int,input().split())
    ans[p - 1] += x
W = [(0,1)]
A = [1] * N
while W:
    de,nod = heappop(W)
    A[nod - 1] = 0
    for i in route[nod - 1]:
        if A[i - 1] == 1:
            heappush(W,(de + 1,i))
            ans[i - 1] += ans[nod - 1]
print(*ans)
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:
  c=(b-a)/(v-w)
  if t>=c:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Fixed, accepted submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
gap=abs(a-b) 
if v>w:
  c=(v-w)*t
  if gap<=c:
    print('YES')
  else:
    print('NO')
else:
  print('NO')
Problem:
How many multiples of d are there among the integers between L and R (inclusive)?

Incorrect submission (verdict: Wrong Answer):
L, R, d = (int(x) for x in input().split())
a = L // d
b = R // d
if R % d == 0:
    b += 1
print(b - a)


Fixed, accepted submission:
L, R, d = (int(x) for x in input().split())
a = L // d
b = R // d
if L % d == 0:
    b += 1
print(b - a)