TnT/CodeNet4Repair huggingface dataset:
Problem:
Rng is preparing a problem set for a qualification round of CODEFESTIVAL.  He has N candidates of problems. The difficulty of the i-th candidate is D_i.  There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.  Determine whether Rng can complete the problem set without creating new candidates of problems.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
DS = input().split()
D = {}
for i in range(N):
    if DS[i] not in D:
        D[DS[i]] = 0
    D[DS[i]] += 1

M = int(input())
T = input().split()
flg = True
for i in range(M):
    if T[i] in D:
        D[T[i]] -= 1
        if D[T[i]] < 0:
            print('No')
            flg = False
            break
    else:
        print('No')
        flg = False
        break
if flg:
    print('Yes')


Fixed, accepted submission:
N = int(input())
DS = input().split()
D = {}
for i in range(N):
    if DS[i] not in D:
        D[DS[i]] = 0
    D[DS[i]] += 1

M = int(input())
T = input().split()
flg = True
for i in range(M):
    if T[i] in D:
        D[T[i]] -= 1
        if D[T[i]] < 0:
            print('NO')
            flg = False
            break
    else:
        print('NO')
        flg = False
        break
if flg:
    print('YES')
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: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):
    checker = {}
    checker['a'] = False
    checker['b'] = False
    checker['c'] = False
    
    if 3 != len(list(input_str)):
        print('No')
        return

    for s in list(input_str):
        checker[s] = True
    
    
    if checker['a'] and checker['b'] and checker['c']:
        print('Yes')
        return
    print('No')
    return


if __name__ == '__main__':
    while True:
        try:
            main(input().strip())
        except EOFError:
            pass


Fixed, accepted submission:
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):
    checker = {}
    checker['a'] = False
    checker['b'] = False
    checker['c'] = False
    
    if 3 != len(list(input_str)):
        print('No')
        return

    for s in list(input_str):
        checker[s] = True
    
    
    if checker['a'] and checker['b'] and checker['c']:
        print('Yes')
        return
    print('No')
    return


if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
    if 1 == L[i][0]:
        s.append(L[i][1])
    if 1 == L[i][1]:
        s.append(L[i][0])
        
for i in range(M):
    if N == L[i][0]:
        g.append(L[i][1])
    if M == L[i][1]:
        g.append(L[i][0])
        
if set(g)&set(s):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed, accepted submission:
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
    if 1 == L[i][0]:
        s.append(L[i][1])
    if 1 == L[i][1]:
        s.append(L[i][0])
        
for i in range(M):
    if N == L[i][0]:
        g.append(L[i][1])
    if N == L[i][1]:
        g.append(L[i][0])
        
if set(g)&set(s):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
tmp = (input().split(" "))
H = int(tmp[0])
W = int(tmp[1])

datas = [input() for i in range(0, H, 1)]

array = []

for data in datas:
  tmp = [x for x in list(data)]
  array.append(tmp)
  
for i in range(0, H, 1):
  for j in range(0, W, 1):
    
    cnt = 0
    
    
    if array[i][j] == "#":
      continue
      
    else:

      for l in range(-1, 2, 1):
        for m in range(-1, 2, 1):
            
          no1 = i + l
          no2 = j + m
          
          if l == no1 and m == no2:
            continue
          
            
          try:
            
            if no1 < 0 or no2 < 0:
              continue
              
            else:
              if array[no1][no2] == "#":
                cnt += 1
              else:
                pass
            
          except:
            pass
          
      array[i][j] = str(cnt)
      
for x in (array):
  print("".join(x))
      

        
        
        

Fixed, accepted submission:
tmp = (input().split(" "))
H = int(tmp[0])
W = int(tmp[1])

datas = [input() for i in range(0, H, 1)]

array = []

for data in datas:
  tmp = [x for x in list(data)]
  array.append(tmp)

for i in range(0, H, 1):
  for j in range(0, W, 1):
    
    cnt = 0
    
    
    if array[i][j] == "#":
      continue
      
    else:

      for l in range(-1, 2, 1):
        for m in range(-1, 2, 1):
                
          no1 = i + l
          no2 = j + m

          if i == no1 and j == no2:
            continue

          try:

            if no1 < 0 or no2 < 0:
              continue
              
            else:
              if array[no1][no2] == "#":
                cnt += 1
              else:
                pass
            
          except:
            pass
          
      array[i][j] = str(cnt)
      
for x in (array):
  print("".join(x))
Problem:
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.  The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it.  Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.  Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = [int(input()) for _ in range(n)]

count = 1
i = 0

while count < n:
  i = a[i] - 1
  if i == 1:
    print(count)
    break
  count += 1
print(-1)


Fixed, accepted submission:
n = int(input())
a = [int(input()) for _ in range(n)]

count = 1
i = 0

while count < n:
  i = a[i] - 1
  if i == 1:
    print(count)
    break
  count += 1
if count >= n:
  print(-1)
Problem:
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i.  The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.  When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.  What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
if n%2==0:
  m=n//2
  ans=0
  for i in range(m):
    ans+=2*a[i]
  ans-=a[0]
else:
  m=n//2
  ans=0
  for i in range(m):
    ans+=2*a[i]
  ans+=a[m]
  ans-=a[0]
print(ans,a)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
if n%2==0:
  m=n//2
  ans=0
  for i in range(m):
    ans+=2*a[i]
  ans-=a[0]
else:
  m=n//2
  ans=0
  for i in range(m):
    ans+=2*a[i]
  ans+=a[m]
  ans-=a[0]
print(ans)
Problem:
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.  You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.

Incorrect submission (verdict: Wrong Answer):
maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        if int(d[i]) in a:
            n-=1
        else:
            a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])



Fixed, accepted submission:
maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
s=input()
ans=0
for i in range(a+b+1):
    if i==a and s[i]=="-":
        ans+=1
        print("a")
    elif i!=a and s[i].isdecimal()==True:
        ans+=1
if ans==a+b+1:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b=map(int,input().split())
s=input()
ans=0
for i in range(a+b+1):
    if i==a and s[i]=="-":
        ans+=1
    elif i!=a and s[i].isdecimal()==True:
        ans+=1
if ans==a+b+1:
    print("Yes")
else:
    print("No")
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 = str(input())

west = 0
for i in range(N):
  if S[i] == "W":
    west += 1

ans_list = [0] * N
for i in range(N):
  if S[i] == "W":
    west -= 1
  if i != 0:
    if S[i - 1] == "E":
      west += 1
  #ans_list[i] = min(west, N - west)
  ans_list[i] = west
#print(ans_list)
print(min(ans_list))
  

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

count = 0
for i in range(N):
  if S[i] == "E":
    count += 1

ans = 10 ** 10
for i in range(N):
  if S[i] == "E":
    count -= 1
  if i != 0:
    if S[i - 1] == "W":
      count += 1
  ans = min(ans, count)
  
print(ans)
Problem:
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.  Assume that initially no person lives in the building.

Incorrect submission (verdict: Wrong Answer):
x = [[[0 for k in range(10)]for j in range(3)]for i in range(4)]
n = int(input())
for i in range(n):
    [b, f, r, v] = map(int, input().split())
    x[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        tmp = list(map(str, x[b][f]))
        print(" ".join(tmp))

    print("#"*20)

Fixed, accepted submission:
x = [[[0 for k in range(10)]for j in range(3)]for i in range(4)]
n = int(input())
for i in range(n):
    [b, f, r, v] = map(int, input().split())
    x[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        tmp = list(map(str, x[b][f]))
        print(" "+" ".join(tmp))
    if b!=3:
        print("#"*20)
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):
# -*- coding: utf-8 -*-

str = input()

if int(str[0:2]) % 111 == 0:
	print("Yes")
elif int(str[1:3]) % 111 == 0:
	print("Yes")
print("No")	


Fixed, accepted submission:
# -*- coding: utf-8 -*-

str = input()
if int(str[0:3]) % 111 == 0:
	print("Yes")
elif int(str[1:4]) % 111 == 0:
	print("Yes")
else:
	print("No")
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):
#77a
a=input()
b=input()
if a[0]==b[-1] and a[1]==b[1] and a[-1]==b[0]:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
#77a
a=input()
b=input()
if a[0]==b[-1] and a[1]==b[1] and a[-1]==b[0]:
    print('YES')
else:
    print('NO')
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
if n < 2:
  print(1)
elif n < 3:
  print(2)
elif n < 5:
  print(4)
elif n < 9:
  print(8)
elif n < 17:
  print(16)
elif n < 33:
  print(32)
else:
  print(64)



Fixed, accepted submission:
print(2**(len(bin(int(input())))-3))
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):
import sys
S=list(input())
print(S)
outp=""
for i in S:
    if(i=="0"):
        outp+="0"
    elif(i=="1"):
        outp+="1"
    else:
        if(len(outp)!=0):
            outp = outp[0:-1]
print(outp)

Fixed, accepted submission:
import sys
S=list(input())
outp=""
for i in S:
    if(i=="0"):
        outp+="0"
    elif(i=="1"):
        outp+="1"
    else:
        if(len(outp)!=0):
            outp = outp[0:-1]
print(outp)
Problem:
Ringo is giving a present to Snuke.  Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things.  You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.

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

if len(i) < 4:
    print('NO')
elif i[:4] == 'YAKI':
    print('YES')
else:
    print('NO')

Fixed, accepted submission:
i = input()

if len(i) < 4:
    print('No')
elif i[:4] == 'YAKI':
    print('Yes')
else:
    print('No')
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):
if __name__ == "__main__":
    while True:
        a,op,b = map(str,input().split())
        if op is "+":
            print("%d"%(int(a)+int(b)))
        elif op is "-":
            print("%d"%(int(a)-int(b)))
        elif op is "*":
            print("%d"%(int(a)*int(b)))
        elif op is "/":
            print("%d"%(int(a)-int(b)))
        else:
            break

Fixed, accepted submission:
if __name__ == "__main__":
    while True:
        a,op,b = map(str,input().split())
        if op is "+":
            print("%d"%(int(a)+int(b)))
        elif op is "-":
            print("%d"%(int(a)-int(b)))
        elif op is "*":
            print("%d"%(int(a)*int(b)))
        elif op is "/":
            print("%d"%(int(a)/int(b)))
        else:
            break
Problem:
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

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


s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
    subsum += a[i]
    remain = s - subsum
    print(subsum, remain)
    res = min(res, abs(remain-subsum))

print(res)

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


s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
    subsum += a[i]
    remain = s - subsum
    res = min(res, abs(remain-subsum))

print(res)
Problem:
As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan.  The other calendar system is era-based calendar, or so-called “Japanese calendar.” This system comes from ancient Chinese systems. Recently in Japan it has been a common way to associate dates with the Emperors. In the era- based system, we represent a year with an era name given at the time a new Emperor assumes the throne. If the era name is “A”, the first regnal year will be “A 1”, the second year will be “A 2”, and so forth.  Since we have two different calendar systems, it is often needed to convert the date in one calendar system to the other. In this problem, you are asked to write a program that converts western year to era-based year, given a database that contains association between several western years and era-based years.  For the simplicity, you can assume the following:    1. A new era always begins on January 1st of the corresponding Gregorian year.   2. The first year of an era is described as 1.   3. There is no year in which more than one era switch takes place.  Please note that, however, the database you will see may be incomplete. In other words, some era that existed in the history may be missing from your data. So you will also have to detect the cases where you cannot determine exactly which era the given year belongs to.

Incorrect submission (verdict: Wrong Answer):
inputnum,outputnum = (int(n) for n in input().split(' '))
data = {}
while True:
    for i in range(inputnum):
        temp = input().split(' ')
        data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1,int(temp[2])]
    for o in range(outputnum):
        targ = int(input())
        for k,v in data.items():
            if v[0] <= targ  <= v[1]:
                print(k + ' ' + str(targ-v[0] + 1))
                break
        else:
            print("Unknown")
    inputnum,outputnum = (int(n) for n in input().split(' '))
    if inputnum == outputnum == 0:
        break

Fixed, accepted submission:
inputnum,outputnum = (int(n) for n in input().split(' '))
while True:
    data = {}
    for i in range(inputnum):
        temp = input().split(' ')
        data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1,int(temp[2])]
    for o in range(outputnum):
        targ = int(input())
        for k,v in data.items():
            if v[0] <= targ  <= v[1]:
                print(k + ' ' + str(targ-v[0] + 1))
                break
        else:
            print("Unknown")
    inputnum,outputnum = (int(n) for n in input().split(' '))
    if inputnum == outputnum == 0:
        break
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)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())

print((a+b)*h//2)