TnT/CodeNet4Repair huggingface dataset:
Problem:
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.  Write a program to count the number of black tiles which he can reach by repeating the moves described above.

Incorrect submission (verdict: Wrong Answer):
if __name__ == "__main__":
    while 1:
        w,h = list(map(int,input().strip().split()))
        if w == h == 0:break
        data = []
        data = []
        for _ in range(h):data.append(list(input()))
        visited = []
        for i in range(h):
            if '@'in data[i]:stack= [(i,data[i].index('@'))]
        count = 0
        while len(stack) !=0:
            y,x= stack.pop()
            count +=1
            if y-1 >= 0 and not (y-1,x)in visited and data[y -1][x] == '.':
                visited.append((y-1,x))
                stack.append((y-1,x))
            if x -1 >= 0 and not (y,x-1)in visited and data[y][x-1] == '.':
                visited.append((y,x-1))
                stack.append((y,x-1))
            if y +1 < h and not (y+1,x)in visited and data[y +1][x] == '.':
                visited.append((y+1,x))
                stack.append((y+1,x))
            if x + 1 < w and not (y,x+1)in visited and data[y][x +1] == '.':
                visited.append((y,x+1))
                stack.append((y,x+1))

Fixed, accepted submission:


if __name__ == "__main__":
    while 1:
        w,h = list(map(int,input().strip().split()))
        if w == h == 0:break
        data = []
        data = []
        for _ in range(h):data.append(list(input()))
        visited = []
        for i in range(h):
            if '@'in data[i]:stack= [(i,data[i].index('@'))]
        count = 0
        while len(stack) !=0:
            y,x= stack.pop()
            count +=1
            if y-1 >= 0 and not (y-1,x)in visited and data[y -1][x] == '.':
                visited.append((y-1,x))
                stack.append((y-1,x))
            if x -1 >= 0 and not (y,x-1)in visited and data[y][x-1] == '.':
                visited.append((y,x-1))
                stack.append((y,x-1))
            if y +1 < h and not (y+1,x)in visited and data[y +1][x] == '.':
                visited.append((y+1,x))
                stack.append((y+1,x))
            if x + 1 < w and not (y,x+1)in visited and data[y][x +1] == '.':
                visited.append((y,x+1))
                stack.append((y,x+1))

        print(count)
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Wrong Answer):
R,G,B,N = map(int,input().split())

ans = 0
for r in range(R):
  if N < r:
    continue
    
  for g in range(G):
    if (N - r - g) <= B:
      ans += 1
      
print(ans)

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

ans = 0
for r in range(3010):
  red = r * R
  if N < red:
    break
  
  for g in range(3010):
    green = g * G
    blue = N - red - green
    if blue < 0:
      break
    if blue % B == 0:
      ans += 1
      
print(ans)
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

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

h = S / 3600
m = (S % 3600) / 60
s = (S % 3600) % 60

print(h,":",m,":",s)


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

h = x // 3600
m = x % 3600 // 60
s = x  % 60

print(h,m,s,sep=':')
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):
import numpy as np

a, b = map(str,input().split())

target = int(a + b)
target_full = np.sqrt(target)
target_resid = target_full % 1

if target_resid == 0:
  print("Yes")
else:
  print("No")
  

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

target = a * b

if target % 2 == 1:
  print("Odd")
else:
  print("Even")
Problem:
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`.  You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

Incorrect submission (verdict: Wrong Answer):
s = input()
print('{}{}{}'.format(s[1],len(s)-2,s[-1]))


Fixed, accepted submission:
s = input()
print('{}{}{}'.format(s[0],len(s)-2,s[-1]))
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):
# coding = utf-8
f=input("")
ra=input("")
a=ra.split()
lista=[int(s) for s in a]
mix=1
base=0
for num in lista:
  for n in range(9):
    if num % 2**n :
      pass
    else:
      break
    if base<n:
      bace=n
print(n)

Fixed, accepted submission:
# coding = utf-8
n=input("")
a=input("")
a=a.split(" ")
a=[int(s) for s in a]
a.sort()
base=100000
n=1
for num in a:
    while num%2**n==0:
        n=n+1
    n=n-1
    if n < base:
        base=n
print(base)
Problem:
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).   Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`.   However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.   Determine if square1001 can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
H, W = map(int, input().split())
S = [['.']*(W + 2)] + [list('.' + input() + '.') for _ in range(H)] + [['.']*(W + 2)]
# print(S)

for i in range(1, H):
    for k in range(1, W):
        if S[i][k] == '#' and S[i][k - 1] != '#' and S[i - 1][k] != '#' and S[i][k + 1] != '#' and S[i + 1][k] != '#':
            print('Yes')
            exit()
print('No')

Fixed, accepted submission:
H, W = map(int, input().split())
S = [['.']*(W + 2)] + [list('.' + input() + '.') for _ in range(H)] + [['.']*(W + 2)]
# print(S)

for i in range(1, H):
    for k in range(1, W):
        if S[i][k] == '#' and S[i][k - 1] != '#' and S[i - 1][k] != '#' and S[i][k + 1] != '#' and S[i + 1][k] != '#':
            print('No')
            exit()
print('Yes')
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
    print("YES")
else:
    print("NO")
Problem:
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.  He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:    * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.  In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**.    * Buy stock: Pay A_i yen and receive one stock.   * Sell stock: Sell one stock for A_i yen.  What is the maximum possible amount of money that M-kun can have in the end by trading optimally?

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
# init
tmp = a[0]
bit_buy = 1
init_bit = 1
money = 1000
ans = money
stock_num = 0
for i in range(1, n):
    if bit_buy and a[i] > a[i - 1]:
        
        
        stock_num = money // a[i - 1]
        money = money - stock_num * a[i - 1]
        tmp = a[i - 1]
        bit_buy = 0
        init_bit = 0
    if (init_bit and i == n - 1) or (bit_buy == 0 and (a[i] < a[i - 1])):
        
        money += stock_num * a[i - 1]
        ans = max(ans, money)
        bit_buy = 1
        stock_num = 0
    print(i, a[i], money)
money += stock_num * tmp
ans = max(ans, money)
print(ans)


Fixed, accepted submission:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
soko = a[0]
urine = 0
ans = 1000
for i in range(len(a) - 1):
    if a[i] < a[i + 1]:
        ans += (ans // a[i]) * (a[i + 1] - a[i])
    #print(ans)
print(ans)
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 = input()
if s[0] == t[2] and s[1] == t[2] and s[2] == t[0]:
    print('YES')
else:
    print('NO')

Fixed, accepted submission:
s = input()
t = input()
if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:
    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):
import re
print('Yes' if re.match('^(dream|dreamer|erase|eraser)+$',input()) else 'No')

Fixed, accepted submission:
import re
print('YES' if re.match('^(dream|dreamer|erase|eraser)+$',input()) else 'NO')
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
N, K = map(int, input().split())
count = 1
for i in range(1,N,2):
    count+=1
if(count >= K):
    print("Yes")
    
else:
    print("No")




Fixed, accepted submission:
N, K = map(int, input().split())
if(N%2==1):
    if(N//2 + 1 >= K):
        print("YES")
    else:
        print("NO")
else:
    if(N//2 >= K):
        print("YES")
    else:
        print("NO")

# print(N//2)
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
def num_sum(L):
  ret = 0
  for l in L:
    ret += int(l)
  return ret

N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  num = num_sum(list(str(i)))
  if A <= num and num <= B:
    ans += num
print(ans)

Fixed, accepted submission:
def num_sum(L):
  ret = 0
  for l in L:
    ret += int(l)
  return ret

N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  num = num_sum(list(str(i)))
  if A <= num and num <= B:
    ans += i
print(ans)
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(int(((a+b)/2)+1))

Fixed, accepted submission:
a,b = map(int, input().split())
print(int(((a+b+1)/2)))
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):
n = int(input())
for i in range(1, n+1):
	x = i
	if x % 3 == 0:
		print(" ")
	while x:
		if x % 10 == 3:
			print(" ")
		x /= 10

Fixed, accepted submission:
n = int(input())
cout = ""
for i in range(1, n+1):
	x = i
	if x % 3 == 0:
		cout += " " + str(i)
	else:
		while x:
			if x % 10 == 3:
				cout += " " + str(i)
				break
			x //= 10
print(cout)
Problem:
Write a program which computes the digit number of sum of two integers a and b.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
c=int(a+b)
count=0
while (c/10 != 0 ):
    c=int(c/10)
    count=count+1
print(count)

Fixed, accepted submission:
import sys
for line in sys.stdin.readlines():
    a, b = map(int,line.split())
    c=int(a+b)
    count=0
    while (c/10 != 0 ):
        c=int(c/10)
        count=count+1
    print(count)
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):
import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = int(input())
if a[1] <= b[1]:
    print('NO')
    sys.exit()
elif abs(a[0]-b[0])//a[1]-b[1] <= t:
    print('Yes')
    sys.exit()
else:
    print('NO')

Fixed, accepted submission:
import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = int(input())
if a[1] <= b[1]:
    print('NO')
    sys.exit()
elif abs(a[0]-b[0])/abs(a[1]-b[1]) <= t:
    print('YES')
    sys.exit()
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=input().split()
n,l=int(n),int(l)
s=sorted([input() for i in range(n)])
print(list(s))


Fixed, accepted submission:
n,l=map(int,input().split())
s=[input() for i in range(n)]
s.sort()
print("".join(s))
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
abx = list(map(int, input().split()))
print(abx[1]//abx[2] - abx[0]//abx[2])

Fixed, accepted submission:
abx = list(map(int, input().split()))
if abx[0]%abx[2]==0:
    print(abx[1]//abx[2] - abx[0]//abx[2] + 1)
else:
    print(abx[1]//abx[2] - abx[0]//abx[2])
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    t = t - t1
    x = x - x1
    y = y - y1
    if x + y <= t and x+y % 2 == t % 2:
        t1 = t
        x1 = x
        y1 = y
        count += 1
if count == n:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    t = abs(t - t1)
    x = abs(x - x1)
    y = abs(y - y1)
    if x + y <= t and (x+y) % 2 == t % 2:
        t1 = t
        x1 = x
        y1 = y
        count += 1
if count == n:
    print("Yes")
else:
    print("No")
Problem:
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.  He has very high awareness of safety, and decides to buy two bells, one for each hand.  The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.

Incorrect submission (verdict: Wrong Answer):
import sys

a, b, c = map(int, sys.stdin.readline().split())

m = max([a,b,c])

print(a + b + c - 2 * m)

Fixed, accepted submission:
import sys

a, b, c = map(int, sys.stdin.readline().split())

m = max([a,b,c])

print(a + b + c - m)
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

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

print(24 + m)

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

print(24 + (24 - m))
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):
N = int(input())
A = list(map(int, input().split()))
A.sort()
xy = []
while(len(A)>1):
    x = A.pop(-1)
    y = A.pop(0)
    xy.append([x, y])
    A.append(x-y)
print(A)

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AM = A.pop(0)
xy = []
if AM > 0 and A[-1] >= 0:
    p = 1
elif AM <= 0 and A[-1] < 0:
    p = 2
else:
    p = 3
if p == 1:
    while(len(A)>1):
        x = A.pop(-1)
        y = A.pop(0)
        xy.append([x, y])
        A.append(x-y)
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 2:
    while(len(A)>1):
        x = AM
        y = A.pop(-1)
        xy.append([x, y])
        AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 3:
    while(len(A)>1):
        y = A.pop(0)
        if y >= 0:
            x = A.pop(-1)
            xy.append([x, y])
            A.append(x-y)
        else:
            x = AM
            xy.append([x, y])
            AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
print(ans)
for out in xy:
    print(*out)
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())
l = list(map(int, input().split()))
a = 0
b = 0

l.sort()
for i in range(n):
    if i%2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a-b)

Fixed, accepted submission:
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0

l = sorted(l, reverse=True)
for i in range(n):
    if i%2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a-b)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = [input().split() for _ in range(N)]

if N ==1:
  n = int(A[0][0])
  move = int(A[0][1]) + int(A[0][2]) 
  if move > n or move%2 != n%2:
    print("NO")
  else:
    print("YES")
  
for i in range(1,N):
  H = int(A[i][1]) - int(A[i -1][1])
  V = int(A[i][2]) - int(A[i -1][2])
  move = H + V
  n = int(A[i][0]) - int(A[i -1][0])
  if move > n or move%2 != n%2:
    print("NO")
    break
  elif i == N -1:
    print("YES")
	  

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

if N ==1:
  n = int(A[0][0])
  move = int(A[0][1]) + int(A[0][2]) 
  if move > n or move%2 != n%2:
    print("No")
  else:
    print("Yes")
  
for i in range(1,N):
  H = abs(int(A[i][1]) - int(A[i -1][1]))
  V = abs(int(A[i][2]) - int(A[i -1][2]))
  move = H + V
  n = int(A[i][0]) - int(A[i -1][0])
  if move > n or move%2 != n%2:
    print("No")
    break
  elif i == N -1:
    print("Yes")
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
import math

n = int(input())

print(math.floor(n**0.5))

Fixed, accepted submission:
import math
n=int(input())
m=math.floor(math.sqrt(n))
print(m*m)
Problem:
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.

Incorrect submission (verdict: Wrong Answer):
words = input().split()
for word in words:
    print(word.swapcase())

Fixed, accepted submission:
words = input()
print(words.swapcase())