TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h, w = map(int, input().split())

s = []
for i in range(h):
    s.append(input())

t = [['']*w for i in range(h)]
print(t.count)

dx = [0, 0, 1, -1, 1, 1, -1, -1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
for y in range(h):
    for x in range(w):
        if s[y][x] == '#':
            t[y][x] = '#'
        else:
            count = 0
            for i in range(8):
                if x + dx[i] < 0 or x + dx[i] >= w or y + dy[i] < 0 or y + dy[i] >= h:
                    continue
                nx = x + dx[i]
                ny = y + dy[i]
                if s[ny][nx] == '#':
                    count += 1
            t[y][x] = str(count)

for i in range(len(t)):
    print(''.join(t[i]))

Fixed, accepted submission:
h, w = map(int, input().split())

s = []
for i in range(h):
    s.append(input())

t = [['']*w for i in range(h)]
# print(t.count)

dx = [0, 0, 1, -1, 1, 1, -1, -1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
for y in range(h):
    for x in range(w):
        if s[y][x] == '#':
            t[y][x] = '#'
        else:
            count = 0
            for i in range(8):
                if x + dx[i] < 0 or x + dx[i] >= w or y + dy[i] < 0 or y + dy[i] >= h:
                    continue
                nx = x + dx[i]
                ny = y + dy[i]
                if s[ny][nx] == '#':
                    count += 1
            t[y][x] = str(count)

for i in range(len(t)):
    print(''.join(t[i]))
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 = list(map(int, input().split()))
if a*b/2 % 2 == 0:
    print("even")
else:
    print("odd")

Fixed, accepted submission:
a,b = list(map(int, input().split()))
if a*b/2 % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
	for _ in range(len(s)):
		l=[s[0]]
		for i in range(len(s)-1):
			l.append(j[i])
			l.append(s[i+1])
	print(l)
	a="".join(l)
	cnt+=eval(a)
print(cnt)

Fixed, accepted submission:
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
	for _ in range(len(s)):
		l=[s[0]]
		for i in range(len(s)-1):
			l.append(j[i])
			l.append(s[i+1])
	a="".join(l)
	cnt+=eval(a)
print(cnt)
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
def main():
    n = input().split()
    a = int(n[0])
    b = int(n[1])
    c = int(n[2])

    if (a > c):
        temp = a
        a = c
        c = temp

    if (a > b):
        temp = b
        b = a
        a = temp

    print("{0} {1} {2}".format(a,b,c))

if __name__ == '__main__':
    main()

Fixed, accepted submission:
def main():
    n = input().split()

    a = int(n[0])
    b = int(n[1])
    c = int(n[2])

    if (a > b):
        temp = a
        a = b
        b = temp

    if (b > c):
        temp = b
        b = c
        c = temp

    if (a > b):
        temp = a
        a = b
        b = temp

    print("{0} {1} {2}".format(a,b,c))
if __name__ == '__main__':
    main()
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
s=input()
l=len(s)
x=[0]*l
for i in range(l):
  for j in range(i,l):
    x[j]+=int(s[i])*(i+1)
a=0
for i in range(l):
  a+=x[i]*(10**(l-i-1))
print(a)

Fixed, accepted submission:
s=input()
l=len(s)
x=[0]*l
for i in range(l):
  for j in range(i,l):
    if j-i>0:
      x[j]+=int(s[i])*(2**i)*(2**(j-i-1))
    else:
      x[j]+=int(s[i])*(2**i)
a=0
for i in range(l):
  a+=x[i]*(10**(l-i-1))
print(a)
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):
x,y = map(int,input().split())
k = 100
if y < 10:
    k = 10
if y >99:
    k = 1000

c = y + x * k
print(c)
for i in range(0,11000):
    if c == i ** 2:
        print('Yes')
        k = 0
        
if k != 0:
    print('No')
        

Fixed, accepted submission:
x,y = map(int,input().split())
if x*y %2 == 0:
  print('Even')
else:
  print('Odd')
Problem:
Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains.  Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.  In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.  Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t.  Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.

Incorrect submission (verdict: Wrong Answer):
import scipy.sparse as ss

n,m,s,t = map(int,input().split())
s,t = s-1,t-1
Gs = ss.dok_matrix((n,n),int)
Gt = ss.dok_matrix((n,n),int)

for _ in range(m):
  u,v,a,b = map(int,input().split())
  u,v = u-1,v-1
  Gs[u,v] = a
  Gs[v,u] = a
  Gt[u,v] = b
  Gt[v,u] = b

Ds = ss.csgraph.dijkstra(Gs, indices = s)
Dt = ss.csgraph.dijkstra(Gt, indices = t)

D = Ds+Dt
D = sorted(((cost, i) for i,cost in enumerate(D)), reverse=True)
print(D)
for i in range(n):
  while D[-1][1] < i:
    D.pop()
  print(int(10**15 - D[-1][0]))

Fixed, accepted submission:
import heapq as hq

# adj list graph
def dijkstra(adj, costs, s):
  N = len(adj)
  q = [(0,s)]
  dist = [float('inf')]*N
  dist[s] = 0
  prev = [None]*N

  while q:
    c, u = hq.heappop(q)
    if c > dist[u]:
      continue

    for v in adj[u]:
      if dist[v] > dist[u] + costs[(u,v)]:
        dist[v] = dist[u] + costs[(u,v)]
        prev[v] = u
        hq.heappush(q, (dist[v], v))

  return prev, dist


n,m,s,t = map(int,input().split())
s,t = s-1,t-1

G = [list() for _ in range(n)]
Cs = dict()
Ct = dict()

for _ in range(m):
  u,v,a,b = map(int,input().split())
  u,v = u-1,v-1
  G[u].append(v)
  G[v].append(u)
  Cs[(u,v)] = a
  Cs[(v,u)] = a
  Ct[(u,v)] = b
  Ct[(v,u)] = b

Ds = dijkstra(G, Cs, s)[1]
Dt = dijkstra(G, Ct, t)[1]

D = sorted(((a+b, i) for i,(a,b) in enumerate(zip(Ds,Dt))), reverse=True)
for i in range(n):
  while D[-1][1] < i:
    D.pop()
  print(int(10**15 - D[-1][0]))
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):
import sys
Money_500 = int(input())
Money_100 = int(input())
Money_50  = int(input())
Amount    = int(input())
Count = 0

if Amount % 50 != 0 or Amount / 1 == 0 or Amount < 50 :
    print(Count)
    print('break')
    sys.exit()



if Money_500 >= Amount / 500 and Amount % 500 == 0:
    Count += 1

for i in range(0,Money_500+1):
    if Amount < i * 500 and i >= 1:
        break

    if ( Amount - ( i * 500 )) >= 100:

        for x in range(0,Money_100+1):
            if ( Amount - ( i * 500 )) - (x * 100) < 0 and i >= 1:
                break

            if ( Amount - (i * 500 ) - ( x * 100 )) / 50 <= Money_50 :
                Count += 1
print ( Count )

Fixed, accepted submission:
import sys
Money_500 = int(input())
Money_100 = int(input())
Money_50  = int(input())
Amount    = int(input())
Count = 0

if Amount % 50 != 0 or Amount / 1 == 0 or Amount < 50 :
    print(Count)
    sys.exit()

for i in range(0,Money_500+1):
    if Amount < i * 500 :
        break

    for x in range(0,Money_100+1):
        if ( Amount - ( i * 500 )) - (x * 100) < 0 :
             break

        if ( Amount - (i * 500 ) - ( x * 100 )) / 50 <= Money_50 :
            Count += 1
print ( Count )
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

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

mx = n
current = n
for c in s:
  if c == "I":
    current += 1
  elif c == "D":
    current -= 1
  if current > mx:
    mx = current


print(mx)
  
  

Fixed, accepted submission:
n = int(input())
s = input()
 
mx = 0
current = 0
for c in s:
  if c == "I":
    current += 1
  elif c == "D":
    current -= 1
  if current > mx:
    mx = current
 
 
print(mx)
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):
ABC = list(map(int, input().split()))
K = int(input())
print(max(ABC) * K + (sum(ABC) - max(ABC)))



Fixed, accepted submission:
ABC = list(map(int, input().split()))
K = int(input())
print(max(ABC) * 2**K + (sum(ABC) - max(ABC)))
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
x, y = map(int, input().split())
x*y
2*(x+y)


Fixed, accepted submission:
x, y = map(int, input().split())
print(x*y, 2*(x+y))
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

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

value = 0
if a%2 == 0:
    value = a/2-1
else:
    value = a/2
print(value)
      

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

value = 0
if a%2 == 0:
    value = round(a/2-1)
else:
    value = round((a+1)/2-1)
print(value)
Problem:
Compute A + B.

Incorrect submission (verdict: Wrong Answer):
import sys
for line in sys.stdin:
    items = line.split()
    print( items[0] + items[1] )

Fixed, accepted submission:
import sys
for line in sys.stdin:
    items = line.split()
    print( int(items[0]) + int(items[1]) )
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math
x = int(input())
n = 16 // (math.log10(1.01))
a = 100
cnt = 0

while a <= x:
    cnt += 1
    a = math.floor(a * 1.01)

'''
for i in range(1, math.floor(n)+1):
    a = math.floor(a * 1.01)
    cnt += 1
    if a >= x:
        break
    else:
        continue
'''

print(cnt)

Fixed, accepted submission:
import math
x = int(input())
n = 16 // (math.log10(1.01))
a = 100
cnt = 0

while a < x:
    cnt += 1
    a = math.floor(a * 1.01)

'''
for i in range(1, math.floor(n)+1):
    a = math.floor(a * 1.01)
    cnt += 1
    if a >= x:
        break
    else:
        continue
'''

print(cnt)
Problem:
あなたは N 個の指輪を持っている．どの指輪にも，アルファベットの大文字 10 文字からなる文字列が刻印されている．指輪には文字列の最初と最後がつながった形で文字が刻印されている．指輪に刻印された文字列を逆順に読む心配はない．  探したい文字列が与えられたとき，その文字列を含む指輪が何個あるかを求めるプログラムを作成せよ．

Incorrect submission (verdict: Wrong Answer):
s=input()
print(sum(len(2*input().split(s))>1 for _ in range(int(input()))))

Fixed, accepted submission:
s=input()
print(sum(len((2*input()).split(s))>1 for _ in range(int(input()))))
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):
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
    total = 0
    str_i = str(i)
    len_i = len(str_i)
    for l in range(len_i):
        total += int(str_i[l])
    if A <= total <= B:
        cnt += 1
print(cnt)


Fixed, accepted submission:
N, A, B = map(int, input().split())
All = 0

for i in range(1, N + 1):
    total = 0
    j = i
    while j != 0:
        total += j % 10
        j = j // 10
    if A <= total <= B:
        All += i

print(All)
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())
num = N// 1000
mode = N % 1000
if mode == 0:
    print(num)
else:
    print(num + 1)

Fixed, accepted submission:
N = int(input())
num = N// 1000
mode = N % 1000
if mode == 0:
    print(0)
else:
    print((num + 1) * 1000 - N)
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=n//1000
b=n//100-a*10
d=n%10
c=n%100-d
if a==b and b==c:
    print("Yes")
elif b==c and c==d:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
n=int(input())
a=n//1000
b=(n//100)-(a*10)
d=n%10
c=((n%100)-d)//10
if a==b and b==c:
    print("Yes")
elif b==c and c==d:
    print("Yes")
else:
    print("No")
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())
A = list(map(int, input().split()))

B = A.copy()

B.sort()

for num in A:
  if B[N//2] >= num:
    print(B[N//2])
  else:
    print(B[N//2-1])


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

B = A.copy()

B.sort()

for num in A:
  if B[N//2] > num:
    print(B[N//2])
  else:
    print(B[N//2-1])
Problem:
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.  Integers M_1, D_1, M_2, and D_2 will be given as input.   It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.   Determine whether the date 2019-M_1-D_1 is the last day of a month.

Incorrect submission (verdict: Wrong Answer):
month_1, day_1 = input().split()
month_2, day_2 = input().split()

int_month_1 = int(month_1)
int_month_2 = int(month_2)

if int_month_1 == int_month_2:
  print(1)
  

Fixed, accepted submission:
month_1, day_1 = input().split()
month_2, day_2 = input().split()

int_month_1 = int(month_1)
int_month_2 = int(month_2)

if int_month_1 == int_month_2:
  print('0')
else:
  print('1')
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
l = input().split()

'''
a = int(l[0])
b = int(l[1])
'''

l = list(map(int,l))

a = l[0]*l[1]
b = 2*(l[0]*l[1])

print(a,b)


Fixed, accepted submission:
l = input().split()

'''
a = int(l[0])
b = int(l[1])
'''

l = list(map(int,l))

a = l[0]*l[1]
b = 2*(l[0]+l[1])

print(a,b)
Problem:
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
k = sum(A)
c = 1  
aa = 1
ans = 1
if A[0] != 0:
    print(-1)
else:
    for i in range(1,N + 1):
        c *= 2
        if A[i] > c:
            aa = 0
            break
        elif A[i] == c:
            if i != N - 1:
                aa = 0
                break
            else:
                ans += c
        else:
            c -= A[i]
            k -= A[i]
            ans += A[i]
            if c >= k:
                c = k
            ans += c
if aa == 0:
    print(-1)
else:
    print(ans)

Fixed, accepted submission:
N = int(input())
A = list(map(int,input().split()))
k = sum(A)

c = 1  

aa = 1
ans = 1
if A[0] != 0:
    aa = 2
    if N != 0:
        print(-1)
    else:
        if A[0] == 1:
            print(1)
        else:
            print(-1)
else:
    for i in range(1,N + 1):
        c *= 2
        
        if A[i] > c:
            
            aa = 0
            break
        elif A[i] == c:
            
            if i != N:
                aa = 0
                break
            else:
                ans += c
        else:
            c -= A[i]
            k -= A[i]
            ans += A[i]
            
            if c >= k:
                
                c = k
            ans += c
            

if aa == 0:
    print(-1)
elif aa == 1:
    print(ans)
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())
ans = (a+b)*h/2

print(ans)

Fixed, accepted submission:
a = int(input())
b= int(input())
h = int(input())
 
ans = (a+b)*h//2
 
print(ans)
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n+1, 10**6):
  for j in str(i):
    if j in a:
      break
    print(i)
    exit()

Fixed, accepted submission:
n, k = map(int, input().split())
a = list(input().split())
for i in range(n, 10**6):
  if all([j not in a for j in str(i)]):
 #   print([j for j in str(i)])
    print(i)
    exit()
Problem:
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.  Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Incorrect submission (verdict: Wrong Answer):
a=input()
b=input()
c=input()
print('a[0]'+'b[1]'+'c[2]')

Fixed, accepted submission:
a=input()[0]
b=input()[1]
c=input()[2]
print(a+b+c)
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):

N = int(input())
dict = {}
for i in range(1, N+1):
    n = float(i)
    cnt = 0
    while n/2>0.0:
        if n%2 == 0.0:
            cnt += 1
        n = n/2
    dict[i] = cnt
print(dict)

Fixed, accepted submission:

N = int(input())
dict = {}
for i in range(1, N+1):
    n = float(i)
    cnt = 0
    while n/2>0.0:
        if n%2 == 0.0:
            cnt += 1
        n = n/2
    dict[i] = cnt

import numpy as np
print(list(dict.keys())[np.argmax(list(dict.values()))])
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 = map(int, input().split())

if A == 5 and B == 7 and C == 5:
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
L = sorted(list(map(int, input().split())))
 
if L[0] == 5 and L[1] == 5 and L[2] == 7:
  print('YES')
else:
  print('NO')