TnT/CodeNet4Repair huggingface dataset:
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
print('Yes' if b-a == c-b else 'No')

Fixed, accepted submission:
a, b, c = map(int, input().split())
print('YES' if b-a == c-b else 'NO')
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/2)

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

print(int((a+b)*h/2))
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Incorrect submission (verdict: Wrong Answer):
def main() :
	S = input()

	remove_len = len(S)  - 7

	for i in range(len(S) - remove_len) :
		s = S[i:i+7]
		if (s == "keyence") :
			print("YES")
			return

	print("NO")


main()

Fixed, accepted submission:
def main() :
	S = input()

	remove_len = len(S)  - 7

	for i in range(len(S) - remove_len) :
		
		s = S[0:i] + S[i+remove_len:]
		if (s == "keyence") :
			print("YES")
			return

	print("NO")


main()
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())
if g*10+b %4==0:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
r,g,b = map(int,input().split())
if (g*10+b )%4==0:
    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):
print(int(input())%1000)

Fixed, accepted submission:
N = int(input())
print((1000 - N%1000) % 1000)
Problem:
Snuke has an empty sequence a.  He will perform N operations on this sequence.  In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1).  You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.

Incorrect submission (verdict: Wrong Answer):
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(N, a, i, b):
    if i == N + 1:
        if a == b:
            return a
        else:
            return None
    i += 1
    for j in range(1, i):
        A = a[:]
        A.insert(j-1, j)
        res = dfs(N, A, i, b)
        if res is not None:
            return res


def main():
    N = int(input())
    b = list(map(int, input().split()))

    res = dfs(N, [], 1, b)
    if res is None:
        print(-1)
    else:
        print(*res, sep="\n")


if __name__ == "__main__":
    main()


Fixed, accepted submission:
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    B = list(map(int, input().split()))

    is_ok = True
    for i, b in enumerate(B, 1):
        if i < b:
            is_ok = False
    if not is_ok:
        print(-1)
        exit()

    ans = []
    for _ in range(N):
        for i in reversed(range(len(B))):
            if B[i] == i + 1:
                break
        ans.append(B[i])
        del B[i]

    ans = ans[::-1]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()
Problem:
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:    * A consists of integers between X and Y (inclusive).   * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.  Find the maximum possible length of the sequence.

Incorrect submission (verdict: Wrong Answer):
A, Y = map(int, input().split())
ans = 0
while A<=Y:
  ans+=1
  A*=2
print(A)

Fixed, accepted submission:
A, Y = map(int, input().split())
ans = 0
while A<=Y:
  ans+=1
  A*=2
print(ans)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
x=input()
print(x*3)

Fixed, accepted submission:
x = int(input())
print(x**3)
Problem:
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.

Incorrect submission (verdict: Wrong Answer):
a = input()
b1 = list(a[0])
b2 = list(a[1])
b3 = list(a[2])
p1 = b1[0]
p2 = b2[0]
p3 = b3[0]
k =""
k += p1 +p2 +p3
print(k.upper())

Fixed, accepted submission:
a = input().split()
b1 = list(a[0])
b2 = list(a[1])
b3 = list(a[2])
p1 = b1[0]
p2 = b2[0]
p3 = b3[0]
k =""
k += p1 +p2 +p3
print(k.upper())
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 numpy as np

N = int(input())
a = np.zeros((N,3))
for i in range(N):
    a[i][0],a[i][1],a[i][2] = map(int,input().split())

memo = np.zeros((N,3))

memo[0][0], memo[0][1], memo[0][2] = a[0][0],a[0][1],a[0][2]
day = 1

while (day < N):
    memo[day] = [max(memo[day-1][(x+1)%3],memo[day-1][(x+2)%3]) + a[day][x] \
                   for x in [0,1,2]]
    day += 1

print(max(memo[day - 1]))

Fixed, accepted submission:
import numpy as np

N = int(input())
a = np.zeros((N,3))
for i in range(N):
    a[i][0],a[i][1],a[i][2] = map(int,input().split())

memo = np.zeros((N,3))

memo[0][0], memo[0][1], memo[0][2] = a[0][0],a[0][1],a[0][2]
day = 1

while (day < N):
    memo[day] = [max(memo[day-1][(x+1)%3],memo[day-1][(x+2)%3]) + a[day][x] \
                   for x in [0,1,2]]
    day += 1

print(int(max(memo[day - 1])))
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
input()
d = [int(x) for x in input().split()]
print(max(d), min(d), sum(d))

Fixed, accepted submission:
input()
d = [int(x) for x in input().split()]
print(min(d), max(d), sum(d))
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 <= a + b else 'No')

Fixed, accepted submission:
a, b, x = map(int, input().split())
print('YES' if a <= x <= a + b else 'NO')
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')
elif A+B == C+D:
    print('Balanced')
else:
    print('Right')


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:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Time Limit Exceeded):
N = int(input())
def f(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a

for i in range(1, N+1):
    if i < 6:
        print(0)
    else:
        x, y, z = 0, 0, 0
        ans = 0
        while True:
            x += 1
            y = 0
            z = 0
            if f(x,y,z) > i:
                break
            while True:
                y += 1
                z = 1
                s = f(x,y,z)
                if s > i:
                    break
                while s <= i:
                    if s == i:
                        ans += 1
                        break
                    z += 1
        print(ans)

Fixed, accepted submission:
N = int(input())
def f(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a
ans = [0] * N

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = f(x,y,z)
            if n <= N:
                ans[n-1] += 1
for a in ans:
    print(a)
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(str((a + b)*h/2))


Fixed, accepted submission:

GBN_DEBUG = False
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)



#S = input()
#N = int(input())
#S, T = input().split()
#a, b, h = map(int, input().split())
#W = [input() for _ in range(N)]
#A = list(map(int, input().split()))

#GBN_DEBUG = True

a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
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):
A, B, C = list(map(int, input().split()))

s = A, B, C
print('Yes') if s.count(5) == 2 and s.count(7) == 1 else print('No')

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

s = A, B, C
print('YES') if s.count(5) == 2 and s.count(7) == 1 else print('NO')
Problem:
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.

Incorrect submission (verdict: Wrong Answer):
def d_remainder_reminder(N, K):
    ans = 0
    for b in range(K + 1, N + 1):
        
        
        p = N // b
        r = N % b
        
        ans += p * max(0, b - K) + max(0, r + 1 - K)
    if K == 0:
        
        
        ans -= N
    return ans

Fixed, accepted submission:
def d_remainder_reminder(N, K):
    ans = 0
    for b in range(K + 1, N + 1):
        
        
        p = N // b
        r = N % b
        
        ans += p * max(0, b - K) + max(0, r + 1 - K)
    if K == 0:
        
        
        ans -= N
    return ans

N,K = [int(i) for i in input().split()]
print(d_remainder_reminder(N, K))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
print(1000-n)

Fixed, accepted submission:
n=int(input())
sen=1000
while sen<n:
  sen+=1000
print(sen-n)
Problem:
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_.   Here, a correct bracket sequence is defined as follows:    * `()` is a correct bracket sequence.   * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence.   * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.   * Every correct bracket sequence can be derived from the rules above.  Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.

Incorrect submission (verdict: Wrong Answer):
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    S = list(input())
    answer = ""
    cnt = 0
    for s in S:
        if s == "(":
            cnt += 1
            answer += "("
        else:
            if cnt > 0:
                answer += ")"
                cnt -= 1
            else:
                answer += "()"
    if cnt > 0:
        answer += ")" * cnt
    print(answer)


if __name__ == "__main__":
    main()


Fixed, accepted submission:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    S = list(input())
    answer = ""
    right = 0
    left = 0
    for s in S:
        if s == "(":
            if right > 0:
                answer = "(" * right + answer
                answer += ")" * right
                right = 0
            left += 1
            answer += "("
        else:
            if left > 0:
                answer += ")"
                left -= 1
            else:
                right += 1
    if left > 0:
        answer += ")" * left
    if right > 0:
        answer = "(" * right + answer + ")" * right
    print(answer)


if __name__ == "__main__":
    main()
Problem:
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.  Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.  Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
palette = [1]
colors = [None] * N
edges = [None] * N
ends = {}

for i in range(1,N):
    edges[i] = [int(n) for n in input().split()]

for i in range(1,N):
    a, b = edges[i]
    if a not in ends:
        ends[a] = [i]
    else:
        ends[a].append(i)
    if b not in ends:
        ends[b] = [i]
    else:
        ends[b].append(i)

for i in range(1,N):
    p = palette[:]
    for j in ends[i]:
        if colors[j]:
            p = [color for color in p if color != colors[j]]
        else:
            if len(p) > 0:
                colors[j] = p[0]
                del p[0]
            else:
                color = len(palette) + 1
                palette.append(color)
                colors[j] = color

for i in range(1,N):
    print(colors[i])

Fixed, accepted submission:
import sys

sys.setrecursionlimit(100000)

N = int(input())
palette = 1
colors = {}
ends = {}
edges = {}

for edge in range(1,N):
    ends[edge] = [int(n) for n in input().split()]

    a, b = ends[edge]
    if a not in edges:
        edges[a] = [edge]
    else:
        edges[a].append(edge)
    if b not in edges:
        edges[b] = [edge]
    else:
        edges[b].append(edge)


def color_edges(parent, root):
    ng = {}
    global palette
    if parent > 0:
        ng[colors[parent]] = True
    for edge in edges[root]:
        if edge in colors:
            color = colors[edge]
        elif palette - len(ng) > 0:
            color = 1
            while color in ng:
                color += 1
            colors[edge] = color
        else:
            palette += 1
            color = palette
            colors[edge] = color

        ng[color] = True
    for edge in edges[root]:
        if edge == parent:
            continue
        a, b = ends[edge]
        if a == root:
            color_edges(edge, b)
        else:
            color_edges(edge, a)

max_edges = 1
root = 1
for node in range(1,N+1):
    if len(edges[node]) > max_edges:
        max_edges = len(edges[node])
        root = node

color_edges(0, root)

print(palette)
for edge in range(1,N):
    print(colors[edge])
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
def func():
    A, B, C = input().split()
    result = 'Yes' if A[-1] == B[0] and B[-1] == C[0] else 'No'
    return result

print(func())


Fixed, accepted submission:
A, B, C = input().split()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')
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):
a = input()
for i in range(len(a)):
    if a[i] == "A":
        b = i
        print(b)
        break
for j in range(len(a)):
    if a[j] == "Z":
        c = j
        print(c)
        break
print(c-b+1)

Fixed, accepted submission:
a = input()
for i in range(len(a)):
    if a[i] == "A":
        b = i
        break
for j in range(len(a)):
    if a[j] == "Z":
        c = j
print(c-b+1)
Problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Incorrect submission (verdict: Wrong Answer):
def solve(N, A):
    c = int(N / 2)
    left = A[c - 1]
    right = A[c]
    for x in range(c - 1):
        print(left)
    print(right)
    print(left)
    for x in range(c + 1, N):
        print(right)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)


Fixed, accepted submission:
def solve(N, A):
    c = int(N / 2)
    left = sorted(A)[c - 1]
    right = sorted(A)[c]
    if left == right:
        for x in range(N):
            print(left)
        return;
    for x in range(N):
        if A[x] <= left:
            print(right)
        if A[x] >= right:
            print(left)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
N, K = map(int,input().split())
D = list(map(int,input().split()))

while True:
  for n in str(N):
    if(n in D):
      break
  else:
    break
  N += 1
print(N)

Fixed, accepted submission:
N, K = map(int,input().split())
D = input().split()

while True:
  for n in str(N):
    if(n in D):
      break
  else:
    break
  N += 1
print(N)
Problem:
You are given an integer sequence of length N, a_1,a_2,...,a_N.  For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.  After these operations, you select an integer X and count the number of i such that a_i=X.  Maximize this count by making optimal choices.

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

all_data = list(set(A))

num = 0

for i in all_data:
  tmp = all_data.count(i) + all_data.count(i+1) + all_data.count(i-1)
  num = max(num, tmp)
  
print(num)

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0]*(100000+2)

for i in A:
  ans[i-1] += 1
  ans[i] += 1
  ans[i+1] += 1

  
print(max(ans))
Problem:
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:    * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.  Determine whether Snuke can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if n%2!=1 and cnt_odd-1<=cnt_4:
  print("Yes")
elif n%2==0 and cnt_odd<=cnt_4:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
x,a,b = (int(input(i)) for i in range(3))

print((x-a) % b )


Fixed, accepted submission:
x,a,b = (int(input()) for i in range(3))

print((x-a) % b )
Problem:
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).  In particular, any integer sequence is similar to itself.  You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.  How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?

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


for i in range(len(a)):
    if a[i]%2 == 1:
        #odd
        o *= 1
    else:
        #even
        o *= 2

print(3**len(a)-o)


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


for i in range(len(a)):
    if a[i]%2 == 1:
        #odd
        o *= 1
    else:
        #even
        o *= 2

print(3**len(a)-o)