TnT/CodeNet4Repair huggingface dataset:
Problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:    * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.  Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

Incorrect submission (verdict: Wrong Answer):
a, b, k = map(int, input().split(' '))
for i in range(0, k):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a/2
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b/2
print(f'{max(0,a)} {max(0,b)}')


Fixed, accepted submission:
a, b, k = map(int, input().split(' '))
for i in range(0, k):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a//2
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b//2
print(f'{max(0,a)} {max(0,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(n*(n-1)//2)

Fixed, accepted submission:
n=int(input())
print(n*(n+1)//2)
Problem:
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.  You and Lunlun the dachshund alternately perform the following operation (starting from you):    * Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.  The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?

Incorrect submission (verdict: Wrong Answer):
import sys
stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
cnt = [1 for x in A if x % 2 == 0]
bool = sum(cnt) % 2 == 0
print('first' if bool else 'second')

Fixed, accepted submission:
import sys
stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
even_cnt = sum([1 for x in A if x % 2 == 0])
odd_cnt = N - even_cnt
print('first' if odd_cnt else 'second')
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):
import scipy as sp
from scipy.spatial.distance import cityblock

def delta(n):
    l = len([0])
    delta = n - sp.vstack((sp.zeros(l), n[1:]))
    return delta


answer = "Yes"
N = int(input())
points = sp.array([0,0,0])
for i in range(N):
    points = sp.vstack((points, [int(i) for i in input().split()]))

points = sp.array(list(points))


for t, x, y in points:
    mdist = cityblock(x, y)
    if mdist - t%2 != 0 and t < mdist:
        answer = "No"
        break

print(answer)

Fixed, accepted submission:
answer = "Yes"
N = int(input())
points = [[int(i) for i in input().split()] for i in range(N)]

for t, x, y in points:
    mdist = abs(x) + abs(y)
    if (mdist - t)%2 != 0 or t < mdist:
        answer = "No"
        break

print(answer)
Problem:
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`.  You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

Incorrect submission (verdict: Wrong Answer):
s = input()
t = 0
for i in range(1,len(s)-2):
    t += 1
print(s[0] + str(t) + s[len(s)-1])

Fixed, accepted submission:
s = list(input())
print(s[0] + str(len(s) - 2 ) + s[-1])
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
t = int(input())
s = t%60
m = t//60
h = m/60
print("{0}:{1}:{2}".format(h,m,s))

Fixed, accepted submission:
h = int(input())
print(h//3600,(h%3600)//60,h%60,sep=":")
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):
N, K = map(int,input().split())
ans = 0
a = K + 1
print(ans)

if K != 0:
    for i in range(K, N):
        s = N % a
        t = N - s
        p = t // a * (a - K)
        q = max(0, s - (K - 1))
        ans += (p + q)
        a += 1
else:
    ans = N ** 2
print(ans)

Fixed, accepted submission:
N, K = map(int,input().split())
ans = 0
a = K + 1

if K != 0:
    for i in range(K, N):
        s = N % a
        t = N - s
        p = t // a * (a - K)
        q = max(0, s - (K - 1))
        ans += (p + q)
        a += 1
else:
    ans = N ** 2
print(ans)
Problem:
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.  Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
c = [list(map(str,input().split())) for _ in range(h)]

for i in range(h):
    print(c[i])
    print(c[i])

Fixed, accepted submission:
h,w = map(int,input().split())
c = [list(map(str,input().split())) for _ in range(h)]

for i in range(h):
    print(''.join(c[i]))
    print(''.join(c[i]))
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dx+'R'*dy
route[1]='D'*dx+'L'*dy
route[2]='L'+'U'*(dx+1)+'R'*(dy+1)+'D'
route[3]='R'+'U'*(dx+1)+'L'*(dy+1)+'U'
print("".join(route))

Fixed, accepted submission:
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dy+'R'*dx
route[1]='D'*dy+'L'*dx
route[2]='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
route[3]='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print("".join(route))
Problem:
You are given three integers A, B and C.  Determine if there exists an equilateral triangle whose sides have lengths A, B and C.

Incorrect submission (verdict: Wrong Answer):

i = input().split()

if i[0]==i[1] and i[1]==i[2]:
    print("YES")
else:
    print("No")

Fixed, accepted submission:
i = input().split()

if i[0]==i[1] and i[1]==i[2]:
    print("Yes")
else:
    print("No")
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Incorrect submission (verdict: Wrong Answer):

a,b,c = map(int,input().split())

if a+b <= c:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:

a,b,c = map(int,input().split())

if a+b >= c:
    print("Yes")
else:
    print("No")
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):
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)

ret = 0
def calc_cumsum(idx,right_str):
    if idx == len(right_str):
        return int(right_str)
    _ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
    _ifnotplus = calc_cumsum(idx+1,right_str)
    print(_ifplus+_ifnotplus)
    return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))


Fixed, accepted submission:
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)

ret = 0
def calc_cumsum(idx,right_str):
    if idx == len(right_str):
        return int(right_str)
    _ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
    _ifnotplus = calc_cumsum(idx+1,right_str)
    return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))
Problem:
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once.  You are given the sequence _A_ and _q_ questions where each question contains _M i_.

Incorrect submission (verdict: Wrong Answer):
import itertools as it

def check(p, li):
    li_ad = [i for i in li if i < p]
    flag = False
    for j in range(len(li_ad)):
        li_perm = list(it.permutations(li_ad, j+1))
        for k in range(len(li_perm)):
            if sum(li_perm[k]) == p:
                flag = True
                break
        if flag:
            break
        
    return flag
    
    
n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
m = list(map(int, input().split()))

min_range = A[0] + A[1]
max_range = sum(A)

for i in range(q):
    if m[i] < min_range or m[i] > max_range:
        print('no')
    else:
        print('yes' if check(m[i], A) else 'no' )

Fixed, accepted submission:
from itertools import combinations

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

l = set(sum(t) for i in range(n) for t in combinations(A, i+1))

for j in m:
    print('yes' if j in l 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:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
n,y=map(int,input().split())
z=int(str(y)[::])
if n*10000<y:
    print("-1 -1 -1")
    exit()

for i in range((y//10000)+1):   
    y-=i*10000
    w=int(str(y)[::])
    if (n-i)*5000<y:
        continue
    for j in range((y//5000)+1):
        y-=j*5000        
        if 1000*(n-i-j)==y:
            print(str(i)+' '+str(j)+' '+str(n-i-j))
            exit()
        y=w
    y=z
print("-1 -1 -1")

Fixed, accepted submission:
n,y=map(int,input().split())
if n*10000<y:
    print("-1 -1 -1")
    exit()

for i in range((y//10000),-1,-1):   
    y-=i*10000
    if (n-i)*5000<y:
        continue
    for j in range((y//5000),-1,-1):
        y-=j*5000        
        if 1000*(n-i-j)==y:
            print(str(i)+' '+str(j)+' '+str(n-i-j))
            exit()
        y+=j*5000
    y+=i*10000
print("-1 -1 -1")
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):
a,b,c=map(int,input().split())
if (b-a)>=(c-a):
  print("B")
else:
  print("A")

Fixed, accepted submission:
a,b,c=map(int,input().split())
if abs(b-a)>=abs(c-a):
  print("B")
else:
  print("A")
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
import sys


def print_arr(arr):
    for v in arr:
        print(v, end=' ')
    print('')

def insertion_sort(arr):
    for i in range(1, len(arr)):
        print_arr(arr)
        v = arr[i]
        j = i-1
        while j >= 0 and arr[j] > v:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = v

input0 = sys.stdin.readline()
input_sample = sys.stdin.readline()
# input_sample = "5 2 4 6 1 3"
input = input_sample.split(" ")
input = [int(i) for i in input]
insertion_sort(input)

Fixed, accepted submission:
import sys


def print_arr(arr):
    ln = ''
    for v in arr:
        ln += str(v) + ' '

    ln = ln.strip()
    print(ln)

def insertion_sort(arr):
    for i in range(1, len(arr)):
        print_arr(arr)
        v = arr[i]
        j = i-1
        while j >= 0 and arr[j] > v:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = v

    print_arr(arr)

input0 = sys.stdin.readline()
input_sample = sys.stdin.readline()
# input_sample = "5 2 4 6 1 3"
input = input_sample.split(" ")
input = [int(i) for i in input]
insertion_sort(input)
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
x, a, b = map(int, input().split())
if a-b <= 0: print("delicious")
elif a-b <= x: print("safe")
else: print("dangerous")

Fixed, accepted submission:
x, a, b = map(int, input().split())
if b-a <= 0: print("delicious")
elif b-a <= x: print("safe")
else: print("dangerous")
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

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

Fixed, accepted submission:
a, b, c = map(int, input().split())
if a + b < c:
  print("No")
else:
  print("Yes")
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
A,B=map(int, input().split())
print(A,B)
C=A*B//2
D=A*B%2
E=C+D
print(E)

Fixed, accepted submission:
A,B=map(int, input().split())
C=A*B//2
D=A*B%2
if A==1 or B==1:
  E=1
else:
  E=C+D
print(E)
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
s = int(input())
h = s/3600
m = (s-3600*h)/60
s = s-3600*h-60*m
print(h,m,s,sep=":")

Fixed, accepted submission:
s=int(input())
h=s//3600
m=s%3600//60
s=s%3600%60
print(h,m,s,sep=":")
Problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.  In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.  When activated, each type of robot will operate as follows.    * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.    * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.  Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

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

sum = 0

for i in range(0, N):
	sum += min(0 - x[i], K - x[i]) * 2

print(sum)

Fixed, accepted submission:
N = int(input())
K = int(input())
x = list(map(int,input().split(" ")))

sum = 0

for i in range(N):
	sum += abs(min(x[i], K - x[i]) * 2)

print(sum)
Problem:
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.

Incorrect submission (verdict: Wrong Answer):
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]
S.sort()
l=[0,0,0,0]

for i in range(3):
    for j in range(2):
        l[S[i][j]-1]+=1
print(l)
if max(l)==3:
    print("NO")
else:
    print("YES")

Fixed, accepted submission:
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]

l=[0,0,0,0]

for i in range(3):
    for j in range(2):
        l[S[i][j]-1]+=1
#print(l)
if max(l)==3:
    print("NO")
else:
    print("YES")
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
s = input()
s.count('1')

Fixed, accepted submission:
s = input()
print(s.count('1'))
Problem:
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other.  Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro:    * Choose an element x in A, and remove exactly x stones from the pile.  A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.

Incorrect submission (verdict: Wrong Answer):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K+1):
    if dp[i] == 0:
        for s in S:
            if i+s > K:
                continue
            else:
                dp[i+s] = 1
    print(dp)
if dp[K]:
    print("First")
else:
    print("Second")


Fixed, accepted submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K+1):
    if dp[i] == 0:
        for s in S:
            if i+s > K:
                continue
            else:
                dp[i+s] = 1
if dp[K]:
    print("First")
else:
    print("Second")
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
n, y = map(int, input().split())
y = y/1000
counter = []

for rep1 in range(n + 1):
    for rep2 in range(n + 1):
        for rep3 in range(n + 1):
            if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
                print(rep1 * 10 + rep2 * 5 + rep3)
                counter = ([rep1, rep2, rep3])
                break

print(counter) if counter != [] else print("-1 -1 -1")

Fixed, accepted submission:
n, y = map(int, input().split())
y = y/1000
answer= []

for ten in range(n + 1):
    for five in range(n + 1 - ten):
        one = n - ten - five
        if ten * 10 + five * 5 + one == y:
            answer = [ten, five, one]
            break

print(answer[0], answer[1], answer[2]) if answer != [] else print("-1 -1 -1")