Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
num_lists = list(map(int, input().split))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Fixed submission:
N = int(input())
num_lists = list(map(int, input().split()))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
num_lists = list(map(int, input().split))
ans = - 1

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)

Fixed submission:
N = int(input())
num_lists = list(map(int, input().split()))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
num_lists = list(map(int, input().split))
ans = 0

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)

Fixed submission:
N = int(input())
num_lists = list(map(int, input().split()))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
num = X//min_powder
print(ans + num )

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
 
print(N + (X-sum(m))//min(m))

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
print(ans + X//min_powder)

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
 
print(N + (X-sum(m))//min(m))

Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
print(ans + X//d)

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
 
print(N + (X-sum(m))//min(m))
Buggy python submission (verdict: Runtime Error):
N = int(input())

card = list(map(int, input().split()))
sorted_card = card.sort(reverse=True)

Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += sorted_card[i]
  else:
    Bob += sorted_card[i]
    
print(Alice - Bob)

Fixed submission:
N = int(input())
 
card = list(map(int, input().split()))
card.sort(reverse=True)
 
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)

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

card = list(map(int, input().split())).sort(reverse= True)

Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)

Fixed submission:
N = int(input())
 
card = list(map(int, input().split()))
card.sort(reverse=True)
 
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)
Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = "8"
print(s)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])

Buggy python submission (verdict: Runtime Error):
s = input
s[3] = "8"
print(s)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])

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

a[3] = 8
print(a)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])

Buggy python submission (verdict: Runtime Error):
a, b = input().split()

a[3] = 8
print(a+b)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])

Buggy python submission (verdict: Runtime Error):
a, b input().split()

a[3] = 8
print(a+b)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])
Buggy python submission (verdict: Runtime Error):
a, b ,c = map(int, input().split())

if a == c:
  print("Yes")
else:
  print("No")

Fixed submission:
number = input()
if number[0] == number[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
X, Y, Z = map(int, input().split())

num_5 = 0
num_7 = 0

if X == 5:
  num_5 += 1
if Y == 5:
  num_5 += 1
if Z == 5:
  num_5 += 1
  
if X == 7:
  num_7 += 1
if Y == 7:
  num_7 += 1
if Z == 7:
  num_7 += 1

if num_5 == 2 && num_7 == 1:
    print("YES")
else:
    print("NO")

Fixed submission:
X, Y, Z = map(int, input().split())
 
num_5 = 0
num_7 = 0
 
if X == 5:
  num_5 += 1
if Y == 5:
  num_5 += 1
if Z == 5:
  num_5 += 1
  
if X == 7:
  num_7 += 1
if Y == 7:
  num_7 += 1
if Z == 7:
  num_7 += 1
  
if num_5 == 2 and num_7 == 1:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
s = [input() for i in range(n)]
s = sorted(s)
print(*s, sep="")



Fixed submission:
N,L =map(int,input().split())
s=sorted([input() for i in range(N)])
print(*s,sep="")

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
s = [input() for i in range(n)].sort()
print(*s, sep="")



Fixed submission:
N,L =map(int,input().split())
s=sorted([input() for i in range(N)])
print(*s,sep="")
Buggy python submission (verdict: Runtime Error):
#codinf:UTF-8
s = input()
print(s.replace("2017","2018")

Fixed submission:
#codinf:UTF-8
s = input()
print(s.replace("2017","2018"))
Buggy python submission (verdict: Runtime Error):
# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(wokr[1])
print(math.ceil((a+b)/2))


Fixed submission:
# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(work[1])
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
s = input()
print(s[0] + (len(s)-2) + s[-1])


Fixed submission:
#coding:UTF-8
s = input()
print(s[0] + str(len(s)-2) + s[-1])
Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
print(ans)
    

Fixed submission:
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)

Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
print(ans)

Fixed submission:
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)

Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
print(ans)

Fixed submission:
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +c
if(num % 4 == 0):
  print("YES")
else:
  print("NO")
  

Fixed submission:
#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +g
if(num % 4 == 0):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
d = {}

i = int(input())

for m in range(i):
	word = input()
	d[m] = word
for n in range(1, i):
	h = n - 1
	a = d[h]
	b = d[n]
	if a[-1] == b[0]:
		continue
	else:
		print('No')
		exit()
for x in range (i - 1):
	for j in range (x + 1, i):
		if d[x] == d[j]:
			print('No')
			exit()
print('Yes')


Fixed submission:
a, b = map(int, input().split())
X = a*b
if X == 2 or X ==4 or X==6:
	print('No')
else:
	print('Yes')
Buggy python submission (verdict: Runtime Error):
import sys 
import math

a, b = map(int, input().split(" "))
if N == 100:
     print(100**a*b+1)
else:
    print(100**a*b)

Fixed submission:
import sys 
import math

a, b = map(int, input().split(" "))
if b == 100:
    print(100**a*b+100**a)
else:
    print(100**a*b)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.insert(0, 0)

	for i in range(1, n+1):
		ans = 0
		tmp = copy.deepcopy(a)
		del tmp[i]

		for j in range(len(tmp)-1):
			ans += abs(tmp[j+1] - tmp[j])
		ans += abs(tmp[-1])
		print(ans)


main()


Fixed submission:
import copy

def calcAbs(a, i):
	return abs(a[i+1] - a[i-1]) - (abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]))

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.insert(0, 0)
	a.insert(len(a), 0)
	#a.append(0)

	total = 0
	for j in range(len(a)-1):
		total += abs(a[j+1] - a[j])

	for i in range(1, n+2-1):
		ans = total + calcAbs(a, i) 

		print(ans)


main()
Buggy python submission (verdict: Runtime Error):
string = input()

z_idx = len(string) - string[::-1].index('Z') - 1

a_idx = string.index('A')

print (z_idx - a_idx + 1)

Fixed submission:
x = int(input())

print ('ABC' if x < 1200 else 'ARC')
Buggy python submission (verdict: Time Limit Exceeded):
import sys, os, random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

def solve(N, M):
        i = N
        while i <= M:
                if M % i == 0:
                        return M / i
                i = i + 1
        assert 0

N, M = rdi()
print solve(N, M)

Fixed submission:
import sys, os, random, math

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

def solve(N, M):
        L = math.sqrt(M) + 0.5
        i = N
        while i <= L:
                if M % i == 0:
                        return M / i
                i = i + 1
        i = N-1
        while i >= 1:
                if M % i == 0 and M / i >= N:
                        return i
                i = i - 1
        assert 0

N, M = rdi()
print solve(N, M)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

K, N = rdi()

if K == 1:
        print " ".join(["1"] * ((N+1)/2))
        sys.exit(0)

if K % 2 == 0:
        print K/2,
        for i in range(N-1):
                print K,
        print
        sys.exit(0)

t = [ K/2+1 ] * N
for i in range(N/2):
        #print t
        if t[-1] == 1:
                #if t[-2] == 1:
                        t = t[:-1]
                #else:
                #       t[-2] -= 1
                #       t = t[:-1] + [ K ] * (N - len(t) + 1)
        else:
                t[-1] -= 1
                t = t + [ K ] * (N - len(t))
        #print t
print " ".join([ str(x) for x in t])

Fixed submission:
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

K, N = rdi()

if K == 1:
        print " ".join(["1"] * ((N+1)/2))
        sys.exit(0)

if K % 2 == 0:
        print K/2,
        for i in range(N-1):
                print K,
        print
        sys.exit(0)

t = [ K/2+1 ] * N
j = N-1
for i in range(N/2):
        if t[j] == 1:
                j -= 1
        else:
                t[j] -= 1
                for k in range(j+1, N):
                        t[k] = K
                j = N-1
        #print t
print " ".join([ str(x) for x in t[:j+1]])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num_list = list(map(int,input().split()))
no_dup = set(num_list)
sorted_dup = sorted(no_dup,reverse=True)
ans = 1
cnt = 0

for n in sorted_dup:
    total = num_list.count(n)
    if cnt == 0 and total >= 4:
        ans = n*n
        cnt = 2
    elif total >= 2:
        ans *= n
        cnt += 1
    if cnt == 2:
        break

if cnt == 0:
    print(0)
else:    
    print(ans)

Fixed submission:
from collections import Counter

n = int(input())
num_list = list(map(int,input().split()))
cntr = Counter(num_list).most_common()
ans = 0

for num,cnt in sorted(cntr,reverse=True):
    if cnt >= 4 and ans == 0:
        ans = num*num
        break
    elif cnt >= 2 and ans == 0:
        ans = num
    elif cnt >= 2:
        ans *= num
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
def ceil(x,y):
    if x%y == 0:
        return x//y
    if x%y == 1:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)

Fixed submission:
def ceil(x,y):
    if x%y == 0:
        return x//y
    else:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_uni = list(set(vo))
ve_uni = list(set(ve))
vo_cnt = [vo.count(x) for x in vo_uni]
ve_cnt = [ve.count(x) for x in ve_uni]
if vo_uni == ve_uni and len(vo_uni) == 1:
    ans = n//2
else:
    ans = n - max(vo_cnt) - max(ve_cnt)
print(ans)

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_dict = collections.Counter(vo)
ve_dict = collections.Counter(ve)
if vo_dict == ve_dict and len(vo_dict) == 1:
    ans = n//2
else:
    if vo_dict.most_common()[0][0] != ve_dict.most_common()[0][0]:
        ans = n - vo_dict.most_common()[0][1] - ve_dict.most_common()[0][1]
    else:
        ans = min(n - vo_dict.most_common()[0][1] - ve_dict.most_common(2)[1][1],
                  n - vo_dict.most_common(2)[1][1] - ve_dict.most_common()[0][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
a_eo = [[a[i][j] % 2 for j in range(W)] for i in range(H)]

N = 0
move = ""
for i in range(H):
    for j in range(W):
        if a_eo[i][j] == 1:
            if j < W-1 and 1 in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i][j+1] += 1
                a_eo[i][j] = 0
                a_eo[i][j+1] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1, j+1+1)
            elif i < H-1 and 1 not in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i+1][j] += 1
                a_eo[i][j] = 0
                a_eo[i+1][j] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1+1, j+1)
            else:
                break

print("%d\n" % N + move)


Fixed submission:
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
a_eo = [[a[i][j] % 2 for j in range(W)] for i in range(H)]

N = 0
move = ""
for i in range(H):
    for j in range(W):
        if a_eo[i][j] == 1:
            if j < W-1 and 1 in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i][j+1] += 1
                a_eo[i][j] = 0
                a_eo[i][j+1] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1, j+1+1)
            elif i < H-1 and 1 not in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i+1][j] += 1
                a_eo[i][j] = 0
                a_eo[i+1][j] = (a_eo[i+1][j] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1+1, j+1)
            else:
                break

print("%d\n" % N + move)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(N-K+1):
    light = x[i:i+K]
    l = light[0]
    r = light[-1]
    time = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    if ans == 0 or time < ans:
        ans = time
print(ans)

Fixed submission:
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**8 * 3
for i in range(N-K+1):
    light = x[i:i+K]
    l = light[0]
    r = light[-1]
    time = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    if time < ans:
        ans = time
print(ans)

Fixed submission:
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**8 * 3

for i in range(N-K+1):
    light = x[i:i+K]
    l = light[0]
    r = light[-1]
    if l*r >= 0:
        time = max(abs(l), abs(r))
    else:
        time = min(abs(l)*2+abs(r), abs(l)+abs(r)*2)
    if time < ans:
        ans = time
print(ans)

Fixed submission:
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**8 * 2
for i in range(N-K):
    l = x[i]
    r = x[i+K-1]
    if l*r >= 0:
        time = max(abs(l), abs(r))
    else:
        time = min(abs(l)*2+abs(r), abs(l)+abs(r)*2)
    if time < ans:
        ans = time
print(time)

Fixed submission:
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	angle=math.acos(dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b)))
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print


Fixed submission:
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	value=dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b))
	value=min(max(value, -1.0), 1.0)
	angle=math.acos(value)
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print
Buggy python submission (verdict: Runtime Error):
import sys
n=input()
adj=[[] for i in range(n+1)]
for i in range(n-1):
	a, b, c=map(int, raw_input().split())
	adj[a].append((b, c))
	adj[b].append((a, c))
size=[0]*(n+1)
def dfs(cur, father):
	size[cur]=1
	for to, weight in adj[cur]:
		if to!=father:
			dfs(to, cur)
			size[cur]+=size[to]
dfs(1, 0)
center=1
while True:
	change=False
	for to, weight in adj[center]:
		if size[to]<size[center] and size[to]*2>=n:
			center=to
			change=True
			break
	if not change:
		break
print>>sys.stderr, center
dfs(center, 0)
result=0
for cur in range(1, n+1):
	for to, weight in adj[cur]:
		if size[to]<size[cur]:
			result+=size[to]*weight
result*=2
print>>sys.stderr, result
for to, weight in adj[center]:
	assert size[to]*2<=n
	if size[to]*2==n:
		print>>sys.stderr, "special"
		print result-weight
		exit()
min_weight=1000000000
for to, weight in adj[center]:
	min_weight=min(min_weight, weight)
print result-min_weight


Fixed submission:
import sys
n=input()
sys.setrecursionlimit(n+1000)
adj=[[] for i in range(n+1)]
for i in range(n-1):
	a, b, c=map(int, raw_input().split())
	adj[a].append((b, c))
	adj[b].append((a, c))
size=[0]*(n+1)
def dfs(cur, father):
	size[cur]=1
	for to, weight in adj[cur]:
		if to!=father:
			dfs(to, cur)
			size[cur]+=size[to]
dfs(1, 0)
center=1
while True:
	change=False
	for to, weight in adj[center]:
		if size[to]<size[center] and size[to]*2>=n:
			center=to
			change=True
			break
	if not change:
		break
print>>sys.stderr, center
dfs(center, 0)
result=0
for cur in range(1, n+1):
	for to, weight in adj[cur]:
		if size[to]<size[cur]:
			result+=size[to]*weight
result*=2
print>>sys.stderr, result
for to, weight in adj[center]:
	assert size[to]*2<=n
	if size[to]*2==n:
		print>>sys.stderr, "special"
		print result-weight
		exit()
min_weight=1000000000
for to, weight in adj[center]:
	min_weight=min(min_weight, weight)
print result-min_weight
Buggy python submission (verdict: Time Limit Exceeded):
import sys
result=input()
def query(n):
	print "? %d"%n
	sys.stdout.flush()
	return raw_input()
i=1
while i<=1000000000 and query(i)=="Y":
	i*=10
if i==1000000000*10:
	while i!=0 and query(i+1)=="Y":
		i/=10
	print i*10 if i!=0 else 1
else:
	l=i/10
	r=i-1
	print l, r
	while l+1!=r:
		if query(((l+r)/2)*10)=="Y":
			r=(l+r)/2
		else:
			l=(l+r)/2
	print r


Fixed submission:
import sys
def query(n):
	print "? %d"%n
	sys.stdout.flush()
	return raw_input()
i=1
while i<=1000000000 and query(i)=="Y":
	i*=10
if i==1000000000*10:
	while i!=0 and query(i+1)=="Y":
		i/=10
	print "! %d"%(i*10 if i!=0 else 1)
else:
	l=i/10
	r=i-1
	while l+1!=r:
		if query(((l+r)/2)*10)=="Y":
			r=(l+r)/2
		else:
			l=(l+r)/2
	print "! %d"%r