TnT/CodeNet4Repair huggingface dataset:
Problem:
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.

Incorrect submission (verdict: Wrong Answer):
word = input()
word.lower()
print("a",":",word.count("a"))
print("b",":",word.count("b"))
print("c",":",word.count("c"))
print("d",":",word.count("d"))
print("e",":",word.count("e"))
print("f",":",word.count("f"))
print("g",":",word.count("g"))
print("h",":",word.count("h"))
print("i",":",word.count("i"))
print("j",":",word.count("j"))
print("k",":",word.count("k"))
print("l",":",word.count("l"))
print("m",":",word.count("m"))
print("n",":",word.count("n"))
print("o",":",word.count("o"))
print("p",":",word.count("p"))
print("q",":",word.count("q"))
print("r",":",word.count("r"))
print("s",":",word.count("s"))
print("t",":",word.count("t"))
print("u",":",word.count("u"))
print("v",":",word.count("v"))
print("w",":",word.count("w"))
print("x",":",word.count("x"))
print("y",":",word.count("y"))
print("z",":",word.count("z"))

Fixed, accepted submission:
import sys
words = str()
data = "abcdefghijklmnopqrstuvwxyz"
for line in sys.stdin:
    words += line.lower()
for i in data:
    print(i+" : "+str(words.count(i)))
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, purpose = map(int, input().split(" "))

resultI = resultJ = resultK = -1

def combiValue(i, j, k):
  return 10000 * i + 5000 * j + 1000 * k

for i in range(n+1):
  for j in range(n+1-i):
    k = n+1 - i - j
    if combiValue(i, j, k) == purpose:
      resultI = i
      resultJ = j
      resultK = k

print("{0} {1} {2}".format(resultI, resultJ, resultK))

Fixed, accepted submission:
n, purpose = map(int, input().split(" "))

resultI = resultJ = resultK = -1

def combiValue(i, j, k):
  return 10000 * i + 5000 * j + 1000 * k

for i in range(n+1):
  for j in range(n+1-i):
    k = n - i - j
    if combiValue(i, j, k) == purpose:
      resultI = i
      resultJ = j
      resultK = k

print("{0} {1} {2}".format(resultI, resultJ, resultK))
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):
R, G, B, N = map(int, input().split())

answer = 0
for r in range(R):
  for g in range(G):
    if r + g > N or N - r - g > B:
      continue
    else:
      answer += 1
print(answer)

Fixed, accepted submission:
R, G, B, N = map(int, input().split())

answer = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if r*R + g*G > N:
      break
    elif (N-r*R-g*G)%B != 0:
      continue
    else:
      answer += 1
print(answer)
Problem:
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.   According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.   Determine if he is correct.

Incorrect submission (verdict: Wrong Answer):
c = [list(map(int, input().split())) for _ in range(3)]

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]
if any(c[1][x] != a2 + c[1][x] for x in [1, 2]) or any(c[2][x] != a3 + c[1][x] for x in [0, 2]):
	print('No')
else:
	print('Yes')


Fixed, accepted submission:
c = [list(map(int, input().split())) for _ in range(3)]

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]

if any(c[1][x] != a2 + c[0][x] for x in [1, 2]) or any(c[2][x] != a3 + c[0][x] for x in [1, 2]):
	print('No')
else:
	print('Yes')
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
cnt = 0
num = int(input())
while num != 0:
  print('Case {0}: {1}', ++cnt, num)
  num = int(input())

Fixed, accepted submission:
import sys
cnt = 1

while 1:
  num=sys.stdin.readline().strip()
  if num == "0":
    break
  print('Case {0}: {1}'.format(cnt, num))
  cnt+=1
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()

if (len(s) < len(t)):
   print('UNRESTORABLE')
   exit()

ns = len(s)
nt = len(t)
for i in range(0, ns-nt+1):
   x = s[i:i+nt]
   ok = 1
   for j in range(nt):
      if (t[j] != x[j] and x[j] != '?'):
         ok = 0
         break

   if (ok == 1):
      ss = s[0:i] + t
      if (i+nt < ns):
         ss = ss + s[i+nt]
      ss = ss.replace('?', 'a')
      exit()

print('UNRESTORABLE')


Fixed, accepted submission:
s = input()
t = input()

ns = len(s)
nt = len(t)

for i in range(ns-nt, -1, -1):
   x = s[i:i+nt]
   for j in range(nt+1):
      if (j == nt):
         ss = s[:i] + t + s[i+nt:]
         print(ss.replace('?', 'a'))
         exit()

      if (x[j] == '?'):
         continue
      elif (x[j] != t[j]):
         break

print('UNRESTORABLE')
Problem:
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.  He has very high awareness of safety, and decides to buy two bells, one for each hand.  The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.

Incorrect submission (verdict: Wrong Answer):
import sys
import math
import bisect

def main():
    A = input().split()
    B = []
    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            B.append(A[i] + A[j])
    print(min(B))
    
if __name__ == "__main__":
    main()


Fixed, accepted submission:
import sys
import math
import bisect

def main():
    A = list(map(int, input().split()))
    A.sort()
    print(sum(A[0:2]))

if __name__ == "__main__":
    main()
Problem:
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.  You are given an integer N. Find the N-th Lucas number.  Here, the i-th Lucas number L_i is defined as follows:    * L_0=2   * L_1=1   * L_i=L_{i-1}+L_{i-2} (i≥2)

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=[2,1]
for i in range(n-2):
  a+=[sum(a[-2:])]
print(a[n-1])

Fixed, accepted submission:
n=int(input())
a=[2,1]
for i in range(n):
  a+=[sum(a[-2:])]
print(a[n])
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):
print(input().count("0"))

Fixed, accepted submission:
print(input().count("1"))
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
x,a,b = map(int, input().split())
if a < b:
  print('delicious')
elif a + x <= b:
  print('safe')
else:
  print('dangerous')

Fixed, accepted submission:
x,a,b = map(int, input().split())
if a >= b:
  print('delicious')
elif a + x >= b:
  print('safe')
else:
  print('dangerous')
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[0 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(ANS)

        



Fixed, accepted submission:
#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while True:
    a, op, b = map(str,input().split())
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) / int(b))
    elif op == '?':
        break

Fixed, accepted submission:
while True:
    a, op, b = map(str,input().split())
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))
    elif op == '?':
        break
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())
water = set()
sugar = set()
cou = 0
co = 0

for i in range(f//b):
    cou = 0
    while 100 * b * i + 100 * a * cou <= f:
        water.add(100 * b * i + 100 * a * cou)
        cou += 1
water = sorted(water)
print(water)

for i in range(f//d):
    cow = 0
    while d * i + c * cow <= f:
        sugar.add(d * i + c * cow)
        cow += 1
sugar = sorted(sugar)
print(sugar)



ans = [0,0,0]

for wat in water:
    for sug in sugar:
        if wat or sug:
            if wat + sug <= f and e / (100 + e) >= sug/(wat+sug):
                if ans[0] <= sug/(wat+sug):
                    ans = [sug/(wat+sug), wat+sug, sug]
print(ans[1],ans[2])

Fixed, accepted submission:
a ,b ,c ,d ,e ,f = map(int,input().split())
water = set()
sugar = set()
cou = 0
co = 0

for i in range(f//b):
    cou = 0
    while 100 * b * i + 100 * a * cou <= f:
        water.add(100 * b * i + 100 * a * cou)
        cou += 1
water = sorted(water)


for i in range(f//d):
    cow = 0
    while d * i + c * cow <= f:
        sugar.add(d * i + c * cow)
        cow += 1
sugar = sorted(sugar)




ans = [0,0,0]

for wat in water:
    for sug in sugar:
        if wat or sug:
            if wat + sug <= f and e / (100 + e) >= sug/(wat+sug):
                if ans[0] <= sug/(wat+sug):
                    ans = [sug/(wat+sug), wat+sug, sug]
print(ans[1],ans[2])
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

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

if a%2==0 and b%2==0 and c%2==1:
    print("NO")
else:
    print("Yes")

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

x=0
for i in range(1,b+1):
    if i*a%b==c:
        x+=1
if x==0:
    print("NO")
else:
    print("YES")
Problem:
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$.  A column vector with m elements is represented by the following equation.  \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\]  A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.  \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\]  $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).  The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula:  \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]

Incorrect submission (verdict: Wrong Answer):
# -*- coding:utf-8 -*-
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(col)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

for i in range(len(result)):
    print(result[i])

Fixed, accepted submission:
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(row)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

for i in range(len(result)):
    print(int(result[i]))
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(' '))
count = 0

for i in range(1, n+1):
    letter_list = []
    for letter in str(i):
        letter_list.append(letter)
    num_list = list(map(int, letter_list))

    if a <= sum(num_list) <= b:
        count += 1

print(count)


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

for i in range(1, n+1):
    letter_list = []
    for letter in str(i):
        letter_list.append(letter)
    num_list = list(map(int, letter_list))

    if a <= sum(num_list) <= b:
        total += i

print(total)
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):
# -*- coding: utf-8 -*-
N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)
    
print(max(0, ans))

Fixed, accepted submission:
# -*- coding: utf-8 -*-
N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)

print(max(0, max(List)))
Problem:
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.  Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.  Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.                 void call(int n){   int i = 1;  CHECK_NUM:   int x = i;   if ( x % 3 == 0 ){     cout << " " << i;     goto END_CHECK_NUM;   }  INCLUDE3:   if ( x % 10 == 3 ){     cout << " " << i;     goto END_CHECK_NUM;   }   x /= 10;   if ( x ) goto INCLUDE3;  END_CHECK_NUM:   if ( ++i <= n ) goto CHECK_NUM;    cout << endl; }

Incorrect submission (verdict: Wrong Answer):

Fixed, accepted submission:
n = int(input())
x = 1
y = ""
z = 1
while True:
    z = 1
    x += 1
    if x % 3 == 0:
        y += " "
        y += str(x)
    else:
        while True:
            b = int(x % 10 ** (z - 1))
            a = int((x - b) / 10 ** z)
            c = a % 10 ** z
            d = a % 10 ** (z - 1)
            if a == 3 or b == 3 or c == 3 or d == 3:
                y += " "
                y += str(x)
                break
            z += 1
            if a < 3 and z > 3:
                break
    if x >= n:
        break
print(y)
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
while 1:
 a,b=map(int,input().split())
 if a+b==0:
  break
 elif a>b:
  print(b,a)
 print(a,b)

Fixed, accepted submission:
while 1:
 a,b=map(int,input().split())
 if a+b==0:
  break
 elif a>b:
  print(b,a)
  continue
 print(a,b)
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):
l=list(input())
for i in range(len(l)):
            del l[-1]
            if len(l)%2!=0:
                        del l[-1]
                        #print('1',l)
            if len(l)%2==0:
                        if l[:len(l)//2]==l[len(l)//2:]:
                                    #print('2',l,'len(l)',len(l))
                                    exit()
                        else:
                                    del l[-1]
                                    #print('3',l)
                                    


Fixed, accepted submission:
l=list(input())
for i in range(len(l)):
            del l[-1]
            if len(l)%2!=0:
                        del l[-1]
                        #print('1',l)
            if len(l)%2==0:
                        if l[:len(l)//2]==l[len(l)//2:]:
                                    print(len(l))
                                    exit()
                        else:
                                    del l[-1]
                                    #print('3',l)
Problem:
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.

Incorrect submission (verdict: Wrong Answer):
li = []
for _ in range(3):
    li += list(map(int, input().split()))

mx = 0
for i in range(1, 5):
    mx = max(mx, li.count(i))

if mx == 3:
    ans = "No"
else:
    ans = "Yes"

print(ans)


Fixed, accepted submission:
li = []
for _ in range(3):
    li += list(map(int, input().split()))

mx = 0
for i in range(1, 5):
    mx = max(mx, li.count(i))

if mx == 3:
    ans = "NO"
else:
    ans = "YES"

print(ans)