TnT/CodeNet4Repair huggingface dataset:
Problem:
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

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

for a, b in ab:
    if a == b:
        print(2 * a - 2)
        continue

    l = 0
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        mx = (m + 1) // 2 * (m - (m + 1) // 2)
        if mx < a * b:
            l = m
        else:
            r = m

    print(l)


Fixed, accepted submission:
q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]

for a, b in ab:
    if a == b:
        print(2 * a - 2)
        continue

    l = 1
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        mx = (m + 1) // 2 * (m + 1 - (m + 1) // 2)
        if mx < a * b:
            l = m
        else:
            r = m

    print(l - 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-200*(N//15)

Fixed, accepted submission:
N=int(input())
print(N*800-200*(N//15))
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())

Sum = 0

for n in range(N+1):
    s = 0
    strn = str(n)
    for i in strn:
        s += int(i)
    if s >= A and s<= B:
        Sum += n
    print("{}".format(n))

print("{}".format(Sum))

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

Sum = 0

for n in range(N+1):
    s = 0
    strn = str(n)
    for i in strn:
        s += int(i)
    if s >= A and s<= B:
        Sum += n

print("{}".format(Sum))
Problem:
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.  The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.  How many different PIN codes can he set this way?  Both the lucky number and the PIN code may begin with a 0.

Incorrect submission (verdict: Wrong Answer):
19
3141592653589793238

Fixed, accepted submission:
N=int(input())
S=input()

count=0
for p in range(10):
    s=S.find(str(p))
    if s==-1:
        continue
    for q in range(10):
        t=S.find(str(q),s+1)
        if t==-1:
            continue
        for r in range(10):
            u=S.find(str(r),t+1)
            if u!=-1:
                count+=1
print(count)
Problem:
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them.  He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).  Find the minimum total cost to achieve his objective.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
        ans.append(c)

print(min(ans))

Fixed, accepted submission:
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(ans))
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

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

Fixed, accepted submission:
a,b,x=map(int,input().split())
if 0<=x-a<=b:
    print("YES")
else:
    print("NO")
Problem:
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of   AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.

Incorrect submission (verdict: Wrong Answer):
w,a,b = map(int,input().split())
print(max(min(a,b)-max(a,b)-w,0))

Fixed, accepted submission:
w,a,b = map(int,input().split())
print(max(abs(a-b)-w,0))
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
def abc(s):
    word = list(s)
    print(word)
    if word[0] != word[1] and word[0] != word[2] and word[1] != word[2]:
        print("Yes")
    else:
        print("No")

S = input("S:")
abc(S)


Fixed, accepted submission:
def abc(s):
    word = list(s)
    if word[0] != word[1] and word[0] != word[2] and word[1] != word[2]:
        print("Yes")
    else:
        print("No")

S = input()
abc(S)
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//15
print(x-y)

Fixed, accepted submission:
n = int(input())
x = n*800
y = (n//15)*200
print(x-y)
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 = (int(x) for x in input().split())
if H % 2 == 1 and W % 2 == 1:
    a = int(H/2)
    b = a + 1
    k = b + (int(W/2))*H
else:
    k = H * W / 2

print(k)

Fixed, accepted submission:
H, W = (int(x) for x in input().split())

if H == 1 or W == 1:
    k = 1
elif H*W % 2 == 1:
    k = int(H / 2) + (int(W / 2)) * H + 1
else:
    k = int(H * W / 2)

print(k)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

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

if (A + K) - (B - K) > 0:
    for i in range(A, B + 1):
        print(i)
else:
    for k in range(K):
        print(A + k)
    for k in range(B - k + 1, B + 1):
        print(k)

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

if (A + K) - (B - K) > 0:
    for i in range(A, B + 1):
        print(i)
else:
    for k in range(A, K + A):
        print(k)
    for k in range(B - K + 1, B + 1):
        print(k)
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
S=set(input())
print("Yes" if S == 3 else "No")

Fixed, accepted submission:
S = input()
if S.count("a")==1 and S.count("b") == 1 and S.count("c") == 1:
    print("Yes")
else:
    print("No")
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):
S = input()
pattern = ''
cnt = len(S)//2
for _ in range(cnt):
    pattern += 'hi'
    print(pattern)
if S == pattern:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
S = input()
pattern = 'hi'
cnt = len(S)//2
for _ in range(cnt-1):
    pattern += 'hi'

if S == pattern:
    print('Yes')
else:
    print('No')
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
def abc():
    rgb = ''.join(input().split())
    print('Yes' if int(rgb) % 4 == 0 else 'No')


abc()


Fixed, accepted submission:
def abc():
    rgb = ''.join(input().split())
    print('NO' if int(rgb) % 4 else 'YES')


abc()
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
import sys


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

文字列の文字集取得
a_len, b_len, c_len = len(a), len(b), len(c)

cnt5, cnt7 = 0, 0


if a_len == 5:
    cnt5 += 1
if a_len == 7:
    cnt7 += 1
if b_len == 5:
    cnt5 += 1
if b_len == 7:
    cnt7 += 1
if c_len == 5:
    cnt5 += 1
if c_len == 7:
    cnt7 += 1


if cnt5 == 2 and cnt7 == 1:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
import sys


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

cnt5, cnt7 = 0, 0


if a == 5:
    cnt5 += 1
if a == 7:
    cnt7 += 1
if b == 5:
    cnt5 += 1
if b == 7:
    cnt7 += 1
if c == 5:
    cnt5 += 1
if c == 7:
    cnt7 += 1


if cnt5 == 2 and cnt7 == 1:
    print("YES")
else:
    print("NO")
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())
z=list(map(int,input().split()))
flag=1
a=0
cnt=0
while flag:
    flag=0

    for i in reversed(range(a,n)):
        if i ==0:
            break
        if z[i]<z[i-1]:
            tmp=z[i]
            z[i]=z[i-1]
            z[i-1]=tmp
            flag=1
            cnt+=1
        print(z)
    a+=1
print(' '.join(list(map(str,z))))
print(cnt)

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

    for i in reversed(range(a,n)):
        if i ==0:
            break
        if z[i]<z[i-1]:
            tmp=z[i]
            z[i]=z[i-1]
            z[i-1]=tmp
            flag=1
            cnt+=1
        
    a+=1
print(' '.join(list(map(str,z))))
print(cnt)
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Incorrect submission (verdict: Wrong Answer):
a,b=list(map(int,input().split(" ")))
if a+b==3 or a==3 or b==3:
  print('Possible')
else:
  print('Impossible')

Fixed, accepted submission:
a,b=list(map(int,input().split(" ")))
if (a+b)%3==0 or a%3==0 or b%3==0:
  print('Possible')
else:
  print('Impossible')
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())
count=[0]*(10**4+1)
for x in range(1,10**2):
    for y in range(1,10**2):
        for z in range(1,10**2):
            n=x**2+y**2+z**2+x*y+y*z+z*x
            if n<=10**4:
                count[n]+=1
for i in range(1,N):
    print(count[i])

Fixed, accepted submission:
from itertools import product
N=int(input())
f=[0]*N
for x,y,z in product(range(1,100),repeat=3):
    n=x**2+y**2+z**2+x*y+y*z+z*x
    if n<=N:
        f[n-1]+=1
for i in range(N):
    print(f[i])
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

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

answer = a * b

print(answer)

if answer%2==0:
    print('Even')

else:
    print('Odd')

Fixed, accepted submission:
a, b = map(int,input().split())
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
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):
# # Make IO faster
# import sys
# input = sys.stdin.readline


# X = input()


# N = int(input())

# X, Y = map(int, input().split())
 for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
if a < b:
    print(a)
else:
    print(a - 1)


Fixed, accepted submission:
a,b=map(int,input().split())
if b>=a:
  print(a)
else:
  print(a-1)
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
import sys
n = int(input())
for i in range(1,6):
  if n < 2**i:
    print(2**(i-1))
    sys.exit()
  elif n == 2**i:
    print(2**i)
    sys.exit()
  else:
    print(64)
    sys.exit()

Fixed, accepted submission:
import sys
N = int(input())
for i in range(0,7):
	if N == 1:
		print(1)
		sys.exit()
	elif N >= 64:
		print(64)
		sys.exit()
	elif N < 2**i:
		print(2**(i-1))
		sys.exit()
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
A = [input() for _ in range(a)]
b = int(input())
B = [input() for _ in range(b)]
count = 0
for i in B:
  if i in A:
    pass
  else:
    count+= 1
print(count)

Fixed, accepted submission:
a = int(input())
A = [input() for _ in range(a)]
b = int(input())
B = [input() for _ in range(b)]
a = list(set(A) | set(B))
c = []
for i in range(len(a)):
  c.append(A.count(a[i]) - B.count(a[i]))
if max(c) < 0:
  print(0)
else:
  print(max(c))
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):
x=int(input())
print((x*(x-1))//2)

Fixed, accepted submission:
x=int(input())
print((x*(x+1))//2)
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, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

b = abs(b - a)
a = 0

if (b + v * t) <= (0 + v * t):
    print("YES")
else:
    print("NO")

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

b = abs(b - a)
a = 0

if (b + w * t) <= (0 + v * t):
    print("YES")
else:
    print("NO")
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

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

print('2018/01/' + S[9:])

Fixed, accepted submission:
S = input()

print('2018/01/' + S[8:])
Problem:
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.  He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.  Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

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

def solve():
  a.sort()
  count = [a.count(i) for i in range(n) if a.count(i)>0]
  count.sort()
  if(len(count)<k):
    print(0)
    return
  print(sum(count[:len(count)-k]))
  return

solve()

Fixed, accepted submission:
import collections

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

def solve():
  c = list(collections.Counter(a).values())
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()
Problem:
How many multiples of d are there among the integers between L and R (inclusive)?

Incorrect submission (verdict: Wrong Answer):
L,R,d = map(int, input().split())
cnt = 0
if d % L != 0:
    L += d % L

while L <= R:
    cnt += 1
    L += d
print(cnt)

Fixed, accepted submission:
L,R,d = map(int, input().split())
cnt = 0
for i in range(L, R + 1):
    if i % d == 0:
        cnt += 1

print(cnt)
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):
a = int(input())
b = int(a / 1000) + 1
c = a % 1000
if c == 0:
  print(0)
else:
  print(b - c)


Fixed, accepted submission:
a = int(input())
b = int(a / 1000) + 1
c = a % 1000
if c == 0:
  print(0)
else:
  print(1000 - c)
Problem:
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.  How many ways are there to choose K consecutive integers?

Incorrect submission (verdict: Wrong Answer):

# -*- coding: utf-8 -*-

n,k = map(int,input().split())

answer = n-k+1
if n > k :
        answer = 0
print( answer )

Fixed, accepted submission:

# -*- coding: utf-8 -*-

n,k = map(int,input().split())

answer = n-k+1
if n < k :
        answer = 0
print( answer )
Problem:
You are given a string S.  Takahashi can insert the character `A` at any position in this string any number of times.  Can he change S into `AKIHABARA`?

Incorrect submission (verdict: Wrong Answer):
import re

S = input()
print('Yes' if re.match(r'A?KIHA?BA?RA?', S) else 'No')


Fixed, accepted submission:
import re

S = input()
print('YES' if re.match(r'^A?KIHA?BA?RA?$', S) else 'NO')
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())
if abs(x-a)>abs(x-b):
    print("A")
else:
    print("B") 

Fixed, accepted submission:
x, a, b = map(int,input().split())
if abs(x - a) > abs(x - b):
    print("B")
else:
    print("A")
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

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:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

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

Fixed, accepted submission:
a, b, x = map(int, input().split())
if a <= x <= a + b:
    print("YES")
else:
    print("NO")