Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
 
K = int(input())
 
import math
answer = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            gcd = math.gcd(math.gcd(i, j), k)
            answer += gcd
 
print(answer)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(input())

import math
answer = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            gcd = math.gcd(math.gcd(i, j), k)
            answer += gcd

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(str(input()))

# R,G,B ひとつずつ
# 距離が等間隔でない

R_pos = []
G_pos = []
B_pos = []
for i in range(N):
    if S[i] == "R":
        R_pos.append(i)
    elif S[i] == "G":
        G_pos.append(i)
    elif S[i] == "B":
        B_pos.append(i)

answer = 0
for r in R_pos:
    for g in G_pos:
        for b in B_pos:
            dis1 = abs(r-g)
            dis2 = abs(g-b)
            dis3 = abs(b-r)
            if dis1 != dis2 and dis2 != dis3 and dis3 != dis1:
                answer += 1
print(answer)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(str(input()))

# R,G,B ひとつずつ
# 距離が等間隔でない

R_pos = []
G_pos = []
B_pos = []
for i in range(N):
    if S[i] == "R":
        R_pos.append(i)
    elif S[i] == "G":
        G_pos.append(i)
    elif S[i] == "B":
        B_pos.append(i)

answer = len(R_pos) * len(G_pos) * len(B_pos)
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            answer -= 1

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(str(input()))

# R,G,B ひとつずつ
# 距離が等間隔でない

R_pos = []
G_pos = []
B_pos = []
for i in range(N):
    if S[i] == "R":
        R_pos.append(i)
    elif S[i] == "G":
        G_pos.append(i)
    elif S[i] == "B":
        B_pos.append(i)

answer = 0
for r in R_pos:
    for g in G_pos:
        for b in B_pos:
            dis1 = abs(r-g)
            dis2 = abs(g-b)
            dis3 = abs(b-r)
            if dis1 != dis2 and dis2 != dis3 and dis3 != dis1:
                answer += 1
print(answer)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = list(str(input()))

# R,G,B ひとつずつ
# 距離が等間隔でない

R_pos = []
G_pos = []
B_pos = []
for i in range(N):
    if S[i] == "R":
        R_pos.append(i)
    elif S[i] == "G":
        G_pos.append(i)
    elif S[i] == "B":
        B_pos.append(i)

answer = len(R_pos) * len(G_pos) * len(B_pos)
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            answer -= 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(read().rstrip())

def F(S):
    left = None
    for i, s in enumerate(list(S)):
        if left is None:
            left = s
            continue

        x = abs(int(left) - int(s))
        if x > 1:
            # if left < s:
            #     return False, i
            # return False, None
            return False, i
    return True, None

def ceil(num, keta):
    list_i = list(str(num))
    if int(list_i[keta-1]) < int(list_i[keta]):
        left = str(int("".join(list_i[:keta])) + 1)
    else:
        left = "".join(list_i[:keta])
    right = "0" * (len(list_i) - 1 - keta)
    right_first = str(int(left[-1]) - 1)
    n = left + right_first + right
    # print("{}->{} left: {} right: {}".format(num, n, left, right))
    return int(n)

runrun_number = 0
i = 0
while True:
    i += 1
    is_runrun, keta = F(str(i))
    if is_runrun:
        # print(i)
        runrun_number += 1
        if runrun_number == K:
            answer = i
            break
        continue
    i = ceil(i, keta) - 1
print(answer)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(read().rstrip())

runrun = [None for _ in range(1, 20)] # 20は十分な値
runrun[1] = (1, 2, 3, 4, 5, 6, 7, 8, 9)

def gen_runrun(keta):
    for x in runrun[keta-1]:
        r = x % 10

        if r > 0:
            yield x * 10 + r - 1
        yield x * 10 + r
        if r < 9: 
            yield x * 10 + r + 1

# 10桁以下のrunrun数の列挙
for keta in range(2, 11):
    runrun[keta] = tuple(gen_runrun(keta))

for keta in range(1, 11):
    if K < len(runrun[keta]):
        answer = runrun[keta][K-1]
        break
    K -= len(runrun[keta])

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
# 日立コン
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, readline().split())

Alist = list(map(int, readline().split()))
Blist = list(map(int, readline().split()))

answer = 10 ** 7
for a in Alist:
    for b in Blist:
        tmp = a + b
        if tmp < answer:
            answer = tmp

for _ in range(0, M):
    x, y, c = map(int, readline().split())
    tmp = Alist[x-1] + Blist[y-1] - c
    if tmp < answer:
        answer = tmp
if answer > 0:
    print(answer)
else:
    print(0)

Fixed submission:
# 日立コン
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, readline().split())

Alist = list(map(int, readline().split()))
Blist = list(map(int, readline().split()))

min_a = min(Alist)
min_b = min(Blist)
answer = min_a + min_b

for _ in range(0, M):
    x, y, c = map(int, readline().split())
    tmp = Alist[x-1] + Blist[y-1] - c
    answer = min(answer, tmp)

if answer > 0:
    print(answer)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
# abc 158
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = readline().strip().decode('utf-8')
Q = int(readline())

is_reversed = False

answer = S
for _ in range(Q):
    l = readline().decode('utf-8').split()
    if len(l) == 1:
        is_reversed = not is_reversed
    else:
        _, F, C = map(str, l)
        if F == "1":
            if is_reversed:
                answer = answer + C
            else:
                answer = C + answer
        else:
            if is_reversed:
                answer = C + answer
            else:
                answer = answer + C

if is_reversed:
    answer = "".join(list(reversed(answer)))
print(answer)

Fixed submission:
# abc 158
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = readline().strip().decode('utf-8')
Q = int(readline())

is_reversed = False

import collections
answer = collections.deque(S)
for _ in range(Q):
    l = readline().decode('utf-8').split()
    if len(l) == 1:
        is_reversed = not is_reversed
    else:
        _, F, C = map(str, l)
        if F == "1":
            if is_reversed:
                answer.append(C)
            else:
                answer.appendleft(C)
        else:
            if is_reversed:
                answer.appendleft(C)
            else:
                answer.append(C)

if is_reversed:
    answer.reverse()
print("".join(answer))
Buggy python submission (verdict: Runtime Error):
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

N = int(readline().rstrip())
al = list(map(int, readline().split()))

# 最大公約数
from fractions import gcd

# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

lcm_ = 0
for a in al:
    if lcm_ == 0:
        lcm_ = a
        continue
    lcm_ = lcm(a, lcm_)

prime = 10 ** 9 + 7
bl = []
for a in al:
    b = int(lcm_ / a)
    bl.append(b)

answer = sum(bl) % prime
print(answer)

Fixed submission:
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N = int(readline().strip())
A = list(map(int, readline().split()))

from fractions import gcd
def lcm(a, b):
    return (a * b) // gcd(a, b)

lcm_ = 1  # 倍数を出したいので初期値は1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ * pow(A[i], MOD-2, MOD)

print(ans % MOD)

Buggy python submission (verdict: Runtime Error):
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

N = int(readline().rstrip())
al = list(map(int, readline().split()))

# 最大公約数
from fractions import gcd

# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

lcm_ = 0
for a in al:
    if lcm_ == 0:
        lcm_ = a
        continue
    lcm_ = lcm(a, lcm_)

prime = 10 ** 9 + 7
bl = []
for a in al:
    b = int(lcm_ / a)
    bl.append(b)

answer = sum(bl)
print(answer)

Fixed submission:
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N = int(readline().strip())
A = list(map(int, readline().split()))

from fractions import gcd
def lcm(a, b):
    return (a * b) // gcd(a, b)

lcm_ = 1  # 倍数を出したいので初期値は1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ * pow(A[i], MOD-2, MOD)

print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def coprime(a, b):
    return gcd(a, b) == 1

mini = min(A, B)
cmlist = []
for i in range(1, mini+1):
  if A % i == 0 and B % i == 0:
    can_append = True
    for cm in cmlist:
      if not coprime(cm, i):
        can_append = False
        break
    if can_append:
	    cmlist.append(i)

print(len(cmlist))

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

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def coprime(a, b):
    return gcd(a, b) == 1
 
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

cmlist = sorted(list(set(divisor(A)) & set(divisor(B))))
res = []
for cm1 in cmlist:
  can_append = True
  for cm2 in res:
    if not coprime(cm1, cm2):
      can_append = False
      continue
  if can_append:
    res.append(cm1)
print(len(res))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdln.readline
s = input()

if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
elif s == "Rainy":
  print("Sunny")

Fixed submission:
from sys import stdin
s = stdin.readline().rstrip()

if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
elif s == "Rainy":
  print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

class Node():
  def __init__(self, num):
    self.num = num
    self.count = 0
    self.nexts = []
    self.checked = False
  def add_nexts(self, node):
    self.nexts.append(node)
  def counter(self, n):
    self.count += n
  def __repr__(self):
    return str(self.num)
  def __str__(self):
    return str(self.num)

N, Q = list(map(int, input().split()))
node_list = [Node(i) for i in range(0, N+1)]
for i in range(0, N-1): 
  a, b = list(map(int, input().split()))
  node_list[a].add_nexts(node_list[b])
  node_list[b].add_nexts(node_list[a])
for i in range(0, Q):
  p, x = list(map(int, input().split()))
  node_list[p].counter(x)
q = collections.deque()
q.append(node_list[1])
while q:
  node = q.pop()
  node.checked = True
  for nexts_node in node.nexts:
    if nexts_node.checked:
      continue
    nexts_node.counter(node.count)
    q.append(nexts_node)
print(*[node.count for node in node_list[1:]])
               

Fixed submission:
import collections

n,q=map(int, input().split())
cnt=[0]*(n+1) # 添字で指定しやすいように一つ多い １以降を使用する
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int, input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int, input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked_=[0]*(n+1)
while q:
  v=q.pop()
  checked_[v]=1
  for u in g[v]:
    if checked_[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])

Buggy python submission (verdict: Runtime Error):
class Node():
  def __init__(self, num):
    self.num = num
    self.count = 0
    self.childs = []
  def add_child(self, node):
    self.childs.append(node)
  def counter(self, n):
    self.count += n
    for node in self.childs:
      node.counter(n)
  def __repr__(self):
    return str(self.num)
  def __str__(self):
    return str(self.num)

N, Q = list(map(int, input().split()))
node_list = [Node(i) for i in range(1, N+1)]
for i in range(0, N-1):
  a, b = list(map(int, input().split()))
  node_list[a-1].add_child(node_list[b-1])
for i in range(0, Q):
  p, x = list(map(int, input().split()))
  node_list[p-1].counter(x)
res=""
for node in node_list:
  res += "{} ".format(node.count)
print(res)

Fixed submission:
import collections

n,q=map(int, input().split())
cnt=[0]*(n+1) # 添字で指定しやすいように一つ多い １以降を使用する
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int, input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int, input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked_=[0]*(n+1)
while q:
  v=q.pop()
  checked_[v]=1
  for u in g[v]:
    if checked_[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
l=[]
i=0
for _ in range(0, n):
  s=input()
  c=collections.Counter(s)
  i+=l.count(c)
  l.append(c)
print(i)

Fixed submission:
import collections
n=int(input())
l=[]
for _ in range(0, n):
  s=list(input())
  s.sort()
  l.append("".join(s))
cc=collections.Counter(l)
i=0
for k, v in cc.items():
  if v >= 2:
    i+=(v*(v-1))/2
print(int(i))
Buggy python submission (verdict: Runtime Error):
input()
hl=map(int, input().split())
hl.reverse()
prev=-1
for h in hl:
  if prev == -1:
    prev == h
    continue
  if h <= prev - 1:
    prev == h
    continue
  if h == prev + 1:
    prev = (h - 1)
    continue
  print("No")
  quit()
print("Yes")

Fixed submission:
input()
hl=list(map(int, input().split()))
hl.reverse()
prev=10**9
for h in hl:
  if h <= prev:
    prev = h
    continue
  if h == prev + 1:
    prev = (h - 1)
    continue
  print("No")
  quit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)
masu= [1] * N

old = [1] * N
loop = 0
while True:
    new = [0] * N
    for i, children in enumerate(masu):
        if S[i] == "L":
            next_i = i - 1
        else:
            next_i = i + 1
        new[next_i] += children
    if new == old:
        if loop % 2 == 0:
            last = masu 
        else:
            last = new
        break
    loop += 1
    old = masu
    masu = new

# これ知らなかった
print(*last)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)

masu = []
char = ""
for i, s in enumerate(S):
    if char == "":
        char += s
        continue
    if char[-1] == s:
        char += s
        continue
    if char[-1] != s:
        masu.append(len(char))
        char = s
        continue
if char:
    masu.append(len(char))

import math

ans = []
for l, r in zip(*[iter(masu)]*2):
    n = len(ans)
    pos_l = n + l
    pos_r = pos_l + 1
    l_num = math.ceil(l / 2) + r // 2
    r_num = l // 2 + math.ceil(r / 2)
    for _ in range(l-1):
        ans.append(0)
    ans.append(l_num)
    ans.append(r_num)
    for _ in range(r-1):
        ans.append(0)

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import copy

S = list(input())
N = len(S)
masu= [1] * N

old = [1] * N
loop = 0
while True:
    new = [0] * N
    for i, children in enumerate(masu):
        if S[i] == "L":
            next_i = i - 1
        else:
            next_i = i + 1
        new[next_i] += children
    if new == old:
        if loop % 2 == 0:
            last = masu 
        else:
            last = new
        break
    loop += 1
    old = copy.copy(masu)
    masu = copy.copy(new)

# これ知らなかった
print(*last)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)

masu = []
char = ""
for i, s in enumerate(S):
    if char == "":
        char += s
        continue
    if char[-1] == s:
        char += s
        continue
    if char[-1] != s:
        masu.append(len(char))
        char = s
        continue
if char:
    masu.append(len(char))

import math

ans = []
for l, r in zip(*[iter(masu)]*2):
    n = len(ans)
    pos_l = n + l
    pos_r = pos_l + 1
    l_num = math.ceil(l / 2) + r // 2
    r_num = l // 2 + math.ceil(r / 2)
    for _ in range(l-1):
        ans.append(0)
    ans.append(l_num)
    ans.append(r_num)
    for _ in range(r-1):
        ans.append(0)

print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
al = [int(input()) for _ in range(0, N)]
for a in al:
  el = filter(lambda x: x != a, al)
  if len(list(el)):
    print(max(el))
  else:
    print(a)

Fixed submission:
N = int(input())
al = [int(input()) for _ in range(0, N)]

max_a = max(al)  
tmp_al = al[:]
tmp_al.remove(max_a)
snd_a = max(tmp_al)
  
for a in al:
  if a == max_a:
    print(snd_a)
  else:
    print(max_a)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, K = map(int, input().split())
l = list(range(A, B+1))
# if K >= len(l):
#     print(*l, sep="\n")
#     quit()
# ans = list(set(l[:K] + l[-K:]))
# ans.sort()
# 
# print(*ans, sep="\n")


Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
  ans.append(i)
for i in range(max(b-k+1,a),b+1):
  ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
  print(i)

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, K = map(int, input().split())
l = list(range(A, B+1))
if K >= len(l):
    print(*l, sep="\n")
    quit()
# ans = list(set(l[:K] + l[-K:]))
# ans.sort()
# 
# print(*ans, sep="\n")


Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
  ans.append(i)
for i in range(max(b-k+1,a),b+1):
  ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
  print(i)

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, K = map(int, input().split())
l = list(range(A, B+1))
if K >= len(l):
    print(*l, sep="\n")
    quit()
ans = list(set(l[:K] + l[-K:]))
ans.sort()

print(*ans, sep="\n")


Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
  ans.append(i)
for i in range(max(b-k+1,a),b+1):
  ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
  print(i)

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, K = map(int, input().split())
l = list(range(A, B+1))
ans = list(set(l[:K] + l[-K:]))
ans.sort()

print(*ans, sep="\n")


Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
  ans.append(i)
for i in range(max(b-k+1,a),b+1):
  ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
  print(i)
Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))


ans = INF
for a in A:
    cnt = 0
    while True:
        q, mod = divmod(a, 2)
        if mod != 0:
            break
        cnt += 1
        a = q
    ans = min(ans, cnt)
print(ants)


Fixed submission:
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))


ans = INF
for a in A:
    cnt = 0
    while True:
        q, mod = divmod(a, 2)
        if mod != 0:
            break
        cnt += 1
        a = q
    ans = min(ans, cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N = int(readline().rstrip())

power = 1
for i in range(1, N+1):
    power = power * i

answer = power % MOD
print(answer)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N = int(readline().rstrip())

answer = 1
for i in range(1, N+1):
    answer = answer * i % MOD

answer = answer % MOD
print(answer)