TnT/CodeNet4Repair huggingface dataset:
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())
if (a + b) > (c + d):
    print("Left")
if (a + b) < (c + d):
    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")
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):

def main():
    n = input()
    if len(n) == 1 or len(n) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Fixed, accepted submission:

def main():
    n = input()
    cnt = 0

    if n[0] == n[1]:
        cnt += 1
    else:
        cnt = 0

    for i in range(2, 4):
        if n[i-1] == n[i]:
            cnt += 1
        else:
            cnt -= 1
        if cnt >= 2:
            print('Yes')
            break
    if cnt < 2:
        print('No')


if __name__ == "__main__":
    main()
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
A, B, C = map(int, input().split())
K = int(input())
m = max(A, B, C)
print(A + B + C + 3 * m)


Fixed, accepted submission:
A, B, C = map(int, input().split())
K = int(input())
m = max(A, B, C)
print(A + B + C + (2**K - 1) * m)
Problem:
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).  The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
for i in range(n):
    k = input().split()
    if k[0] == 'S':
        for i in range(1,14):
            if int(k[1])==i:
                continue
            else:
                print('S {0}'.format(i))
    if k[0] == 'H':
        for i in range(1,14):
            if int(k[1])==i:
                continue
            else:
                print('H {0}'.format(i))            
    if k[0] == 'C':
        for i in range(1,14):
            if int(k[1])==i:
                continue
            else:
                print('C {0}'.format(i))
    if k[0] == 'D':
        for i in range(1,14):
            if int(k[1])==i:
                continue
            else:
                print('D {0}'.format(i))            
        


Fixed, accepted submission:
n = int(input())
S = [1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(n):
    variations,number = input().split()
    if variations == 'S':
        S.remove(int(number))
    if variations == 'C':
        C.remove(int(number))
    if variations == 'H':
        H.remove(int(number))
    if variations == 'D':
        D.remove(int(number))

for i in range(len(S)):
    print('{} {}'.format('S',S[i]))

for i in range(len(H)):
    print('{} {}'.format('H',H[i]))

for i in range(len(C)):
    print('{} {}'.format('C',C[i]))

for i in range(len(D)):
    print('{} {}'.format('D',D[i]))
Problem:
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.  He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.  To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.  How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
ue = list(set(list(map(int, input().split()))))
mid = list(set(list(map(int, input().split()))))
bot = list(set(list(map(int, input().split()))))
ue.sort()
mid.sort()
bot.sort()


ans = 0
for i in ue:
    for j in mid:
        if j <= i:
            continue
        else:
            for k in range(len(bot)):
                if bot[k] <= j:
                    continue
                else:
                    ans += len(bot) - k

print(ans)


Fixed, accepted submission:
import bisect


N = int(input())
ue = (list(map(int, input().split())))
mid = (list(map(int, input().split())))
bot = (list(map(int, input().split())))
ue.sort()
mid.sort()
bot.sort()

ans = 0
for i in mid:
    ans += bisect.bisect_left(ue, i) * (len(bot) - bisect.bisect_right(bot, i))
print(ans)
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):
A = input()
B = input() 
if A == B[::-1]:
	print("Yes")
else:
	print("No")

Fixed, accepted submission:
A = input()
B = input() 

print("YES") if A == B[::-1] else print("NO")
Problem:
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains.  Write a program which prints heights of the top three mountains in descending order.

Incorrect submission (verdict: Wrong Answer):
inputList = []
while True:
    try:
        num = int(input())
    except EOFError:
        break
    inputList.append(num)

inputList.sort()
for x in range(len(inputList) - 1, -1, -1):
    print(inputList[x])

Fixed, accepted submission:
inputList = []
while True:
    try:
        num = int(input())
    except EOFError:
        break
    inputList.append(num)

inputList.sort()
length = len(inputList)
for i in range(3):
    print(inputList[length - i - 1])
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
s = input()
print('2017/s[4:]')


Fixed, accepted submission:
s = input()
print('2018{}'.format(s[4:]))
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-a)//x)

Fixed, accepted submission:
a, b, x = map(int, input().split(" "))
ans = b//x - (a - 1)//x

print(ans)
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
x=int(input())
s = 0
t = 0
while s < x:
  s += t
  t += 1
print(t)

Fixed, accepted submission:
x=int(input())
s = 0
t = 0
while True:
    s += t
    if s >= x:
        break
    t += 1
print(t)
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
a,b,c=[int(i) for i in input().split()]
if a+b==c or b+c==a or c+a==b:
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
a,b,c=[int(i) for i in input().split()]
if (a+b)==c or (b+c)==a or (c+a)==b:
  print('Yes')
else:
  print('No')
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(n%1000)

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

if n%1000 == 0:
    print(0)
else:
    print(1000 - n%1000)
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

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

for i in range(0,len(Strings)):
    if Strings[i] == "A":
        length = i
        print(i)
        break

for i in range(len(Strings))[::-1]:
    if Strings[i] == "Z":
        length2 = i
        print(i)
        break

print(length2 - length +1 )

Fixed, accepted submission:
Strings = input()

for i in range(0,len(Strings)):
    if Strings[i] == "A":
        length = i
        break

for i in range(len(Strings))[::-1]:
    if Strings[i] == "Z":
        length2 = i
        break

print(length2 - length +1 )
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3])
        exit()



Fixed, accepted submission:
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3], "=7", sep="")
        exit()
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):
N, K = [int(i) for i in input().split()]

if K < (N - 1) // 2:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
N, K = [int(i) for i in input().split()]
 
if (K - 1) <= (N - 1) // 2:
  print("YES")
else:
  print("NO")
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
k=int(input())
s=1

for i in range(n):
    if (2*s)<k:
        s=2*s
    else:
        s+=k
print(s)

Fixed, accepted submission:
N=int(input())
K=int(input())
n=1
for i in range(N):
    n=min(n*2,n+K)
    #print(n)
print(n)
Problem:
Takahashi is playing with N cards.  The i-th card has an integer X_i on it.  Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:    * The integers on the two cards are the same.   * The sum of the integers on the two cards is a multiple of M.  Find the maximum number of pairs that can be created.  Note that a card cannot be used in more than one pair.

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

Fixed, accepted submission:
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()


p = [0]*m

q = [0]*m

cnt = 1
for i in range(n):
    q[x[i]%m] += 1
    if i == n-1 or x[i] != x[i+1]:
        p[x[i]%m] += cnt//2
        cnt = 1
    else:
        cnt += 1

res = 0

for i in range(m):
    if i==0:
        res += q[0]//2
        continue
    if i > m-i:
        break
    if i == m-i:
        res += q[i]//2
        continue

    if q[i] >= q[m-i]:
        res += q[m-i]
        q[i] -= q[m-i]
        res += min(q[i]//2,p[i])
    else:
        res += q[i]
        q[m-i] -= q[i]
        res += min(q[m-i]//2,p[m-i])
print(res)
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int, input().split())
list=[]
for i in range(b):
    list.append(a*(i+1)%b)
print('Yes' if c in list else 'No')

Fixed, accepted submission:
a,b,c=map(int, input().split())
list=[]
for i in range(b):
    list.append(a*(i+1)%b)
print('YES' if c in list else 'NO')
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
r,g,b = map(int,input().split())
print('Yes' if (r*100+g*10+b)%4 == 0 else 'No')

Fixed, accepted submission:
r,g,b = map(int,input().split())
print('YES' if (r*100+g*10+b)%4 == 0 else 'NO')
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 == 1:
        continue
    else:
        if S[:len(S)//2] == S[len(S)//2:len(S)]:
            print(len(S))
        else:
            continue

Fixed, accepted submission:
S = input()
S = S[:-1]
def cutstring(s):
    n = len(s)
    if n % 2 == 1:
        return cutstring(s[:-1])
    else:
        if s[:n//2] == s[n//2:]:
            return n
        else:
           return cutstring(s[:-1])
ans = cutstring(S)
print(ans)
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
n=input()
print(len(n))
word=""
for i in range(len(n)):
    if i%2==0:
        word+=n[i]
print(word)

Fixed, accepted submission:
n=input()
word=""
for i in range(len(n)):
    if i%2==0:
        word+=n[i]
print(word)
Problem:
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.  You are given an integer N. Find the N-th Lucas number.  Here, the i-th Lucas number L_i is defined as follows:    * L_0=2   * L_1=1   * L_i=L_{i-1}+L_{i-2} (i≥2)

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


Fixed, accepted submission:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    l.append(l[-1] + l[-2])
print(l[n])
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("Odd")
else:
        print("Even")


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

if (a*b)%2 :
        print("Odd")
else:
        print("Even")
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
n,m,x,y=map(int,input().split())
ans="No War"
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(x+1,y+1):
    for j in range(n):
        for k in range(m):
            if a[j]>=i or i>b[k]:
                ans="War"
print(ans)


Fixed, accepted submission:
N, M, X, Y = map(int, input().split())
list_x = [int(i) for i in input().split()]
list_y = [int(j) for j in input().split()]
if max(list_x) >= min(list_y):
    print('War')
else:
    if X < max(list_x) + 1 <= Y:
        print('No War')
    else:
        print('War')
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
a = 0
for i in range(N):
    a+= i
print(a)

Fixed, accepted submission:
N = int(input())
a = 0
for i in range(N):
    a+= i+1
print(a)
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

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

if c>=a and c<=b:
  print("YES")
  exit()
print("NO")

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

if c >= a and c <=b:
  print("Yes")
else:
  print("No")
Problem:
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.  Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** :    * Add 2 to a_i.   * Add 1 to b_j.

Incorrect submission (verdict: Wrong Answer):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    expected = sum(B) - sum(A)
    if expected < 0:
        print('NO')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a) // 2
    if add_a + add_b <= expected:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Fixed, accepted submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    expected = sum(B) - sum(A)
    if expected < 0:
        print('No')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a + 1) // 2
    if add_a <= expected and add_b <= expected:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
Problem:
When a boy was cleaning up after his grand father passing, he found an old paper:         In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer".  His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper.  For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town.  You can assume that d ≤ 100 and -180 ≤ t ≤ 180\.

Incorrect submission (verdict: Wrong Answer):
from math import *

x = 0
y = 0
D = []
A = []
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(A[i] * pi / 180)
    y = y + D[i] * sin(A[i] * pi / 180)
print(x,y)

Fixed, accepted submission:
from math import *

x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(sum_a * pi / 180)
    y = y - D[i] * sin(sum_a * pi / 180)
    if abs(x-round(x))<10**(-7):
        x=round(x)
    if abs(y - round(y)) < 10 ** (-7):
        y=round(y)
    sum_a += A[i]
if x >= 0:
    print(floor(x))
else:
    print(floor(x)+1)
if y >= 0:
    print(floor(y))
else:
    print(floor(y)+1)