TnT/CodeNet4Repair huggingface dataset:
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):
min, max, K = map(int, input().split())

if ((max - min + 1) > 2*K):
    for i in range(min, max+1):
        print(i)

else:
    for i in range(min, min+K):
        print(i)
    for i in range(max-K, max+1):
        print(i)

Fixed, accepted submission:
min, max, K = map(int, input().split())

if ((max - min + 1) < 2*K):
    for i in range(min, max+1):
        print(i)

else:
    for i in range(min, min+K):
        print(i)
    for i in range(max-K+1, max+1):
        print(i)
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

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

m = n % 500
if m <= a:
    print("YES")
else:
    print("NO")

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

m = n % 500
if m <= a:
    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):
n, a, b = map(int, input().split())
cnt = 0 
ans = 0
print(n)
for i in range(n+1):
	
	sum_ = 0
	m = i

	while True:
		sum_ += m % 10
		m //= 10
		if not m:
			break
	if a <= sum_ <= b:
		ans += i

print(ans)

Fixed, accepted submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
	sum_ = 0
	m = i

	while True:
		sum_ += m % 10
		m //= 10
		if not m:
			break
	if a <= sum_ <= 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())
print("Yes") if((a < b and b < c) or (a > b and b > c)) else print("No")

Fixed, accepted submission:
a, b, c = map(int, input().split())
print("Yes") if((a < c and c < b) or (a > c and c > b)) else print("No")
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

Incorrect submission (verdict: Wrong Answer):
print(len(set(input())))

Fixed, accepted submission:
print(len(set(input().split())))
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(int(n*(n+1)/2))
Problem:
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.

Incorrect submission (verdict: Wrong Answer):
def main():

    def diffarray(arr):
        sum = 0
        tmp = arr[0]
        for digit in arr[1:]:
            sum += abs(tmp - digit)
            tmp = digit
        return sum

    def insert(arr,max):
        
        cur = arr[-1]
        arr_ = arr[:-1]
        retarr = arr

        for i in range(len(arr_)):
            newarr = arr_[:i] + [cur] + arr_[i:]
            tmpdiff = diffarray(newarr)
            if max < tmpdiff:
                max = tmpdiff
                retarr = newarr

        return max, retarr

    N = int(input())
    arr=[]
    for i in range(N):
        arr.append(int(input()))
    arr.sort()

    max_diff = diffarray(arr)

    for i in range(N):
        max_diff, arr = insert(arr,max_diff)




    print(max_diff)

    return


main()

Fixed, accepted submission:
def main():
    N = int(input())
    array = [int(input()) for _ in range(N)]
    array.sort()

    div, mod = divmod(N, 2)
    if mod == 0:
        fore, last_in_fore, first_in_rear, rear = array[:div-1], array[div-1], array[div], array[div+1:]
        a = 2 * sum(rear) + first_in_rear - last_in_fore - 2 * sum(fore)
        print(a)
        return
    else:
        #mode1 (mfrfm):(1,-2,2,-2,1)
        fore1, mid1, rear1 = array[:div], array[div:div+2], array[div+2:]
        a1 = -2 * sum(fore1) + sum(mid1) + 2 * sum(rear1)
        #mode2 (mrfrm):(1,2,-2,2,1)
        fore2, mid2, rear2 = array[:div-1], array[div-1:div+1], array[div+1:]
        a2 = -2 * sum(fore2) - sum(mid2) + 2 * sum(rear2)

        print(max(a1, a2))
        return
    return


main()
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

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

if B >= C >= A:
  print('YES')
  
else:
  print('NO')

Fixed, accepted submission:
A,B,C =map(int,input().split())
 
if C>=A and C<=B:
	print('Yes')
else:
	print('No')
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

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

group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]
list_of_list = [group_a, group_b, group_c]

count_match = 0

for list_i in list_of_list:
    if input_list in list_i:
        count_match += 1
        break

if count_match == 1:
    print('Yes')
else:
    print('No')


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

group_a = {1, 3, 5, 7, 8, 10, 12}
group_b = {4, 6, 9, 11}
group_c = {2}

list_of_list = [group_a, group_b, group_c]

count_match = 0

for set_i in list_of_list:
    if set_i.issuperset(input_set):
        count_match += 1
        print('Yes')
        break

if not count_match >= 1:
    print('No')
Problem:
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation.  An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, the adjacency list $Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$. That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.  An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A = a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.  Write a program which reads a directed graph $G$ represented by the adjacency list, and prints its adjacency-matrix representation. $G$ consists of $n\; (=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively.

Incorrect submission (verdict: Wrong Answer):
# ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]


graph_table = [[0]*n for i in range(n)]


for d in data:
    node_id = d[0]
    num_of_e = d[1]
    for e in d[2:]:
        graph_table[node_id-1][e-1] = 1

print(graph_table)

# ??????
for g in graph_table:
    print(*g)

Fixed, accepted submission:
# ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]


graph_table = [[0]*n for i in range(n)]


for d in data:
    node_id = d[0]
    num_of_e = d[1]
    for e in d[2:]:
        graph_table[node_id-1][e-1] = 1

# ??????
for g in graph_table:
    print(*g)
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())
a = 0
b = 0
c = 0
d = 0
for n in range(N):
    s = input()
    if s == 'AC':
        a += 1
    if s == 'WA':
        b += 1
    if s == 'TLE':
        c += 1
    if s == 'RE':
        d += 1
print('AC × {}'.format(a))
print('WA × {}'.format(b))
print('TLE × {}'.format(c))
print('RE × {}'.format(d))

Fixed, accepted submission:
N = int(input())
a = 0
b = 0
c = 0
d = 0
for n in range(N):
    s = input()
    if s == 'AC':
        a += 1
    if s == 'WA':
        b += 1
    if s == 'TLE':
        c += 1
    if s == 'RE':
        d += 1

print('AC x ' + str(a))
print('WA x ' + str(b))
print('TLE x ' + str(c))
print('RE x ' + str(d))
Problem:
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.    * `0 p x`: a_p \gets a_p + x   * `1 l r`: Print \sum_{i = l}^{r - 1}{a_i}.

Incorrect submission (verdict: Wrong Answer):


def lowbit(x):
	return x & (-x)

def update(n , c ,x , y):
	while x <= n:
		c[x] += y
		x += lowbit(x)

def query(c , x):
	print(len(c) , x)
	ans = 0
	while x != 0:
		ans += c[x]
		x -= lowbit(x)
	return ans

def main():
	n , q = map(int , input().split())
	a_li = list(map(int , input().split()))
	a_li.insert(0,0)
	sum_li = [0 for _ in range(n + 1)]
	for i in range(1 , n + 1):
		sum_li[i] = sum_li[i - 1] + a_li[i]

	c = [0 for _ in range(n + 1)]
	for _ in range(q):
		t , l , r = map(int , input().split())
		if t == 1:
			print(query(c , r) - query(c , l) +  sum_li[r] - sum_li[l])
		else:
			update(n , c , l + 1 , r)

if __name__ == '__main__':
	main()

Fixed, accepted submission:


def lowbit(x):
	return x & (-x)

def update(n , c ,x , y):
	while x <= n:
		c[x] += y
		x += lowbit(x)

def query(c , x):
	ans = 0
	while x != 0:
		ans += c[x]
		x -= lowbit(x)
	return ans

def main():
	n , q = map(int , input().split())
	a_li = list(map(int , input().split()))
	a_li.insert(0,0)
	sum_li = [0 for _ in range(n + 1)]
	for i in range(1 , n + 1):
		sum_li[i] = sum_li[i - 1] + a_li[i]

	c = [0 for _ in range(n + 1)]
	for _ in range(q):
		t , l , r = map(int , input().split())
		if t == 1:
			print(query(c , r) - query(c , l) +  sum_li[r] - sum_li[l])
		else:
			update(n , c , l + 1 , r)

if __name__ == '__main__':
	main()
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

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

for i in range(10**6):
    if A * i % B == C:
        print('Yes')
        break
else:
    print('No')

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

for i in range(10**6):
    if A * i % B == C:
        print('YES')
        break
else:
    print('NO')
Problem:
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information:  If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest.  Given this information, determine whether TopCoDeer is honest.

Incorrect submission (verdict: Wrong Answer):
a, b = map(str, input().split())
if a == 'D':
  print(b)
else:
  if b == 'H':
    print('D')
  else:
    print('H')

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

if a == 'H':
  print(b)
else:
  if b == 'D':
    print('H')
  else:
    print('D')
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while 1:
    a, operator, b = input().split()
    if operator == "+":
        print(int(a) + int(b))
    elif operator == "-":
        print(int(a) - int(b))
    elif operator == "*":
        print(int(a) * int(b))
    elif operator == "/":
        print(int(a) / int(b))
    elif operator == "?":
        break
    else:
        print("'" + operator + "'" + " is not a operator.")

Fixed, accepted submission:
while 1:
    a, operator, b = input().split()
    if operator == "+":
        print(int(a) + int(b))
    elif operator == "-":
        print(int(a) - int(b))
    elif operator == "*":
        print(int(a) * int(b))
    elif operator == "/":
        print(int(a) // int(b))
    elif operator == "?":
        break
    else:
        print("'" + operator + "'" + " is not a operator.")
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):
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,X = map(int, lines.pop(0).split(' '))
    if ( A <= X and A + B >= X ):
        print('YES')
    else:
        print('NO')

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]


Fixed, accepted submission:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,X = map(int, lines.pop(0).split(' '))
    if ( A <= X and A + B >= X ):
        print('YES')
    else:
        print('NO')

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):
x,y =map(int,input().split())
number=set([i+1 for i in range(12)])
a=[2]
b=[4,6,9,11]
c=list(set(number)-set(a)-set(b))
if x in a and y in a:print('YES')
elif x in b and y in b:print('YES')
elif x in c and y in c:print('YES')
else:print('NO')


Fixed, accepted submission:
A =list(map(int,input().split()))
a=[2]
b=[4,6,9,11]
c=[1,3,5,7,8,10,12]
if set(A)<=set(a) or set(A)<=set(b) or set(A)<=set(c):
  print('Yes')
else:print('No')
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
print(int(input())^3)


Fixed, accepted submission:
print(int(input())**3)
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int,input().split())
A = []
for i in range(1,b+1):
    mod = a*i % b
    if mod in A:break
    A.append(mod)

A.sort()
if len(A) >= 2:
    i = A[1]
else:
    i = 0

if i == 0 and c == 0:
    print('Yes')
    exit()
elif i == 0 and c != 0:
    print('No')
    exit()

if c % i == 0:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
a, b, c = map(int,input().split())
ans = 'NO'

for i in range(1,b+1):
    mod = a*i % b
    if mod == 0:continue
    elif c % mod == 0:
        ans = 'YES'
        break

print(ans)
Problem:
Your task is to perform a simple table calculation.  Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.

Incorrect submission (verdict: Wrong Answer):
H,W = map(int,input().split())
table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()
    



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

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W+1):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(list,input().split())
if a == b and b == c:
    print('1')
elif a == b or a == c or b == c:
    print('2')
else:
    print('1')

Fixed, accepted submission:
a,b,c = map(list,input().split())
if a == b and b == c:
    print('1')
elif a == b or a == c or b == c:
    print('2')
else:
    print('3')
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())
ans = N*(N-1)/2
print(int(ans))

Fixed, accepted submission:
N = int(input())
ans = N*(N+1)/2
print(int(ans))
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):
list = list(str(input()))
while True:
    list.pop(-1)
    print(list)
    if len(list)%2==0:
        M=len(list)//2
        if list[0:M-1] == list[M:-1]:
            print(len(list))
            break

Fixed, accepted submission:
S = input()
for i in range(len(S)):
    S=S[:-1]
    if S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        break
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
i = int(input())
print(str(i^3))

Fixed, accepted submission:
i = int(input())
print(str(i**3))
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

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

res = ''
for i, elem in enumerate(s):
  if i % 2 == 0:
    res += elem
print(elem)

Fixed, accepted submission:
s = input()

res = ''
for i, elem in enumerate(s):
  if i % 2 == 0:
    res += elem
print(res)
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):
price=int(input())

print(price%1000)



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

ans=price%1000

if ans!=0:
    ans=1000-ans

print(ans)
Problem:
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.  You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.  Determine if there are more people wearing a red hat than people wearing a blue hat.

Incorrect submission (verdict: Wrong Answer):
N=input(int())
n=input(int())
A=n.count("R")
B=n.count("B")
if A>B:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
N=input(str())
n=input(str())
A=n.count("R")
B=n.count("B")
if A>B:
  print("Yes")
else:
  print("No")
Problem:
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:    * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.   * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.  The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Incorrect submission (verdict: Wrong Answer):
import math

N, H = map(int, input().split())
kiri = []
nage = []
for n in range(N):
    tmps = list(map(int, input().split()))
    kiri.append(tmps[0])
    nage.append(tmps[1])

kiri_max = max(kiri)
nage.sort(reverse=True)

count = 0
while (H > 0):
    if (len(nage) != 0):
        H -= nage[0]
        nage.pop(0)
        count += 1
    else:
        if ( H % kiri_max):
            count += H // kiri_max
        else:
            count += H // kiri_max + 1
        break

print(count)

Fixed, accepted submission:
import math

N, H = map(int, input().split())
kiri = []
nage = []
for n in range(N):
    tmps = list(map(int, input().split()))
    kiri.append(tmps[0])
    nage.append(tmps[1])

kiri_max = max(kiri)
nage.sort(reverse=True)
nage = list(filter(lambda x: x >= kiri_max, nage))

count = 0
while (H > 0):
    if (len(nage) != 0):
        H -= nage[0]
        nage.pop(0)
        count += 1
    else:
        if ( H % kiri_max == 0):
            count += H // kiri_max
        else:
            count += H // kiri_max + 1
        break

print(count)