TnT/CodeNet4Repair huggingface dataset:
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 = list(input())
for i in range(len(s)):
    del s[-1]
    s = "".join(s)
    print(s)
    if s[0:len(s)//2]*2 == s:
        print(len(s))
        break
    s = list(s)

Fixed, accepted submission:
s = list(input())
for i in range(len(s)):
    del s[-1]
    s = "".join(s)
    if s[0:len(s)//2]*2 == s:
        print(len(s))
        break
    s = list(s)
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())

print(min(abs(x-a), abs(x-b)))

Fixed, accepted submission:
x, a, b = map(int, input().split())
 
if abs(x-a) < abs(x-b):
  print('A')
else:
  print('B')
Problem:
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.  Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.  Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.                 void call(int n){   int i = 1;  CHECK_NUM:   int x = i;   if ( x % 3 == 0 ){     cout << " " << i;     goto END_CHECK_NUM;   }  INCLUDE3:   if ( x % 10 == 3 ){     cout << " " << i;     goto END_CHECK_NUM;   }   x /= 10;   if ( x ) goto INCLUDE3;  END_CHECK_NUM:   if ( ++i <= n ) goto CHECK_NUM;    cout << endl; }

Incorrect submission (verdict: Wrong Answer):
num = int(input())
nabeatu = ""
for i in range(num + 1):
    if i % 3 == 0 or "3" in str(i):
        nabeatu = nabeatu + str(i) + " "
print(nabeatu)

Fixed, accepted submission:
num = int(input())
nabeatu = []
for i in range(1,num + 1):
    if i % 3 == 0 or "3" in str(i):
        nabeatu.append(str(i))
print(" " + " ".join(nabeatu))
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
In = [map(int, input().split()) for _ in range(N)]

s = (0, 0)
t = 0
success = True

for move in In:
    before_x, before_y = s
    tn, after_x, after_y = move

    dist_xy = abs(after_x - before_x) + abs(after_y - before_y)
    walk = tn - t

    if walk < dist_xy:
        success *= False

    if walk % 2 == 0 and dist_xy % 2 != 0:
        success *= False
    elif walk % 2 != 0 and dist_xy % 2 == 0:
        success *= False

    s = (after_x, after_y)
    t = tn

print("YES" if success else "NO")

Fixed, accepted submission:
N = int(input())
In = [map(int, input().split()) for _ in range(N)]

s = (0, 0)
t = 0
success = True

for move in In:
    before_x, before_y = s
    tn, after_x, after_y = move

    dist_xy = abs(after_x - before_x) + abs(after_y - before_y)
    walk = tn - t

    if walk < dist_xy:
        success *= False
        break

    if walk % 2 == 0 and dist_xy % 2 != 0:
        success *= False
        break
    elif walk % 2 != 0 and dist_xy % 2 == 0:
        success *= False
        break

    s = (after_x, after_y)
    t = tn

print("Yes" if success else "No")
Problem:
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for _ in range(m):
  i=t
  p,x=map(int,input().split())
  i[p-1]=x
  print(sum(i))

Fixed, accepted submission:
from copy import deepcopy
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for _ in range(m):
  i=deepcopy(t)
  p,x=map(int,input().split())
  i[p-1]=x
  print(sum(i))
Problem:
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.  We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.  At most how many people can sit on the seat?

Incorrect submission (verdict: Wrong Answer):
x,y,z = map(int,input().split())
i = 1
while(y+z*2+(z+y)*i < x):
    i += 1
print(i)

Fixed, accepted submission:
x,y,z = map(int,input().split())
i = 1
while(y+z*2+(z+y)*i <= x):
    i += 1
print(i)
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","NO"][a-b != c-b])

Fixed, accepted submission:
a,b,c =map(int,input().split())
print(["YES","NO"][b-a != c-b])
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())
print((1+n)/2*n)

Fixed, accepted submission:
n=int(input())
print(int((1+n)/2*n))
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
l = {1}
for i in range(2,32):
  j = 1
  while(i ** j <= N):
    l.add(i ** j)
    j += 1

for i in range(N, 0, -1):
  if(i in l):
    print(i)
    break

Fixed, accepted submission:
N = int(input())
l = {1}
for i in range(2,32):
  j = 2
  while(i ** j <= N):
    l.add(i ** j)
    j += 1

for i in range(N, 0, -1):
  if(i in l):
    print(i)
    break
Problem:
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.  Find the number of chocolate pieces prepared at the beginning of the camp.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
D,X = map(int,input().split())
A = []
for i in range(N):
  A.append(int(input()))
print(X+len(A))

Fixed, accepted submission:
N = int(input())
D,X = map(int,input().split())
A = []
ans = 0
for i in range(N):
  A.append(int(input()))
for i in range(N):
  ans += (D-1)//A[i]+1
print(X+ans)
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):
words = ["dream", "dreamer", "erase","eraser"]
reverse_words = []
for word in words:
    reverse_words.append(word[::-1])
S = input()
S = S[::-1]

while len(S) !=0:
    flag = 0
    for word in reverse_words:
        if S.startswith(word):
            S = S[len(word):]
            flag=1
            break
    if (not flag):
        print("No")
        quit()
print("Yes")


Fixed, accepted submission:
words = ["dream", "dreamer", "erase","eraser"]
reverse_words = []
for word in words:
    reverse_words.append(word[::-1])
S = input()
S = S[::-1]

while len(S) !=0:
    flag = 0
    for word in reverse_words:
        if S.startswith(word):
            S = S[len(word):]
            flag=1
            break
    if (not flag):
        print("NO")
        quit()
print("YES")
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: Wrong Answer):
n = int(input())

ans = [0]*60001

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            a = i**2+j**2+k**2+i*j+i*k+j*k
            ans[a]+=1
for i in range(n+1):
    print(ans[i])


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

ans = [0]*60001

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            a = i**2+j**2+k**2+i*j+i*k+j*k
            ans[a]+=1
for i in range(1,n+1):
    print(ans[i])
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):
s=input()
r=""
for i in range(len(s)):
    if i%2==0:
        r+=s[i]
print(r)

Fixed, accepted submission:
x,t=(int(i) for i in input().split())
d=x-t
if d<0:
    d=0
print(d)
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(int(N%1000))

Fixed, accepted submission:
N=int(input())
if (N%1000)==0:
  print(0)
else:
  print(1000-(N%1000))
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):
print((int(input())-int(input())%int(input())))

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

Incorrect submission (verdict: Wrong Answer):
H, W = map(int, input().split(' '))
print("{} {}".format(H, W))
count = [['0']*W for i in range(H)]

def update_count(i, j, count):
    count[i][j] = '#'
    start_i = 0 if i-1 < 0 else i-1
    end_i = H if i + 2 > H else i+2
    start_j = 0 if j-1 < 0 else j-1
    end_j = W if j + 2 > W else j+2
    for k in range(start_i, end_i):
        for l in range(start_j, end_j):
            if count[k][l] != '#':
                count[k][l] = str(1 + int(count[k][l]))
    return count

for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '#':
            count = update_count(i, j, count)

for i in range(H):
    print(''.join(count[i]))


Fixed, accepted submission:
H, W = map(int, input().split(' '))
count = [['0']*W for i in range(H)]

def update_count(i, j, count):
    count[i][j] = '#'
    start_i = 0 if i-1 < 0 else i-1
    end_i = H if i + 2 > H else i+2
    start_j = 0 if j-1 < 0 else j-1
    end_j = W if j + 2 > W else j+2
    for k in range(start_i, end_i):
        for l in range(start_j, end_j):
            if count[k][l] != '#':
                count[k][l] = str(1 + int(count[k][l]))
    return count

for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '#':
            count = update_count(i, j, count)

for i in range(H):
    print(''.join(count[i]))
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())

cnt = 0
for i in range(a):
  for j in range(b):
    for k in range(c):
      if 500*i + 100*j + 50*k == x:
        cnt+=1
print(cnt)

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

cnt = 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:
        cnt+=1
print(cnt)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
try:
    s = input()
    t = input()
    s_ = sorted(s)
    t_ = sorted(t, reverse=True)
    print(s_)
    print(t_)
    print('No' if s_>t_ else 'Yes')
except EOFError:
    pass

Fixed, accepted submission:
try:
    s = input()
    t = input()
    s_ = sorted(s)
    t_ = sorted(t, reverse=True)
    print('Yes' if s_<t_ else 'No')
except EOFError:
    pass
Problem:
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Incorrect submission (verdict: Time Limit Exceeded):
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

sum = 0
for c in T:
    left = 0
    right = n
    mid = 0
    while left < right:
        mid = int(( left + right ) / 2)
        if c == S[mid]:
            sum += 1
            break
print(sum)

Fixed, accepted submission:
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

sum = 0
for c in T:
    left = 0
    right = n
    mid = 0
    if c == S[left] or c == S[right-1]:
        sum += 1
    else:
        while left+1 < right:
            mid = int(( left + right ) / 2)
            if c == S[mid]:
                sum += 1
                break
            if c > S[mid]:
                left = mid
                mid = 0
            elif c < S[mid]:
                right = mid
                mid = 0
print(sum)
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input()) % 500
print(['NO', 'YES'][int(input()) >= N])

Fixed, accepted submission:
N = int(input()) % 500
print(['No', 'Yes'][int(input()) >= N])
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):

a, b = map(int, input().split())
c = int((a + b) / 2)
print(c + 1)

Fixed, accepted submission:
import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
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):
A, B, C, D=list(map(int, list(input())))

for b in [B, -B]:
  for c in [C, -C]:
    for d in [D, -D]:
      if A+b+c+d==7:
        output=str(A)
        
        if b<0:
          output+=str(b)
        else:
          output+='+'+str(b)
          
        if c<0:
          output+=str(c)
        else:
          output+='+'+str(c)
          
        if d<0:
          output+=str(d)
        else:
          output+='+'+str(d)
          
print(output)

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

for b in [B, -B]:
  for c in [C, -C]:
    for d in [D, -D]:
      if A+b+c+d==7:
        output=str(A)
        
        if b<0:
          output+=str(b)
        else:
          output+='+'+str(b)
          
        if c<0:
          output+=str(c)
        else:
          output+='+'+str(c)
          
        if d<0:
          output+=str(d)
        else:
          output+='+'+str(d)
          
print(output+'=7')
Problem:
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.  Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:    * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.  What is the minimum number of operations required to achieve the objective?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(input())
b=list(input())
c=list(input())

print(a,b,c)

ans=0

for i in range(n):

    s=[a[i],b[i],c[i]]
    buff=set(s)
    ans += len(buff)-1

print(ans)

Fixed, accepted submission:
n=int(input())
a=list(input())
b=list(input())
c=list(input())

ans=0

for i in range(n):

    s=[a[i],b[i],c[i]]
    buff=set(s)
    ans += len(buff)-1

print(ans)
Problem:
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode:                 BubbleSort(A) 1 for i = 0 to A.length-1 2     for j = A.length-1 downto i+1 3         if A[j] < A[j-1] 4             swap A[j] and A[j-1]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 4 of the pseudocode.

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

for i in range(n):
    for j in range(i + 1, n):
        if (nums[j] < nums[i]):
            temp = nums[j]
            nums[j] = nums[i]
            nums[i] = temp
            count += 1

print(count)
print(' '.join([str(i) for i in nums]))



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

def bubble_sort(a):
    global cnt
    for i in range(len(a)):
        l = 0
        r = 1

        while r < len(a):
            if a[l] > a[r]:
                a[l], a[r] = a[r], a[l]
                cnt += 1
            l += 1
            r += 1


    
    #     for j in range(i + 1, len(a)):
    #         if a[i] > a[j]:
    #             a[i], a[j] = a[j], a[i]

bubble_sort(a)
print(*a)
print(cnt)
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

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

kyori = abs(b-a)
hayasa = wb-va

if hayasa <= 0:
  print('NO')
elif kyori / hayasa > t:
  print('YES')
else:
  print('NO')


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

kyori = abs(b-a)
hayasa = wb-va

if hayasa >= 0:
  print('NO')
elif kyori / abs(hayasa) <= t:
  print('YES')
else:
  print('NO')
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):
s=list(input())
print(s)
a,b,c,d=s[0],s[1],s[2],s[3]
aa,bb,cc,dd=int(a),int(b),int(c),int(d)
ops=['+']*3

def sumsum(a,b,c,d):
    return a+b+c+d

print(sumsum(aa,bb,cc,dd))
if sumsum(aa,bb,cc,dd)==7:
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb==7:
    ops[0]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc==7:
    ops[1]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*dd==7:
    ops[2]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc==7:
    ops[0],ops[1]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc-2*dd==7:
    ops[1],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*dd==7:
    ops[0],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*bb-2*dd==7:
    ops='-'*3
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()


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


def dfs(count, string):
    if count == 4:
        if eval(string) == 7:
            return string + '=7'
        else:
            return ''
    plus = dfs(count + 1, string + '+' + S[count])
    minus = dfs(count + 1, string + '-' + S[count])
    return plus + minus


print(dfs(1, S[0])[:9])