TnT/CodeNet4Repair huggingface dataset:
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())
a=10000
b=5000
c=1000
x=Y//c
ans=('-1','-1','-1')
if N-x>=0:
  for i in range(x):
    for j in range(N-i):
      for k in range(N-i-j):
        if Y==a*k+b*j+c*i:
          ans=(str(k),str(j),str(i))
          break
print(' '.join(ans))

Fixed, accepted submission:
n, y = map(int,input().split())
flag=False
for i in range(y//10000, -1, -1):
    for j in range((y-i*10000)//5000, -1, -1):
        k=(y-i*10000-j*5000)/1000
        if i+j+k==n:
            print(str(i)+" "+str(j)+" "+str(int(k)))
            flag=True
            break
    if flag==True:
        break
if flag==False:
    print("-1 -1 -1")
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(k):
    if i % 2 ==0:
        if a % 2 == 1:
            a - 1
        else:
            diff = int(a/2)
            a = a - diff
            b += diff
    else:
        if b % 2 == 1:
            b - 1
        else:
            diff = int(b/2)
            b = b - diff
            a += diff
print(a,b)

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


for i in range(0,k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        diff = a//2
        a -= diff
        b += diff
    else:
        if b % 2 == 1:
            b -= 1
        diff = b//2
        b -= diff
        a += diff

print(a,b)
Problem:
Rng is going to a festival.  The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer.  Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.

Incorrect submission (verdict: Wrong Answer):
s = input()
print(s[:len(s)-4])

Fixed, accepted submission:
s = input()
print(s[:len(s)-8])
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

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

if A[0]>A[2]>A[1] or A[0] < A[2] < A[1]:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
# coding: utf-8
# Your code here!
A = list(map(int,input().split()))
#print(A)
 
if A[0]>A[2]>A[1] or A[0] < A[2] < A[1]:
    print("Yes")
else:
    print("No")
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:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
M, D = map(int, input().split())
cnt = 0
for m in range(1, M + 1):
    for d in range(22, D + 1):
        d1, d10 = int(str(d)[1]), int(str(d)[0])
        if d1 >= 2 and d1 * d10 == m:
            print(m, d)
            cnt += 1
print(cnt)

Fixed, accepted submission:
M, D = map(int, input().split())
cnt = 0
for m in range(1, M + 1):
    for d in range(22, D + 1):
        d1, d10 = int(str(d)[1]), int(str(d)[0])
        if d1 >= 2 and d1 * d10 == m:
            cnt += 1
print(cnt)
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):
H,W = input().split()

H = int(H)
W = int(W)

t = H * W

mod = t % 2

if mod == 0:
    print(t/2)
else:
    print(int(t/2) + 1)

Fixed, accepted submission:
H,W = input().split()

H = int(H)
W = int(W)

t = H * W

mod = t % 2

if H != 1 and W != 1:
    if mod == 0:
        print(int(t/2))
    else:
        print(int(t/2) + 1)
else:
    print(1)
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())

s = (a + b) * h/2
print(round(s))
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, total = map(int, input().strip().split(" "))
bills = [-1, -1, -1]

for i in range(int(total/1000)+1):

    x = total - 1000*i

    for j in range(int(x/5000)+1):

        y = x-5000*j

        for k in range(int(y/10000)+1):

            z = y-10000*k

    
    buff = [i, j, k]

    if sum(buff) == N:
        bills = buff

print(bills)



Fixed, accepted submission:
N, total = map(int, input().strip().split(" "))
bills = [-1, -1, -1]

for i in range(int(total/10000)+1):

    x = total - 10000*i

    for j in range(int(x/5000)+1):

        y = x-5000*j

        k = N - i -j

        if y-1000*k == 0:
    
            bills = [i, j, k]
            break

print(" ".join(map(str, bills)))
Problem:
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:    * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.

Incorrect submission (verdict: Wrong Answer):
import sys

pre_strk = 1
now_strk = 1
ans = 1
n = int(input())
d_list = list(map(int,input().split()))
d_list.sort()
print(d_list)
if d_list[0] != 0:
    print(0)
    sys.exit()

for i in range(1,n):
    if d_list[i] == d_list[i-1]:
        now_strk += 1
    elif d_list[i] != d_list[i-1] and (d_list[i-1] != 1 or d_list[i-1] != 0):
        ans *= pre_strk ** now_strk
        pre_strk = now_strk
        now_strk = 1
        print(ans)
    else:
        pre_strk = now_strk
        now_strk = 1
ans *= pre_strk ** now_strk
print(ans)



Fixed, accepted submission:
import sys

pre_strk = 1
now_strk = 1
ans = 1
n = int(input())
d_list = list(map(int,input().split()))
# print(d_list)
if d_list[0] != 0:
    print(0)
    sys.exit()

d_list.sort()
if d_list[1] == 0:
    print(0)
    sys.exit()

for i in range(1,n):
    if d_list[i] == d_list[i-1]:
        now_strk += 1

    elif d_list[i] > d_list[i-1] + 1:
        print(0)
        sys.exit()

    elif d_list[i] != d_list[i-1] and d_list[i-1] != 1:
        for j in range(now_strk):
            ans *= pre_strk
        pre_strk = now_strk
        now_strk = 1
        # print(ans)
        ans = ans % 998244353

    else:
        pre_strk = now_strk
        now_strk = 1
for i in range(now_strk):
    ans *= pre_strk
print(ans%998244353)
Problem:
Write a program which reads an integer and prints sum of its digits.

Incorrect submission (verdict: Wrong Answer):
from sys import stdin
for line in stdin:
    if line == '0':
        break
    num = list(map(int, line.strip('\n')))
    print(sum(num))


Fixed, accepted submission:
from sys import stdin
for line in stdin:
    if line == '0\n':
        break
    num = list(map(int, line.strip('\n')))
    print(sum(num))
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
count1 = 0
count2 = 0
N, A, B = map(int, input().split())
S = list(input())
for i in S:
  if i == "a" and A + B >= count1:
    print("Yes")
    count1 += 1
  elif i == "b" and A + B >= count1 and B >= count2:
    print("Yes")
    count1 += 1
    count2 += 1
  else :
    print("No")

Fixed, accepted submission:
count1 = 0
count2 = 0
N, A, B = map(int, input().split())
S = list(input())
for i in S:
  if i == "a" and A + B > count1:
    print("Yes")
    count1 += 1
  elif i == "b" and A + B > count1 and B > count2:
    print("Yes")
    count1 += 1
    count2 += 1
  else :
    print("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) - 1, 0, -1):
    S = S[:i]
    print(S)
    if i % 2 == 0 and S[:(i//2)] == S[(i//2):]:
        print(i)
        break

Fixed, accepted submission:
S = input()
for i in range(len(S) - 1, 0, -1):
    S = S[:i]
    if i % 2 == 0 and S[:(i//2)] == S[(i//2):]:
        print(i)
        break
Problem:
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies.  Snuke can perform the following operation any number of times:    * Choose a box containing at least one candy, and eat one of the candies in the chosen box.  His objective is as follows:    * Any two neighboring boxes contain at most x candies in total.  Find the minimum number of operations required to achieve the objective.

Incorrect submission (verdict: Wrong Answer):
N,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
count = 0
if a[1] > x:
    difference = x-a[1]
    count += difference
    a[1] -= difference
     
for i in range(N-1):
    difference = x - (a[i] + a[i+1])
    if difference < 0:
        count += abs(difference)
        a[i+1] += difference

print(a)
print(count)

Fixed, accepted submission:
N,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
count = 0
if a[1] > x:
    difference = x-a[1]
    count += difference
    a[1] -= difference
     
for i in range(N-1):
    difference = x - (a[i] + a[i+1])
    if difference < 0:
        count += abs(difference)
        a[i+1] += difference
        if a[i+1] < 0:
            a[i] += a[i]
            a[i+1] = 0 


print(count)
Problem:
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.  At least how many operations are necessary to satisfy the following conditions?    * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.   * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.

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

now = a[0]
m = now < 0 and -1 or 1
result = 0

for i, v in enumerate(a[1:]):
    tmp = now * -1
    if m < 0:
        tmp += 1
        if tmp > v:
            now += v
        else:
            result += abs(tmp - v)
            now = -1
    else:
        tmp -= 1
        if tmp < v:
            now += v
        else:
            result += abs(tmp - v)
            now = 1
    m *= -1
print(result)


Fixed, accepted submission:
import numpy as np

input()
a = list(map(int, input().split()))

def calc(a):
    value = a[0]
    sign = value >= 0
    result = 0
    for i in a[1:]:
        value += i
        diff = 0
        if sign and value >= 0:
            diff = value + 1
        elif not sign and value < 0:
            diff = value - 1
        result += abs(diff)
        sign = not sign
        value -= diff
        if value == 0:
            diff += sign
            value += diff
            result += diff
    return result

if a[0] == 0:
    a[0] = 1
    r1 = calc(a[:])
    a[0] = -1
    r2 = calc(a[:])
    print(min(r1, r2) + 1)
else:
    r1 = calc(a[:])
    diff = -a[0] - a[0] // abs(a[0])
    a[0] += diff
    r2 = calc(a[:]) + abs(diff)
    print(min(r1, r2))
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 x >= (b-a):
  print('delicious')
else:
  print('dangerous')

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

if a >= b:
  print('delicious')
elif x >= (b - a):
  print('safe')
else:
  print('dangerous')
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
n,k,x,y = [int(input()) for i in range(4)]
print(n*x+abs(n-k)*y)

Fixed, accepted submission:
n,k,x,y = [int(input()) for i in range(4)]
print(n*x-(x-y)*max(n-k,0))
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):
n = input()

if n == n[0] * 4:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
s = input()

if (s[0] * 3 in s) or (s[3] * 3 in s):
    print("Yes")
else:
    print("No")
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
def digit_sum(x):
  string_x = str(x)
  total = 0
  for char in string_x:
    total += int(char)
  return total
a, b, c = map(int, input().split())

sum=0
for i in range(0,a):
    if(digit_sum(i)>=b and digit_sum(i)<=c):
        sum=sum+i

print(sum)
    


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

def ok(a):
    s = 0
    while a > 0:
        s += a % 10
        a //= 10
    return (A <= s and s <= B)

s = 0
for i in range(1, n+1):
    if ok(i):
        s += i
print(s)
Problem:
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T  T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.

Incorrect submission (verdict: Wrong Answer):
sentence=input()
snt=sentence.lower()
word=input()

cnt=sentence.count(word)
print(cnt)

Fixed, accepted submission:
w= input().casefold()
 
cnt = 0
 
while(1):
    snt = input()
    if snt == "END_OF_TEXT":
        break
    sntt = snt.casefold()
    words = sntt.split()
    cnt += words.count(w)
     
print(cnt)
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):
n = input()
s = input()
count = 0
countl = 0
for c in s:
    if c=='(':
        count += 1
    else:
        count -= 1
    if count < 0:
        countl += 1
        count = 0
count = 0
countr = 0
for c in s[::-1]:
    if c=='(':
        count -= 1
    else:
        count += 1
    if count < 0:
        countr += 1  
        count = 0
print(countl)
print(countr)
print("("*countl + s + ")"*countr)

        

Fixed, accepted submission:
n = input()
s = input()
count = 0
countl = 0
for c in s:
    if c=='(':
        count += 1
    else:
        count -= 1
    if count < 0:
        countl += 1
        count = 0
count = 0
countr = 0
for c in s[::-1]:
    if c=='(':
        count -= 1
    else:
        count += 1
    if count < 0:
        countr += 1  
        count = 0
print('('*countl + s + ')'*countr)
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
a = 0
w = 0
t = 0
r = 0
for i in range(n):
    if s[i]  == "AC":
        a += 1
    elif s[i] == "WA":
        w += 1
    elif s[i] == "TLE":
        t += 1
    else:
        r += 1
print("AC x" +str(a))
print("WA x" +str(w))
print("TLE x" +str(t))
print("RE x" +str(r))

Fixed, accepted submission:
n = int(input())
s = [input() for _ in range(n)]
a = 0
w = 0
t = 0
r = 0
for i in range(n):
    if s[i]  == "AC":
        a += 1
    elif s[i] == "WA":
        w += 1
    elif s[i] == "TLE":
        t += 1
    else:
        r += 1
print("AC x",str(a))
print("WA x",str(w))
print("TLE x",str(t))
print("RE x",str(r))
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

Incorrect submission (verdict: Wrong Answer):
w = list(input())
W = list(set(w))
cnt = [0]*len(W)

for i in w:
    cnt[W.index(i)] += 1

for i in cnt:
    if i%2!=0:
        print('NO')
        exit()
print('YES')


Fixed, accepted submission:
w = list(input())
W = list(set(w))
cnt = [0]*len(W)

for i in w:
    cnt[W.index(i)] += 1

for i in cnt:
    if i%2!=0:
        print('No')
        exit()
print('Yes')
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
ans = 800 * N - N // 15
print(ans)


Fixed, accepted submission:
N = int(input())
ans = 800 * N - (N // 15) * 200
print(ans)
Problem:
A Hitachi string is a concatenation of one or more copies of the string `hi`.  For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not.  Given a string S, determine whether S is a Hitachi string.

Incorrect submission (verdict: Wrong Answer):
import re

pattern = re.compile("(hi)+")
s = input()
print("YES" if pattern.fullmatch(s) else "NO")

Fixed, accepted submission:
import re

pattern = re.compile("(hi)+")
s = input()
print("Yes" if pattern.fullmatch(s) else "No")