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, M, K = map(int, input().split())
# N = int(input())
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True

for i in T:
    
    for n, j in enumerate(D):
        if i == j:
            D.pop(n)
            # print(D)
            flag = True
            break
    if flag == False:
        print("No")
        ans_flag = False
        break
    else:
        flag = False
if ans_flag == True:
    print("Yes")


Fixed, accepted submission:
import collections

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True
d = collections.Counter(D)
t = collections.Counter(T)
# print(d.most_common())
# print(t.most_common())
for i in t:
    i_str = str(i)
    d_count = d[i]
    if d_count < t[i]:
        print("NO")
        ans_flag = False
        break

if ans_flag == True:
    print("YES")
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

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

h = str(S//360)
M = S%360

m = str(M//60)

s = str(M%60)
print(h+":"+m+":"+s)

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

h = str(S//3600)
M = S%3600

m = str(M//60)

s = str(M%60)
print(h+":"+m+":"+s)
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

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

ans = 0
if a == 0:
    ans = 1
ans += int((b - a) / x )
print(ans)

Fixed, accepted submission:
a, b, x = map(int, input().split())
ans = 0

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 
    return f
print(fanc(b, x) - fanc(a - 1, x))
Problem:
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.  How many grams of sand will the upper bulb contains after t seconds?

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
print(max(0,b-a))

Fixed, accepted submission:
a,b=map(int,input().split())
print(max(0,a-b))
Problem:
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them.  He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).  Find the minimum total cost to achieve his objective.

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

stack = []

for i in range(n):
    stack.append(a[i])
    stack.reverse()

st = ""

for i in range(len(stack)):
    st = st + str(stack[i])

print(" ".join(st))

Fixed, accepted submission:
N = int(input())
*A, = map(int, input().split())


min = float("inf")
for y in range(-100, 101, 1):
    sum = 0
    for a in range(len(A)):
        sum = sum + (A[a]-y)**2
    if min > sum:
        min = sum
        ans = y

print(min)
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():  
	nums = input().split(" ")
	nums.sort(key = int)
	print(" ".join(nums))
if __name__ == '__main__':
  main()

Fixed, accepted submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main(): 
	nums = []
	while True:
		x = input().split(" ")
		if x == ["0","0"]:
			break
		x.sort(key = int)
		nums.append(x)
	for i in nums:
			print(" ".join(i))
if __name__ == '__main__':
  main()
Problem:
Takahashi is organizing a party.  At the party, each guest will receive one or more snack pieces.  Takahashi predicts that the number of guests at this party will be A or B.  Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.  We assume that a piece cannot be divided and distributed to multiple guests.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
c = min(a, b)
print(c)
for i in range(c, a * b + 1):
    if i % a == 0 and i % b == 0:
        print(i)
        exit()

Fixed, accepted submission:
a, b = map(int, input().split())
c = a * b
d = min(a, b)
j = 1
for i in range(2, d + 1):
    j += 1
    if a % j == 0 and b % j == 0:
        c //= j
        a //= j
        b //= j
        j = 1
print(c)
Problem:
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.

Incorrect submission (verdict: Wrong Answer):
import string

chs = dict([(ch, 0) for ch in string.ascii_lowercase])

for ch in input():
    if ch not in chs:
        continue

    chs[ch] += 1

for k, v in chs.items():
    print(k, ':', v)

Fixed, accepted submission:
import string

dic = { ch:0 for ch in string.ascii_lowercase }

while True:
    try:
        line = input()

        for ch in line:
            c = ch.lower()

            if c not in dic:
                continue

            dic[c] += 1

    except EOFError:
        break

for ch in string.ascii_lowercase:
    print(ch, ':', dic[ch])
Problem:
A Hitachi string is a concatenation of one or more copies of the string `hi`.  For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not.  Given a string S, determine whether S is a Hitachi string.

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

for i in range(len(s)-1):
  if (s[i]== "h" and s[i+1] == "i"):
    if i+1 == len(s)-1:
      print("Yes")
    elif s[i+2] != "i":
      print("No")
    else:
      print("Yes")
  else:
    print("No")
      

Fixed, accepted submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
if s == 'hi' or s == 'hihi' or s == 'hihihi' or s == 'hihihihi' or s == 'hihihihihi':
    print('Yes')
else:
    print('No')
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int,input().split())
if min(a,c)<= b and max(a,c) >= b:
    print("Yes")
else :
    print("No")


Fixed, accepted submission:
a,b,c = map(int,input().split())
if min(a,b)<= c and max(a,b) >= c:
    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):
ls = list(map(int, input().split()))
count = 0
for i in ls:
  if i == 1:
    count += 1
print(count)

Fixed, accepted submission:
import sys
from collections import Counter

s = sys.stdin.readline().rstrip()

def main():
    c = Counter(s)
    print(c.get('1', 0))

if __name__ ==  '__main__':
    main()
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
d = 0
for a in A[::2]:
  d += a
for a in A[1::2]:
  d -= a
print(d)


Fixed, accepted submission:
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
A.reverse()
d = 0
for a in A[::2]:
  d += a
for a in A[1::2]:
  d -= a
print(d)
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
import collections

abc = collections.Counter(input().split())

print('Yes' if abc['5'] == 2 and abc['7'] == 1 else 'No')


Fixed, accepted submission:
import collections

abc = collections.Counter(input().split())

print('YES' if abc['5'] == 2 and abc['7'] == 1 else 'NO')
Problem:
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.  The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day:    * A: Swim in the sea. Gain a_i points of happiness.   * B: Catch bugs in the mountains. Gain b_i points of happiness.   * C: Do homework at home. Gain c_i points of happiness.  As Taro gets bored easily, he cannot do the same activities for two or more consecutive days.  Find the maximum possible total points of happiness that Taro gains.

Incorrect submission (verdict: Wrong Answer):
import sys
N = int(input())
summer = []
for i in range(N):
    summer.append(list(map(int, sys.stdin.readline().rstrip().split(" "))))
print(summer)

INF = float('inf')
DP = [[-INF for i in range(3)] for i in range(N)]
print(DP)


for i in range(N):
    if i == 0:
        DP[i] = summer[i]
    else:
        DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + summer[i][0]
        DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + summer[i][1]
        DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + summer[i][2]

print(max(DP[N-1]))

Fixed, accepted submission:
import sys
N = int(input())
summer = []
for i in range(N):
    summer.append(list(map(int, sys.stdin.readline().rstrip().split(" "))))

INF = float('inf')
DP = [[-INF for i in range(3)] for i in range(N)]

for i in range(N):
    if i == 0:
        DP[i] = summer[i]
    else:
        DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + summer[i][0]
        DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + summer[i][1]
        DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + summer[i][2]

print(max(DP[N-1]))
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):
from collections import Counter

def main():
    n = int(input())
    s = [input() for i in range(n)]
    print(s)
    ac = 0    
    wa = 0
    tle = 0
    re = 0
    for i in s:
        if i == 'AC':
            ac += 1
        elif i == 'WA':
            wa += 1
        elif i == 'TLE':
            tle += 1
        elif i == 'RE':
            re += 1
    print('AC x', ac)
    print('WA x', wa)
    print('TLE x', tle)
    print('RE x', re)
    
if __name__ == '__main__':
    main()

Fixed, accepted submission:
n = int(input())
s = [input() for i in range(n)]
for i in ['AC', 'WA', 'TLE', 'RE']:
    print(i, 'x',  s.count(i))
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: Time Limit Exceeded):
A,B,C,D,E,F = map(int,input().split())

W = []
S = []


for i in range(F+1):
    for j in range(F+1):
        x = 100*A*i + 100*B*j
        W.append(x)


for i in range(F+1):
    for j in range(F+1):
        y = C*i + D*j
        S.append(y)

maxcon = 0
limitcon = 100*E/(100+E)
ans1 = 0
ans2 = 0


for i in range(1,len(W)):
    for j in range(1,len(S)):
        sw = W[i] + S[j]
        con = 100*S[j] / sw
        if (sw <= F) and (con <= limitcon) and (maxcon < con):
            maxcon = con
            ans1 = sw
            ans2 = S[j]



print("%s %s"%(ans1,ans2))

Fixed, accepted submission:
A,B,C,D,E,F=map(int,input().split())

best_sugarwater = 100*A
best_sugar = 0
best_con = 0
max_con = E/(100+E)

maxA = F//(100*A)
for i in range(maxA+1):
    maxB = (F-100*A*i)//(100*B)
    for j in range(maxB+1):
        water = 100*A*i+100*B*j
        maxC = (F-100*A*i-100*B*j)//C
        for k in range(maxC+1):
            maxD = (F-100*A*i-100*B*j-C*k)//D
            for l in range (maxD+1):
                sugar = C*k+D*l
                if sugar + water == 0 :
                    pass
                elif (best_con < sugar/(sugar + water) <= max_con ):
                    best_sugarwater = sugar + water
                    best_sugar = sugar
                    best_con = sugar/(sugar + water)

print(best_sugarwater,best_sugar)
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())


area = (a + b) * h / 0.5
print(area)

Fixed, accepted submission:

a = int(input())
b = int(input())
h = int(input())
 

area = int((a + b) * h / 2)
print(area)
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):
s = input()

for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 0 and s[:len(s)//2] == s[-len(s)//2:]:
        print(s)
        break

Fixed, accepted submission:
s = input()

for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 0 and s[:len(s)//2] == s[-len(s)//2:]:
        print(len(s))
        break
Problem:
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".

Incorrect submission (verdict: Wrong Answer):
# B_KEYENCE String

import sys

S = list(input())

key = ['k','e','y','e','n','c','e']
i = 0
for _ in range(len(S)) :
    if S[_] == key[i] :
        i += 1

if i > 6 :
    print("YES")
else :
    print("NO")


Fixed, accepted submission:
#A_Beginning
import sys

N = list(map(int, input().split()))

wk = [99 for _ in range(len(N))]
flg = True
for i in range(len(N)) :
    if N[i] == 1 or N[i] == 9 or N[i] == 7 or N[i] == 4 :
        for _ in range(len(wk)) :
            if wk[_] == N[i] :
                flg = False
                break
        if flg == False :
            break
        else :
            wk[i] = N[i]
            flg = True
    else :
        flg = False
        break

if flg == True :
    print("YES")
else :
    print("NO")
Problem:
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
# Your code here!

S = int(input())
lis = []
for item in range(0,int(S)):
    tmp = input()
    lis.append(int(tmp))
ls = sorted(lis)
#print(ls)
#print(ls[int(S/2)])
i = 0
lo = 0
hg = int(S)-1
ans =  ls[hg]- ls[int(S/2)]
#print("first",ans)
if S % 2 == 1 or S % 2 == 0:
    for k in range(0,int(S/2)+1):
        #print(i)
    # TODO: write code...
    # TODO: write code...
    # TODO: write code...
    #if(i != 0):
        #hg-=1
        if(i == int(S)-1):
            break
        ans = ans + ls[hg] - ls[lo]
        i+=1
        #print(ls[hg],ls[lo])
        hg-=1
        if(i == int(S)-1):
            break
        ans = ans + ls[hg] - ls[lo]
        #print(ls[hg],ls[lo])
        lo+=1
        i+=1

else:
    for i in range(0,int(S/2)+1):
    
    # TODO: write code...
    # TODO: write code...
    # TODO: write code...
    #if(i != 0):
        #hg-=1
        ans = ans + ls[hg] - ls[lo]
        print(ls[hg],ls[lo])
        if(hg == int(S/2)):
            break
        hg-=1
        ans = ans + ls[hg] - ls[lo]
        print(ls[hg],ls[lo])
        lo+=1



print(ans)
 #   hg-=1
 #   print(ls[hg] , ls[lo])
 
 #   print(ans)
 
 #   lo+=1
 #   hg-=1
 #   print(ls[hg] , ls[lo])
 #   print(ans)


Fixed, accepted submission:
# coding: utf-8
# Your code here!

S = int(input())
lis = []
for item in range(0,int(S)):
    tmp = input()
    lis.append(int(tmp))
ls = sorted(lis)
lsb = sorted(lis)

center = ls[int(S/2-0.5)]
ans1 = ls[-1] - center
ls.remove(center)
for k in range(0,int(S/2)):
    try:
        
        ans1 = ans1 + ls.pop(-1) - ls[0]
        ans1 = ans1 + ls[-1] -ls.pop(0)
    except:
        break
    
if S % 2 ==0:
    print(ans1)
    exit()

center = lsb[int(S/2)]
ans2 = center - lsb[0] 

lsb.remove(center)

for k in range(0,int(S/2)):
    try:
        ans2 = ans2 + lsb[-1] - lsb.pop(0) 
        ans2 = ans2 + lsb.pop(-1) - lsb[0] 

    except:
        break
print(max(ans1,ans2))
Problem:
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:    * Question 1: Are you subscribing to Newspaper X?   * Question 2: Are you subscribing to Newspaper Y?  As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.  What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?  Write a program to answer this question.

Incorrect submission (verdict: Wrong Answer):
n,a,b=map(int,input().split());print(min(n,a+b),max(0,a+b-n))

Fixed, accepted submission:
n,a,b=map(int,input().split());print(min(a,b),max(0,a+b-n))
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
S=input()
str_list=["dream","dreamer","erase","eraser"]

S_tmp=""
while True:
  S_tmp=S
  for str in str_list:
    S=S.replace(str,"") 
  
  if S_tmp==S:
    break

if S=="":
  print("Yes")
if S!="":
  print("No")  

Fixed, accepted submission:
S=input()
str_list=["dreamer","eraser","dream","erase"]
     
while True:
  S_tmp=S
  for str in str_list:
    if S[-len(str):]==str:
      S=S[0:len(S)-len(str)]
        
  if S_tmp==S:
    break    
        
if S=="":
  print("YES")
if S!="":
  print("NO")
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
s=input()
s=sorted(s)
l=['a','b','c']
if s==l:
    print('YES')
else:
    print('NO')

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

if s[0]=='a' and s[1]=='b' and s[2]=='c':
    print('Yes')
else:
    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):
n, m = map(int, input().split())
if (n*m)%2:
    print("Even")
else:
    print("Odd")

Fixed, accepted submission:
a, b = map(int, input() .split())
c = (a * b) % 2
if c == 0:
    print("Even")
else:
    print("Odd")
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    for word in words:
        if s.startswith(t + word):
            t = t + word
            break
        else:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    t_fixed = t
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    else:
        for word in words:
            if s.startswith(t + word):
                t = t + word
                break
        if t == t_fixed:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')