TnT/CodeNet4Repair huggingface dataset:
Problem:
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.    * Operation 1: Pour 100A grams of water into the beaker.   * Operation 2: Pour 100B grams of water into the beaker.   * Operation 3: Put C grams of sugar into the beaker.   * Operation 4: Put D grams of sugar into the beaker.  In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Incorrect submission (verdict: Wrong Answer):
a, b, c, d, e, f = map(int, input().split())

print(100,100)

Fixed, accepted submission:
a, b, c, d, e, f = map(int, input().split())


ans = (0, 0, 0)


for i in range(0, f // (100 * a) + 1):
    for j in range(0, f // (100 * b) + 1):
        if i == 0 and j == 0:
            continue

        
        waterV = 100 * a * i + 100 * b * j
        if waterV > f:
            break

        
        leftVolume = f - waterV
        
        satouMax = min((a*i + b*j) * e, leftVolume)  

        
        sMax = 0
        for si in range(0, satouMax // c + 1):
            blnOk = False
            for sj in range(0, satouMax // d + 1):
                satou = c * si + d * sj
                if satou == satouMax:
                    sMax = satou
                    blnOk = True
                    break
                if satou > satouMax:
                    break
                sMax = max(sMax, satou)

            if blnOk:
                break

        
        noudo = 100 * sMax / (waterV + sMax)

        if ans[0] <= noudo:
            ans = (noudo, waterV+sMax, sMax)

print(ans[1], ans[2])
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):
from functools import reduce
num = int(reduce(lambda a,b:a+b, input().split(), ""))
print('Yes' if num%4 == 0 else 'No')



Fixed, accepted submission:
from functools import reduce
num = int(reduce(lambda a,b:a+b, input().split(), ""))
print('YES' if num%4 == 0 else 'NO')
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):
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
    x=s[len(s)-1-i:len(s)-1-i+l]
    cnt=0
    for j in range(l):
        if x[j]=="?" or x[j]==t[j]:
            cnt+=1
        else:
            break
    if cnt==l:
        u=s[:len(s)-1-i].replace("?","a")
        v=s[len(s)-1-i+l:].replace("?","a")
        key=u+t+v
        a.append(key)
if len(a)==0:
    print("UNRESTORABLE")
    exit()
a=sorted(a)
print(a)


Fixed, accepted submission:
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
    x=s[len(s)-1-i:len(s)-1-i+l]
    cnt=0
    for j in range(l):
        if x[j]=="?" or x[j]==t[j]:
            cnt+=1
        else:
            break
    if cnt==l:
        u=s[:len(s)-1-i].replace("?","a")
        v=s[len(s)-1-i+l:].replace("?","a")
        key=u+t+v
        a.append(key)
if len(a)==0:
    print("UNRESTORABLE")
    exit()
a=sorted(a)
print(a[0])
Problem:
M-kun is a student in Aoki High School, where a year is divided into N terms.   There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:    * For the first through (K-1)-th terms: not given.   * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.  M-kun scored A_i in the exam at the end of the i-th term.   For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.

Incorrect submission (verdict: Wrong Answer):
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
p = 1
for i in range(k):
  p *= arr[i]
grades = [p]
for i in range(k, n):
  p /= arr[i-k]
  p *= arr[k]
  grades.append(p)
for i in range(1, len(grades)):
  if grades[i] > grades[i-1]:
    print("Yes")
  else:
    print("No")


Fixed, accepted submission:
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
for i in range(k, n):
    if arr[i] > arr[i-k]:
        print("Yes")
    else:
        print("No")
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
n_1 = 0

a = list(str(input()))
print(a)
for i in a:
    if i == "1":
        n_1 += 1

print(n_1)

Fixed, accepted submission:
n_1 = 0

a = list(str(input()))
for i in a:
    if i == "1":
        n_1 += 1

print(n_1)
Problem:
There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.

Incorrect submission (verdict: Wrong Answer):
import bisect

N = int(input())
A = sorted(map(int,input().split()))

i = bisect.bisect_left(A, 0)
j = bisect.bisect_right(A, 0)

if i == j:
    if i == 0:
        negatives = A[:1]
        positives = A[1:]
    elif i == N:
        negatives = A[:-1]
        positives = A[-1:]
    else:
        negatives = A[:i]
        positives = A[i:]

else:
    m = max((i+j)//2, 1)
    negatives = A[:m]
    positives = A[m:]


score = sum(positives) - sum(negatives)
print(score)

def it():

    def balanced(pos, neg):
        y = neg.pop()
        x = pos.pop()
        yield (x,y)
        y = x-y
        while pos and neg:
            x = neg.pop()
            yield (x,y)
            y = x-y
            x = pos.pop()
            yield (x,y)
            y = x-y

    if len(positives) < len(negatives):

        x = positives.pop()

        while len(positives)+1 < len(negatives):
            y = negatives.pop()
            yield (x,y)
            x -= y
        positives.append(x)
        for x,y in balanced(positives, negatives):
            yield x,y

    elif len(positives) > len(negatives):
        x = negatives.pop()

        while len(negatives)+1 < len(positives):
            y = positives.pop()
            yield (x,y)
            x -= y
        negatives.append(x)
        for x,y in balanced(positives, negatives):
            yield x,y


for x,y in it():
    print(x,y)












Fixed, accepted submission:
from bisect import bisect

def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res)



s,res = solve()
print(s)
print('\n'.join(f'{a} {b}' for a,b in res))
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):
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
    S = input()
    if(S == "AC"):
        AC+=1
    elif(S == "WA"):
        WA+=1
    elif(S == "TLE"):
        TLE+=1
    elif(S == "RE"):
        RE+=1

print("AC × " + str(AC) + "\nWA ×" + str(WA) + "\nTLE ×" + str(TLE) + "\nRE ×" + str(RE))

Fixed, accepted submission:
N = int(input())
s = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
    print('{0} x {1}'.format(v, s.count(v)))
Problem:
Compute A \times B, truncate its fractional part, and print the result as an integer.

Incorrect submission (verdict: Wrong Answer):
from decimal import Decimal
a,b=map(Decimal,input().split())
print(round(a*b))

Fixed, accepted submission:
from decimal import Decimal
import math
a,b=map(Decimal,input().split())
print(math.floor(a*b))
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 x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            print(x, y, z)
            exit()
        else:
            print(-1, -1, -1)

Fixed, accepted submission:
N, Y = map(int, input().split())
ansX = -1
ansY = -1
ansZ = -1
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            ansX = x
            ansY = y
            ansZ = z
            
print(ansX, ansY, ansZ)
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
if __name__ == "__main__":
    S = input()

    result = "yes"
    # for each character in S
    for c in S:
        # there is a same character in S
        if S.count(c) > 1:
            result = "no"
            break

    print(result)

Fixed, accepted submission:
if __name__ == "__main__":
    A, B = map(int, input().split())

    if A + B >= 10:
        print("error")
    else:
        print(A + B)
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

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

V = "keyence"

for i in range(len(S) - len(V) + 1):
    print(i, S[:i], S[i-len(V):])
    if S[:i] + S[i-len(V):] == V:
        print("YES")
        exit(0)
print("NO")


Fixed, accepted submission:
S = input()

V = "keyence"
t = len(S) - len(V)

for i in range(len(S) - t + 1):
    if S[:i] + S[i+t:] == V:
        print("YES")
        exit(0)
print("NO")
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
x ,y = [int(i) for i in input().split()]
if x <= y:
    print(x,' ',y,sep='')
else:
    print(y,' ',x,sep=' ')

Fixed, accepted submission:
while True:
    x, y = [int(i) for i in input().split()]
    if x > y:
        print(y ,x)
    elif x ==0 and y == 0:
        break
    else:
        print(x,y)
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):
base=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=input()
t=input()

S=[]
T=[]


answer="No"

for i in s:
    S.append(base.index(i))
for j in t:
    T.append(base.index(j))
S=sorted(S)
T=sorted(T,reverse=True)

for k in range(min(len(S),len(T))):
    if S[k]>T[k]:
        answer="NO"
    elif S[k]<T[k]:
        answer="Yes"
if answer=="No" and len(S)<len(T):
    answer="Yes"
elif answer=="NO":
    answer="No"
print(answer)


Fixed, accepted submission:
base=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=input()
t=input()

S=[]
T=[]


answer="NO"

for i in s:
    S.append(base.index(i))
for j in t:
    T.append(base.index(j))
S=sorted(S)
T=sorted(T,reverse=True)
#print(S)
#print(T)

for k in range(min(len(S),len(T))):
    if S[k]>T[k]:
        answer="No"
        break
    elif S[k]<T[k]:
        answer="Yes"
        break
if answer=="NO" and len(S)<len(T):
    answer="Yes"
elif answer=="NO" and len(S)>=len(T):
    answer="No"

print(answer)
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):
s_a = input()
s_b = input()
if s_a[0] == s_b[2] and s_a[2] == s_a[0] and s_a[1] == s_b[1]:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
s_a = input()
s_b = input()
if s_a[0] == s_b[2] and s_a[2] == s_b[0] and s_a[1] == s_b[1]:
    print("YES")
else:
    print("NO")
Problem:
M-kun is a competitor in AtCoder, whose highest rating is X.   In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:    * From 400 through 599: 8-kyu   * From 600 through 799: 7-kyu   * From 800 through 999: 6-kyu   * From 1000 through 1199: 5-kyu   * From 1200 through 1399: 4-kyu   * From 1400 through 1599: 3-kyu   * From 1600 through 1799: 2-kyu   * From 1800 through 1999: 1-kyu  What kyu does M-kun have?

Incorrect submission (verdict: Wrong Answer):
X = int(input())
A = 2000 - X
if A % 200 == 0:
    print(str(A // 200) + "級") 
else:
    print(str(A // 200 + 1) + "級") 

Fixed, accepted submission:
X = int(input())
A = 2000 - X
if A % 200 == 0:
    print(str(A // 200)) 
else:
    print(str(A // 200 + 1))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

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

if n==0:
    print('0')
else:
    print(1000-n)

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

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

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
if (c>e and d>f) or (c<e and d<f):
    print(0)
else:
    if c<e:
        c,d,e,f=e,f,c,d
    s=(c-e)*a
    t=(f-d)*b
    if s>t:
        print(0)
    elif s==t:
        print("infinity")
    else:
        print(int((s+t)/(t-s))-1-(1 if (s+t)%(t-s)==0 else 0))

Fixed, accepted submission:
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
if (c>e and d>f) or (c<e and d<f):
    print(0)
else:
    if c<e:
        c,d,e,f=e,f,c,d
    s=(c-e)*a
    t=(f-d)*b
    if s>t:
        print(0)
    elif s==t:
        print("infinity")
    else:
        print(int(s/(t-s))+int(t/(t-s))-(1 if s%(t-s)==0 else 0))
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())
j = [0] * 4
for i in range(n):
    s=input()
    if s == "AC":
        j[0] += 1
    elif s=="WA":
        j[1] += 1
    elif s=="TLE":
        j[2] += 1
    elif s == "RE":
        j[3] += 1
for k in range(4):
    print(f"AC × {j[k]}")


Fixed, accepted submission:

n = int(input())
j = [0] * 4
moji = ["AC", "WA", "TLE", "RE"]
for i in range(n):
    s=input()
    if s == "AC":
        j[0] += 1
    elif s=="WA":
        j[1] += 1
    elif s=="TLE":
        j[2] += 1
    elif s == "RE":
        j[3] += 1
for k in range(4):
    print(f"{moji[k]} x {j[k]}")
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=map(int, input().split())
if a*b%2 == 0:
         print("even")
else:
         print("odd")



Fixed, accepted submission:
a,b=map(int, input().split())
if a*b%2 == 0:
         print("Even")
else:
         print("Odd")
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):
a = map(str,input())
a = list(a)
c = False

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("YES")
      c=True

if c == False:
  print("NO")

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

for x in range(2):
  if a[x] == a[x+1]:
    if a[x+1] == a[x+2]:
      print("Yes")
      exit()

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):
def main():
    a, b = [int(i) for i in input().split()]
    if a*b%2 == 0:
        print("Odd")
    else:
        print("Even")


if __name__ == '__main__':
    main()

Fixed, accepted submission:
def main():
    a, b = [int(i) for i in input().split()]
    if a*b%2 == 0:
        print("Even")
    else:
        print("Odd")


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

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

Fixed, accepted submission:
s = input()
w = int(input())
ans = []
if len(s)%w == 0:
  for i in range(len(s)//w):
    ans.append(s[w*i])
else:
  for i in range(len(s)//w+1):
    ans.append(s[w*i])
print("".join(ans))
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)


Fixed, accepted submission:
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
  
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)
Problem:
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.  You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing.  The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = input()
d = {"E":0, "W":0}
for i in s:
    d[i] += 1
print(min(d.values()))

Fixed, accepted submission:
n = int(input())
s = input()
c = s.count("E")
d = c
for i in s:
  if i == "E":
    d -= 1
  else:
    d += 1
  c = min(c,d)
print(c)