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)]

for i in range(h):
    l = ''
    for j in range(w):
        if s[i][j] == '#':
            l += s[i][j]
        else:
            l += str(sum([t[max(0,j-1):min(j+2,w)].count('#')\
                     for t in s[max(0,i):min(h,i+2)]]))
    print(l)

Fixed, accepted submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

for i in range(h):
    l = ''
    for j in range(w):
        if s[i][j] == '#':
            l += s[i][j]
        else:
            l += str(sum([t[max(0,j-1):min(j+2,w)].count('#')\
                     for t in s[max(0,i-1):min(h,i+2)]]))
    print(l)
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = int(input())
if (N - A) % 500 == 0:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
n = int(input())
a = int(input())
if (n % 500) <= a:
  print('Yes')
else:
  print('No')
Problem:
ある部屋ではICカードを用いて鍵を開け閉めする電子錠システムを用いている。 このシステムは以下のように動作する。  各ユーザーが持つICカードを扉にかざすと、そのICカードのIDがシステムに渡される。 システムはIDが登録されている時、施錠されているなら開錠し、そうでないのなら施錠し、それぞれメッセージが出力される。 IDが登録されていない場合は、登録されていないというメッセージを出力し、開錠及び施錠はおこなわれない。  さて、現在システムにはN個のID(U1, U2, ……, UN)が登録されており、施錠されている。 M回ICカードが扉にかざされ、そのIDはそれぞれ順番にT1, T2, ……, TMであるとする。 この時のシステムがどのようなメッセージを出力するか求めよ。

Incorrect submission (verdict: Wrong Answer):
if __name__ == '__main__':
    n = int(input())
    reg = []
    for _ in range(n):
        reg.append(input())
    m = int(input())
    state = 0

    for _ in range(m):
        p = input()
        if p in reg and not state:
            print("Opened by %s" % (p))
            state = 1
        elif p in reg and state:
            print("Closed by %s" % (p))
            state = 0
        else:print("Unkown %s" % (p))

Fixed, accepted submission:
if __name__ == '__main__':
    n = int(input())
    reg = []
    for _ in range(n):
        reg.append(input())
    m = int(input())
    state = 0

    for _ in range(m):
        p = input()
        if p in reg and not state:
            print("Opened by %s" % (p))
            state = 1
        elif p in reg and state:
            print("Closed by %s" % (p))
            state = 0
        else:print("Unknown %s" % (p))
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):
hw = input().split()
h = int(hw[0])
w = int(hw[1])

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

ans_field = []
for i in range(h):
  ans_field.append('')
  for j in range(w):
    s = ''
    peris = [[i-1, j-1], [i-1, j], [i-1, j+1], [i, j-1], [i, j+1], [i+1, j-1], [i+1, j], [i+1, j+1]]
    for peri in peris:
      try:
        s += field[peri[0]][peri[1]]
      except:
        pass
    sharp = 0
    for letter in s:
      if letter=='#':
        sharp += 1
    ans_field += str(sharp)

for i in range(h):
  print(ans_field)

Fixed, accepted submission:
hw = input().split()
h = int(hw[0])
w = int(hw[1])

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

ans_field = []
for i in range(h):
  ans_field.append('')
  for j in range(w):
    if field[i][j]=='.':
      s = ''
      
      peris = [[i-1, j-1], [i-1, j], [i-1, j+1], [i, j-1], [i, j+1], [i+1, j-1], [i+1, j], [i+1, j+1]]
      for peri in peris:
        if peri[0]!=-1 and peri[1]!=-1:  
          try:
            s += field[peri[0]][peri[1]]
          except:
            pass
      sharp = 0
      for letter in s:
        if letter=='#':
          sharp += 1
      ans_field[i] += str(sharp)
    else:
      ans_field[i] += '#'

for i in range(h):
  print(ans_field[i])
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):
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    a, b, c = map(int, input().split())

    print('YES' if a <= c <= b else 'NO')
    
if __name__ == '__main__':
    solve()

Fixed, accepted submission:
import sys
 
def solve():
    a, b, c = map(int, input().split())
    
    print('Yes' if a <= c <= b else 'No')

if __name__ == '__main__':
    solve()
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

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

if h%2==0:
  
  print(h*w/2)
else:
  set1=h
  if w%2==0:
    print(set1*w/2)
  else:
    rm=w//2
    print(set1*rm+h//2+1)
  

Fixed, accepted submission:
h, w=map(int, input().split())
if h==1 or w==1:
  print(1)
else:
  ans=(h*w)//2
  if h*w%2==1:
    print(ans+1)
  else:
    print(ans)
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map (int, input().split())
count = 0
for i in range(a+1, b+1):
    if c % i == 0:
        count += 1

print (count)

Fixed, accepted submission:
a, b, c = map (int, input().split())
count = 0
for i in range(a, b+1):
    if c % i == 0:
        count += 1

print (count)
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):

N = int(input())
a = list(map(int,input().split()))
print(a)
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)

Fixed, accepted submission:

N = int(input())
a = list(map(int,input().split()))
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)
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 = input().split()
result = int(a)*int(b)
if result%2 == 0:
    print("even")
else:
    print("odd")

Fixed, accepted submission:
a,b = input().split()
result = int(a)*int(b)
if result%2 == 0:
    print("Even")
else:
    print("Odd")
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

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

for i in range(0,50001):
    if int(i*1.08)==N:
      print(N)
      exit()
print(":(")

Fixed, accepted submission:
N = int(input())
 
for i in range(0,N+1):
    if int(i*1.08)==N:
      print(i)
      exit()
print(":(")
Problem:
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.  At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:    * Choose a (connected) rope with a total length of at least L, then untie one of its knots.  Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Incorrect submission (verdict: Wrong Answer):



n, l = map(int, input().split())
a = list(map(int, input().split()))
idx = 0
for i in range(1, n):
    if a[i - 1] + a[i] >= l:
        idx = i
        break
if idx == 0:
    print("impossibe")
    exit()

print("possible")

ans = [idx]
for i in range(idx - 1, 0, -1):
    ans.append(i)
for i in range(idx + 1, n):
    ans.append(i)
for a in ans[::-1]:
    print(a)

Fixed, accepted submission:



n, l = map(int, input().split())
a = list(map(int, input().split()))
idx = 0
for i in range(1, n):
    if a[i - 1] + a[i] >= l:
        idx = i
        break
if idx == 0:
    print("Impossible")
    exit()

print("Possible")

ans = [idx]
for i in range(idx - 1, 0, -1):
    ans.append(i)
for i in range(idx + 1, n):
    ans.append(i)
for a in ans[::-1]:
    print(a)
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())

for a in range(n+1):
  for b in range(n+1-a):
    c=n-a-b
    if y==a*10000+b*5000+c*1000 and n==a+b+c:
      print(a,b,c)
      break
      

Fixed, accepted submission:
n,y = map(int,input().split())
l=0
for a in range(n+1):
  for b in range(n+1-a):
    c=n-a-b
    if y==a*10000+b*5000+c*1000 and n==a+b+c:
      i=a
      j=b
      k=c
      
      l=1
      break

if l==1:
  print(i,j,k)
else:
  print(-1,-1,-1)
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 = list(input())
for i in range(len(S)):
    if len(S)%2 != 0:
        S.pop()
    else:
        if S[:len(S)//2] == S[len(S)//2:]:
            res = len(S)
            break
        else:
            S.pop()
            S.pop()
print(res)

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

if len(S)%2 != 0:
    S.pop()
else:
    S.pop()
    S.pop()
    
for i in range(len(S)):
    if S[:len(S)//2] == S[len(S)//2:]:
        res = len(S)
        break
    else:
        S.pop()
        S.pop()
print(res)
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):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
  for j in range(b + 1):
    ts = i * 500 + j * 100
    if x - ts >= 0 and (a - ts) % 50 == 0 and (a - ts) // 50 <= c:
      ans += 1
print(ans)


Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
  for j in range(b + 1):
    ts = i * 500 + j * 100
    if x - ts >= 0 and (x - ts) % 50 == 0 and (x - ts) // 50 <= c:
      ans += 1
print(ans)
Problem:
Write a program which reads a list of student test scores and evaluates the performance for each student.  The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.  The final performance of a student is evaluated by the following procedure:    * If the student does not take the midterm or final examination, the student's grade shall be F.   * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.   * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.   * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.   * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.   * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


while True:
    inp = input().split(" ")
    m = int(inp[0])
    f = int(inp[1])
    r = int(inp[2])
    
    if m < 0 and f < 0 and r < 0 :
        break
    
    if m < 0 or f < 0 :
        S = "F"
    else:
        t = m + f
        if t < 50:
            if r >= 50:
                S = "C"
            else:
                S = "D"
        elif t < 65:
            S = "C"
        elif t < 80:
            S = "B"
        else:
            S = "A"

    print(S)

Fixed, accepted submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


while True:
    inp = input().strip().split(" ")
    m = int(inp[0])
    f = int(inp[1])
    r = int(inp[2])
#    print(inp[1])
    
    if m < 0 and f < 0 and r < 0 :
        break
    
    if m < 0 or f < 0 :
        S = "F"
    else:
        t = m + f
        if t < 30:
            S = "F"
        elif t < 50:
            if r >= 50:
                S = "C"
            else:
                S = "D"
        elif t < 65:
            S = "C"
        elif t < 80:
            S = "B"
        else:
            S = "A"

    print(S)
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):
a,b,c = map(int,input().split())
if 0 <= c-a <= b:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,c = map(int,input().split())
if 0 <= c-a <= b:
    print("YES")
else:
    print("NO")
Problem:
We have an N \times N square grid.  We will paint each square in the grid either black or white.  If we paint exactly A squares white, how many squares will be painted black?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
nn=n**n
a=int(input())
print(nn-a)

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

a=int(input())

print(n**2-a)
Problem:
There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all.  There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.  Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.  Compute the minimum number of days on which the same type of cake as the previous day will be eaten.

Incorrect submission (verdict: Wrong Answer):
K, T = map(int, input().split())
a = list(map(int, input().split()))
if max(a) < (K+1)//2:
	print(max(a) - (K+1)//2)
else:
	print(0)


Fixed, accepted submission:
K, T = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)-max(a)
if max(a) - s < 2:
	print(0)
else:
	print(max(a)-s-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):
X = int(input())
yokin = 100

def genYokin():
    global yokin
    return int(yokin*1.01)

year_cnt = 0
while True:
    if X < yokin:
        break
    yokin = genYokin()
    year_cnt += 1

print(year_cnt)

Fixed, accepted submission:
X = int(input())
yokin = 100

def getNextYokin():
    global yokin
    return int(yokin*1.01)

year_cnt = 0
while True:
    if X <= yokin:
        break
    yokin = getNextYokin()
    year_cnt += 1

print(year_cnt)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b)):
    ans.append(i)
for j in range(max(a,b-k+1),b+1):
    ans.append(j)
ans=sorted(list(set(ans)))
print(ans)
for i in range(len(ans)):
    print(ans[i])

Fixed, accepted submission:
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b)):
    ans.append(i)
for j in range(max(a,b-k+1),b+1):
    ans.append(j)
ans=sorted(list(set(ans)))
for i in range(len(ans)):
    print(ans[i])
Problem:
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.  You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.

Incorrect submission (verdict: Wrong Answer):
while(True):
    max=0
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<m):
                max=sum
    if m==0:
        print("NONE")
    else:
        print(max)





Fixed, accepted submission:
maxs=[]
while(True):
    max=-1
    
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<=m):
                max=sum
    maxs.append(max)

for i in maxs:
    if i==-1:
        print("NONE")
    else:
        print(i)
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):
lis_1=[1,3,5,7,8,10,12]
lis_2=[4,6,9,11]
lis_3=[2]
x,y=map(int,input().split())
if (x,y) in (lis_1 or lis_2 or lis_3):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
lis=[1,3,1,2,1,2,1,1,2,1,2,1]
x,y=map(int,input().split())
print("Yes" if lis[x-1]==lis[y-1] else "No")
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

Incorrect submission (verdict: Wrong Answer):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c1,c2=0,0
for i in range(m):
  if i < x:
    c1+=1
  else:
    c2+=1
print(min(c1,c2))

Fixed, accepted submission:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c1,c2=0,0
for i in a:
  if i < x:
    c1+=1
  else:
    c2+=1
print(min(c1,c2))
Problem:
AtCoder Mart sells 1000000 of each of the six items below:    * Riceballs, priced at 100 yen (the currency of Japan) each   * Sandwiches, priced at 101 yen each   * Cookies, priced at 102 yen each   * Cakes, priced at 103 yen each   * Candies, priced at 104 yen each   * Computers, priced at 105 yen each  Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible.   (Ignore consumption tax.)

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

digit = len(str(n))
min = 10**(digit-1)
max = min * 1.05


if n >= min and n <= max:
  print(1)
else:
  print(0)


Fixed, accepted submission:
n = input()

digit = len(n)
num = int(n)

min = 0
if digit == 3:
  min = int(n[0] + '00')
elif digit == 4:
  min = int(n[0] + n[1] + '00')
elif digit == 5:
  min = int(n[0] + n[1] + n[2] + '00')
elif digit == 6:
  min = int(n[0] + n[1] + n[2] + n[3] + '00')
else:
  min = 9999999999
  
max = min * 1.05
if num >= min and num <= max:
  print(1)
else:
  print(0)