TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
mid=lst[2]
dif1=lst[2]-lst[1]
dif2=lst[1]-lst[0]
q1,mod1=divmod(dif1,2)
q2,mod2=divmod(dif2,2)
dif3=min(dif1,dif2)
if mod1==mod2:
  if mod1==0:
    print(dif1+dif2)
  else:
    print(dif1+dif2+1)
else:
  print(dif1+dif2+2)
  



Fixed, accepted submission:
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
dif1=lst[2]-lst[1]
dif2=lst[2]-lst[0]
q1,mod1=divmod(dif1,2)
q2,mod2=divmod(dif2,2)
dif3=min(dif1,dif2)
if mod1==mod2:
  if mod1==0:
    print(q1+q2)
  else:
    print(q1+q2+1)
else:
  print(q1+q2+2)
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    t = input()

    sl = len(s)
    tl = len(t)

    if t in s:
        for i in range(sl):
            if s[i]=='?':
                print('a', end='')
            else:
                print(s[i], end='')
        print()
        return

    contain = 0
    for i in range(sl-1, 0, -1):
        if i+tl-1>=sl:
            continue
        ok = 1
        for j in range(tl):
            if s[i+j] not in ['?', t[j]]:
                ok = 0
                break
        if ok:
            s = s[:i] + t + s[i+tl:]
            for i in range(sl):
                if s[i]=='?':
                    print('a', end='')
                else:
                    print(s[i], end='')
            return

    print('UNRESTORABLE')
            

solve()


Fixed, accepted submission:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    t = input()

    sl = len(s)
    tl = len(t)

    if t in s:
        for i in range(sl):
            if s[i]=='?':
                print('a', end='')
            else:
                print(s[i], end='')
        print()
        return

    for i in range(sl-1, -1, -1):
        if i+tl-1>=sl:
            continue
        ok = 1
        for j in range(tl):
            if s[i+j] not in ['?', t[j]]:
                ok = 0
                break
        if ok:
            s = s[:i] + t + s[i+tl:]
            for i in range(sl):
                if s[i]=='?':
                    print('a', end='')
                else:
                    print(s[i], end='')
            
            print()
            return

    print('UNRESTORABLE')
            

solve()
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

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

for i in range(len(s)):
  if s[i] == "0" or s[i] == "1":
    ans += s[i]
  elif s[i] == "B":
    ans = ans[:-1]
  print(i,ans)

Fixed, accepted submission:
s = list(input())
n = len(s)
ans = []
for i in range(n):
  if s[i] == "B":
    if len(ans) > 0:
      ans.pop()
  else:
    ans.append(s[i])
print("".join(ans))
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
print(800*n-200*n//15)

Fixed, accepted submission:
n=int(input())
print(800*n-200*(n//15))
Problem:
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.

Incorrect submission (verdict: Wrong Answer):

nk=input().split()

n=int(nk[0])
k=int(nk[1])

weight=[int(input()) for i in range(n)]

def ok(m):
    load=0
    track=1
    # sum all the weight and count the track number we need
    for i in range(n):
        load+=weight[i]
        if load>m:
            load=0
            track+=1
            i-=1
            print(track)
        elif load==m:
            load=0
            track+=1
            print(track)
        else:
            print(track)
            continue

    if track<=k:
        return True
    else:
        return False

low=0
high=sum(weight)
while low+1<high:
# low<mid<high
#not ok(l) and ok(h)
    mid=(low+high)//2
    if ok(mid):
        high=mid
        print("high="+str(high))
    else:
        low=mid
        print("low="+str(low))

print(high)

Fixed, accepted submission:



nk=input().split()

n=int(nk[0])
k=int(nk[1])

weight=[int(input()) for i in range(n)]

def ok(m):
    load=0
    track=1
    # sum all the weight and count the track number we need
    for i in range(n):
        load+=weight[i]
        if load==m:
            load=0
            if i!=n-1:
                track+=1
        elif load>m:
            if weight[i]>m:
                return False
            else:
                load=weight[i]
                track+=1
        else:
            continue

    if track<=k:
        return True
    else:
        return False

low=0
high=sum(weight)
while low+1<high:
# low<mid<high
#not ok(l) and ok(h)
    mid=(low+high)//2
    if ok(mid):
        high=mid
    else:
        low=mid



print(high)
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
s = list(input())
s.sort()
if s == 'abc':
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
s = list(input())
s.sort()
s = ''.join(s)
if s == "abc":
    print('Yes')
else:
    print('No')
Problem:
There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Incorrect submission (verdict: Time Limit Exceeded):
while True:
    try:
        N, M = map(int, input().split())
        a = [int(input()) for _ in range(M)]
        
        if (1 in a):
            f = [1, 0]
        else:
            f = [1, 1]
            
        for i in range(2, N+1):
            if i in a:
                f.append(0)
            else:
                f.append(f[i-1] + f[i-2])
        
        print(f[N]%1000000007)
    except:
        break

Fixed, accepted submission:
mod = 1000000007

while True:
    try:
        N, M = map(int, input().split())
        
        
        a = [0] * (N+1)
        for _ in range(M):
            a[int(input())] = 1
        
        dp = [0] * (N+1)
        dp[0] = 1
        dp[1] = 0 if a[1] else 1
        
        for i in range(2, N+1):
            if a[i]:
                dp[i] = 0
            else:
                dp[i] = dp[i-1] + dp[i-2]
        
        print(dp[N] % mod)
    except:
        break
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):
    x = 0
    y = i
    while y>0:
        x += y%10
        y //=10
    if a <= x <= b:
        ans += i

print(ans)

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

ans = 0
for i in range(1, n+1):
    x = 0
    y = i
    while y>0:
        x += y%10
        y //=10
    if a <= x <= b:
        ans += i

print(ans)
Problem:
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.  Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:    * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.  At least how many explosions do you need to cause in order to vanish all the monsters?

Incorrect submission (verdict: Wrong Answer):
import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict

def main():
    finput=lambda :sys.stdin.readline().strip()
    n,a,b=map(int,finput().split())
    h=[int(finput()) for _ in range(n)]
    gs=lambda a,b:a//b+(a%b>0)
    def enough(t):
        s=sum([max(x-t*b,0)//(a-b)+(max(x-t*b,0)%b>0) for x in h])
        if s<=t:
            return True
        else:
            return False
    
    #    if l==0:
    #        return t
    #    t=t+l//2
    #    if enough(t):
    
    #    else:
    
    l=max(h)//b+1
    t=0
    while l>0:
        t=t+l//2
        if enough(t):
            t=t-l//2
            l=l//2
        else:
            t+=1
            l=l-l//2
    print(t)

if __name__=='__main__':
    main()



Fixed, accepted submission:
import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict

def main():
    finput=lambda :sys.stdin.readline().strip()
    n,a,b=map(int,finput().split())
    h=[int(finput()) for _ in range(n)]
    gs=lambda a,b:a//b+(a%b>0)
    def enough(t):
        s=sum([max(x-t*b,0)//(a-b)+(max(x-t*b,0)%(a-b)>0) for x in h])
        if s<=t:
            return True
        else:
            return False
    
    #    if l==0:
    #        return t
    #    t=t+l//2
    #    if enough(t):
    
    #    else:
    
    l=max(h)//b+1
    t=0
    while l>0:
        t=t+l//2
        if enough(t):
            t=t-l//2
            l=l//2
        else:
            t+=1
            l=l-l//2
    print(t)

if __name__=='__main__':
    main()
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Wrong Answer):

# coding: utf-8

# In[3]:

import sys
input = sys.stdin.readline
R, G, B, N = map(int, input().split())


# In[5]:

cnt = 0
a, b, c = sorted([R, G, B], reverse=True)
for i in range(N//a+1):
    for j in range((N-R*i)//b+1):
        if (N-a*i+b*j)%c == 0:
                cnt += 1
print(cnt)


# In[ ]:





Fixed, accepted submission:

# coding: utf-8

# In[3]:

import sys
input = sys.stdin.readline
R, G, B, N = map(int, input().split())


# In[14]:

cnt = 0
a, b, c = sorted([R, G, B], reverse=True)
#print(a, b, c)
#print(N//a)
for i in range(N//a+1):
    for j in range((N-a*i)//b+1):
        tmp = N-a*i-b*j
        if tmp%c == 0:
            #print('{}*{} + {}*{}'.format(a, i, b, j))
            cnt += 1
print(cnt)


# In[19]:

list(range(1//3 + 1))


# In[ ]:
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Incorrect submission (verdict: Wrong Answer):
input()
n=input()
a=c=0
for i in n:
  if i=='I':a+=1
  else:a-=1
  c=max(a,c)
print(a)

Fixed, accepted submission:
input()
s=input()
a=c=0
for i in s:
  if i=='I':a+=1
  else:a-=1
  c=max(a,c)
print(c)
Problem:
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = str(input())
K = int(input())
K_S = S[K - 1]
print(K_S)
for i in range(N):
    if S[i] != K_S:
        S = S.replace(S[i], '*')
print (S)

Fixed, accepted submission:
N = int(input())
S = str(input())
K = int(input())
K_S = S[K - 1]
for i in range(N):
    if S[i] != K_S:
        S = S.replace(S[i], '*')
print (S)
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):
import sys
input = sys.stdin.readline
def inp():
    return(int(input()))
def inps():
    return str(input())
n = inp()
arr= []
cac = 0
cwa = 0
ctle = 0
cra = 0
for i in range(n):
    s = inps().rsplit()[0]
    if s=="AC": cac+=1
    elif s=="WA": cwa+=1
    elif s=="TLE": ctle+=1
    else: cra+=1
c = [cac, cwa, ctle, cra]
s = ["AC x ", "WA x ", "TLE x ", "RA x "]
for i in range(len(s)):
    print(s[i]+str(c[i]))

Fixed, accepted submission:
import sys
input = sys.stdin.readline

def inp():
    return(int(input()))

def inpf():
    return(float(input()))


def inps():
    return str(input())



n = inp()
arr= []
cac = 0
cwa = 0
ctle = 0
cra = 0
for i in range(n):
    s = inps().rsplit()[0]
    if s=="AC": cac+=1
    elif s=="WA": cwa+=1
    elif s=="TLE": ctle+=1
    else: cra+=1
c = [cac, cwa, ctle, cra]
s = ["AC x ", "WA x ", "TLE x ", "RE x "]
for i in range(len(s)):
    print(s[i]+str(c[i]))
Problem:
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.  Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.  If given integers or the sum have more than 80 digits, print "overflow".

Incorrect submission (verdict: Wrong Answer):
for i in range(int(input())):
    n1 = list(input())
    n2 = list(input())
    if len(n2) > len(n1):
        n1, n2 = n2, n1

    ans = []
    for i in range(len(n1)):
        a = int(ans.pop(0)) if len(ans) == i + 1 else 0
        c1 = int(n1.pop(-1))
        c2 = int(n2.pop(-1)) if len(n2) != 0 else 0
        ans = list(str(a + c1 + c2)) + ans
    print(''.join(ans))

Fixed, accepted submission:
#!/usr/bin/python
# AOJ
# 0015

for i in range(int(input())):
    n1 = list(input())
    n2 = list(input())
    if len(n2) > len(n1):
        n1, n2 = n2, n1

    ans = []
    for i in range(len(n1)):
        a = int(ans.pop(0)) if len(ans) == i + 1 else 0
        c1 = int(n1.pop(-1))
        c2 = int(n2.pop(-1)) if len(n2) != 0 else 0
        ans = list(str(a + c1 + c2)) + ans
    if len(ans) > 80:
        print('overflow')
    else:
        print(''.join(ans))
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):
def judge_status_summary():
    N = int(input())
    res = {"AC":0,"WA":0,"TLE":0,"RE":0}
    for i in range(N):
        res[input()] += 1
    
    for k in res:
        print("{} X {}".format(k,res[k]))
        
judge_status_summary()

Fixed, accepted submission:
def judge_status_summary():
    N = int(input())
    res = {"AC":0,"WA":0,"TLE":0,"RE":0}
    for i in range(N):
        res[input()] += 1
    
    for k in res:
        print("{} x {}".format(k,res[k]))
        
judge_status_summary()
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
print(input().count("1"))

Fixed, accepted submission:
N = input()
A = list(map(int, input().split()))
count = 0
while all(a%2==0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())

print(X - A % B)


Fixed, accepted submission:
X = int(input())
A = int(input())
B = int(input())

print((X - A) % B)
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())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    else:
      ans[j] += F - (ans[j]-S)%F
    ans[j] += C
    
for i in ans:
  print(i)



Fixed, accepted submission:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j]%F != 0:
      ans[j] += F - ans[j]%F
    ans[j] += C
    
for i in ans:
  print(i)
Problem:
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.  We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.  Find the maximum number of robots that we can keep.

Incorrect submission (verdict: Time Limit Exceeded):
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

xl.sort(key=lambda x:x[1])

cnt = [0 for _ in range(10**8)]
ans = [0 for _ in range(n)]

for i in range(n):
    for j in range(xl[i][0] - xl[i][1] + 1, xl[i][0] + xl[i][1]):
        if cnt[j] == 0:
            cnt[j] = 1
        else:
            break
        if j == xl[i][0] + xl[i][1]-1:
            ans[i] = 1

print(sum(ans))


Fixed, accepted submission:
import sys
input = sys.stdin.readline

n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl2 = sorted([[x + l, x - l] for x, l in xl])

ans = 0
mr = xl2[0][1]
for r, l in xl2:
    if l >= mr:
        ans += 1
        mr = r
print(ans)
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())
print((a+b)*(h/2))

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*(h/2)))