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):
a,b,k = map(int,input().split())
li = []
x = 0
while a + x <= b and b - x >= a and x <= k :
    li.append(a+x)
    li.append(b-x)
    x += 1
se = set(li)
li = list(se)
li.sort()
for i in li :
    print(i)

Fixed, accepted submission:
a,b,k = map(int,input().split())
li = []
x = 0
while a + x <= b and b - x >= a and x <= k-1 :
    li.append(a+x)
    li.append(b-x)
    x += 1
se = set(li)
li = list(se)
li.sort()
for i in li :
    print(i)
Problem:
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`.  Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.

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

cost=[]
left=0
right=0
for i in range(N):
	if S[i]=='#':
		right+=1

cost.append(N-right)
for i in range(0,N):
	if S[i]=='#':
		left+=1
		right-=1
	print(left,right)
	cost.append(left+N-i-1-right)

cost.sort()
print(cost[0])

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

cost=[]
left=0
right=0
for i in range(N):
	if S[i]=='#':
		right+=1

cost.append(N-right)
for i in range(0,N):
	if S[i]=='#':
		left+=1
		right-=1
	cost.append(left+N-i-1-right)

cost.sort()
print(cost[0])
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):
n=int(input())
if((1000-n)>0):
  print(1000-n)
else:
  print(0)

Fixed, accepted submission:
n=int(input())
if(n%1000==0):
    print(0)
else:
    x=n%1000
    print(1000-x)
Problem:
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:    * For any two vertices painted in the same color, the distance between them is an even number.  Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
uvw=[list(map(int,input().split())) for i in range(n-1)]


def Graph(ab):
    log=[0]*n
    G=[[] for i in range(n)]
    
    for a,b,c in ab:
        G[a-1].append(b)
        G[b-1].append(a)
        if c%2==0:
            log[a-1]=1
            log[b-1]=1
        #up_G[b-1]=a
    return log #,up_G

log=Graph(uvw)
print(*log,sep='\n')

Fixed, accepted submission:

def Graph(ab):
    G=[[] for i in range(n)]
    
    for a,b,c in ab:
        G[a-1].append((b,c%2))
        G[b-1].append((a,c%2))
        #up_G[b-1]=a
    return G #,up_G
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p,0))
    ans=[0]*n
    while q:
        V,P,S=q.pop()
        if S==0:
            
            #q.append((V,1))
            for new_v,dis in G[V-1]:
                if new_v==P:continue
                ans[new_v-1]=(ans[V-1]+dis)%2
                q.append((new_v,V,0))
    return ans
n=int(input())
uvw=[list(map(int,input().split())) for i in range(n-1)]
G=Graph(uvw)
#print(G)
ans=dfs(G,1,-1)
print(*ans,sep='\n')
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
A, B = map(int, input().split())
chars = list(input())
for i in range(A):
    if not chars[i].isdigit():
        print("Noa")
        exit()
if chars[A] != '-':
    print("No")
    exit()

for i in range(B):
    if not chars[i].isdigit():
        print("No")
        exit()

print("Yes")
    


Fixed, accepted submission:
A, B = map(int, input().split())
chars = input()
if chars[A] == '-' and chars[:A].isdigit() and chars[-B:].isdigit():
    print("Yes")
else:
    print("No")
Problem:
The door of Snuke's laboratory is locked with a security code.  The security code is a 4-digit number. We say the security code is _hard to enter_ when it contains two consecutive digits that are the same.  You are given the current security code S. If S is hard to enter, print `Bad`; otherwise, print `Good`.

Incorrect submission (verdict: Wrong Answer):
while True:
    try:
        S = input()
        
        for i in range(len(S)-1):
            if S[i] == S[i-1]:
                print("Bad")
                break
        else:
            print("Good")
    except:
        break

Fixed, accepted submission:
while True:
    try:
        S = input()
        
        for i in range(len(S)-1):
            if S[i] == S[i+1]:
                print("Bad")
                break
        else:
            print("Good")
    except:
        break
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print(N*(N-1)//2)

Fixed, accepted submission:
N = int(input())
print(N*(N+1)//2)
Problem:
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.  Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l = [int(input(i)) for i in [0]*n]
print(list(set(l)))


Fixed, accepted submission:
n = int(input())
l = [int(input()) for i in [0]*n]
print(len(list(set(l))))
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int, input().split())
m = []
for y in range(h):
  s = input()
  l = []
  for i in s:
    if i == '#':
      l.append(1)
    else:
      l.append(0)
  m.append(l)

print(m)
for y in range(h):
  s = ''
  for x in range(w):
    bomb = 0
    for i,j in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
      if y+j < 0 or x+i < 0 or x+i >= w or y+j >= h:
        continue
      if m[y+j][x+i] == 1:
        bomb += 1
    if m[y][x] == 1:
      bomb = '#'
    s += str(bomb)
  print(s)
    

Fixed, accepted submission:
h,w = map(int, input().split())
m = []
for y in range(h):
  s = input()
  l = []
  for i in s:
    if i == '#':
      l.append(1)
    else:
      l.append(0)
  m.append(l)

for y in range(h):
  s = ''
  for x in range(w):
    bomb = 0
    for i,j in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
      if y+j < 0 or x+i < 0 or x+i >= w or y+j >= h:
        continue
      if m[y+j][x+i] == 1:
        bomb += 1
    if m[y][x] == 1:
      bomb = '#'
    s += str(bomb)
  print(s)
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())
ans = min(abs(x-a),abs(x-b))
print(ans)

Fixed, accepted submission:
x,a,b = map(int,input().split())
if abs(x-a)<abs(x-b):
    print("A")
else:
    print("B")
Problem:
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?

Incorrect submission (verdict: Wrong Answer):
N = input()
num=0

for i in range(len(N)):
    if N[i] ==2:
        num += 1
print(num)

Fixed, accepted submission:
N = input().strip()
num=0

for i in range(len(N)):
    if N[i] == '2':
        num += 1
        
print(num)
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

Incorrect submission (verdict: Wrong Answer):
1000000000000


Fixed, accepted submission:
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return sorted(divisors,reverse=True)

N = int(input())
div = make_divisors(N)
ans = [(a - 1) for a in div if a > 1 and N % (a - 1) == N // (a - 1)]
print(sum(ans))
Problem:
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(lambda x:int(x)**0.5,input().split())
print('YNeos'[a+b<c::2])

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

if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:
  print("No")
Problem:
販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):
Sum, Ave, Cou = 0, 0, 0
while True :
    try :
        a, b = input().split(',')
        Sum += int(a) * int(b)
        Ave += int(b)
        Cou += 1
    except : break
if Ave / Cou - Ave // Cou > 0.5 : print(Sum, Ave // Cou+1)
else : print(Sum,Ave//Cou)

Fixed, accepted submission:
Sum, Ave, Cou = 0, 0, 0
while True :
    try :
        a, b = input().split(',')
        Sum += int(a) * int(b)
        Ave += int(b)
        Cou += 1
    except : break
print(Sum)
if Ave / Cou - Ave // Cou >= 0.5 : print(Ave // Cou+1)
else : print(Ave//Cou)
Problem:
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime.  You are given Q queries.  In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.

Incorrect submission (verdict: Time Limit Exceeded):
# D
prime_num = set([2])
size = int(1e5)*2+1
for i in range(3,size,2):
    for p in prime_num:
        if i%p==0: break
        else: continue
    else:
        prime_num.add(i)

cnt = [0]*(int(1e5)+2)
for p in prime_num:
    if p<=int(1e5) and (p+1)//2 in prime_num:
        cnt[p] = 1
for i in range(1, int(1e5)+2):
    cnt[i] += cnt[i-1]
    
Q = int(input())
for _ in range(Q):
    l,r = map(int, input().split())
    print(cnt[r]-cnt[l])

Fixed, accepted submission:
# D
from math import sqrt
def sieve(n:int)->list:
    
    if n<2:  return [False]*(n+1)
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(sqrt(n))+1):
        if is_prime[i]:
            for j in range(i*i, n+1, i):
                is_prime[j] = False
    
    return is_prime


N = int(1e5)
is_prime = sieve(N)
# like-2017
cnt = [0]*(N+1)
for i in range(1, N+1):
    cnt[i] += cnt[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt[i] += 1
    
import sys
Q = sys.stdin.readline()
for l,r in (map(int, line.split()) for line in sys.stdin.readlines()):
    print(cnt[r] - cnt[l-1])
Problem:
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.  How many squares i satisfy both of the following conditions?    * The assigned number, i, is odd.   * The written integer is odd.

Incorrect submission (verdict: Wrong Answer):
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in a:
        if i+1 % 2 == 0 and a[i] % 2 == 0:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Fixed, accepted submission:
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if (i+1) % 2 == 1 and a[i] % 2 == 1:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
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):
N = int("".join(map(str,input().split())))
print(("No","Yes")[N % 4 == 0])

Fixed, accepted submission:
N = int("".join(map(str,input().split())))
print(("NO","YES")[N % 4 == 0])
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
k=int(input())
ans=1
for i in range(n):
  ans=max(ans+k,ans*2)
print(ans)
  

Fixed, accepted submission:
n=int(input())
k=int(input())
ans=1
for i in range(n):
  ans=min(ans+k,ans*2)
print(ans)
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())
for _ in range(q):
    R = list(map(int, input().split()))
    a, b = min(R), max(R)
    if b - a <= 1:
        res = 2 * (a-1)

    else:
        c = int((a*b)**0.5)
        if c ** 2 == a * b:
            c -= 1
        if c * (c+1) < a * b:
            res = 2 * (c-1) + 1
        else:
            res = 2 * (c-1) - 1
    print(res)

Fixed, accepted submission:
q = int(input())
for _ in range(q):
    R = list(map(int, input().split()))
    a, b = min(R), max(R)
    if b - a <= 1:
        res = 2 * (a-1)

    else:
        c = int((a*b)**0.5)
        if c ** 2 == a * b:
            c -= 1
        if c * (c+1) < a * b:
            res = 2 * (c-1) + 1
        else:
            res = 2 * (c-1)
    print(res)
Problem:
Joisino the magical girl has decided to turn every single digit that exists on this world into 1.  Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).  She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).  You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:    * If A_{i,j}≠-1, the square contains a digit A_{i,j}.   * If A_{i,j}=-1, the square does not contain a digit.  Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.

Incorrect submission (verdict: Wrong Answer):
H,W = map(int, input().split())
c, A = [], []
num = [0] * 10
for _ in range(10):
    ci = list(map(int, input().split()))
    ci[0], ci[1] = ci[1], ci[0]
    c.append(ci)
for _ in range(H):
    A += list(map(int, input().split()))
for i in [0] + list(range(2, 10)):
    num[i] += A.count(i)

c = [[0]] + c[:1] + c[2:]
num[0], num[1] = num[1], num[0]

dp = [[10000 for i in range(10)] for j in range(10)]
dp[1][1] = c[1][0]
for i in range(2, 10):
    dp[i][i] = min(c[i][0], min(c[i][j] + dp[i-1][j] for j in range(i-1, 0, -1)))
    for j in range(1, i):
        dp[i][j] = min(dp[i-1][j], c[j][i] + dp[i][i])

print(sum(dp[9][i] * num[i] for i in range(1,10)))

Fixed, accepted submission:
H,W = map(int, input().split())
c, A = [], []
num = [0] * 10
for _ in range(10):
    ci = list(map(int, input().split()))
    ci[0], ci[1] = ci[1], ci[0]
    c.append(ci)
for _ in range(H):
    A += list(map(int, input().split()))
for i in [0] + list(range(2, 10)):
    num[i] += A.count(i)

c = [[0]] + c[:1] + c[2:]
num[0], num[1] = num[1], num[0]

dp = [[c[i][0] for i in range(10)]] + [[10000 for i in range(10)] for j in range(9)]
for i in range(1, 10):
    for j in range(1, 10):
            dp[i][j] = min(c[j][k] + dp[i-1][k] for k in range(1, 10))

print(sum(dp[9][i] * num[i] for i in range(1,10)))
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

Incorrect submission (verdict: Wrong Answer):
keys = input()
r = ''
for k in keys:
  if k == 0:
    r += '0'
  elif k == '1':
    r += '1'
  elif k == 'b':
    r = r[:len(r)-1]
print(r)

Fixed, accepted submission:
keys = input()
r = ""
for k in keys:
  if k == "0":
    r += "0"
  elif k == "1":
    r += "1"
  elif k == "B":
    r = r[:len(r)-1]
print(r)
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())
a=n*(n+1)/2
print(a)

Fixed, accepted submission:
n=int(input())
a=int(n*(n+1)/2)
print(a)
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())
if((a*b)%2 == 0):
    print('Odd')
else:
    print('Even')


Fixed, accepted submission:
a,b = map(int, input().split())
if((a*b)%2 == 0):
    print('Even')
else:
    print('Odd')
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N=input()
N=int(N)

flag=True

tk=0

xk,yk=0,0

for i in range(N):
    txy=input()
    
    t,x,y=txy.split()
    t=int(t)
    x=int(x)
    y=int(y)
    
    if abs(t-tk) >= abs(x-xk)+abs(y-yk):
        
        if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
            print('Yes')
            flag=True
        else:
            print('No')
            flag=False
    else:
        print('No')
        flag=False
    
    tk=tk+t
    xk=xk+x
    yk=yk+y
    
    if not flag:
        break


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

flag=True

tk=0

xk=0
yk=0

for i in range(N):
    txy=input()
    
    t,x,y=txy.split()
    t=int(t)
    x=int(x)
    y=int(y)
    
    if abs(t-tk) >= abs(x-xk)+abs(y-yk):
        
        if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
            flag=True
        else:
            flag=False
    else:
        flag=False
    
    tk=t
    xk=x
    yk=y
    
    if not flag:
        print('No')
        break

if flag:
    print('Yes')
Problem:
Snuke built an online judge to hold a programming contest.  When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)  Determine whether the judge can return the string `AC` as the verdict to a program.

Incorrect submission (verdict: Wrong Answer):
s=input()
flag=False
for i in range(len(s)-1):
  if s[i:i+1]=='AC':
    flag=True
if flag:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
s=input()
flag=False
for i in range(len(s)-1):
  if s[i:i+2]=='AC':
    flag=True
if flag:
  print('Yes')
else:
  print('No')