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 = [list(input()) for _ in range(H)]

s = [[0]*(W+2)]*(H+2)

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            s[i+1][j+1] = 9

for i in range(H):
    for j in range(W):
        if s[i+1][j+1] >= 9:
            s[i+0][j+0] += 1
            s[i+0][j+1] += 1
            s[i+0][j+2] += 1
            s[i+1][j+0] += 1
            s[i+1][j+1] += 1
            s[i+1][j+2] += 1
            s[i+2][j+0] += 1
            s[i+2][j+1] += 1
            s[i+2][j+2] += 1

for i in range(1,H+1):
    ans = ""
    for j in range(1,W+1):
        ans += str(s[i][j])
    print(ans)


Fixed, accepted submission:
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

T = [[0]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            T[i+1][j+1] = 9

for i in range(1,H+1):
    for j in range(1,W+1):
        if T[i][j] >= 9:
            T[i-1][j-1] += 1
            T[i-1][j+0] += 1
            T[i-1][j+1] += 1
            T[i+0][j-1] += 1
            T[i+0][j+0] += 1
            T[i+0][j+1] += 1
            T[i+1][j-1] += 1
            T[i+1][j+0] += 1
            T[i+1][j+1] += 1

for i in range(1,H+1):
    ans = ""
    for j in range(1,W+1):
        if T[i][j] >= 9:
            T[i][j] = "#"
        ans += str(T[i][j])
    print(ans)
Problem:
Write a program which reads an integer and prints sum of its digits.

Incorrect submission (verdict: Wrong Answer):
while True:
    count = 0
    num = [int(i) for i in input().split(" ")]
    if num[0] == 0:
        break
    for n in num:
        count += n
    print(count)
     

Fixed, accepted submission:
while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x]
    print(sum(num))
Problem:
Aizu Ocean Transport Company (AOTC) accepted a new shipping order. The pieces of the cargo included in this order all have the same square footprint (2m x 2m). The cargo room has a rectangular storage space of 4m width with various longitudinal extents. Each pieces of cargo must be placed in alignment with partition boundaries which form a 1m x 1m square grid. A straddling arrangement with a neighboring partition (for example, protrusion by 50 cm) is not allowed. Neither an angled layout nor stacked placement are allowed. Note also that there may be some partitions on which any cargo loading is prohibited.         AOTC wishes to use the currently available ship for this consignment and needs to know how many pieces of cargo it can accommodate.  Make a program to report the maximum cargo capacity of the cargo space given the following information: the depth (m) of the cargo space and the loading- inhibited partitions.

Incorrect submission (verdict: Wrong Answer):
h, n = map(int, input().split())
c = {i:set() for i in range(h)}
for i in range(n):
    a, b = map(int, input().split())
    c[b].add(a)
count = 0
for i in range(h - 1):
    l = c[i] | c[i + 1]
    p = None
    if l == set():
        count += 2
        c[i + 1].add(1)
        c[i + 1].add(2)
    elif 0 not in l and 1 not in l:
        p = 1
    elif 2 not in l and 3 not in l:
        p = 3
    elif 1 not in l and 2 not in l:
        p = 2
    if p:
        j = 1
        while i + j < h:
            if c[i + j] == set():
                j += 1
            else:
                break
        if (j - 1) % 2:
            count += 1
            c[i + 1].add(p - 1)
            c[i + 1].add(p)
print(count)


Fixed, accepted submission:
h, n = map(int, input().split())
c = [set() for i in range(h + 1)]
for i in range(n):
    a, b = map(int, input().split())
    c[b].add(a)
c[h] = set([1, 2])
count = 0
for i in range(h - 1):
    l = c[i] | c[i + 1]
    p = None
    if l == set():
        count += 2
        c[i + 1].add(1)
        c[i + 1].add(2)
    elif 0 not in l and 1 not in l:
        p = 1
    elif 2 not in l and 3 not in l:
        p = 3
    elif 1 not in l and 2 not in l:
        p = 2
    if p:
        j = 0
        while True:
            if c[i + j + 1] | c[i + j + 1] == set():
                j += 1
            else:
                break
        if p != 2 and p - 1 not in c[i + j + 1] and p not in c[i + j + 1]:
            count += 1
            c[i + 1].add(p - 1)
            c[i + 1].add(p)
            continue
        if j % 2 or j < 2:
            count += 1
            c[i + 1].add(p - 1)
            c[i + 1].add(p)
print(count)
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):


def over(X, start=100):
    i = 0
    current = start
    while True:
        i += 1
        current += int(current * 0.01)
        if current > X:
            return i

def main():
    X = int(input())

    result = over(X, 100)

    print(result)
   


if __name__ == '__main__':
    main()

Fixed, accepted submission:


def over(X, start=100):
    i = 0
    current = start
    while True:
        i += 1
        current += current // 100
        if current >= X:
            return i

def main():
    X = int(input())

    result = over(X, 100)

    print(result)
   


if __name__ == '__main__':
    main()
Problem:
Compute A \times B, truncate its fractional part, and print the result as an integer.

Incorrect submission (verdict: Wrong Answer):
def main(numbers: list):
    print(int(round(numbers[0] * numbers[1], 0)))


# N = int(input())
line = list(map(float, input().split()))
main(line)


Fixed, accepted submission:


def main(numbers: list):
    a = int(numbers[0])
    b = int(numbers[1].replace('.', ''))
    ans = a * b // 100
    print(ans)


# N = int(input())
line = list(map(str, input().split()))
main(line)
Problem:
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Incorrect submission (verdict: Wrong Answer):


N = int(input())
T = list()
A = list()

for _ in range(N):
    t, a = list(map(lambda x: int(x), input().split()))
    T.append(t)
    A.append(a)

ans = 1

for i in range(N):
    while (ans % (T[i] + A[i])) != 0:
        ans += 1
    print(ans)

print(ans)


Fixed, accepted submission:

ans = 0

for i in range(int(input())):
    t_i, a_i = list(map(lambda x: int(x), input().split()))

    if i == 0:
        t, a = t_i, a_i

    else:
        n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
        t = n*t_i
        a = n*a_i

    ans = t + a

print(ans)
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):
import math
print(math.ceil(int(input())/1000))

Fixed, accepted submission:
a=int(input())
while a > 1000:
  a-=1000
print(1000-a)
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += 1
print(ans)


Fixed, accepted submission:
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += i
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):
a = int(input())
h = a // (60**2)
m = (a-60**2) // 60
s = (a%3600)%60
print("%d:%d:%d"%(h,m,s))

Fixed, accepted submission:
t = int(input())
h = t//3600
m = (t-h*3600)//60
s = t-h*3600-m*60
print(str(h)+":"+str(m)+":"+str(s))
Problem:
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`.  Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = input()
S = [0 if si == "
def taskC(N,S):
    Wlist = []
    Blist = []
    Wcount = 0
    Bcount = 0
    S0 = S[0]
    for si in S:
        if si == 0:
            Bcount += 1
            if Wcount > 0:
                Wlist = [Wcount] + Wlist
                Wcount = 0
        else:
            Wcount += 1
            if Bcount >0:
                Blist += [Bcount]
                Bcount = 0
    Wlist = ([Wcount] + Wlist) if Wcount > 0 else Wlist
    Blist = (Blist + [Bcount]) if Bcount > 0 else Blist
    if len(Wlist)+len(Blist) <= 1:
        return 0
    if len(Wlist)>len(Blist):
        Wlist = Wlist[:-1]
        S0 = 0
    elif len(Blist)>len(Wlist):
        Blist = Blist[:-1]
        S0 = 0
    Wsum = [0]
    Bsum = [0]
    for ind in range(len(Wlist)):
        Wsum = [ Wsum[0] + Wlist[ind]] + Wsum
        Bsum += [ Bsum[-1] + Blist[ind]]
    ret = min([Wsum[i]+Bsum[i] for i in range(len(Wsum))])
    if S0 == 0:
        ret2 = min([Wsum[i]+Bsum[i+1] for i in range(len(Wsum)-1)])
        return min(ret, ret2)
    else:
        ret2 = min([Wsum[i+1]+Bsum[i] for i in range(len(Wsum)-1)])
        return min(ret, ret2)
taskC(N,S)

Fixed, accepted submission:
N = int(input())
S = input()
Bsum = [0] 
Wsum = [0] 
for i in range(N):
    Bsum += [Bsum[-1]+(1 if S[i]=="#" else 0) ]
    Wsum += [Wsum[-1]+(1 if S[N-i-1]=="." else 0)]
print(min([Bsum[i]+Wsum[N-i] for i in range(N+1)]))
Problem:
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.    * Operation 1: Pour 100A grams of water into the beaker.   * Operation 2: Pour 100B grams of water into the beaker.   * Operation 3: Put C grams of sugar into the beaker.   * Operation 4: Put D grams of sugar into the beaker.  In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Incorrect submission (verdict: Wrong Answer):
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(A):
    for b in range(B):
        for c in range(C):
            for d in range(D):
                x = 100 * (a + b)
                y = c + d
                if x + y <= F and y <= x * E // 100 and x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x
                        ans_B = y
                        tmp = y / (x + y)

print(ans_A, ans_B)


Fixed, accepted submission:
A, B, C, D, E, F = map(int, input().split())

tmp = 0
ans_A = 0
ans_B = 0
for a in range(31):
    for b in range(31):
        x = 100 * (a * A + b * B)
        if x > F:
            break
        for c in range((x // 100 * E) // C + 1):
            for d in range(((x // 100 * E) - c) // D + 1):
                y = c * C + d * D
                if x + y > F or y > x * E // 100:
                    break
                if x + y != 0:
                    if y / (x + y) > tmp:
                        ans_A = x + y
                        ans_B = y
                        tmp = y / (x + y)

if ans_A == 0:
    print(100 * A, 0)
else:
    print(ans_A, ans_B)
Problem:
A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).     **Fig. 1**  A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node."  Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ :    * node ID of _u_   * parent of _u_   * depth of _u_   * node type (root, internal node or leaf)   * a list of chidlren of _u_  If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent.  A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node**  The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_.  The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_.  Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.  Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.     **Fig. 2**

Incorrect submission (verdict: Wrong Answer):
n = int(input())
tree = [[-1,0,0,0] for _ in range(n)]
t = ["root", "internal node", "leaf"]

for i in range(n):
    _, _, *c = map(int, input().split())
    tree[i][3] = c
    if tree[i][2]:
        tree[i][2] = 1
    for k in c:
        tree[k][0] = i
        tree[k][1] = tree[i][1] + 1
        tree[k][2] = 2

for i in range(n):
    tree[i][2] = t[tree[i][2]]
    print("node {}: parent = {}, depth = {}, {}, {}".format(i, *tree[i]))

Fixed, accepted submission:
def set_pdt(i, p, d):
    u = tree[i]
    u[0], u[1] = p, d
    for c in u[3]:
        set_pdt(c, i, d+1)
    else:
        if u[0] == -1:
            u[2] = "root"
        elif u[3]:
            u[2] = "internal node"
        else:
            u[2] = "leaf"

n = int(input())
tree = [[-1,0,0,0] for _ in range(n)]
root = set(range(n))

for _ in range(n):
    i, k, *c = map(int, input().split())
    tree[i][3] = c
    root -= set(c)
    
set_pdt(root.pop(), -1, 0)

for i in range(n):
    u = tree[i]
    print("node {}: parent = {}, depth = {}, {}, {}".format(i, *u))
Problem:
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.  Print the answer in degrees, but do not print units.

Incorrect submission (verdict: Wrong Answer):
line = list(input())
win = line.count("o")
#print(len(line),win)
match = 15-len(line)
if win + match > 7:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
a = int(input())
print(180*(a-2))
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())  
m = [input() for _ in range(n)]

print('AC × ' + str(m.count('AC')))
print('WA × ' + str(m.count('WA')))
print('TLE × ' + str(m.count('TLE')))
print('RE × ' + str(m.count('RE')))


Fixed, accepted submission:
n = int(input())  
m = [input() for _ in range(n)]

print('AC x ' + str(m.count('AC')))
print('WA x ' + str(m.count('WA')))
print('TLE x ' + str(m.count('TLE')))
print('RE x ' + str(m.count('RE')))
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):
n,s=int(input()),str(input())
ans=0
for i in range(n-1):
  for j in range(i,n):
    x=s[i:j+1]
    if all(x.count(c)==1 for c in x):
      ans+=1
print(ans%(10**9+7))

Fixed, accepted submission:
import collections
n,s=int(input()),list(input())
l=(collections.Counter(s)).values()
ans=1
for x in l:
  ans*=(x+1)
print((ans-1)%(10**9+7))
Problem:
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:    * Question 1: Are you subscribing to Newspaper X?   * Question 2: Are you subscribing to Newspaper Y?  As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.  What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?  Write a program to answer this question.

Incorrect submission (verdict: Wrong Answer):
x, y, z = map(int,input().split())
print(min(y,z), max(0, x-y-z))

Fixed, accepted submission:
x, y, z = map(int,input().split())
print(min(y,z), max(0,y+z-x))
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):
s=str(input())
# print(s)
List=list(s)
List.pop(-1)
# print(List)
ans=0
for i in range((len(List)//2)+1):
    R=List[0:i]
    L=List[i:i+len(R)]
    # print("L",L,"R",R)
    if(R==L):
        print(i,i+1,R,L)
        ans=len(R)*2

print(ans)

Fixed, accepted submission:
s=str(input())
# print(s)
List=list(s)
List.pop(-1)
# print(List)
ans=0
for i in range((len(List)//2)+1):
    R=List[0:i]
    L=List[i:i+len(R)]
    # print("L",L,"R",R)
    if(R==L):
        # print(i,i+1,R,L)
        ans=len(R)*2

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):
import time
print(time.ctime())

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

a = S//3600 #h
b = (S%3600)//60 #m
c = (S%3600)%60 # s

print('{0}:{1}:{2}'.format(a,b,c))
Problem:
Write a program which reads a sequence and prints it in the reverse order.

Incorrect submission (verdict: Wrong Answer):
a = input()
x = input()
y = x.split(' ')
y.sort(reverse=True)
b = ' '.join(y)
print(' '+b)

Fixed, accepted submission:
a = int(input())
x = input()
y = x.split(' ')
c =[]
for i in range(a):
    c.append(y[(a-1)-i])
b = ' '.join(c)
print(b)
Problem:
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.

Incorrect submission (verdict: Wrong Answer):
s=str(input())
x=0
for i in range(len(s)):
  if s.count(s[i])==0:
    x+=1
if x==len(s):
  print('yes')
else:
  print('no')
  

Fixed, accepted submission:
s=str(input())
x=0
for i in range(len(s)):
  if s.count(s[i])==1:
    x+=1
if x==len(s):
  print('yes')
else:
  print('no')
Problem:
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.  Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.

Incorrect submission (verdict: Wrong Answer):
def main() :
    n = int(input())
    nums = []
    for i in range(0, n) :
        x = int(input())
        nums.append(x)

    count = 0
    judge = 0
    for i in nums :
        print(i)
        for j in range(2, i) :
            if (i % j) != 0 :
                judge += 0
            else :
                judge += 1

        if judge == 0 :
            count += 1

    print(count)


if __name__ == '__main__' :
    main()

Fixed, accepted submission:
import math

def isPrime(x) :
    if x == 2 :
        return True

    if x < 2 or x % 2 == 0 :
        return False

    i = 3
    while i <= math.sqrt(x) :
        if x % i == 0 :
            return False
        i += 2

    return True


def main() :
    n = int(input())
    nums = []
    for i in range(n) :
        x = int(input())
        nums.append(x)

    print(sum(map(isPrime, nums)))


if __name__ == '__main__' :
    main()
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())
c = a*b

if c % 2 == 0:
    print("even")
else:
    print("odd")

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

if c % 2 == 1:
    print("Odd")
else:
    print("Even")
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):
c=[list(map(int,input().split())) for _ in range(3)]

for a0 in range(101):
  b0=c[0][0]-a0
  b1=c[0][1]-a0
  b2=c[0][2]-a0
  
  a1= c[1][0]-b0
  if a1 != c[1][1]-b1 or a1 != c[1][2]-b2:
    continue
  a2= c[2][0]-b0
  if a2 != c[2][1]-b1 or a2 != c[2][2]-b2:
    continue
  print("Yes")
  print(a0,a1,a2)
  print(b0,b1,b2)
  
  exit()
print("No")

Fixed, accepted submission:
c=[list(map(int,input().split())) for _ in range(3)]

a0=0
b0=c[0][0]-a0
b1=c[0][1]-a0
b2=c[0][2]-a0

a1= c[1][0]-b0
a2= c[2][0]-b0
if a1 == c[1][1]-b1 == c[1][2]-b2\
and a2 == c[2][1]-b1 == c[2][2]-b2:
  print("Yes")
else:
  print("No")