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 = [input() for _ in range(H)]
answer = [[0 if cell == '.' else '#' for cell in row] for row in S]

dxy = [(-1,1),(-1,0),(-1,-1),(0,1),(0,-1),(1,1),(1,0),(1,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            continue
        for dx, dy in dxy:
            x = i + dx
            y = j + dy
            if x < 0 or x >= H:
                continue
            if y <= 0 or y >= W:
                continue
            if S[x][y] == '#':
                continue
            answer[x][y] += 1
#print(answer)
for i in answer:
    print(*i,sep='')

Fixed, accepted submission:
H,W = map(int,input().split())
S = [input() for _ in range(H)]
answer = [[0 if cell == '.' else '#' for cell in row] for row in S]

dxy = [(-1,1),(-1,0),(-1,-1),(0,1),(0,-1),(1,1),(1,0),(1,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            continue
        for dx, dy in dxy:
            x = i + dx
            y = j + dy
            if x < 0 or x >= H:
                continue
            if y < 0 or y >= W:
                continue
            if S[x][y] == '#':
                continue
            answer[x][y] += 1
#print(answer)
for i in answer:
    print(*i,sep='')
Problem:
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered.  This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source.  DFS timestamps each vertex as follows:    * $d[v]$ records when $v$ is first discovered.   * $f[v]$ records when the search finishes examining $v$’s adjacency list.  Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules:    * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively.   * IDs in the adjacency list are arranged in ascending order.   * The program should report the discover time and the finish time for each vertex.   * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID.   * The timestamp starts with 1.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
g = [0] * n

time = 0

for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

def search(i):
    global time
    time = time + 1
    d[i] = time
    g[i] = 1
    for j in range(i, n):
        if (graph[i][j] == 1) & (g[j] == 0):
            search(j)
    time = time + 1
    f[i] = time if f[i] == 0 else f[i]


search(0)
[print(i+1, d[i], f[i]) for i in range(n)]


Fixed, accepted submission:
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
g = [0] * n

time = 0

for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

def search(i):
    global time
    time = time + 1
    d[i] = time
    g[i] = 1
    for j in range(n):
        if (graph[i][j] == 1) & (g[j] == 0):
            search(j)
    time = time + 1
    f[i] = time

for i in range(n):
    if g[i] == 0:
        search(i)
[print(i+1, d[i], f[i]) for i in range(n)]
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())

a = 0
		
while N%(2**a)==0:
	a += 1

b = 2**(a-1)

print(b)

Fixed, accepted submission:
import math

N = int(input())

M = math.floor(math.log2(N))

print(2**M)
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 = list(input())
print(n)
if n[1] != n[2]:
  print('No')
elif n[0] == n[1] or n[2] == n[3]:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
n = list(input())
#print(n)
if n[1] != n[2]:
  print('No')
elif n[0] == n[1] or n[2] == n[3]:
  print('Yes')
else:
  print('No')
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

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

if a[2]>=a[0] and a[2]<=a[1]:
  print('YES')
  
else:
  print('NO')

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

if (a[2]>=a[0]) and (a[2]<=a[1]):
  print('Yes')
  
else:
  print('No')
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())
alice = 0
bob = 0
cards = [int(val) for val in input().split()]

cards = sorted(cards, reverse=True)

print(cards)

for i in range(n):
    if i % 2 == 0:
        alice += int(cards[i])
    else:
        bob += int(cards[i])
        
print(alice - bob)

Fixed, accepted submission:
n = int(input())
a,b = 0,0
cards = [int(val) for val in input().split()]
 
cards = sorted(cards, reverse=True)
 
for i in range(n):
    if i % 2 == 0:
        a += cards[i]
    else:
        b += cards[i]
        
print(a - b)
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())
S = [input() for i in range(N)]
print("AC × "+str( S.count("AC")))
print("WA × "+str( S.count("WA")))
print("TLE × "+str( S.count("TLE")))
print("RE × "+str( S.count("RE")))

Fixed, accepted submission:
N = int(input())
S = [input() for i in range(N)]
print("AC x "+str( S.count("AC")))
print("WA x "+str( S.count("WA")))
print("TLE x "+str( S.count("TLE")))
print("RE x "+str( S.count("RE")))
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

Incorrect submission (verdict: Wrong Answer):

value = int(input())
seat_list = []
people = 0
while True:
	try:
		seat = input()
		seat_list.append(seat.split(" "))
	except EOFError:
		break

def aaa(seat_list, people):
		people = seat_list[len(seat_list)-1] - seat_list[0]

print(people)


Fixed, accepted submission:
n = int(input())
cnt = 0
for i in range(n):
    l, r = map(int, input().split())
    cnt += (r-l+1)
print(cnt)
Problem:
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.  Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** :    * Add 2 to a_i.   * Add 1 to b_j.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
for i in range(n):
    if b[i]<a[i]:
        d+=b[i]-a[i]
    else:
        k=b[i]-a[i]
        if k%2==1:
            d+=1
            c+=(k+1)//2
        else:
            c+=k//2
print("Yes" if d>=c else"No")

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
for i in range(n):
    if b[i]<=a[i]:
        d+=a[i]-b[i]
    else:
        k=b[i]-a[i]
        if k%2==1:
            d+=1
            c+=(k+1)//2
        else:
            c+=k//2
print("Yes" if c>=d else"No")
Problem:
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.  The i-th operation is as follows:    1. Append a_i to the end of b.   2. Reverse the order of the elements in b.  Find the sequence b obtained after these n operations.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
n_list = list(map(int, input().split()))
new_list = []

for i in range(n):
    tmp = int(n_list[0])
    n_list.pop(0)
    new_list.append(tmp)
    new_list.reverse()

print(new_list)


Fixed, accepted submission:
from collections import deque
n = int(input())
a_list = list(map(int, input().split()))
q = deque([]) 
if n%2 == 0:
    for i in range(n):
        if i%2 == 0:
            q.append(a_list[i])
        else:
            q.appendleft(a_list[i])
else:
    for i in range(n):
        if i%2 == 1:
            q.append(a_list[i])
        else:
            q.appendleft(a_list[i])
b = map(str, list(q))
print(' '.join(b))
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):
alpha = [chr(i) for i in range(97,97 + 26)]

def Count(s,t):
	ret = 0
	for i in alpha:
		if i in s and i in t:ret+=1
	return ret

n = int(input())
s = input()

ans = 0
for i in range(1,n):
	print(s[:i],s[i:])
print(ans)

Fixed, accepted submission:
alpha = [chr(i) for i in range(97,97 + 26)]

def Count(s,t):
	ret = 0
	for i in alpha:
		if i in s and i in t:ret+=1
	return ret

n = int(input())
s = input()

ans = 0
for i in range(1,n):
	ans = max(ans,Count(s[:i],s[i:]))
print(ans)
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Incorrect submission (verdict: Wrong Answer):
s = input()
pos = s.find('9')
if pos != -1:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
s = input()
pos = s.find('9')
if pos != -1:
    print("Yes")
else:
    print("No")
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 = [int(x) for x in input().split()]
c = a * b
print("Yes" if c % 2 == 0 else "No")

Fixed, accepted submission:
a, b = [int(x) for x in input().split()]
c = a * b
print("Even" if c % 2 == 0 else "Odd")
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())
ans = 0
for i in range(n):
    if a <= sum(list(map(int, list(str(i+1))))) <= b:
        ans += 1
print(ans)

Fixed, accepted submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
Problem:
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
max(a + b, a - b, a * b)


Fixed, accepted submission:
a, b = map(int, input().split())
print(max(a + b, a - b, a * b))
Problem:
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.  Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:    * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.  What is the minimum number of operations required to achieve the objective?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i]:
        count += 1
    else:
        count += 2
print(count)


Fixed, accepted submission:
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or a[i] == c[i]:
        count += 1
    else:
        count += 2
print(count)
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):
a,b,x=map(int,input().split())
ans=(b-a+1)/x
print(round(ans))

Fixed, accepted submission:
a,b,x=map(int,input().split())
ans_a=(a-1)//x
ans_b=b//x
print(ans_b-ans_a)
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
a,b=map(str,input().split())
num=int(a+b)
print(num)

ans=num**0.5

if ans//1==ans:
    print('Yes')
else:
    print('No')

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

ans=num**0.5

if (ans//1)**2==num:
    print('Yes')
else:
    print('No')
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
N,Y = map(int,input().split())
ans = 0
for a in range(N+1):
  for b in range(N+1-a):
    c = N-a-b
    if a*10000+b*5000+c*1000 == Y:
      z = a
      y = b
      x = c
      ans = 1
      break
      
if ans == 1:
  print(x,y,z)
else:
  print(-1,-1,-1)

Fixed, accepted submission:
N,Y = map(int,input().split())
ans = 0
for a in range(N+1):
  for b in range(N+1-a):
    c = N-a-b
    if a*10000+b*5000+c*1000 == Y:
      z = a
      y = b
      x = c
      ans = 1
      break
      
if ans == 1:
  print(z,y,x)
else:
  print(-1,-1,-1)
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

Incorrect submission (verdict: Wrong Answer):

C1 = str(input())
C2 = str(input())


ori_str = C1 + C2


rev_str = ori_str[-1::-1]


if ori_str == rev_str:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:

C1 = str(input())
C2 = str(input())


ori_str = C1 + C2


rev_str = ori_str[-1::-1]


if ori_str == rev_str:
    print("YES")
else:
    print("NO")
Problem:
A railroad running from west to east in Atcoder Kingdom is now complete.  There are N stations on the railroad, numbered 1 through N from west to east.  Tomorrow, the opening ceremony of the railroad will take place.  On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.  The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.  Here, it is guaranteed that F_i divides S_i.  That is, for each Time t satisfying S_i≤t and t％F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A％B denotes A modulo B, and there will be no other trains.  For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
res = [0] * n
for i in range(1, n):
  c, s, f = map(int, input().split())
  res[i-1] += s + c
  for j in range(i-1):
    if res[j] < s:
      res[j] = s + c
    elif res[j] == s:
      res[j] += c
    else:
      if (res[j] - s) % f == 0:
        res[j] += c
      else:
        res[j] += f + c
print(res)

Fixed, accepted submission:
n = int(input())
res = [0] * n
for i in range(1, n):
  c, s, f = map(int, input().split())
  res[i-1] += s + c
  for j in range(i-1):
    if res[j] < s:
      res[j] = s + c
    elif res[j] == s:
      res[j] += c
    else:
      if (res[j] - s) % f == 0:
        res[j] += c
      else:
        res[j] = s + (((res[j] - s) // f) + 1) * f + c
for elem in res:
  print(elem)
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

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

if s[:a].isdecimal()==True and s[-b:]==True and s[a]=='-':
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b=map(int,input().split())
s=input()
if 1<=a<=5 and 1<=b<=5:
    if s[a]=="-":
        if s[0:a].isdecimal() and s[a+1:a+b+1].isdecimal():
            print("Yes")
            exit()
print("No")
Problem:
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).  In particular, any integer sequence is similar to itself.  You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.  How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?

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

even = odd = 0

for a in A:
  if a%2:
    odd += 1
  else:
    even += 1
    
print(3**n - (odd+(even*2)**n))

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

even = odd = 0

for a in A:
  if a%2:
    odd += 1
  else:
    even += 1
    
print(3**n - 2**even)
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):
n = int(input())
print(int(n ** 0.5))


Fixed, accepted submission:
n = int(input())
print(int(n ** 0.5) ** 2)
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):
import itertools


def sum_strlong(strlong):
    ans = int(strlong)
    for i in range(1, len(strlong)):
        for comb in itertools.combinations(range(len(strlong)-1), i):
            integer = ''
            for j, digit in enumerate(strlong):
                integer += digit
                if j in comb:
                    integer += '+'
            ans += eval(integer)
    return ans


if __name__ == '__main__':
    print(sum_strlong('9'*10))

Fixed, accepted submission:
import itertools


def sum_strlong(strlong):
    ans = int(strlong)
    for i in range(1, len(strlong)):
        for comb in itertools.combinations(range(len(strlong)-1), i):
            integer = ''
            for j, digit in enumerate(strlong):
                integer += digit
                if j in comb:
                    integer += '+'
            ans += eval(integer)
    return ans


def main():
    print(sum_strlong(input()))


main()
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())
for i in range(n):
    t, x, y = map(int, input().split())
    if x+y>t or (x+y-t)%2 !=0:
        print('NO')
        exit()
print('YES')

Fixed, accepted submission:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x+y>t or (x+y-t)%2 ==1:
        print('No')
        exit()
print('Yes')
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Incorrect submission (verdict: Wrong Answer):
def bin(a):
  return 2*a

def ten(a):
  return a+10

N = int(input())
K = int(input())
value = 1
for i in range(N):
  if bin(value) <= ten(value) :
    value = bin(value)
  else:
    value = ten(value)
print(value)

Fixed, accepted submission:
def bin(a):
  return 2*a

def ten(a):
  return a+K

N = int(input())
K = int(input())
value = 1
for i in range(N):
  if bin(value) <= ten(value) :
    value = bin(value)
  else:
    value = ten(value)
print(value)