TnT/CodeNet4Repair huggingface dataset:
Problem:
We have a grid with H rows and W columns. At first, all cells were painted white.  Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.  Compute the following:    * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?

Incorrect submission (verdict: Wrong Answer):
h,w,n = map(int,input().split())
s = [[0 for j in range(w+2)] for i in range(h+2)]
#print(s)
for i in range(0,n):
    x,y = map(int,input().split())
    s[x-1][y-1] += 1
    s[x-1][y] += 1
    s[x-1][y+1] += 1
    s[x][y-1] += 1
    s[x][y] += 1
    s[x][y+1] += 1
    s[x+1][y-1] += 1
    s[x+1][y] += 1
    s[x+1][y+1] += 1

print(s)
ans = [0] * 10
for i in range(2,h):
    for j in range(2,w):
        ans[s[i][j]] += 1
for i in range(0,10):
    print(ans[i])


Fixed, accepted submission:
def add_memo(tate,yoko):
    global memo
    if 2 <= tate <= h-1:
        if 2 <= yoko <= w-1:
            memo.append([tate,yoko])

h,w,n = map(int,input().split())
#print(s)
memo = []
for i in range(0,n):
    x,y = map(int,input().split())
    add_memo(x-1,y-1)
    add_memo(x-1,y)
    add_memo(x-1,y+1)
    add_memo(x,y-1)
    add_memo(x,y)
    add_memo(x,y+1)
    add_memo(x+1,y-1)
    add_memo(x+1,y)
    add_memo(x+1,y+1)

memo.sort()
ans = [0] * 10
ans[0] = (h-2)*(w-2)
tmp_x = 0
tmp_y = 0
count = 0
for i in range(0,len(memo)):
    if tmp_x == memo[i][0] and tmp_y == memo[i][1]:
        ans[count] -= 1
        count += 1
        ans[count] += 1
    else:
        ans[0] -= 1
        count = 1
        ans[count] += 1
    tmp_x = memo[i][0]
    tmp_y = memo[i][1]
#    print(memo[i],count)

for i in range(0,10):
    print(ans[i])
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 = input()
print(int(N)*(int(N)+1)/2)


Fixed, accepted submission:
N = input()
s = 0
i = 1
while i <= int(N):
	s = s + i
	i = i + 1
print(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 = list(input())

b = s.count("*")
b_l = 0
lst =[n - b]

for i in range(len(s)):
	b_l += (s[i] == "*")
	lst.append(2 * b_l + (n - i - 1) - b)
print(min(lst))

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

b = 0
w = s.count(".")
m = w

for i in range(n):
	if s[i] == "#":
		b += 1
	else:
		w -= 1
	m = min(m, b + w)
print(m)
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())
print('Yes' if a+b==c else 'No')

Fixed, accepted submission:
a,b,c=map(int,input().split())
print('Yes' if a+b>=c else 'No')
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):
tate, yoko = map(int, input().split())
s  = [input()  for i in range(tate)]
dxy = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
for i in range(tate):
    for j in range(yoko):
        if s[i][j] == "#":
            save = []
            for dx, dy in dxy:
                if i + dy < 0 or i + dy > tate - 1 or j + dx < 0 or j + dx > yoko - 1: continue
                if s[i + dy][j + dx] == "#": 
                    save.append("#")
                    break
            if "#" in save: continue
            else:
                print("NO")
                exit()
print("YES")

Fixed, accepted submission:
tate, yoko = map(int, input().split())
s  = [input()  for i in range(tate)]
dxy = [(-1, 0), (0, -1), (0, 1), (1, 0),]
for i in range(tate):
    for j in range(yoko):
        if s[i][j] == "#":
            save = []
            for dx, dy in dxy:
                if i + dy < 0 or i + dy > tate - 1 or j + dx < 0 or j + dx > yoko - 1: continue
                if s[i + dy][j + dx] == "#": 
                    save.append("#")
                    break
            if "#" in save: continue
            else:
                print("No")
                exit()
print("Yes")
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

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

sum = 700

for i in s:
    if i == "o":
        sum += 100

print(sum)

Fixed, accepted submission:
import sys

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

if a <= x <= a + b:
    print("YES")
else:
    print("NO")
Problem:
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.  He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.  To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.  How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

Incorrect submission (verdict: Wrong Answer):
import bisect

if __name__ == "__main__":
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    BB = []
    CC = []

    print(A)
    print(B)
    print(C)
    print('-------')

    cnt = 0

    for i in range(N):
        b = B[i]
        a_index = bisect.bisect_left(A, b)
        if i == 0:
            BB.append(a_index)
        else:
            BB.append(BB[i-1] + a_index)

    for i in range(N):
        c = C[i]
        b_index = bisect.bisect_left(B, c)
        if b_index == 0:
            CC.append(0)
            continue
        if i == 0:
            CC.append(BB[b_index - 1])
        else:
            CC.append(CC[i-1] + BB[b_index - 1])

    
    # print(CC)

    print(CC[-1])


Fixed, accepted submission:
import bisect

if __name__ == "__main__":
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    BB = []
    CC = []

    # print(A)
    
    # print(C)
    # print('-------')

    cnt = 0

    for i in range(N):
        b = B[i]
        a_index = bisect.bisect_left(A, b)
        if i == 0:
            BB.append(a_index)
        else:
            BB.append(BB[i-1] + a_index)

    for i in range(N):
        c = C[i]
        b_index = bisect.bisect_left(B, c)
        if b_index == 0:
            CC.append(0)
            continue
        if i == 0:
            CC.append(BB[b_index - 1])
        else:
            CC.append(CC[i-1] + BB[b_index - 1])

    
    # print(CC)

    print(CC[-1])
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
l = input().split()
x = int(l[0])
t = int(l[1])
y = x - t
print('{0}'.format(y))

Fixed, accepted submission:
def abs(x):
	if x >= 0:
		return x
	else:
		return -1 * x
		
ls = list(map(int,input().split()))
if abs(ls[0] - ls[1]) < abs(ls[0] - ls[2]):
	print ('A')
else:
	print ('B')
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
ticket = list(str(input()))

for state in range(1 << (len(ticket)-1)):
    fomula = ticket[0] + ''.join(('+' if state >> i & 1 else '-') + x for i, x in enumerate(ticket[1:]))
    if eval(fomula) == 7:
        print(fomula)
        exit()


Fixed, accepted submission:


numbers = list(input())

for i in range(1 << (len(numbers)-1)):
    tmp = numbers[0]
    for j in range(len(numbers)-1):  
        if (i >> j) & 1:
            tmp += "+"
        else:
            tmp += "-"
        tmp += numbers[j+1]
    if eval(tmp) == 7:
        print(tmp+"=7")
        break
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):


ns=input().split()
for i in range(len(ns)):
     ns[i]=int(ns[i])
asum=sum(ns)
amin=min(ns)
amax=max(ns)
print(amin, amax,asum)


Fixed, accepted submission:

n=input()
ns=input().split()
for i in range(len(ns)):
     ns[i]=int(ns[i])
asum=sum(ns)
amin=min(ns)
amax=max(ns)
print(amin, amax,asum)
Problem:
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.  Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s.  Given the name of the contest, print the abbreviation of the name.

Incorrect submission (verdict: Wrong Answer):
s=input()
print("A" + s[0] + "C")

Fixed, accepted submission:
s=input()
print("A"+s[8]+"C")
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):
data = [int(i) for i in input().split(" ")]
print(data)
total = 0
for i in data:
    if i==7 or i==5:
        total += i
if total == 17:
  	print("YES")
else:
  	print("NO")

Fixed, accepted submission:
tupni = [int(idx) for idx in input().split(" ")]
tupni.sort()
if tupni == [5,5,7]:
  print("YES")
else:
  print("NO")
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
#!usr/bin/env python3

def main():
    count = 1
    while True:
        x = int(input())
        print('Case ' + str(count) + ': ' + str(x))
        count += 1
        if x == 0:
            break


if __name__ == '__main__':
    main()



# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_B

Fixed, accepted submission:
#!usr/bin/env python3

def main():
    count = 1
    while True:
        x = int(input())
        if x == 0:
            break
        print('Case %d: %d' % (count, x))
        count += 1


if __name__ == '__main__':
    main()
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("No")
else:
    print("Yes")


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

if A + B >= C:
    print("Yes")
else:
    print("No")
Problem:
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:      a + b + c + d = n      For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).

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

n=int(input())
out=0
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				if(i+j+k+l==n):out+=1
print(out)


#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Fixed, accepted submission:
import sys
import math as mas

x=[0]*60
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				x[i+j+k+l]+=1
for i in sys.stdin:
	print(x[int(i)])

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))
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):
a, b, c = map(str, input().split())
if a == b and b == c:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
a, b, c = map(str, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
Problem:
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.

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


root = pre[1]
pre = iter(pre).__next__

def dfs(l, r):
    if l >= r:
        return
    c = pre()
    m = ino.index(c)
    dfs(l, m)
    dfs(m+1, r)
    print(c)
    
dfs(0, len(ino))




Fixed, accepted submission:
n = int(input())
pre = list(map(int, input().split()))
ino = list(map(int, input().split()))

d = []
root = pre[0]
pre = iter(pre).__next__

def dfs(l, r):
    global d
    if l >= r:
        return
    c = pre()
    m = ino.index(c)
    dfs(l, m)
    dfs(m+1, r)
    d += [c]
    
dfs(0, len(ino))
print(*d)
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
def main(sx, sy, tx, ty):
    answer = ''
    d_x = tx - sx
    d_y = ty - sy

    one_right = 'R' * d_x
    one_up    = 'U' * d_y
    answer += one_right + one_up

    one_down  = 'D' * d_y
    one_left  = 'L' * (d_x + 1)
    answer += one_down + one_left + 'L'

    two_up    = 'U' * (d_y + 1)
    two_right = 'R' * (d_x + 1)
    answer += two_up + two_right + 'DR'

    two_down  = 'D' * (d_y + 1)
    two_left  = 'L' * (d_x + 1)
    answer += two_down + two_left + 'U'

    return answer

# print(main(
#     0, 0, 1, 2
# ))

if __name__ == '__main__':
    sx, sy, tx, ty = [int(e) for e in input().split()]
    print(main(sx, sy, tx, ty))


Fixed, accepted submission:
def main(sx, sy, tx, ty):
    answer = ''
    d_x = tx - sx
    d_y = ty - sy

    one_right = 'R' * d_x
    one_up    = 'U' * d_y
    answer += one_up + one_right

    one_down  = 'D' * d_y
    one_left  = 'L' * (d_x + 1)
    answer += one_down + one_left

    two_up    = 'U' * (d_y + 1)
    two_right = 'R' * (d_x + 1)
    answer += two_up + two_right + 'DR'

    two_down  = 'D' * (d_y + 1)
    two_left  = 'L' * (d_x + 1)
    answer += two_down + two_left + 'U'

    return answer

# print(main(
#     0, 0, 1, 2
# ))

if __name__ == '__main__':
    sx, sy, tx, ty = [int(e) for e in input().split()]
    print(main(sx, sy, tx, ty))
Problem:
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.

Incorrect submission (verdict: Wrong Answer):
import sys

num = int(sys.stdin.readline().strip())

for i in range(num):
    data = sys.stdin.readline().strip().split(' ')
    a = int(data[0])
    b = int(data[1])
    c = int(data[2])
    if a == b and b == c:
        print('YES')
    else:
        print('NO')
        

Fixed, accepted submission:
import sys

def is_right(edges):
    max_len = max(edges)
    edges.remove(max_len)
    return max_len ** 2 == edges[0] ** 2 + edges[1] ** 2
    
num = int(sys.stdin.readline().strip())

for i in range(num):
    data = sys.stdin.readline().strip().split(' ')
    a = int(data[0])
    b = int(data[1])
    c = int(data[2])
    if is_right([a, b, c]):
        print('YES')
    else:
        print('NO')
Problem:
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.  You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.  Determine if there are more people wearing a red hat than people wearing a blue hat.

Incorrect submission (verdict: Wrong Answer):
s=input()
r=s.count("R")
b=s.count("B")
print("Yes" if r>b else "No")

Fixed, accepted submission:
n=input()
s=input()
r=s.count("R")
b=s.count("B")
print("Yes" if r>b else "No")
Problem:
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.  They start simultaneously at the same point and moves as follows **towards the east** :    * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.   * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.  How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.

Incorrect submission (verdict: Wrong Answer):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    t1, t2 = LI()
    a1, a2 = LI()
    b1, b2 = LI()

    if a1 < b1:
        tmp = b1
        b1 = a1
        a1 = tmp

        tmp = b2
        b2 = a2
        a2 = tmp

    l1 = (a1 - b1) * t1
    l2 = (a2 - b2) * t2
    l3 = l1 + l2
    print(l1, l2)
    if l3 == 0:
        print("infinity")
        return
    if l3 > 0:
        print(0)
        return
    ans = 1
    print(ans + 2 * (l1 // (-l3)))






if __name__ == '__main__':
    main()

Fixed, accepted submission:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    t1, t2 = LI()
    a1, a2 = LI()
    b1, b2 = LI()

    if a1 < b1:
        tmp = b1
        b1 = a1
        a1 = tmp

        tmp = b2
        b2 = a2
        a2 = tmp

    l1 = (a1 - b1) * t1
    l2 = (a2 - b2) * t2
    l3 = l1 + l2

    if l3 == 0:
        print("infinity")
        return
    if l3 > 0:
        print(0)
        return
    ans = 1
    if l1 % (-l3) == 0:
        print(ans + 2 * (l1 // (-l3)) - 1)
        return
    print(ans + 2 * (l1 // (-l3)))






if __name__ == '__main__':
    main()
Problem:
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.

Incorrect submission (verdict: Wrong Answer):
S = input()
w = int(input())
stack = []
for x in range(len(S)//w):
    stack.append(S[x*w])
print("".join(stack))


Fixed, accepted submission:
import math
S = input()
w = int(input())
stack = []
for x in range(math.ceil(len(S)/w)):
    stack.append(S[x*w])
print("".join(stack))