TnT/CodeNet4Repair huggingface dataset:
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()) #500
atani=500
b=int(input())
btani=100
c=int(input())
ctani=50
x=int(input())

asum=0
bsum=0
csum=0
cnt=0

for aa in range(0, a):
  #print(asum)
  if asum > x:
    break
  elif asum == x:
    cnt += 1
  
  bsum=0
  for bb in range(0, b):
    #print('bsum:{}'.format(asum + bsum))
    if asum + bsum > x:
      break
    elif asum + bsum == x:
      cnt += 1
      
    csum=0
    for cc in range(0, c):
      if asum + bsum + csum > x:
        break
      elif asum + bsum + csum == x:
        cnt += 1
        
      csum += ctani
    
    bsum += btani
  
  asum += atani

bsum=0        
for bb in range(0, b):
    #print('bsum:{}'.format(asum + bsum))
    if bsum > x:
      break
    elif bsum == x:
      cnt += 1
      
    csum=0
    for cc in range(0, c):
      if bsum + csum > x:
        break
      elif bsum + csum == x:
        cnt += 1
        
      csum += ctani
    
    bsum += btani

csum=0        
for cc in range(0, c):
    if csum > x:
      break
    elif csum == x:
      cnt += 1
        
    csum += ctani
    
print(cnt)

Fixed, accepted submission:
a=int(input()) #500
atani=500
b=int(input())
btani=100
c=int(input())
ctani=50
x=int(input())

asum=0
bsum=0
csum=0
cnt=0

for aa in range(0, a+1):
  if asum > x:
    break
  elif asum == x:
    cnt += 1
    break
    
  
  bsum=0
  for bb in range(0, b+1):
    if asum + bsum > x:
      break
    elif asum + bsum == x:
      cnt += 1
      break
      
      
    csum=0
    for cc in range(0, c+1):
      if asum + bsum + csum > x:
        break
      elif asum + bsum + csum == x:
        cnt += 1
        
        
      csum += ctani
    
    bsum += btani
  
  asum += atani

print(cnt)
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())
res = 0
for i in range(1,n+1):
  tmp = 0
  for j in range(len(str(i))):
    tmp += int(str(i)[j])
  if a <= tmp <= b:
    res += 1
print(res)

Fixed, accepted submission:
n,a,b = map(int, input().split())
res = 0
for i in range(1,n+1):
  tmp = 0
  for j in range(len(str(i))):
    tmp += int(str(i)[j])
  if a <= tmp <= b:
    res += i
print(res)
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
i = list(map(int, input().split()))
a = i[0]
b = i[1]

if b > a:
  print(a)
else:
  print(a - 1)

Fixed, accepted submission:
i = list(map(int, input().split()))
a = i[0]
b = i[1]

if b >= a:
  print(a)
else:
  print(a - 1)
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):
a = list(input())
for i in range(8):
    b = []
    for j in range(4):
        b.append(a[j])
        if j == 3:
            pass
        else:
            if((i>>j)&1):
                b.append('+')
            else:
                b.append('-')
    c = ''.join(b)
    if eval == 7:
        break
    else:
        pass
print(c+'=4')

Fixed, accepted submission:
a = list(input())
for i in range(8):
    b = []
    for j in range(4):
        b.append(a[j])
        if j == 3:
            pass
        else:
            if((i>>j)&1):
                b.append('+')
            else:
                b.append('-')
    c = ''.join(b)
    if eval(c) == 7:
        break
    else:
        pass
print(c+'=7')
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 = 2
# a = [[3,1,2],[6,1,1]]
N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'YES'
for i in range(N):
    t1 = int(b[i][0])
    x1 = int(b[i][1])
    y1 = int(b[i][2])
    t2 = int(b[i+1][0])
    x2 = int(b[i+1][1])
    y2 = int(b[i+1][2])

    td = t2-t1
    xyd = (x2+y2) - (x1+y1)

    
    if((td%2==xyd%2) & (td>=xyd)):
        rtn = rtn
    else:
        rtn = 'NO'

print(rtn)



Fixed, accepted submission:
# N = 2
# a = [[3,1,2],[6,1,1]]
N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'Yes'
for i in range(N):
    t1 = int(b[i][0])
    x1 = int(b[i][1])
    y1 = int(b[i][2])
    t2 = int(b[i+1][0])
    x2 = int(b[i+1][1])
    y2 = int(b[i+1][2])

    td = t2-t1
    xyd = (x2+y2) - (x1+y1)

    
    if((td%2==xyd%2) & (td>=xyd)):
        rtn = rtn
    else:
        rtn = 'No'

print(rtn)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

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

print("Yes" if n < s else "No")

Fixed, accepted submission:
print("Yes" if sorted((input())) < sorted((input()))[::-1] else "No")
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())
sl = []
bl = [[0 for _ in range(w)] for _ in range(h)]

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

def scheck(s):
    if s == "#":
        return 1
    else:
        return 0
        
def check(i,j,sl):
    cnt = 0
    for k in range(-1,2):
        for l in range(-1,2):
            if h > i+k >= 0 and w > j+l >= 0:
                cnt += scheck(sl[i+k][j+l])
    return cnt

for i in range(h):
    for j in range(w):
        if sl[i][j] == ".":
            bl[i][j] = check(i,j,sl)
        else:
            bl[i][j] = "#"

for b in bl:
    print(*b)

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

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

def scheck(s):
    if s == "#":
        return 1
    else:
        return 0
        
def check(i,j,sl):
    cnt = 0
    for k in range(-1,2):
        for l in range(-1,2):
            if h > i+k >= 0 and w > j+l >= 0:
                cnt += scheck(sl[i+k][j+l])
    return str(cnt)

for i in range(h):
    for j in range(w):
        if sl[i][j] == ".":
            bl[i][j] = check(i,j,sl)
        else:
            bl[i][j] = "#"

for b in bl:
    t = ''.join(b)
    print(t)
Problem:
Snuke built an online judge to hold a programming contest.  When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)  Determine whether the judge can return the string `AC` as the verdict to a program.

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

if s.count("AC") >=1:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
s=input()

if s.count("AC") >=1:
  print("Yes")
else:
  print("No")
Problem:
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.

Incorrect submission (verdict: Wrong Answer):
N, K = map(int, input().split())
nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))
nums.sort()
print(nums)

sumb = 0
for n in nums:
    sumb += n[1]
    if sumb >= K:
        print(n[0])
        break

Fixed, accepted submission:
N, K = map(int, input().split())
nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))
nums.sort()

sumb = 0
for n in nums:
    sumb += n[1]
    if sumb >= K:
        print(n[0])
        break
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/2*w)
else:
  if w % 2 == 0:
    print((h//2 * w//2)*2)
  else:
    print(h*((w+1)//2) - w)

Fixed, accepted submission:
h, w = map(int, input().split())
#print(h, w)
if h == 1 or w == 1:
  print(1)
elif h % 2 == 0 or w % 2 == 0:
  print(h*w//2)
else:
  print((h*w//2) + 1)
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
def solve():
    H,W=map(int,input().split())
    for i in range(W+2):
        print("#",end='')
    print()
    for i in range(H):
        print("#")
        s=input()
        print(s)
        print("#")
    for i in range(W+2):
        print("#",end='')
    print()


if __name__ == "__main__":
    solve()

Fixed, accepted submission:
def solve():
    H,W=map(int,input().split())
    for i in range(W+2):
        print("#",end='')
    print()
    for i in range(H):
        print("#",end='')
        s=input()
        print(s,end='')
        print("#")
    for i in range(W+2):
        print("#",end='')
    print()

if __name__ == "__main__":
    solve()
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
if __name__ == "__main__":
  r, g, b = map(int, input().split()) 
  number = r * 100 + g * 10 + b
  if number % 4 != 0:
    print("No")
  else:
    print("Yes")

Fixed, accepted submission:
if __name__ == "__main__":
  r, g, b = map(int, input().split()) 
  number = r * 100 + g * 10 + b
  if number % 4 != 0:
    print("NO")
  else:
    print("YES")
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math

def resolve():
    # O(logx)
    X = int(input())
    keika = 0
    yokin = 100

    while X <= yokin:
        yokin = math.floor(yokin * 1.01)
        keika += 1

    print(keika)


if __name__ == "__main__":
    resolve()

Fixed, accepted submission:
import math

def resolve():
    # O(logx)
    X = int(input())
    keika = 0
    yokin = 100

    while yokin < X:
        keika += 1
        yokin += math.floor(yokin * 0.01)

    print(keika)


if __name__ == "__main__":
    resolve()
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
A,B,C,X,Y=map(int,input().split())
ans= min(A+B,C)*min(X,Y)
if X>Y:
  ans+=min(A,C)*(X-Y)
else:
  ans+=min(B,C)*(Y-X)
print(ans)



  

Fixed, accepted submission:
A, B, C, X, Y = map(int, input().split())
print(min(A*X+B*Y, X*C*2 + max(0, Y-X)*B, Y*C*2 + max(0, X-Y)*A))
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())
alist = list(map(int, input().split()))
ans = 0

for i in range(N):
    if alist[alist[i]-1]+1 == i:
        ans += 1
print(ans)

Fixed, accepted submission:
N = int(input())
alist = list(map(int, input().split()))
ans = 0

for i in range(N):
    if alist[alist[i]-1]-1 == i:
        ans += 1
print(ans//2)
Problem:
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a _contiquous_ subsequence.

Incorrect submission (verdict: Wrong Answer):
while True:
    N=int(input())
    if N==0:
        break
    num=0
    res=-11111111
    for i in range(N):
        a=int(input())
        num=max(num+a,a)
        res=max(num,res)

    print(num)



Fixed, accepted submission:
while True:
    N=int(input())
    
    if N==0:
        break
    
    num=0
    res=-11111111
    for i in range(N):
        a=int(input())
        num=max(num+a, a)
        #print(num)
        res=max(num, res)
        #print(res)

    print(res)
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
a = list(map(int, input().split()))
if a[0] + a[1] + a[2] == max(a) * 2:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
a = list(map(int, input().split()))
if a[0] + a[1] + a[2] == max(a) * 2:
    print('Yes')
else:
    print('No')
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())

if n % 1000 == 0:
    print("0")
else:
    print(1000 - n % 1000)

Fixed, accepted submission:
n = int(input())
s = list(input() for i in range(n))

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if s[i] == "AC":
        ac+=1
    elif s[i] == "WA":
        wa += 1
    elif s[i] == "TLE":
        tle += 1
    else:
        re += 1

print("AC x", str(ac))
print("WA x",str(wa))
print("TLE x",str(tle))
print("RE x",str(re))
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):
s = input()


for i in range(1 << 3):
    count = int(s[0])
    for j in range(1, 4):
        if i & (1 << j-1):
            count+=int(s[j])
        else:
            count-=int(s[j])
    
    if count == 7:
        ans = s[0] 
        for j in range(1, 4):
            if i & (1 << j):
                ans += '+'+s[j]
            else:
                ans += '-'+s[j]

        ans += '=7'
        print(ans)
        exit()

Fixed, accepted submission:
s = input()


for i in range(1 << 3):
    count = int(s[0])
    for j in range(1, 4):
        if i & (1 << j-1):
            count+=int(s[j])
        else:
            count-=int(s[j])
    
    if count == 7:
        ans = s[0] 
        for j in range(1, 4):
            if i & (1 << j-1):
                ans += '+'+s[j]
            else:
                ans += '-'+s[j]

        ans += '=7'
        print(ans)
        exit()
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())
cnt=0
for a in range(A):
    for b in range(B):
        for c in range(C):
            if 500*a+100*b+50*c==X:
                cnt=cnt+1
print(cnt)


Fixed, accepted submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+50*c==X:
                cnt=cnt+1
print(cnt)
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):
n = input()
if n in '9':
	print('Yes')
else:
	print('No')

Fixed, accepted submission:
n = input()
if '9' in n:
	print('Yes')
else:
	print('No')
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
a, b, n = map(int, input().split())
print(min((a * n), b))

Fixed, accepted submission:
n, a, b = map(int, input().split())
print(min((a * n), b))
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):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))


a = sorted(a)
b = sorted(b)
c = sorted(c)

print(a)
print(b)
print(c)


def lower_bound(arr , x):
    l = 0
    r = len(c)
    for i in range(100):
        mid = (l + r) // 2
        
        if x <= arr[mid]:
            r = mid
        else:
            l = mid
    return r


count = 0
for i in range(n):
    a_count = lower_bound(a , b[i])
    c_count = len(c) - lower_bound(c , b[i] + 1)
    count += a_count * c_count

print(count)


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


a = sorted(a)
b = sorted(b)
c = sorted(c)


def lower_bound(arr , x):
    l = 0
    r = len(c)
    for j in range(30):
        mid = (l + r) // 2
        
        if x <= arr[mid]:
            r = mid
        else:
            l = mid
    return r


count = 0
for i in range(n):
    a_count = lower_bound(a , b[i])
    c_count = len(c) - lower_bound(c , b[i] + 1)
    count += a_count * c_count

print(count)
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())
count = 0

for i in range(a):
    for j in range(b):
        for k in range(c):
            sum = 500*i + 100*j + 50*k
            if x == sum:
                count += 1

print(count)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            sum = 500*i + 100*j + 50*k
            if x == sum:
                count += 1

print(count)
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
x = list(map(int, input().split()))
k = int(input())
ans = sum(x) - max(x)
ans += max(x) ** k
print(ans)

Fixed, accepted submission:
x = list(map(int, input().split()))
k = int(input())
ans = sum(x) - max(x)
ans += max(x) * 2 ** k
print(ans)