TnT/CodeNet4Repair huggingface dataset:
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())
print("YES" if A<=X and (A+B) <= X else "NO")

Fixed, accepted submission:
a,b,x = map(int,input().split())
print('YES' if x >= a and (a+b) >= x else 'NO')
Problem:
We have an N \times N square grid.  We will paint each square in the grid either black or white.  If we paint exactly A squares white, how many squares will be painted black?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=int(input())
print(n^2 -a)

Fixed, accepted submission:
n=int(input())
a=int(input())
print(n**2 -a)
Problem:
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.  Print the answer in degrees, but do not print units.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print((180-360/N)*N)

Fixed, accepted submission:
N = int(input())
print(int((180-360/N)*N))
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):
str = list(map(int, input().split()))
a = str[0]
b = str[1]
i = 1
if a < b:
  big = b
  small = a
else:
  big = a
  small = b

while i != 0:
  i = big % small
  big = small
  small = i

print (a*b/big)

Fixed, accepted submission:
str = list(map(int, input().split()))
a = str[0]
b = str[1]
i = 1
if a < b:
  big = b
  small = a
else:
  big = a
  small = b

while i != 0:
  i = big % small
  big = small
  small = i

print (int(a*b/big))
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()

match = -1
for i in range(len(s) - len(t) + 1):
    is_term_match = True
    for j in range(len(t)):
        if s[i + j] != "?" and s[i + j] != t[j]:
            is_term_match = False
            break
    if is_term_match:
        match = i
        break

if match == -1:
    print("UNRESTORABLE")
else:
    s = s[0:match] + t + s[match + len(t):]
    print(match)
    print(s)
    for i in range(len(s)):
        if s[i] == "?":
            s = s[0:i] + "a" + s[i + 1:]
    print(s)


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

match = -1
if len(s) >= len(t):
    for i in range(len(s) - len(t) + 1):
        is_term_match = True
        for j in range(len(t)):
            if s[i + j] != "?" and s[i + j] != t[j]:
                is_term_match = False
                break
        if is_term_match:
            match = i

if match == -1:
    print("UNRESTORABLE")
else:
    s = s[0:match] + t + s[match + len(t):]
    for i in range(len(s)):
        if s[i] == "?":
            s = s[0:i] + "a" + s[i + 1:]
    print(s)
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 and a <=x:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,x = map(int,input().split())
if a+b >= x and a <=x:
    print("YES")
else:
    print("NO")
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
import math


def solution(N, K):
    if (math.ceil((N + 1) / 2) >= K):
        return "YES"
    else:
        return "NO"


n, k = [int(s) for s in input().split(' ')]
solution(n, k)


Fixed, accepted submission:
import math


def solution(N, K):
    if (math.floor((N + 1) / 2) >= K):
        return "YES"
    else:
        return "NO"


n, k = [int(s) for s in input().split(' ')]
print(solution(n, k))
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
  print('A')
else:
  print('B')

Fixed, accepted submission:
x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
  print('B')
else:
  print('A')
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())
print(b//x - a//x)

Fixed, accepted submission:
a,b,x = map(int,input().split())
if a == 0:
	print(b//x + 1)
else:
    print(b//x - (a-1)//x)
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
d=dict()
for i in range(b):
  s,l=input().split()
  if s in d.keys():
    d[s]+=1
    if l in d.keys():
      d[l]+=1
    else:
      d[l]=1
  else:
    d[s]=1
    if l in d.keys():
      d[l]+=1
    else:
      d[l]=1

print(d.keys)

Fixed, accepted submission:
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
for i in range(n):
  print(l[i])
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):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 20:49:53 2017

@author: thvinmei
"""

if __name__ == '__main__':
    S=input()
    
    if (S[0:4]=="YAKI"):
        print("YES")
    else:
        print("NO")

Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 20:49:53 2017

@author: thvinmei
"""

if __name__ == '__main__':
    S=input()
    
    if (S[0:4]=="YAKI"):
        print("Yes")
    else:
        print("No")
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
A, B = map(int, input().split())
print("error") if A+B>=10 else A+B

Fixed, accepted submission:
A, B = map(int, input().split())
print("error") if A+B>=10 else print(A+B)
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())
l = S[K - 1]
result = ""
print(l)
for s in S:
    if s != l:
         result += "*"
    else:
         result += s
print(result)

Fixed, accepted submission:
N = int(input())
S = input()
K = int(input())
l = S[K - 1]
result = ""
for s in S:
    if s != l:
         result += "*"
    else:
         result += s
print(result)
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()
H=input()

slen=len(S)
hlen=len(H)

ans=False
for i in range(slen-hlen):
  jud=True
  for j in range(hlen):
    if S[i+j]!='?' and S[i+j]!=H[j]:
      jud=False
      break
  if jud:
    S=S[:i]+H+S[i+hlen:]
    ans=True
if ans:
  S=S.replace('?','a')
  print(S)
else:
  print("UNRESTORABLE")

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

slen=len(S)
hlen=len(H)

jisho=[]
ans=False
for i in range(slen-hlen+1):
  jud=True
  for j in range(hlen):
    if S[i+j]!='?' and S[i+j]!=H[j]:
      jud=False
      break
  if jud:
    ansS=S[:i]+H+S[i+hlen:]
    ans=True
    ansS=ansS.replace('?','a')
    jisho.append(ansS)

if ans:
  jisho.sort()
  print(jisho[0])
else:
  print("UNRESTORABLE")
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())
a = [0]*n
b = [0]*n
maxa = 0
for i in range(n):
    a[i], b[i] = map(int, input().split())
    maxa = max(maxa, a[i]) 
b.sort()
bsum = sum(b)
count = n

if bsum >= h:
    i = 0
    while bsum - b[i] > h:
        bsum -= b[i]
        i += 1
        count -= 1
else:
    if (h - bsum) % maxa == 0:
        count += (h - bsum) // maxa
    else:
        count += (h - bsum + 1)//maxa


print(a, b)
print(maxa)
print(count)

Fixed, accepted submission:
n, h = map(int, input().split())
a = [0]*n
b = [0]*n
maxa = 0
for i in range(n):
    a[i], b[i] = map(int, input().split())
    maxa = max(maxa, a[i])

c = []
for i in range(n):
    if b[i] >= maxa:
        c.append(b[i])
        
c.sort()
csum = sum(c)
count = len(c)

if csum >= h:
    i = 0
    while csum - c[i] >= h:
        if i == len(c):
            break
        else:
            csum -= c[i]
            i += 1
            count -= 1
else:
    if (h - csum) % maxa == 0:
        count += (h - csum) // maxa
    else:
        count += (h - csum) // maxa
        count += 1

print(count)
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<=x<=a+b):
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a,b,x =map(int,input().split())
if(a<=x<=a+b):
  print("YES")
else:
  print("NO")
Problem:
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.  Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.  For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:    * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.   * For every i, B_i \leq C_i holds.  If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
if sum(l_a)<sum(l_b):
  print(-1)
  exit()
l_sa = sorted(list(i-j for i,j in zip(l_a,l_b)))
s = 0
cou =0
print(l_sa)
for i in l_sa:
  if i<0:
    s += i
    cou +=1
  else:
    break
#print(s,cou)
l_sb = l_sa[::-1]
for i in l_sb:
  if s<0:
    s += i
    cou += 1
 #   print(s,cou)
  else:
    break
print(cou)
  

Fixed, accepted submission:
n = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
if sum(l_a)<sum(l_b):
  print(-1)
  exit()
l_sa = sorted(list(i-j for i,j in zip(l_a,l_b)))
s = 0
cou =0
#print(l_sa)
for i in l_sa:
  if i<0:
    s += i
    cou +=1
  else:
    break
#print(s,cou)
l_sb = l_sa[::-1]
for i in l_sb:
  if s<0:
    s += i
    cou += 1
    #print(s,cou)
  else:
    break
print(cou)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

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

if a * b // 2 == 0:
  print("Even")
else:
  print("Odd")
  

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

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
n = input()
l = len(n)
ans = 0
for i in range(l):
  for j in range(l-1):
    ans+=int(n[i])*(10**j)*(2**(l-1-j-1))
print(ans)

Fixed, accepted submission:
S = input()
n = len(S)
ans = 0
for i in range(n):
  a = int(S[i])
  for j in range(n-i):
    ans += a * 10**j * 2**i * 2**(max(0,n-i-j-2))
print(ans)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a, b = input().split()
c = int(a+b)
def d(c):
    for i in range(4, 400):
        if i**2 == c:
            return print('Yes')
    return print('No')

d(c)

Fixed, accepted submission:
a, b = map(int, input().split())
if (a*b) % 2: print('Odd')
else: print('Even')
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)
x = 0
ans = abs(2 * a[0] - s)
snuke = 0

for i in range(1, n-1):
    snuke += 2 * a[i]
    if abs(snuke - s) < ans:
        ans = abs(snuke - s)

print(ans)


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

s = sum(a)
x = 0
ans = abs(2 * a[0] - s)
snuke = a[0]

for i in range(1, n-1):
    snuke += a[i]
    if abs(2 * snuke - s) < ans:
        ans = abs(2 * snuke - s)

print(ans)
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
X=int(input())
i=100
l=0
while i<=X:
  i=int(i*1.01)
  l+=1
print(l)

Fixed, accepted submission:
X=int(input())
i=100
year=0
while i<X:
  i+=i//100
  year+=1
print(year)
Problem:
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.  You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.

Incorrect submission (verdict: Wrong Answer):

s = input()

a_index = s.find("A")
b_index = s.rfind("Z")

print(b_index - a_index + 1)


Fixed, accepted submission:

x = int(input())

if x < 1200:
    print("ABC")
else:
    print("ARC")
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
N, L = map(int, input().split())
S = []
master = 'abcdefghijklmnopqrstuvwxyz'

def f(s1, s2, l):
    for i in range(l):
        if master.index(s1[i]) == master.index(s2[i]):
            continue
        elif master.index(s1[i]) > master.index(s2[i]):
            return 'greater'
        elif master.index(s1[i]) < master.index(s2[i]):
            return 'less'
    return 'equal'

for _ in range(N):
    if _ == 0:
        S.append(input())
    else:
        s2 = input()
        max_iter = len(S)
        for i in range(max_iter):
            compared = f(s2, S[i], L)
            print(compared)
            print(S)
            if compared == 'greater' and i == max_iter-1:
                S.insert(i, s2)
            elif compared == 'greater':
                continue
            elif compared == 'less':
                S.insert(i, s2)
                break
            elif compared == 'equal':
                S.insert(i, s2)
                break

print(''.join(S))

Fixed, accepted submission:
N, L = map(int, input().split())
S = []
master = 'abcdefghijklmnopqrstuvwxyz'

def f(s1, s2, l):
    for i in range(l):
        if master.index(s1[i]) == master.index(s2[i]):
            continue
        elif master.index(s1[i]) > master.index(s2[i]):
            return 'greater'
        elif master.index(s1[i]) < master.index(s2[i]):
            return 'less'
    return 'equal'

for _ in range(N):
    if _ == 0:
        S.append(input())
    else:
        s = input()
        max_iter = len(S)
        for i in range(max_iter):
            compared = f(s, S[i], L)
            if compared == 'greater' and i == max_iter-1:
                S.append(s)
                break
            elif compared == 'less':
                S.insert(i, s)
                break
            elif compared == 'equal':
                S.insert(i, s)
                break
            else:
                continue

print(''.join(S))
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 = list(map(int, input().split()))
print(min(n[1], n[2]))
print(max(0, n[1] - n[2]))

Fixed, accepted submission:
n = list(map(int, input().split()))
print(min(n[1], n[2]), max(0, n[1] + n[2] - n[0]))
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 = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
    
    if op == '+':
        print(a + b)
    
    if op == '-':
        print(a - b)
        
    if op == '*':
        print(a * b)
        
    if op == '/':
        print(a / b)

Fixed, accepted submission:
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
    
    if op == '+':
        print(a + b)
    
    if op == '-':
        print(a - b)
        
    if op == '*':
        print(a * b)
        
    if op == '/':
        print(a // b)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a):
    for j in range(b):
        for k in range(c):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)
Problem:
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.  Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan.  Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.

Incorrect submission (verdict: Wrong Answer):
A, B, C, D= map(int, input().split())
L = A + B
R = C + D
if L >R:
    print("Left")
if L < R:
    print("Right")
else:
    print("Balanced")

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

if A +B > C+D:
    print("Left")
elif A+B < C+D:
    print("Right")
else:
    print("Balanced")