Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())

edge = [[] for i in range(n)]
ans = [-1] * n
odd = []
even =[]
nums = [[],[],[]]
for i in range(1,n+1):
    nums[i % 3].append(i)

def dfs(x, last = -1, d = 0):
    if d % 2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:continue
        dfs(nxt, x, d + 1)

for i in range(n-1):
    a, b = map(int, input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)

dfs(0)

zerocnt = len(nums[0])

if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()

elif len(odd) <= zerocnt:
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()

else:
    for num in nums[1]:
        ans[even.pop()] = num
    for num in nums[2]:
        ans[odd.pop()] = num
    rest = nums[0]
    for even_node in even:
        ans[even_node] = rest.pop()
    for odd_node in odd:
        ans[odd_node] = rest.pop()

print(*ans)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
n = int(input())

edge = [[] for i in range(n)]
ans = [-1] * n
odd = []
even =[]
nums = [[],[],[]]
for i in range(1,n+1):
    nums[i % 3].append(i)

def dfs(x, last = -1, d = 0):
    if d % 2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:continue
        dfs(nxt, x, d + 1)

for i in range(n-1):
    a, b = map(int, input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)

dfs(0)

zerocnt = len(nums[0])

if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()

elif len(odd) <= zerocnt:
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()

# len
# nums[1] >= nums[2] >= nums[0] >= nums[1]-1
else:
    for num in nums[1]:
        ans[even.pop()] = num
    for num in nums[2]:
        ans[odd.pop()] = num
    rest = nums[0]
    for even_node in even:
        ans[even_node] = rest.pop()
    for odd_node in odd:
        ans[odd_node] = rest.pop()

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7#prime
n = int(input())
a = list(map(int, input().split()))

primes = {}

for val in a:
    p = 2
    while p * p <= val:
        if val % p == 0:
            cnt = 0
            while val % p == 0:
                cnt += 1
                val //= p
            if p not in primes:
                primes[p] = cnt
            else:
                primes[p] = max(cnt, primes[p])
        p += 1

    if val != 1:
        if val not in primes:
            primes[val] = 1


lcm = 1
for p in primes:
    lcm = lcm * pow(p, primes[p], MOD) % MOD

   
def inv(x):
    return pow(x, MOD-2, MOD)

ans = 0
for val in a:
    ans += lcm * inv(val) % MOD
    ans %= MOD

print(ans)

         

Fixed submission:
MOD = 10**9 + 7#prime
n = int(input())
a = list(map(int, input().split()))

primes = {}

for val in a:
    p = 2
    while p * p <= val:
        if val % p == 0:
            cnt = 0
            while val % p == 0:
                cnt += 1
                val //= p
            if p not in primes:
                primes[p] = cnt
            else:
                primes[p] = max(cnt, primes[p])
        p += 1

    if val != 1:
        if val not in primes:
            primes[val] = 1


lcm = 1
for p in primes:
    lcm = lcm * pow(p, primes[p], MOD) % MOD

   
def inv(x):
    return pow(x, MOD-2, MOD)

ans = 0
for val in a:
    ans += lcm * inv(val) % MOD
    ans %= MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

def tdfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        distt[to] = distt[x] + 1
        tdfs(to, x)

def adfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        dista[to] = dista[x] + 1
        adfs(to, x)

tdfs(u)
adfs(v)
ans = 0

for i in range(1, n+1):
    if distt[i] >= dista[i]:continue
    l = distt[i]
    k = dista[i] - distt[i]
    ans = max(ans, k - 1 + l)

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(200000)
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

def tdfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        distt[to] = distt[x] + 1
        tdfs(to, x)

def adfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        dista[to] = dista[x] + 1
        adfs(to, x)

tdfs(u)
adfs(v)
ans = 0

for i in range(1, n+1):
    if distt[i] >= dista[i]:continue
    l = distt[i]
    k = dista[i] - distt[i]
    ans = max(ans, k - 1 + l)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = (10**9) + 7

n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 60
for num in a:
    for j in range(60):
        cnt[j] += (num >> j) % 2

ans = 0
for b in range(60):
    ans += cnt[b] * (n - cnt[b]) << b
    ans %= MOD

print(ans)



Fixed submission:
MOD = (10**9) + 7

n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 60
for num in a:
    for j in range(60):
        cnt[j] += (num >> j) % 2

ans = 0
for b in range(60):
    ans += cnt[b] * (n - cnt[b]) << b
    ans %= MOD

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

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)
    

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

if d == 0:
    if x == 0:print(1)
    else:print(n+1)
    exit(0)

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
edge = [[] for i in range(n)]
a = [0] * n
b = [0] * n

color_dict = {}
k = 0

def dfs(x, last = -1, ban_color = -1):
    global k
    color = 1
    for to in edge[x]:
        if to == last:continue
        if color == ban_color:color += 1
        color_dict[(x, to)] = color
        dfs(to, x, color)
        color += 1
    k = max(k, color-1)

for i in range(n-1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    edge[a[i]].append(b[i])
    edge[b[i]].append(a[i])


dfs(0)
print(k)

for i in range(n-1):
    if (a[i], b[i]) in color_dict:
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

n = int(input())
edge = [[] for i in range(n)]
a = [0] * n
b = [0] * n

color_dict = {}
k = 0

def dfs(x, last = -1, ban_color = -1):
    global k
    color = 1
    for to in edge[x]:
        if to == last:continue
        if color == ban_color:color += 1
        color_dict[(x, to)] = color
        dfs(to, x, color)
        color += 1
    k = max(k, color-1)

for i in range(n-1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    edge[a[i]].append(b[i])
    edge[b[i]].append(a[i])


dfs(0)
print(k)

for i in range(n-1):
    if (a[i], b[i]) in color_dict:
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans += max(0, (4-x)*100000)
ans += max(0, (4-y)*100000)
if x == 1 and y == 1:
	ans += 400000
print(ans)

Fixed submission:
x, y = map(int, input().split())
ans = 0
ans += max(0, (4-x)*100000)
ans += max(0, (4-y)*100000)
if x == 1 and y == 1:
	ans += 400000
print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())
x, y = map(int, input().split())

nowx, nowy = 0, 0
ans = []

while(abs(nowx - x) + abs(nowy - y) >= 2*K):
    if x - nowx >= K:
        nowx += K
    elif nowx - x >= K:
        nowx -= K
    elif y - nowy >= K:
        nowy += K
    else:
        nowy -= K
    ans.append((nowx, nowy))

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1 and K % 2 == 0:
    print(-1)
    exit(0)

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1:
    if abs(nowx+K - x) + abs(nowy - y) < 2*K:nowx += K
    elif abs(nowx-K - x) + abs(nowy - y) < 2*K:nowx -= K
    elif abs(nowx - x) + abs(nowy+K - y) < 2*K:nowy += K
    elif abs(nowx - x) + abs(nowy-K - y) < 2*K:nowy -= K
    ans.append((nowx, nowy))

rest = K*2 - (abs(nowx-x) + abs(nowy-y))
rest //= 2

xgo = (x - nowx) // abs(nowx - x)
ygo = (y - nowy) // abs(nowy - y)

if abs(nowx-x) >= abs(nowy-y):
    nowx += xgo * (K - rest)
    nowy -= ygo * rest
    ans.append((nowx, nowy))
    
else:
    nowy += ygo * (K - rest)
    nowx -= xgo * rest
    ans.append((nowx, nowy))

ans.append((x, y))

print(len(ans))
for (x, y) in ans:
    print(x,y)

        

Fixed submission:
K = int(input())
x, y = map(int, input().split())

nowx, nowy = 0, 0
ans = []

def ok():
    global ans, x, y
    ans.append((x, y))
    print(len(ans))
    for (x, y) in ans:
        print(x,y)
    exit(0)
        


while(abs(nowx - x) + abs(nowy - y) >= 2*K):
    if x - nowx >= K:
        nowx += K
    elif nowx - x >= K:
        nowx -= K
    elif y - nowy >= K:
        nowy += K
    else:
        nowy -= K
    ans.append((nowx, nowy))

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1 and K % 2 == 0:
    print(-1)
    exit(0)

    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()
    
if (abs(nowx - x) + abs(nowy - y)) % 2 == 1:
    if abs(nowx+K - x) + abs(nowy - y) < 2*K:nowx += K
    elif abs(nowx-K - x) + abs(nowy - y) < 2*K:nowx -= K
    elif abs(nowx - x) + abs(nowy+K - y) < 2*K:nowy += K
    elif abs(nowx - x) + abs(nowy-K - y) < 2*K:nowy -= K
    ans.append((nowx, nowy))
    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()

rest = K*2 - (abs(nowx-x) + abs(nowy-y))
rest //= 2
xgo, ygo = 1, 1

if nowx != x:
    xgo = (x - nowx) // abs(nowx - x)
if nowy != y:
    ygo = (y - nowy) // abs(nowy - y)

if abs(nowx-x) >= abs(nowy-y):
    nowx += xgo * (K - rest)
    nowy -= ygo * rest
    ans.append((nowx, nowy))
    
else:
    nowy += ygo * (K - rest)
    nowx -= xgo * rest
    ans.append((nowx, nowy))

ok()
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
MOD = 10**9 + 7


S = 0

def stick(n):
    return n * (n+1) // 2

def calc(w, h):
    L = w * (w-1) // 2
    R = L + w * (h-1)
    return (L + R) * h // 2

for i in range(n):
    for j in range(m):
        S += calc(i+1, j+1)
        S += calc(i+1, m-j)
        S += calc(n-i, j+1)
        S += calc(n-i, m-j)
        S -= stick(i)
        S -= stick(j)
        S -= stick(n-i-1)
        S -= stick(m-j-1)
        S %= MOD
if S % 2 == 0:S //= 2
else: S = (S + MOD) // 2
S %= MOD
if S < 0:S += MOD
def fact(x):
    if x == 0:return 1
    else: return x * fact(x-1) % MOD

def rev(x):
    return pow(x, MOD-2, MOD)

def nCk(n, k):
    return fact(n) * rev(fact(k)) % MOD * rev(fact(n-k)) % MOD

print(S * nCk(n+m-2, k-2) % MOD)

Fixed submission:
n, m, k = map(int, input().split())
MOD = (10**9) + 7


S = 0

def stick(n):
    return n * (n+1) // 2

def calc(w, h):
    L = w * (w-1) // 2
    R = L + w * (h-1)
    return (L + R) * h // 2

for i in range(n):
    for j in range(m):
        S += calc(i+1, j+1)
        S += calc(i+1, m-j)
        S += calc(n-i, j+1)
        S += calc(n-i, m-j)
        S -= stick(i)
        S -= stick(j)
        S -= stick(n-i-1)
        S -= stick(m-j-1)
        S %= MOD
        
if S % 2 == 0:S //= 2
else: S = (S + MOD) // 2
S %= MOD
if S < 0:S += MOD

def fact(x):
    res = 1
    for i in range(1, x+1):
        res = res * i % MOD
    return res


def rev(x):
    return pow(x, MOD-2, MOD)

def nCk(n, k):
    return fact(n) * rev(fact(k)) % MOD * rev(fact(n-k)) % MOD

print(S * nCk(n*m-2, k-2) % MOD)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"

Fixed submission:
cnt = [0] * 100
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"
Buggy python submission (verdict: Runtime Error):
k, a, b = map(int, raw_input().split())
if a >= b:
    print(res)
    exit()

res = k
k -= a-1
if k >= 0:res = max(res, a + (k / 2) * (b-a))
k -= 1
if k >= 0:res = max(res, a + 1 + (k / 2) * (b-a))
print res


Fixed submission:
k, a, b = map(int, raw_input().split())
res = k+1
if a >= b:
    print(res)
    exit()

k -= a-1
if k >= 0:res = max(res, a + (k / 2) * (b-a))
k -= 1
if k >= 0:res = max(res, a + 1 + (k / 2) * (b-a))
print res
Buggy python submission (verdict: Runtime Error):
s = int(input())
ans = 1
nums = set()
while s not in nums:
  ans += 1
  if s % 2 == 0: s // = 2
  else: s = s * 3 + 1
  nums.add(s)
print(ans)


Fixed submission:
s = int(input())
ans = 1
nums = set()
while s not in nums:
    ans += 1
    nums.add(s)
    if s % 2 == 0: s //= 2
    else: s = s * 3 + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(max(a)-min(a))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1

a.sort()

b = a[n/2]

for i in range(n):
    a[i] = abs(a[i]-b)
print(sum(a))


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

a.sort()

b = a[n//2]

for i in range(n):
    a[i] = abs(a[i]-b)
print(sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
res = 0
for a in range(n):
  b = n - a
  res = sum(map(int, str(a))) + sum(map(int, str(b)))
 print(res)

Fixed submission:
n = input()
res = 1<<10
def ds(x):
    return sum(map(int,list(str(x))))

for a in range(1,n):
    b = n - a
    res = min(ds(a) + ds(b), res)

print res
Buggy python submission (verdict: Time Limit Exceeded):
hoge = [False] * 1080

for i in range(1, 1080):
 x = i*i
 while(x < 1080):
  hoge[x] = True
  x *= i

X = input()

while not hoge[X]: X -= 1
print X

Fixed submission:
hoge = [False] * 1080
hoge [1] = True
for i in range(2, 1080):
 x = i*i
 while(x < 1080):
  hoge[x] = True
  x *= i

X = input()

while not hoge[X]: X -= 1
print X
Buggy python submission (verdict: Runtime Error):
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < a.size():
  if a[p] == a[p-1]:
    edge.append(a[p])
    p += 2
  else:
    p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

Fixed submission:
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < len(a):
      if a[p] == a[p-1]:
              edge.append(a[p])
              p += 2
      else:
              p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

Buggy python submission (verdict: Runtime Error):
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < a.size():
  if a[p] == a[p-1]:
    p += 2
    edge.append(a[p])
  else:
    p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

Fixed submission:
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < len(a):
      if a[p] == a[p-1]:
              edge.append(a[p])
              p += 2
      else:
              p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]
Buggy python submission (verdict: Runtime Error):
    a,b = map(int, raw_input().split())
    cnt = b - a + 1
    if a > 0:print 'Positive'
    elif b < 0:print ['Positive', 'Negative'][cnt%2]
    else:print 'Zero'

Fixed submission:
a,b = map(int, raw_input().split())
cnt = b - a + 1
if a > 0:print 'Positive'
elif b < 0:print ['Positive', 'Negative'][cnt%2]
else:print 'Zero'
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = string(input())
if a >= 3200:
  print(s)
else:
  print('red')

    
  

Fixed submission:
a = int(input())
s = str(input())
if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
n = input()
if int(n)%1000 = 0:
    print(0)
if int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))

Fixed submission:
n = input()
if int(n)%1000 == 0:
    print(0)
elif int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Fixed submission:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,102)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])

Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000

for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Fixed submission:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,102)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])

Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(1,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []

for i in p1:
    ans = min(abs(i-x),ans)
    if ans >= abs(i-x):
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Fixed submission:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,102)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])
Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m = map(int,input().split())
print(a**2+b**2-2*a*b*math.cos(math.radians(h*30 - m*5.5)))**0.5

Fixed submission:
import math
a,b,h,m = map(int,input().split())

print((a**2+b**2-(2*a*b*math.cos(math.radians(h*30 - m*5.5))))**0.5)

Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m = map(int,input().split())
print((a**2+b**2-2*a*b*math.cos(math.radians(h*30 - m*5.5))))**0.5

Fixed submission:
import math
a,b,h,m = map(int,input().split())

print((a**2+b**2-(2*a*b*math.cos(math.radians(h*30 - m*5.5))))**0.5)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
for i in range(10**8):
    if i**5 == x:
        print(i,0)
        break
    elif i**5 == x-1:
        print(i,-1)
        break
    elif i**5 == x+1:
        print(i,1)

Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
for i in range(10**8):
    if i**5 == x:
        print(i,0)
        break
    elif i**5 == x-1:
        print(i,-1)
        break

Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
b = (-1)
for i in range(10**7):
    a = i
    if (a-b)*(a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4) == x:
        print(a,b)
        break

Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
b = (-1)
for i in range(10**8):
    a = i
    if (a-b)*(a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4) == x:
        print(a,b)
        break

Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()

Buggy python submission (verdict: Runtime Error):
x = int(input())
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

temp = prime_factorize(x)
ma = min(temp)
a = 0
b = 0
if x == 1:
    print(0,-1)
else:
    for i in range(ma+1):
        a = ma-i
        b = a-ma
        #print(a,b)
        if a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4 == max(temp):
            print(a,b)
            break


Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()