TnT/CodeNet4Repair huggingface dataset:
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 i in range(M+1):
    for j in range(D):
        if len(str(j)) >= 2:
            aaa=str(j)[-1]
            bbb=str(j)[-2]
            if int(aaa) >= 2 and int(bbb) >= 2 and int(aaa)*int(bbb) == i :
                print(bbb+aaa)
                cnt +=1
        else:
            pass

Fixed, accepted submission:
M,D = map(int,input().split())
cnt = 0


for i in range(M+1):
    for j in range(D+1):
        if len(str(j)) >= 2:
            aaa=str(j)[-1]
            bbb=str(j)[-2]
            if int(aaa) >= 2 and int(bbb) >= 2 and int(aaa)*int(bbb) == i :
                cnt +=1
        else:
            pass
print(cnt)
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 = list(map(int, input().split()))

if a[0] + a[1] == a[2] + a[3]:
  print('Balanced')
elif a[0] + a[1] < a[2] + a[3]:
  print('Left')
else:
  print('Right')

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

if a[0] + a[1] == a[2] + a[3]:
  print('Balanced')
elif a[0] + a[1] < a[2] + a[3]:
  print('Right')
else:
  print('Left')
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
a=int(input())
if a%2==1:
  print(a//2)
else:
  print(a/2+a)

Fixed, accepted submission:
a=int(input())
if a%2==1:
  print(a//2)
else:
  print(a//2-1)
Problem:
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**.  Here, an sequence b is a **good sequence** when the following condition holds true:    * For each element x in b, the value x occurs exactly x times in b.  For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.  Find the minimum number of elements that needs to be removed so that a will be a good sequence.

Incorrect submission (verdict: Wrong Answer):
import collections
N = int(input())
a = [int(i) for i in input().split()]
hint = collections.Counter(a)
b = hint.most_common()
ans = 0
for val, num in b:
    if val != num:
        ans += num
print(ans)

Fixed, accepted submission:
import collections

N = int(input())
a = [int(i) for i in input().split()]
ans = 0

num = collections.Counter(a).most_common()

for a, b in num:
    if b < a:
        ans += b
    elif a < b:
        ans += b-a
print(ans)
Problem:
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.  They start simultaneously at the same point and moves as follows **towards the east** :    * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.   * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.  How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.

Incorrect submission (verdict: Wrong Answer):
import numpy

t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

v1=b1-a1
v2=b2-a2
print(v1,v2)
x1=v1*t1
x2=v2*t2
print(x1,x2)
if numpy.sign(x1)==numpy.sign(x2):
    #print("one")
    print(0)
elif abs(x2)-abs(x1)<0:
    #print("two")
    print(0)
elif -x1==x2:
    print("infinity")
else:
    #print("hello")
    print(x1,2*(abs(x2)-abs(x1)))
    print(2*(x1//(abs(x2)-abs(x1)))+1)


Fixed, accepted submission:
import numpy

t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

v1=b1-a1
v2=b2-a2

x1=v1*t1
x2=v2*t2
di = abs(abs(x2)-abs(x1))
if numpy.sign(x1)==numpy.sign(x2):
    print(0)
elif abs(x2)<abs(x1):
    print(0)
elif abs(x1)==abs(x2):
    print("infinity")
else:
    if abs(x1)%di==0:
        print(abs(int(2*(x1/di))))
        
    else:
        print(abs(int(2*(x1//di)+1)))
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
if n % 2 == 0:
    print(n // 2)
else:
    print((n-1)//2)

Fixed, accepted submission:
n = int(input())
if n % 2 == 0:
    print(n // 2 - 1)
else:
    print((n-1)//2)
Problem:
_ButCoder Inc._ runs a programming competition site called _ButCoder_. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called _Kaiden_ ("total transmission"). Note that a user's rating may become negative.  Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).  According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?

Incorrect submission (verdict: Wrong Answer):
from math import ceil
k,a,b=map(int,input().split())
k-=a
if k<=0:
  print(1)
elif a>b:
  print(1+ceil(k/(a-b)))
else:
  print(-1)

Fixed, accepted submission:
from math import ceil
k,a,b=map(int,input().split())
if k<=a:
  print(1)
elif a>b:
  print(1+(k-b-1)//(a-b)*2)
else:
  print(-1)
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):
s = input()
upper_diff = ord('A') - ord('a')


def to_upper(c: str) -> str:
    return chr(ord(c) + upper_diff)


out = "".join(map(to_upper, s))
print(out)

Fixed, accepted submission:
s = input().split()
upper_diff = ord('A') - ord('a')


def to_upper(c):
    # print("c:", c)
    return chr(ord(c) + upper_diff)


out = "".join(map(to_upper, [x[0] for x in s]))
print(out)
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):
n = int(input())
x = list(map(int,input().split()))
for i in range(1,n):
    v = x[i]
    j = i - 1
    while j >= 0:
        if x[j] > v:
            x[j + 1] = x[j]
            x[j] = v
        j += -1
    print (*x)

Fixed, accepted submission:
n = int(input())
x = list(map(int,input().split()))
print (*x)
for i in range(1,n):
    v = x[i]
    j = i - 1
    while j >= 0:
        if x[j] > v:
            x[j + 1] = x[j]
            x[j] = v
        j += -1
    print (*x)
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())
print('delicious' if b <= a else 'safe' if b <= x else 'dangerous')

Fixed, accepted submission:
x, a, b = map(int, input().split())
print('delicious' if b <= a else 'safe' if b <= a + x else 'dangerous')
Problem:
機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。  「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。  

Incorrect submission (verdict: Wrong Answer):
import sys

c1 = c2 = 0
for line in sys.stdin:
    a, b, c = map(int, line.split(','))
    if a**2 + b**2 == c**2:
        c1 += 1
    elif a == b:
        c2 += 1
print(c1, c2)

Fixed, accepted submission:
import sys

c1 = c2 = 0
for line in sys.stdin:
    a, b, c = map(int, line.split(','))
    if a**2 + b**2 == c**2:
        c1 += 1
    elif a == b:
        c2 += 1
print(c1)
print(c2)
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):
S = input()

a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
  a[i] = ch[::-1]

T = ''

S = S[::-1]

flag = True
while flag:
  if S[:5] in a:
    S = S[5:]
  elif S[:6] in a:
    S = S[6:]
  elif S[:7] in a:
    S = S[7:]
  elif len(S)==0:
    ans  = 'Yes'
    flag = False
  else:
    ans  = 'No'
    flag = False
  
print(ans)

Fixed, accepted submission:
S = input()

a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
  a[i] = ch[::-1]

S = S[::-1]

flag = True
while flag:
  if len(S)==0:
    ans  = 'YES'
    flag = False
  elif S[:5] in a:
    S = S[5:]
  elif S[:6] in a:
    S = S[6:]
  elif S[:7] in a:
    S = S[7:]
  else:
    ans  = 'NO'
    flag = False
  
print(ans)
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().split())
d = a // b
r = a % b
f = a / b

Fixed, accepted submission:
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, '{:.5f}'.format(f))
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):
n,a,b = map(int, input().split())
ans = 0

for i in range(1, n+1):
  if a<=sum([int(c) for c in str(i)])<=b:
    ans+=1
print(ans)

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

for i in range(1, n+1):
  if a<=sum([int(c) for c in str(i)])<=b:
    ans+=i
print(ans)
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,b,c = map(int,input().split())
if b > a:
    z = a
    a = b
    b = z
if a <= c <= b:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
a,b,c = map(int,input().split())
if a > b:
    z = a
    a = b
    b = z
if a <= c <= b:
    print('Yes')
else:
    print('No')
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

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

if N/2>K-1:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
N,K=map(int,input().split())
 
if N/2>K-1:
  print('YES')
else:
  print('NO')
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):
S=input()
if S=='keyence':
    print('YES')
else:
    pass
if S[:6]=='keyence' or S[-7:-1]=='keyence':
    print('YES')
else:
    pass
if S[0]=='k':
    if S[-6:-1]=='eyence':
        print('YES')
    else:
        pass
if S[:1]=='ke':
    if S[-5:-1]=='yence':
        print('YES')
    else:
        pass
if S[:2]=='key':
    if S[-4:-1]=='ence':
        print('YES')
    else:
        pass
if S[:3]=='keye':
    if S[-3:-1]=='nce':
        print('YES')
    else:
        pass
if S[:4]=='keyen':
    if S[-2:-1]=='ce':
        print('YES')
    else:
        pass
if S[:5]=='keyen':
    if S[-1]=='e':
        print('YES')
    else:
        pass


Fixed, accepted submission:
S=input()
if S=='keyence' or S[0:7]=='keyence' or S[-7:]=='keyence':
    print('YES')
    exit()
else:
    pass

if S[0]=='k':
    if S[-6:]=='eyence':
        print('YES')
        exit()
    else:
        pass
if S[:2]=='ke':
    if S[-5:]=='yence':
        print('YES')
        exit()
    else:
        pass
if S[:3]=='key':
    if S[-4:]=='ence':
        print('YES')
        exit()
    else:
        pass
if S[:4]=='keye':
    if S[-3:]=='nce':
        print('YES')
        exit()
    else:
        pass
if S[:5]=='keyen':
    if S[-2:]=='ce':
        print('YES')
        exit()
    else:
        pass
if S[:6]=='keyenc':
    if S[-1]=='e':
        print('YES')
        exit()
    else:
        pass
print('NO')
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
a,b,x = map(int,input().split())
print((b-a)//x)

Fixed, accepted submission:
a,b,x = map(int,input().split())
print((b-a)//x+1 if a%x == 0 else (b//x-a//x))
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
num = input().split()

if int(num[1]) >=11:
  print(num[0])
else:
  print(int(num[0])-1)

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

if int(num[1]) >= int(num[0]):
  print(num[0])
else:
  print(int(num[0])-1)
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())
x=n*800
y=(n-n%15)/15
print(int(x-y))

Fixed, accepted submission:
n=int(input())
x=n*800
y=((n-n%15)/15)*200
print(int(x-y))
Problem:
Takahashi is a user of a site that hosts programming contests.   When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows:    * Let the current rating of the user be a.   * Suppose that the performance of the user in the contest is b.   * Then, the new rating of the user will be the avarage of a and b.  For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.  Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.   Find the performance required to achieve it.

Incorrect submission (verdict: Wrong Answer):
import sys

num = 1
n = int(sys.stdin.readline().strip())
k = int(sys.stdin.readline().strip())

for i in range(n):
    num = min(num + k, 2 * num)

print(num)

Fixed, accepted submission:
import sys

r = int(sys.stdin.readline().strip())
g = int(sys.stdin.readline().strip())

print(2*g - r)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
import math
b = math.sqrt(a)
c = float(b)
print(c)

Fixed, accepted submission:
import math
print(math.floor(math.sqrt(int(input())))**2)
Problem:
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).

Incorrect submission (verdict: Wrong Answer):
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

print(mask)
def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            print(i,j)
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(input())
dices = [input().split() for _ in range(n)]

print('Yes' if diff_check_all(dices, n) else 'No')

Fixed, accepted submission:
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    if sorted(dice1) != sorted(dice2):
        return False
    
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(input())
dices = [input().split() for _ in range(n)]

print('Yes' if diff_check_all(dices, n) else 'No')
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(3001):
    for j in range(3001):
        x = n - (r * i + g * j)
        if x < 0:
            continue
        if x % b == 0:
            cnt += 1

print(cnt)


Fixed, accepted submission:
def main():
    r, g, b, n = map(int, input().split())

    cnt = 0
    for i in range(n+1):
        for j in range(n+1):
            b_num = n - r*i - g*j
            if b_num >= 0 and b_num % b == 0:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()
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())
print(-(-(a+b)/2))

Fixed, accepted submission:
a,b=map(int,input().split())
print(-(-(a+b)//2))
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,A = map(int,open(0))
print("YES" if A>=(N%500) else "NO")

Fixed, accepted submission:
N,A = int(input()),int(input())
print("Yes" if A>=(N%500) else "No")
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):
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

def insertion_sort(A, N):
    for i in range(1, N):
        key = A[i]
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = key

        for a in A:
            print(str(a) + ' ', end='')
        print('')


insertion_sort(A, N)


Fixed, accepted submission:
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

def insertion_sort(A, N):
    for i in range(N):
        key = A[i]
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = key

        string = list(map(str, A))
        print(' '.join(string))

insertion_sort(A, N)
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
c = input()
vow = ['a','i','u','e','o']
for i in range(len(vow)):
  if i in vow:
    print('vowel')
    break
  if i == len(vow)-1:
    print('consonant')

Fixed, accepted submission:
c = input()
vow = ['a','i','u','e','o']
if c in vow:
  print('vowel')
else:
  print('consonant')