TnT/CodeNet4Repair huggingface dataset:
Problem:
  The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.  One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one contestant to another, because judges with any relationship whatsoever with a specific contestant are temporarily excluded for scoring his/her performance.  Basically, scores given to a contestant's performance by the judges are averaged to decide his/her score. To avoid letting judges with eccentric viewpoints too much influence the score, the highest and the lowest scores are set aside in this calculation. If the same highest score is marked by two or more judges, only one of them is ignored. The same is with the lowest score. The average, which may contain fractions, are truncated down to obtain final score as an integer.  You are asked to write a program that computes the scores of performances, given the scores of all the judges, to speed up the event to be suited for a TV program.

Incorrect submission (verdict: Wrong Answer):
j = 0
lists = []
flag = 0
cnt = 0
while 1:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        lists.append(s)
    for i in range(n):
        if lists[i] == max(lists):
            flag += 1
            pass
        elif lists[i] == min(lists):
            flag += 1
            pass
        else:
            cnt += lists[i]
    if flag >= 2:
        n -= 2
    print(cnt // n)



Fixed, accepted submission:
j = 0
lists = []
flag = 0
cnt = 0
while 1:
    cnt = 0
    flag_max = 0
    flag_min = 0
    lists = []
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        lists.append(s)
    for i in range(n):
        if lists[i] == max(lists):
            flag_max += 1
            pass
        elif lists[i] == min(lists):
            flag_min += 1
            pass
        else:
            cnt += lists[i]
    n -= 2
    if flag_max >= 2:
        cnt += max(lists)
    elif flag_min >= 2:
        cnt += min(lists)
    print(cnt // n)
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
lst = {}
for _ in range(n):
  temp = input()
  if temp in lst:
    lst[temp] = lst[temp]+1
  else:
    lst[temp] = 1
m = int(input())
for _ in range(m):
  temp = input()
  if temp in lst:
    lst[temp] = lst[temp] - 1
print(max(0,lst[max(lst)]))

Fixed, accepted submission:
def main():
	n = int(input())
	lst = {}
	for _ in range(n):
		temp = input()
		if temp in lst:
			lst[temp] = lst[temp]+1
		else:
			lst[temp] = 1
	m = int(input())
	for _ in range(m):
		temp = input()
		if temp in lst:
			lst[temp] = lst[temp] - 1
	ans = 0
	for i in lst:
		ans = max(lst[i], ans)
	print(ans)

main()
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):
s = input()

cnt = sum([int(c) for c in s])

Fixed, accepted submission:
s = input()
 
cnt = sum([int(c) for c in s])
print(cnt)
Problem:
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).   Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.   Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.   When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.  The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.

Incorrect submission (verdict: Wrong Answer):
import sys

H, W = map(int, input().split())
sx = 0
sy = 0
gx = H-1
gy = W-1
C = [list(i for i in input()) for _ in range(H)]
inf = -1
distance = [[inf] * W for _ in range(H)]
queue = []
queue.insert(0, (sy, sx))
distance[sy][sx] = 0
X = 0
while True:
    try:
        y, x = queue.pop()
        # print(y,x)
    except:
        # print("Fail")
        break
    for i in range(4):
        nx = x + (-1, 0, 1, 0)[i]
        ny = y + (0, -1, 0, 1)[i]
        # print("nynx",ny,nx)
        if (0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and C[ny][nx] != '#' and distance[ny][nx] == inf):
            queue.insert(0, (ny, nx))
            distance[ny][nx] = distance[y][x] + 1
            C[ny][nx] = "!"
    

if distance[H-1][W-1] != inf:
    #print(distance[gy][gx])
    ans = 0
    for i in C:
        ans += i.count(".")
        print(i)
    print(ans)
    print(distance)
else:
    print("Fail")

Fixed, accepted submission:
import sys

H, W = map(int, input().split())
sx = 0
sy = 0
gx = W-1
gy = H-1
ans = 0
A = [list(i for i in input()) for _ in range(H)]
for j in A:
    ans += j.count(".")
inf = -1
distance = [[inf] * W for _ in range(H)]
queue = []
queue.insert(0, (sy, sx))
distance[sy][sx] = 0
X = 0
while True:
    try:
        y, x = queue.pop()
        # print(y,x)
    except:
        # print("Fail")
        break
    for i in range(4):
        nx = x + (-1, 0, 1, 0)[i]
        ny = y + (0, -1, 0, 1)[i]
        # print("nynx",ny,nx)
        if (0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and A[ny][nx] != '#' and distance[ny][nx] == inf):
            queue.insert(0, (ny, nx))
            distance[ny][nx] = distance[y][x] + 1
            A[ny][nx] = "!"
    

if distance[H-1][W-1] != inf:
    #print(distance[gy][gx])
    ans -= distance[gy][gx] + 1
    print(ans)
else:
    print(-1)
Problem:
Find the edit distance between given two words s1 and s2.  The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:    * **insertion** : Insert a character at a particular position.   * **deletion** : Delete a character at a particular position.    * **substitution** : Change the character at a particular position to a different character

Incorrect submission (verdict: Wrong Answer):
s1=input()
s2=input()
ls1=len(s1)
ls2=len(s2)
f=[[0 for j in range(ls2+1)] for i in range(ls1+1)]
for i in range(ls1+1):
    f[i][0]=i
for i in range(ls2+1):
    f[0][i]=i
for i in range(1,ls1+1):
    for j in range(1,ls2+1):
        if s1[i-1]!=s2[j-1]:
            f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)
        else:
            f[i][j]=f[i-1][j-1]
print(f)



Fixed, accepted submission:
s1=input()
s2=input()
ls1=len(s1)
ls2=len(s2)
f=[[0 for j in range(ls2+1)] for i in range(ls1+1)]
for i in range(ls1+1):
    f[i][0]=i
for i in range(ls2+1):
    f[0][i]=i
for i in range(1,ls1+1):
    for j in range(1,ls2+1):
        if s1[i-1]!=s2[j-1]:
            f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)
                       
        else:
            f[i][j]=f[i-1][j-1]
print(f[i][j])
Problem:
You are given a string S.  Takahashi can insert the character `A` at any position in this string any number of times.  Can he change S into `AKIHABARA`?

Incorrect submission (verdict: Wrong Answer):
s=input()
str=["A","K","I","H","A","B","A","R","A"]
count=0
for i in range(9):
    if s[count]==str[i]:
        count+=1
    if count==len(s):
        break
if count!=len(s):
    print("No")
else:
    print("Yes")


Fixed, accepted submission:
s=input()
str=["A","K","I","H","A","B","A","R","A"]
count=0
ans=0
for i in range(9):
    if count==len(s) and i<8:
        ans=1
        break
    elif count==len(s):
        break
    if s[count]==str[i]:
        count+=1
    elif s[count]!=str[i] and str[i]!="A":
        ans=1
        break
if len(s)>9:
    ans=1
if ans==1:
    print("NO")
else:
    print("YES")
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
M,D=map(int,input().split())
result=0

for i in (2,D//10+1):
  if i<D//10:
    result+=M//i-1
  else:
    if D%10>=2:
      result+=min(M//i,D%10)-1
print(result)

Fixed, accepted submission:
M,D=map(int,input().split())
result=0
 
for i in range(2,D//10+1):
  if i<D//10:
    result+=max(min(M//i,9)-1,0)
    #print(i,min(M//i,9)-1)
  else:
    if D%10>=2:
      result+=max(min(M//i,D%10)-1,0)
      #print(i,min(M//i,D%10)-1)
print(result)
Problem:
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:    * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.   * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.  The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Incorrect submission (verdict: Wrong Answer):
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c)

Fixed, accepted submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,h=LI()
  l=[]

  for _ in range(n):
    a,b=LI()
    l.append([a,-1])
    l.append([b,1])

  l=sorted(l,key=lambda x:x[0],reverse=True)
  # print(l)

  ans=0
  for i,x in enumerate(l):
    if x[1]==1:
      ans+=1
      h-=x[0]
    else:
      ans+=-(-h//x[0])
      return ans

    if h<=0:
      return ans

  return ans

# main()
print(main())
Problem:
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:  \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\]  where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.

Incorrect submission (verdict: Wrong Answer):
n, m, L = map(int, input().split())

a = [list(map(int, input().split())) for _ in range(m)]
b = [list(map(int, input().split())) for _ in range(L)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]

for ci in c:
    print(*ci)

Fixed, accepted submission:
n, m, L = map(int, input().split())

a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]

for ci in c:
    print(*ci)
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
A, B, X = map(int, input().split())

if A + B >= X >= A:
    print('Yes')
else:
    print('No')

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

if A + B >= X >= A:
    print('YES')
else:
    print('NO')
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
lr = [[int(i) for i in input().split()] for j in range(n)]
ans = 0
for i in range(n):
    ans += lr[i][1] - lr[i][0]
print(ans)

Fixed, accepted submission:
n = int(input())
lr = [[int(i) for i in input().split()] for j in range(n)]
ans = 0
for i in range(n):
    ans += lr[i][1] - lr[i][0]+1
print(ans)
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):
print(int(input())%1000)

Fixed, accepted submission:
N = int(input())
change = 1000 - (N % 1000) if N % 1000 != 0 else 0
print(change)
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):
N,M,R = map(int,input().split())
ans = ''
for i in range(M+1):
    if  (i * N) % M == R:
        ans = 'Yes'
        break;
if ans == '':
    ans = 'No'
print(ans)

Fixed, accepted submission:
N,M,R = map(int,input().split())
ans = ''
for i in range(M+1):
    if  (i * N) % M == R:
        ans = 'YES'
        break;
if ans == '':
    ans = 'NO'
print(ans)
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())

print(1000-(N-round(N,-3)))

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

while True:
    if N >= 1000:
        N -= 1000
    else:
        break

if N == 0:
    print(0)
else:
    print(1000-N)
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
s = input()
s_list = list(s)
while True:
    l5 = s_list[-5:]
    l6 = s_list[-6:]
    l7 = s_list[-7:]
    s5 = s6 = s7 = ''

    for ch in l5:
        s5 += ch
#    print("s5 :", s5)
    for ch in l6:
        s6 += ch
#    print("s6 :", s6)
    for ch in l7:
        s7 += ch
#    print("s7 :", s7)

    if (s5 == 'erase') | (s5 == 'dream'): 
        s_list = s_list[:-5]
#       print("s_list:", s_list)
    elif s6 == 'eraser':
        s_list = s_list[:-6]
#       print("s_list:", s_list)
    elif s7 == 'dreamer':
        s_list = s_list[:-7]
#       print("s_list:", s_list)
    else:
        print('NO')
#       print("s_list:", s_list)
        exit()

    if  s_list == []:
        print('YES')
        exit()



Fixed, accepted submission:
ch = input()
if (ch == 'a') | (ch == 'i') | (ch == 'u') | (ch == 'e') | (ch == 'o'):
    print('vowel')
else:
    print('consonant')
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 = int(input())
t = []
p = [0, 0, 0]
while(n):
    a, b, c = input().split(' ')
    t.append([int(a), int(b), int(c)])
    n-=1
for i in t:
    while(p[0] < i[0]):
        p[0]+=1
        if i[1] > p[1]:
            p[1]+=1
        elif i[2] > p[2]:
            p[2]+=1
        elif i[1] < p[1]:
            p[1]-=1
        elif i[2] < p[2]:
            p[2]-=1
        else:
            p[1]-=1
        print(p)
    if p != i:
        print('No')
        exit()
print('Yes')

Fixed, accepted submission:
n = int(input())
t = []
p = [0, 0, 0]
while(n):
    a, b, c = input().split(' ')
    t.append([int(a), int(b), int(c)])
    n-=1
for i in t:
    while(p[0] < i[0]):
        p[0]+=1
        if i[1] > p[1]:
            p[1]+=1
        elif i[2] > p[2]:
            p[2]+=1
        elif i[1] < p[1]:
            p[1]-=1
        elif i[2] < p[2]:
            p[2]-=1
        else:
            p[1]-=1
    if p != i:
        print('No')
        exit()
print('Yes')
Problem:
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_.  When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.  What is the abbreviation for the N-th round of ABC? Write a program to output the answer.

Incorrect submission (verdict: Wrong Answer):
"ABC"+input()

Fixed, accepted submission:
print("ABC"+input())
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=input()
k=int(input())
j=s[k-1]
new_s=""
for i in range(n):
  if s[i]!=j:
    new_s+="*"
  else:
    new_s+=j

Fixed, accepted submission:
n=int(input())
s=input()
k=int(input())
j=s[k-1]
new_s=""
for i in range(n):
  if s[i]!=j:
    new_s+="*"
  else:
    new_s+=j
print(new_s)
Problem:
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.  The i-th operation is as follows:    1. Append a_i to the end of b.   2. Reverse the order of the elements in b.  Find the sequence b obtained after these n operations.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(A[i])
    B.reverse()

print(B)

Fixed, accepted submission:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
B = deque()
for i in range(n):
    if(i%2 == 0):
        B.append(A[i])
    if(i%2 == 1):
        B.appendleft(A[i])

if(n%2 == 1):
    B.reverse()
text = ""
for b in B:
    text += str(b) + " "
text = text[:-1]
print(text)
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()

count_e = [0] * n
count_w = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'E':
            count_e[i] = 1
        else:
            count_w[i] = 1
        continue
    if s[i] == 'E':
        count_e[i] = count_e[i-1] + 1
        count_w[i] = count_w[i-1]
    else:
        count_w[i] = count_e[i-1]
        count_e[i] = count_e[i-1] + 1

ans = 10 ** 9
for i in range(n):
    if s[i] == 'E':
        e = count_e[-1] - count_e[i]
        w = count_w[i]
    else:
        e = count_e[-1] - count_e[i]
        w = count_w[i] - 1
    ans = min(ans,e+w)
print(ans)

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

count_e = [0] * n
count_w = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'E':
            count_e[i] = 1
        else:
            count_w[i] = 1
        continue
    if s[i] == 'E':
        count_e[i] = count_e[i-1] + 1
        count_w[i] = count_w[i-1]
    else:
        count_e[i] = count_e[i-1]
        count_w[i] = count_w[i-1] + 1

ans = 10 ** 9
for i in range(n):
    if s[i] == 'E':
        e = count_e[-1] - count_e[i]
        w = count_w[i]
    else:
        e = count_e[-1] - count_e[i]
        w = count_w[i] - 1
    ans = min(ans,e+w)
print(ans)