TnT/CodeNet4Repair huggingface dataset:
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import bisect

N = int(input())
INF = 10**10
nums = list(map(int, input().split()))
nums.sort()
n_max = nums[-1]
n_half = n_max//2
nums = [-INF] + nums + [INF]
pos = bisect.bisect_left(nums, n_half)
if abs(n_half-nums[pos]) >= abs(n_half-nums[pos-1]):
  print(n_max, nums[pos-1])
else:
  print(n_max, nums[pos])



Fixed, accepted submission:
import bisect

N = int(input())
INF = 10**10
nums = list(map(int, input().split()))
nums.sort()
n_max = nums[-1]
n_half = n_max//2
nums = [-INF] + nums + [INF]
pos = bisect.bisect_left(nums, n_half)
if abs(n_half-abs(n_max-nums[pos])) >= abs(n_half-abs(n_max-nums[pos-1])):
  print(n_max, nums[pos-1])
else:
  print(n_max, nums[pos])
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
n = input()
a,b,c,d = map(int,list(n))
op =[1,1,1]
v = ["?","+","-"]
ans = 0
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            op[0] = i
            op[1] = j
            op[2] = k
            if a+b*op[0]+c*op[1]+d*op[2] == 7:
                print("{}{}{}{}{}{}{}==7".format(a,v[op[0]],b,v[op[1]],c,v[op[2]],d))
                break


Fixed, accepted submission:
n = input()
a,b,c,d = map(int,list(n))
op =[1,1,1]
v = ["?","+","-"]
ans = 0
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            op[0] = i
            op[1] = j
            op[2] = k
            if a+b*op[0]+c*op[1]+d*op[2] == 7:
                print("{}{}{}{}{}{}{}=7".format(a,v[op[0]],b,v[op[1]],c,v[op[2]],d))
                break
        else:
            continue
        break
    else:continue
    break
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: Time Limit Exceeded):
n=int(input())
ans=1
while ans<n:
  ans*=2
  if ans>n:
    ans//=2
print(ans)

Fixed, accepted submission:
n=int(input())
ans=1
while ans<n:
  ans*=2
  if ans>n:
    ans//=2
    break
print(ans)
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( int(n*(n-1)/2))

Fixed, accepted submission:
n = int(input())
print( int(n*(n+1)/2))
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
s = int(input().replace(' ', ''))
print('Yes') if int(s ** 0.5 ** 2) == s else print('No')

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

L = []
for i in range(318):
	L.append(i**2)

n = a * 10 ** len(str(b))+ b
if n in L:
	print('Yes')
else:
	print('No')
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

Incorrect submission (verdict: Wrong Answer):
w = 'hthtn'


w = list(w)
w.sort()

isBeautiful = True
length = len(w)
for i in range(0, length, 2):
  if w[i] is not w[i + 1]:
    isBeautiful = False
    break

print('Yes' if isBeautiful else 'No')

Fixed, accepted submission:


def isBeautiful(w):
    w = list(w)
    length = len(w)
    
    if length % 2 != 0:
        return False
    
    w.sort()
    for i in range(0, length, 2):
      if w[i] != w[i + 1]:
        return False
    
    return True

w = input().strip()
 
print('Yes' if isBeautiful(w) else 'No')
Problem:
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.    * `0 u v`: Add an edge (u, v).   * `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.

Incorrect submission (verdict: Wrong Answer):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)


class UnionFind():
    def __init__(self, n):
        self.par = [-1] * n

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])  # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]:  
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, q = map(int, input().split())
uf = UnionFind(n)
for _ in range(q):
    t, u, v = map(int, input().split())
    u -= 1
    v -= 1
    if t == 0:
        # add
        uf.unite(u, v)
    else:
        print(1 if uf.same(u, v) else 0)


Fixed, accepted submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)


class UnionFind():
    def __init__(self, n):
        self.par = [-1] * n

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])  # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]:  
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, q = map(int, input().split())
uf = UnionFind(n)
for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        # add
        uf.unite(u, v)
    else:
        print(1 if uf.same(u, v) else 0)
Problem:
ある日、殿様は一人の大工に、「台風や地震が来たときに町人が避難できる、頑丈で大きな建物を造りなさい。」と命じました。しかし、その頑丈で大きな建物を完成させるには、大きな太い柱が必要です。町にそんな大きな柱はありません。そこで、大工は遠くの山里まで大きな柱を調達しに行くことになりました（大工は町から里山に行って、町に戻ってくる必要があります）。  大工の褒美は、殿様から受け取ったお金から柱の代金と交通費を差し引いた余りです。下の地図のように、山里に行くには、いろいろな町を通るたくさんの街道があり、2つの町をつなぐ街道はそれぞれ交通費が違います。大工の褒美を最大にするにはどのように街道をたどり調達すればよいでしょうか。最大となる大工の褒美を出力するプログラムを作成してください。ただし、町の数を n とすれば、各町は 1 から n までの整数で識別されます。2 つの町を直接つなぐ街道は 2 本以上ありません。    ※ 矢印上の数字は、その方向に行くための交通費を示します。

Incorrect submission (verdict: Wrong Answer):
# AOJ 0117 A reward for a Carpenter
# Python3 2018.6.21 bal4u

INF = 0x7fffffff

import heapq
def dijkstra(V, to, start, goal):
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while len(Q):
		t, s = heapq.heappop(Q)
		if s == goal: break
		if dist[s] <= t: continue
		for i in to[s]:
			e, cost = i
			nt = t + cost
			if dist[e] > nt:
				dist[e] = nt
				heapq.heappush(Q, (nt, e))
	return dist[goal]

n = int(input())+1
to = [[] for i in range(n)]
for i in range(int(input())):
	a, b, c, d = list(map(int, input().split(',')))
	to[a].append((b, c))
	to[b].append((a, d))
s, g, V, P = list(map(int, input().split(',')))
if s == g: print(V-P)
else: print(V-P - dijkstra(n, to, s, g) - dijkstra(n, to, g, s))


Fixed, accepted submission:
# AOJ 0117 A reward for a Carpenter
# Python3 2018.6.21 bal4u

INF = 0x7fffffff

import heapq
def dijkstra(V, to, start, goal):
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while len(Q):
		t, s = heapq.heappop(Q)
		if s == goal: break
		if dist[s] < t: continue
		for i in to[s]:
			e, cost = i
			nt = t + cost
			if dist[e] > nt:
				dist[e] = nt
				heapq.heappush(Q, (nt, e))
	return dist[goal]

n = int(input())+1
to = [[] for i in range(n)]
for i in range(int(input())):
	a, b, c, d = list(map(int, input().split(',')))
	to[a].append((b, c))
	to[b].append((a, d))
s, g, V, P = list(map(int, input().split(',')))
if s == g: print(V-P)
else: print(V-P - dijkstra(n, to, s, g) - dijkstra(n, to, g, s))
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 = list(input().split())
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ','.join(T)
  if mojiretu == ["maerd"] or mojiretu == ["remaerd"] or mojiretu == ["esare"] or mojiretu == ["resare"]:
    T =[]
if len(T) == 0:
  print("YES")
else:
  print("NO")


Fixed, accepted submission:
S = input()
S = list(S)
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ''.join(T)
  m = len(mojiretu)
  if mojiretu == "maerd" or mojiretu == "remaerd" or mojiretu == "esare" or mojiretu == "resare":
    T =[]
  elif m==8:
      break
N = len(T)
if N == 0:
  print("YES")
else:
  print("NO")
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):
import sys
len(set(sys.stdin.read().split("\n")[1:-1]))

Fixed, accepted submission:
import sys
print(len(set(sys.stdin.read().split("\n")[1:-1])))
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())
A = [int(x) for x in input().split()]

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
    print(" ".join([str(x) for x in A]))

Fixed, accepted submission:
n = int(input())
A = [int(x) for x in input().split()]
print(" ".join([str(x) for x in A]))

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
    print(" ".join([str(x) for x in A]))
Problem:
M-kun has the following three cards:    * A red card with the integer A.   * A green card with the integer B.   * A blue card with the integer C.  He is a genius magician who can do the following operation at most K times:    * Choose one of the three cards and multiply the written integer by 2.  His magic is successful if both of the following conditions are satisfied after the operations:    * The integer on the green card is **strictly** greater than the integer on the red card.   * The integer on the blue card is **strictly** greater than the integer on the green card.  Determine whether the magic can be successful.

Incorrect submission (verdict: Wrong Answer):
A,B,C = map(int,input().split())
N = int(input())
stack = [(A,B,C,N)]
flag = False
while stack:
  a,b,c,n = stack.pop()
  if a<b and B<c:
    fag = True
    break
  if n>0:
    stack.append((a*2,b,c,n-1))
    stack.append((a,b*2,c,n-1))
    stack.append((a,b,c*2,n-1))
print('Yes') if flag else print('No')

Fixed, accepted submission:
A,B,C = map(int,input().split())
N = int(input())
stack = [(A,B,C,N)]
flag = False
while stack:
  a,b,c,n = stack.pop()
  if a<b and b<c:
    flag = True
    break
  if n>0:
    stack.append((a*2,b,c,n-1))
    stack.append((a,b*2,c,n-1))
    stack.append((a,b,c*2,n-1))
print('Yes') if flag else print('No')
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
num_li = list(map(int, input().split()))
count = 0
loop = True
while True:
    for i in num_li:
        if i%2 == 1:
            loop = False
            break
    if loop == False:
        break
    else:
        count += 1
print(count)

Fixed, accepted submission:
length = int(input())
num_li = list(map(int, input().split()))
count = 0
loop = True
while loop == True:
    for i in range(length):
        if num_li[i]%2 == 1:
            loop = False
            break
        else:
            num_li[i] /= 2
    if loop == True:
        count += 1
print(count)
Problem:
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.  You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.  However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.  For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.

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

print(a)


t = 0
for i in range(1,n + 2):
  t += abs(a[i] - a[i-1])

for i in range(1,n + 1):
  print(t - abs(a[i] - a[i -1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))

Fixed, accepted submission:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.insert(n + 1,0)

t = 0
for i in range(1,n + 2):
  t += abs(a[i] - a[i-1])

for i in range(1,n + 1):
  print(t - abs(a[i] - a[i -1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

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

print(words)

for i in range(len(words)-1):
	if words[i][-1] == words[i+1][0]:
		ans = 'YES'
	else:
		ans = 'NO'
		break
		
print(ans)


Fixed, accepted submission:
words = list(input().split())


for i in range(len(words)-1):
	if words[i][-1] == words[i+1][0]:
		ans = 'YES'
	else:
		ans = 'NO'
		break
		
print(ans)
Problem:
We held two competitions: Coding Contest and Robot Maneuver.  In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.  DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.

Incorrect submission (verdict: Wrong Answer):
if __name__ == '__main__':
  x, y = map(int, input().split())
  priceX = priceY = 0
  
  print(y)
  if(x == 1):
    priceX = 300000
  elif(x == 2):
    priceX = 200000
  elif(x == 3):
    priceX = 100000
  else:
  	priceX = 0

  if(y == 1):
    priceY = 300000
  elif(y == 2):
  	priceY = 200000
  elif(y == 3):
   	priceY = 100000
  else:
   	priceY = 0

  print(priceX)
  print(priceY)
  if(x == 1 and y == 1):
   	print(400000 + priceX + priceY)
  else:
   	print(priceX + priceY)

Fixed, accepted submission:
if __name__ == '__main__':
  x, y = map(int, input().split())
  priceX = priceY = 0
  if(x >= 1 and x <= 205 and y >= 1 and y<= 205):
    if(x == 1):
      priceX = 300000
    elif(x == 2):
      priceX = 200000
    elif(x == 3):
      priceX = 100000
    else:
  	  priceX = 0

    if(y == 1):
      priceY = 300000
    elif(y == 2):
  	  priceY = 200000
    elif(y == 3):
   	  priceY = 100000
    else:
   	  priceY = 0
    
    if(x == 1 and y == 1):
   	  print(400000 + priceX + priceY)
    else:
   	  print(priceX + priceY)
Problem:
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.  Find the number of chocolate pieces prepared at the beginning of the camp.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

choco = 0

for i in range(N):
  for j in range(N):
    a = i*A[j] + 1
    if a < D:
      choco += 1
    
print(choco+1)

Fixed, accepted submission:
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

choco = X

for i in range(N):
  j = 0
  a = 0
  while a <= D:
    a = j*A[i] + 1
    if a <= D:
      choco += 1
    j += 1
    
print(choco)
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):
x = input()
x.replace('', 'hi')
if len(x) > 0:
	print('No')
else:
	print('Yes')

Fixed, accepted submission:
if len(input().replace('hi', '')) > 0:
	print('No')
else:
	print('Yes')
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: Wrong Answer):
def isPrime(x):
    if x < 2:
        return False
    if x % 2 == 0:
        return False
    cur = 3
    while True:
        if cur * cur > x:
            break
        if x % cur == 0:
            return False
        cur += 2
    return True


Q = int(input())
num = [0] * 100010
for i in range(3,100001,2):
    if isPrime(i) and isPrime((i+1)//2):
        num[i] += 1
for i in range(0,100001):
    num[i+1] += num[i]


for _ in range(Q):
    l,r = map(int, input().split())
    print(num[r] - num[l-1])


Fixed, accepted submission:
def isPrime(x):
    if x < 2:
        return False
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    cur = 3
    while True:
        if cur * cur > x:
            break
        if x % cur == 0:
            return False
        cur += 2
    return True


Q = int(input())
num = [0] * 100010
for i in range(3,100001,2):
    if isPrime(i) and isPrime((i+1)//2):
        num[i] += 1
for i in range(0,100001):
    num[i+1] += num[i]


for _ in range(Q):
    l,r = map(int, input().split())
    print(num[r] - num[l-1])
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
h,w=map(int, input().split())
print("*"*w+"**")
for i in range(0, h):
    print("*"+input()+"*")
print("*"*w+"**")
    

Fixed, accepted submission:
h,w=map(int, input().split())
ar=[input() for _ in range(0,h)]
print("#"*w+"##")
for _ in ar:
    print("#"+_+"#")
print("#"*w+"##")
Problem:
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once.  You are given the sequence _A_ and _q_ questions where each question contains _M i_.

Incorrect submission (verdict: Wrong Answer):
def check(A, n,  mi):
    i, E, s = 0, [0 for i in range(n)], 0
    while i < n:
        if s == mi: return True
        if E[i] == 0:
            s += A[i]
            E[i] = 1
            i = 0
        else:
            E[i] = 0
            s -= A[i]
            i += 1
    return False

def ALDS1_5A():
    n, A, q = int(input()),list(map(int, input().split())), int(input())
    for m in input().split():
        if check(A, n, int(m)):
            print('Yes')
        else:
            print('no')

if __name__ == '__main__':
    ALDS1_5A()

Fixed, accepted submission:
def ALDS1_5A():
    n, A, q = int(input()), list(map(int, input().split())), int(input())
    S=[False for i in range(2001)]
    for a in A:
        for i in range(2001-a, 0, -1):
            if S[i]: S[i+a] = True
        S[a] = True
    for mi in input().split():
        if S[int(mi)]:
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    ALDS1_5A()
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):
def solve():
    a, b, k = map(int, input().split())
    ans = list()
    for i in range(a, min(a+k, b+1), 1):
        ans.append(i)
    for i in range(b, max(b-k,a), -1):
        ans.append(i)
    for i in set(ans):
        print(i)
    return 0

if __name__ == "__main__":
    solve()

Fixed, accepted submission:
def solve():
    a, b, k = map(int, input().split())
    ans = list()
    for i in range(a, min(a+k, b+1), 1):
        ans.append(i)
    for i in range(b, max(b-k,a), -1):
        ans.append(i)
    ans = list(set(ans))
    ans.sort()
    for i in ans:
        print(i)
    return 0

if __name__ == "__main__":
    solve()