Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

pos = 1
seen = [1]
while True:
	if A[pos] in seen:
		seen.append(A[pos])
		break
	seen.append(A[pos])
	pos = A[pos]

length = len(seen)

initial, loop = 0, 0
for i in range(length):
	if seen[i] == seen[-1]:
		initial = i
		loop = length - 1 - initial
		break

if k < length:
	print(seen[k])
	exit()

kk = (k - initial) % loop
print(seen[initial + kk])

Fixed submission:
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

pos = [1]

for i in range(2 * n):
	nxt = A[pos[-1]]
	pos.append(nxt)

if k < n + 1:
	print(pos[k])
	exit()

loop_end = n
loop_start = n - 1

while pos[loop_start] != pos[loop_end]:
	loop_start -= 1

period = loop_end - loop_start
k = k % period

while k < n:
	k += period

print(pos[k])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

same = 0
for i in range(1, n + 1):
	if A[i] == i:
		same += 1

k = k % (n - same)

pos = 1
for i in range(1, k + 1):
	pos = A[pos]

print(pos)

Fixed submission:
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

pos = [1]

for i in range(2 * n):
	nxt = A[pos[-1]]
	pos.append(nxt)

if k < n + 1:
	print(pos[k])
	exit()

loop_end = n
loop_start = n - 1

while pos[loop_start] != pos[loop_end]:
	loop_start -= 1

period = loop_end - loop_start
k = k % period

while k < n:
	k += period

print(pos[k])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))[::-1]

cnt = 0
for i in range(n - 1):
	k = 1
	for j in range(i + 1,n):
		if k == A[i] + A[j]:
			cnt += 1
		k += 1

print(cnt)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))[::-1]

import collections

L = [i + A[i] for i in range(n)]
R = [j - A[j] for j in range(n)]

cL = collections.Counter(L)
cR = collections.Counter(R)

cnt = 0

MAX = 200000
for x in range(MAX):
	cnt += cL[x] * cR[x]

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

s = input()
n = len(s)

T = [0] * (n + 1)

for k in range(n):
	tmp = int(s[k:])
	T[k] = tmp % 2019
    
c = Counter(T)

cnt = 0
for v in c.values():
	if v > 1:
		cnt += v * (v - 1) // 2

print(cnt)

Fixed submission:
s = input()
n = len(s)

MOD = 2019
T = [1] + [0] * 2018
d, p = 0, 1
for c in reversed(s):
	d = (d + p * int(c)) % MOD
	p = p * 10 % 2019
	T[d] += 1

print(sum(x * (x - 1) // 2 for x in T))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

dp = [0] * (n + 1)

for i in range(3, n):
	cnt = 0
	j = 0
	while i - j >= 3:
		sub = s[j:i+1]
		if int(sub) % 2019 == 0:
			cnt += 1
		j += 1
	dp[i] = dp[i - 1] + cnt

print(dp[n-1])

Fixed submission:
s = input()
n = len(s)

MOD = 2019
T = [1] + [0] * 2018
d, p = 0, 1
for c in reversed(s):
	d = (d + p * int(c)) % MOD
	p = p * 10 % 2019
	T[d] += 1

print(sum(x * (x - 1) // 2 for x in T))

Buggy python submission (verdict: Time Limit Exceeded):
s = '0' + input()
n = len(s)
cnt = 0

dp = []

for i in range(1, n-2):
	for j in range(i+3, n+1):
		tmp = int(s[i:j])
		if tmp in dp:
			cnt += 1
		elif tmp % 2019 == 0:
			dp.append(tmp)
			cnt += 1

print(cnt)

Fixed submission:
s = input()
n = len(s)

MOD = 2019
T = [1] + [0] * 2018
d, p = 0, 1
for c in reversed(s):
	d = (d + p * int(c)) % MOD
	p = p * 10 % 2019
	T[d] += 1

print(sum(x * (x - 1) // 2 for x in T))

Buggy python submission (verdict: Time Limit Exceeded):
s = '0' + input()
n = len(s)
cnt = 0

for i in range(1, n-2):
	for j in range(i+3, n+1):
		tmp = int(s[i:j])
		if tmp % 2019 == 0:
			cnt += 1

print(cnt)

Fixed submission:
s = input()
n = len(s)

MOD = 2019
T = [1] + [0] * 2018
d, p = 0, 1
for c in reversed(s):
	d = (d + p * int(c)) % MOD
	p = p * 10 % 2019
	T[d] += 1

print(sum(x * (x - 1) // 2 for x in T))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

def fac(n):
  if n == 0:
    return 1
  else:
    return n * fac(n-1)

def binom(n,k):
  if n==0:
    return 0
  else:
    return fac(n) // (fac(n-k) * fac(k))

print(binom(n,2) + binom(m,2))


Fixed submission:
n,m=map(int,input().split())

def fac(n):
  if n == 0:
    return 1
  else:
    return n * fac(n-1)

def binom(n,k):
  if n==0 or n==1:
    return 0
  else:
    return fac(n) // (fac(n-k) * fac(k))

print(binom(n,2) + binom(m,2))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

head = ''
tail = ''
flip = 0

for _ in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = query[1]
		c = query[2]
		if (f == '1' and flip == 0) or (f == '2' and flip == 1):
			head += c
		else:
			tail += c

if flip:
	head, tail = tail, head
	s = s[::-1]

print(head[::-1] + s + tail)

Fixed submission:
s = input()
q = int(input())

head = []
tail = []
flip = 0

for i in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = int(query[1]) - 1
		c = query[2]
		if (f ^ flip) == 0:
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)

Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())

head = []
tail = []
flip = 0

for i in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = query[1]
		c = query[2]
		if (f ^ flip) == 0:
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)

Fixed submission:
s = input()
q = int(input())

head = []
tail = []
flip = 0

for i in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = int(query[1]) - 1
		c = query[2]
		if (f ^ flip) == 0:
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
	query = list(map(str, input().split()))
	if query[0] == '1':
		s = s[::-1]
	elif query[0] == '2':
		if query[1] == '1':
			s = query[2] + s
		elif query[1] == '2':
			s = s + query[2]

print(s)

Fixed submission:
s = input()
q = int(input())

head = []
tail = []
flip = 0

for i in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = int(query[1]) - 1
		c = query[2]
		if (f ^ flip) == 0:
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for i in range(n)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
print(*max_k_list)

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

if a==b and b==c: print('No')
elif a==b or b==c or c==a: print('Yes')
else: print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(m):
  if a[i]%2==0:
    if a[i]%3!=0 and a[i]%5!=0:
      print('DENIED')
      exit()
print('APPROVED')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            print('DENIED')
            exit()
print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n=int(input())
s=[input() for i in range(n)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
print(*max_k_list)

Fixed submission:
from collections import Counter

n=int(input())
s=[input() for i in range(n)]

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
ans.sort()
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for i in range(n)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
print(*max_k_list)

Fixed submission:
from collections import Counter

n=int(input())
s=[input() for i in range(n)]

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
ans.sort()
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for i in range(n)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
print(*max_k_list)

Fixed submission:
from collections import Counter

n=int(input())
s=[input() for i in range(n)]

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
ans.sort()
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list((map(int,input().split())))

e = lambda p: (1+p)/2 #期待値

#期待値の配列
exp=[e(p[0])]
for i in range(1,n):
    tmp=exp[i-1]+e(p[i])
    exp.append(tmp)
    
#累積和
subsum=[]
for i in range(n-k+1):
    subsum.append(sum(p[i:k+i]))
    
#累積和の最大値のインデックス
idx = subsum.index(max(subsum))

if idx==0: print(exp[k-1])
else: print(exp[(idx-1)+k]-exp[(idx-1)])

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+p[i]
res=0
for i in range(n-k+1):
    res=max(res,s[i+k]-s[i])
print((res+k)/2)
Buggy python submission (verdict: Runtime Error):
h,n = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

if a[0]+a[1]>=h: print('Yes')
else: print('No')

Fixed submission:
h,n = map(int,input().split())
a = list(map(int,input().split()))
 
if sum(a)>=h: print('Yes')
else: print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
for _ in range(min(k,n)):
    h.pop(0)
print(sum(h))

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
# for _ in range(min(k,n)):
#     h.pop(0)
print(sum(h[min(k,n):]))
Buggy python submission (verdict: Runtime Error):
import numpy
h=int(input())
p=int(numpy.log2(h))
print(2**(p+1)-1)

Fixed submission:
import numpy
h=int(input())
p=int(numpy.log2(h))
print(2**(p+1)-1)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
Magic = [list(map(int, input().split())) for _ in range(N)]

INF = 1 << 30
dp = [INF] * (H + 1)
dp[0] = 0

for h in range(H):
	for damage, cost in Magic:
		next_index = min(h + damage, H)
		dp[next_index] = min(dp[next_index], dp[h] + cost)

print(dp[H])

Fixed submission:
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)

# dp
INF = 1 << 30
dp = [INF] * (H + 1) # dp[i]: モンスターの体力を i 減らすため消耗する魔力の最小値
dp[0] = 0
for h in range(H + 1):
	for n in range(N):
		dp[h] = min(dp[h], B[n] + dp[max(h - A[n], 0)])

print(dp[H])

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)

# dp
INF = 1 << 30
dp = [INF] * (H + 1) # dp[i]: モンスターの体力を i 減らすため消耗する魔力の最小値
dp[0] = 0
for h in range(H + 1):
	for n in range(N):
		dp[h] = min(dp[h], B[n] + dp[max(h - A[n], 0)])

print(dp[H])

Fixed submission:
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)

# dp
INF = 1 << 30
dp = [INF] * (H + 1) # dp[i]: モンスターの体力を i 減らすため消耗する魔力の最小値
dp[0] = 0
for h in range(H + 1):
	for n in range(N):
		dp[h] = min(dp[h], B[n] + dp[max(h - A[n], 0)])

print(dp[H])
Buggy python submission (verdict: Runtime Error):
cnt_1 = 0
cnt_2 = 0
for i in range(1,n+1):
    for j in range(i,n+1):
        #対象な場合
        #(1,1),(22,22),(333,333)
        if i==j and (str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]):
            cnt_1 += 1
        #異なる数字の場合
        #揃っていてもnより大きい場合はNG
        elif (str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]):
                cnt_2 += 1
print(cnt_1 + cnt_2*2)

Fixed submission:
n=int(input())
cnt=[[0]*10 for i in range(10)] #(10,10)サイズの配列
ret = 0

def hoge(m):
    #return m[-1],m[0]
    return (m%10, int(str(m)[0]))

for k in range(1,n+1):
    a,b = hoge(k)
    cnt[a][b] += 1    

for i in range(1,10):
    for j in range(1,10):
        ret += cnt[i][j] * cnt[j][i]

print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 0
for i in range(len(S)):
  if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C':
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
cnt = 0
for i in range(len(S)-2):
  if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C':
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())

import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
  
print(lcm(a,b))

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

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
  
print(lcm(a,b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2) ** 0.5

ans *= 2/N
print(ans)

Fixed submission:
n = int(input())
lis = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2) ** 0.5

ans *= 2/n

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n=int(input())
lis=[input().split() for i in range(n)]

res=[]
for i in range(n):
    for j in range(i+1,n):
        dist=(int(lis[i][0])-int(lis[j][0]))**2 + (int(lis[i][1])-int(lis[j][1]))**2
        res.append(dist)
sqrt_res = [i**0.5 for i in res]
ans = 0
perm = list(itertools.permutations(sqrt_res, n-1))
for v in perm:
    ans+=sum(v)
print(ans/len(perm))  

Fixed submission:
n = int(input())
lis = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2) ** 0.5

ans *= 2/n

print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())

if (x+y)%3!=0:print(0)
else:
    n,m=y//3,y//3
    p = 10**9+7
    N = 2*10**6+10  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, N+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    print(cmb(n+m,n,p))


Fixed submission:
def cmb(n, r, p):
    if r<0 or n<r:
        return 0
    r=min(r, n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

mod=10**9+7
MAXN=2*10**6+10
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]

for i in range(2, MAXN+1):
    fact.append((fact[-1]*i)%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)

x,y=map(int, input().split())
res=0
if (x+y)%3==0:
    m=(2*x-y)//3
    n=(2*y-x)//3
    res=cmb(m+n,m,mod)
print(res)

Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())

if (x+y)%3!=0:print(0)
else:
    n,m=y//3,y//3
    p = 10**9+7
    N = 2+10**6+10  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, N+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    print(cmb(n+m,n,p))

Fixed submission:
def cmb(n, r, p):
    if r<0 or n<r:
        return 0
    r=min(r, n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

mod=10**9+7
MAXN=2*10**6+10
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]

for i in range(2, MAXN+1):
    fact.append((fact[-1]*i)%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)

x,y=map(int, input().split())
res=0
if (x+y)%3==0:
    m=(2*x-y)//3
    n=(2*y-x)//3
    res=cmb(m+n,m,mod)
print(res)

Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())

if (x+y)%3!=0: print(0)
else:
    n,m=y//3,y//3
    p = 10 ** 9 + 7
    N = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, N+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    print(cmb(n+m,n,mod))

Fixed submission:
def cmb(n, r, p):
    if r<0 or n<r:
        return 0
    r=min(r, n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

mod=10**9+7
MAXN=2*10**6+10
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]

for i in range(2, MAXN+1):
    fact.append((fact[-1]*i)%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)

x,y=map(int, input().split())
res=0
if (x+y)%3==0:
    m=(2*x-y)//3
    n=(2*y-x)//3
    res=cmb(m+n,m,mod)
print(res)
Buggy python submission (verdict: Runtime Error):
s = input()

def rle(s):
	tmp, count, ans = s[0], 1, ""
	for i in range(1,len(s)):
		if tmp == s[i]:
			count += 1
		else:
			ans += tmp + str(count)
			tmp = s[i]
			count = 1
	ans += tmp + str(count)
	return ans

r = rle(s)

if (len(r) // 2) % 2 == 1:
	r += '>0'

res = 0
for i in range(len(r) // 4):
	a, b = int(r[4*i+1]), int(r[4*i+3])
	ma, mi = max(a, b), min(a, b)
	res += (ma * (ma + 1)) // 2 + (mi * (mi - 1)) // 2
print(res)

Fixed submission:
s = input()
n = len(s)
res = [0] * (n + 1)
t = 0
for i in range(n):
	if s[i] == '<':
		t += 1
	else:
		t = 0
	res[i + 1] = t

t = 0
for i in range(n - 1, -1, -1):
	if s[i] == '>':
		t += 1
	else:
		t = 0
	res[i] = max(res[i], t)

print(sum(res))
Buggy python submission (verdict: Runtime Error):
n = int(input())

qq = []
for i in range(1,10):
  for j in range(1,10):
    qq.append(i*j) if i*j not in qq

print('Yes') if n in qq else print('No')

Fixed submission:
n = int(input())

lis = []
for i in range(10):
  for j in range(i,10):
    lis.append(i*j)
    
if n in lis: print('Yes')
else: print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
#n=i*jを満たすi,jで，i+jが最小

lis=prime_factorize(n)
lis.sort()
lis_a=[lis[i] for i in range(len(lis)) if i%2==0]
lis_b=[lis[i] for i in range(len(lis)) if i%2!=0]
print(product(lis_a)+product(lis_b)-2)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
def product(lis):
    res=1
    for i in range(len(lis)):
        res*=lis[i]
    return res

Fixed submission:
n=int(input())
mini=2*n
for a in range(1,int(n**0.5)+1):
    if n%a==0:
        b=n//a
        if mini>a+b:
            mini=a+b
print(mini-2)
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())

import numpy as np
if x>a*a*b/2:#半分よりも多い場合
    theta=np.arctan(2*(a*a*b)/a*a*a)
else:#半分に満たない場合
    theta=np.arctan((a*b*b)/(2*x))
theta = theta * 180 / np.pi
print(theta)

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

from math import atan, degrees
if x>=a*a*b/2:#半分よりも多い場合
    rad=atan(2/a*(b-x/a**2))
else:
    rad=atan((a*b*b)/(2*x))
print(degrees(rad))
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())

h = [int(input()) for i in range(n)]

ans = 0

for i in range(n):
	if h[i] >= k:
		ans += 1


print(ans)

Fixed submission:
n,k = map(int, input().split())

h = [int(x) for x in input().split()]

ans = 0

for i in range(n):
	if h[i] >= k:
		ans += 1


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = [int(x) for x in input().split()]


ans = []

for i in range(n):
	idx = a.index(min(a))
	a[idx] = n+100
	ans.append(idx+1)

print(*ans)




Fixed submission:
n = int(input())

a = [int(x) for x in input().split()]

ans = [0 for i in range(n)]

for i in range(n):
	ans[a[i]-1] = i+1

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]

for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

def dfs(v, parent, add):
	value[v] += add
	for x in graph[v]:
		if x == parent:
			continue
		dfs(x, v, value[v])

dfs(1, 0, 0)
print(*value[1:])

Fixed submission:
import sys
input = sys.stdin.readline

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

AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]
# 各ノードと連結するノードを要素に持つ配列
# e.g., graph[1] -> ノード１と連結するノードを要素に持つ
for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

# 根に点数を入れる
value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

# 根から値を流す
q = [(1, 0)]
while q:
	x, parent = q.pop() # (1, 0)
	value[x] += value[parent]
	# 連結する成分について繰り返す
	# このとき、親のノードに流さないように注意
	# ここでの操作は、自分の子のノードを加えること
	for y in graph[x]:
		if y == parent:
			continue
		q.append((y, x)) #(親,子)

res = ' '.join(map(str, value[1:]))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())

AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]
# 各ノードと連結するノードを要素に持つ配列
# e.g., graph[1] -> ノード１と連結するノードを要素に持つ
for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

# 根に点数を入れる
value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

# 根から値を流す
q = [(1, 0)]
while q:
	x, parent = q.pop() # (1, 0)
	value[x] += value[parent]
	# 連結する成分について繰り返す
	# このとき、親のノードに流さないように注意
	# ここでの操作は、自分の子のノードを加えること
	for y in graph[x]:
		if y == parent:
			continue
		q.append((y, x)) #(親,子)

res = ' '.join(map(str, value[1:]))
print(res)

Fixed submission:
import sys
input = sys.stdin.readline

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

AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]
# 各ノードと連結するノードを要素に持つ配列
# e.g., graph[1] -> ノード１と連結するノードを要素に持つ
for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

# 根に点数を入れる
value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

# 根から値を流す
q = [(1, 0)]
while q:
	x, parent = q.pop() # (1, 0)
	value[x] += value[parent]
	# 連結する成分について繰り返す
	# このとき、親のノードに流さないように注意
	# ここでの操作は、自分の子のノードを加えること
	for y in graph[x]:
		if y == parent:
			continue
		q.append((y, x)) #(親,子)

res = ' '.join(map(str, value[1:]))
print(res)
Buggy python submission (verdict: Runtime Error):
k,x=map(int,input().split())

mini = x-k+1
maxi = k+x-1

lis = []
for i in range(mini,max+1):
  lis.append(i)

print(*lis)

Fixed submission:
k,x=map(int,input().split())
 
mini = x-k+1
maxi = k+x-1
 
lis = []
for i in range(mini,maxi+1):
  lis.append(i)
 
print(*lis)