Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from numba import njit

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

@njit
def solution(A,N):
    mod = (10**9)+7
    res = 0
    for i in range(N-1):
        for j in range(i+1,N):
           res += ((A[i] % mod) * (A[j] % mod)) % mod
    return res
  
mod = (10**9)+7
res = solution(A,N)
print(res % mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
A_j = sum(A)
mod = (10**9)+7
res = 0
for i in range(N-1):
    A_j -= A[i]
    res += (A[i] * (A_j % mod)) % mod

print(res % mod)

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

mod = (10**9)+7
res = 0
for i in range(N-1):
    res += (A[i] * (sum(A[i+1:]) % mod)) % mod
    
print(res % mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
A_j = sum(A)
mod = (10**9)+7
res = 0
for i in range(N-1):
    A_j -= A[i]
    res += (A[i] * (A_j % mod)) % mod

print(res % mod)

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

mod = (10**9)+7
res = 0
for i in range(N-1):
    for j in range(i+1,N):
       res += ((A[i] % mod) * (A[j] % mod)) % mod
    
print(res % mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
A_j = sum(A)
mod = (10**9)+7
res = 0
for i in range(N-1):
    A_j -= A[i]
    res += (A[i] * (A_j % mod)) % mod

print(res % mod)

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

res = 0
for i in range(N-1):
    for j in range(i+1,N):
       res += A[i]*A[j]
    
print(res%((10**9)+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
A_j = sum(A)
mod = (10**9)+7
res = 0
for i in range(N-1):
    A_j -= A[i]
    res += (A[i] * (A_j % mod)) % mod

print(res % mod)

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

res = 0
for i in range(N-1):
    for j in range(i+1,N):
       res += A[i]*A[j]
    
print(res%((10**9)+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
A_j = sum(A)
mod = (10**9)+7
res = 0
for i in range(N-1):
    A_j -= A[i]
    res += (A[i] * (A_j % mod)) % mod

print(res % mod)
Buggy python submission (verdict: Runtime Error):
K=int(input())
amari_list = []
amari = 7%K
amari_list.append(amari)
for i in range(1,K):
    amari = (amari * 10 + 7)% K
    if amari == 0:
        print(i+1)
        break
    if amari in amari_list:a
        print(-1)
        break
    if i == (K-1):
        print(-1)
    else:
        amari_list.append(amari)
        

Fixed submission:
K = int(input())
count = 1
mod = 7
answer = -1

for _ in range(K):
    if mod % K == 0:
        answer = count
        break
    count += 1
    mod = (mod * 10 + 7) % K

print(answer)
Buggy python submission (verdict: Runtime Error):
s = input()
R_num = s.count("R")
print(s[:R_num].count("W")


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

R_num = s.count("R")
print(s[:R_num].count("W"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
p=0
ppl = [a[0]]*2
best_index = 1
best_point = a[0]
for i in a[1:]:
    p += best_point
    ppl = ppl[:best_index]+[i]+ppl[best_index:]
    #print(ppl)
    point_list = [min(ppl[i],ppl[i+1]) for i in range(0,len(ppl)-1)]
    #print(point_list)
    best_point = max(point_list)
    for j,q  in enumerate(point_list):
        if q == best_point:
            best_index = j+1
            continue
            
print(p)

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

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)

Buggy python submission (verdict: Runtime Error):
from numba import njit
N = int(input())
a = list(map(int, input().split()))

@njit
def fnc(N,a):
    a.sort(reverse = True)
    p=0
    ppl = [a[0]]*2
    best_index = 1
    best_point = a[0]
    for i in a[1:]:
        p += best_point
        ppl = ppl[:best_index]+[i]+ppl[best_index:]
        #print(ppl)
        point_list = [min(ppl[i],ppl[i+1]) for i in range(0,len(ppl)-1)]
        #print(point_list)
        best_point = max(point_list)
        for j,q  in enumerate(point_list):
            if q == best_point:
                best_index = j+1
                continue
    return p     

print(fnc(N,a))

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

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
from numba import njit
N = int(input())
a = list(map(int, input().split()))

@njit
def fnc(N,a):
    a.sort(reverse = True)
    p=0
    ppl = [a[0]]*2
    best_index = 1
    best_point = a[0]
    for i in a[1:]:
        p += best_point
        ppl = ppl[:best_index]+[i]+ppl[best_index:]
        #print(ppl)
        point_list = [min(ppl[i],ppl[i+1]) for i in range(0,len(ppl)-1)]
        #print(point_list)
        best_point = max(point_list)
        for j,q  in enumerate(point_list):
            if q == best_point:
                best_index = j+1
                continue
    return p     

print(fnc(N,a))

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

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
p=0
ppl = [a[0]]*2
best_index = 1
best_point = a[0]
for i in a[1:]:
    p += best_point
    ppl = ppl[:best_index]+[i]+ppl[best_index:]
    #print(ppl)
    point_list = [min(ppl[i],ppl[i+1]) for i in range(0,len(ppl)-1)]
    #print(point_list)
    best_point = max(point_list)
    for j,q  in enumerate(point_list):
        if q == best_point:
            best_index = j+1
            continue
            
print(p)

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

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0
for i in range(N1):
    sum_tmp = 0
    for j in range(i+1, N):
        sum_tmp += Ai[j]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))

Fixed submission:
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0

sum_tmp = 0
for j in range(0, N):
    sum_tmp += Ai[j]

for i in range(N1):
    sum_tmp -= Ai[i]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))

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

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += Ai[i]*Ai[j]
        if sum > mod_val:
            sum = sum % mod_val
        #print("{} {}".format(i, j))

print(sum)

Fixed submission:
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0

sum_tmp = 0
for j in range(0, N):
    sum_tmp += Ai[j]

for i in range(N1):
    sum_tmp -= Ai[i]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))
Buggy python submission (verdict: Runtime Error):
L, R, d = map(int, input().split(" "))

tmp = (R-L+1)/d
if tmp < 1 :
    if (d >= L) & (d <= R):
        count1 = 1
else:
    count1 = tmp

print(int(count1))


Fixed submission:
L, R, d = map(int, input().split(" "))

a = R // d
b = (L-1) // d
print(a-b)
Buggy python submission (verdict: Runtime Error):
d,t,s=input().split()
if d/s<t :
    print("Yes")
else:
    print("No")

Fixed submission:
d,t,s=map(int,input().split())
if d/s<=t :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input().strip()	 # novel
T = input().strip()  # substring

x = len(T)
ans = len(S)
for i in range(len(S) - x):
  U = S[i:i+x]
  cost = sum(1 if U[k] != T[k] for k in range(x))
  ans = min(ans, cost)
print(ans)

Fixed submission:
S = input().strip()	 # novel
T = input().strip()  # substring

x = len(T)
ans = len(S)
for i in range(len(S) - x + 1):
  U = S[i:i+x]
  cost = sum(1 if U[k] != T[k] else 0 for k in range(x))
  ans = min(ans, cost)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

total = 0
for i in range(N):
  for j in range(i+1, N):
    total += A[i] * A[j]

print(total % MOD)

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

MOD = 10**9 + 7

sum_a = sum(A)
sum_squares = sum([a*a for a in A])

ans = (sum_a**2 - sum_squares)//2
ans %= MOD

print(ans)

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

MOD = 10**9 + 7

total = 0
for i in range(N):
  for j in range(i+1, N):
    total += A[i] * A[j]

print(total % MOD)

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

MOD = 10**9 + 7

sum_a = sum(A)
sum_squares = sum([a*a for a in A])

ans = (sum_a**2 - sum_squares)//2
ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
MAX_A = 10**6

sieve = [[] for _ in range(MAX_A+1)]
# sieve[i] = True if i is prime
# sieve[i] = prime factors of i

for f in range(2, MAX_A + 1):
  if not sieve[f]:
    c = f
    while c <= MAX_A:
      sieve[c].append(f)
      c += f

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

cnt = defaultdict(int)
for a in A:
  for s in sieve[a]:
    cnt[s] += 1

def is_pairwise_coprime():
  return all(v == 1 for v in cnt.values())

def is_setwise_coprime():
  return all(v < N for v in cnt.values())

if is_pairwise_coprime():
  print('pairwise coprime')
elif is_setwise_coprime():
  print('setwise coprime')
else:
  print('not coprime')

Fixed submission:
from collections import defaultdict
MAX_A = 10**6

sieve = [[] for _ in range(MAX_A+1)]
# sieve[i] = True if i is prime
# sieve[i] = prime factors of i

for f in range(2, MAX_A + 1):
  if not sieve[f]:
    c = f
    while c <= MAX_A:
      sieve[c].append(f)
      c += f

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

cnt = defaultdict(int)
for a in A:
  for s in sieve[a]:
    cnt[s] += 1

def is_pairwise_coprime():
  return all(v == 1 for v in cnt.values())

def is_setwise_coprime():
  return all(v < N for v in cnt.values())

if is_pairwise_coprime():
  print('pairwise coprime')
elif is_setwise_coprime():
  print('setwise coprime')
else:
  print('not coprime')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

c = 0
for i in range(1, N):
  if A[i-1] > A[i]:
  	c += A[i-1] - A[i]
    A[i] = A[i-1]
  
  
print(c)


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

c = 0
for i in range(1, N):
  if A[i-1] > A[i]:
    c += A[i-1] - A[i]
    A[i] = A[i-1]
  
  
print(c)
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input())

# pts = [tuple(map(int, input())) for _ in range(N)]

ans = 0
if _ in range(N):
  x, y = map(int, input())
  if x**2 + y**2 <= D**2:
    ans+=1
    
print(ans)
  

Fixed submission:
N, D = map(int, input().split(' '))

# pts = [tuple(map(int, input())) for _ in range(N)]

ans = 0
for _ in range(N):
  x, y = map(int, input().split(' '))
  if x**2 + y**2 <= D**2:
    ans+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
  if a < b:
    return gcd(b, a)
  if b == 0:
    return a
  return gcd(b, a%b)

K = int(input())

if gcd(K, 10) != 1:
  print(-1)
else:
  if K % 7 == 0:
    K/=7
  ans = 1
  cur = 1
  while cur % K != 0:
    cur += pow(10, ans, K)
    ans += 1
  print(ans)

Fixed submission:
def gcd(a, b):
  if a < b:
    return gcd(b, a)
  if b == 0:
    return a
  return gcd(b, a%b)

K = int(input())

if gcd(K, 10) != 1:
  print(-1)
else:
  if K % 7 == 0:
    K//=7
  ans = 1
  cur = 1
  while cur % K != 0:
    cur += pow(10, ans, K)
    ans += 1
  print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
print 10 - X//200

Fixed submission:
X = int(input())
print(10 - X//200)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = map(int, input().split())

answers = ["Yes" if A[i] > A[i-K] else "No" for i in range(K, N)]
print("\n".join(answers))

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
answers = ["Yes" if A[i] > A[i-K] else "No" for i in range(K, N)]
print("\n".join(answers))
Buggy python submission (verdict: Runtime Error):
N = int(input())

planes = {
  'U': [],
  'R': [],
  'D': [],
  'L': []
}

for _ in range(N):
  x, y, t = input().split()
  x, y = int(x), int(y)
  planes[t].append((x, y))
  
BIG = 10**18
  
def time(ps):
  sort(ps)
  ans = BIG
  for i in range(len(ps)-1):
    y1, x1, t1 = ps[i]
    y2, x2, t2 = ps[i+1]
    
    if y1 != y2:
      continue
    
    if t1 == 1 and t2 = -1:
      ans = min(ans, x2 - x1)
  return 5*ans


ud = [(x, y, 1) for x, y in planes['U']] + [(x, y, -1) for x, y in planes['D']]
lr = [(y, x, 1) for x, y in planes['R']] + [(y, x, -1) for x, y in planes['L']]

ur = [(x+y, y-x, 1) for x, y in planes['U']] + [(x+y, y-x, -1) for x, y in planes['R']]
ul = [(x-y, y+x, 1) for x, y in planes['U']] + [(x-y, y+x, -1) for x, y in planes['L']]
rd = [(x-y, y+x, 1) for x, y in planes['R']] + [(x-y, y+x, -1) for x, y in planes['D']]
ld = [(x+y, y-x, 1) for x, y in planes['L']] + [(x+y, y-x, -1) for x, y in planes['D']]

ans = min(time(ud), time(lr), time(ur), time(ul), time(rd), time(ld))
if ans >= BIG:
  print("SAFE")
else:
  print(ans)

  

Fixed submission:
N = int(input())

planes = {
  'U': [],
  'R': [],
  'D': [],
  'L': []
}

for _ in range(N):
  x, y, t = input().split()
  x, y = int(x), int(y)
  planes[t].append((x, y))
  
BIG = 10**18
  
def time(ps):
  ps.sort()
  ans = BIG
  for i in range(len(ps)-1):
    y1, x1, t1 = ps[i]
    y2, x2, t2 = ps[i+1]
    
    if y1 != y2:
      continue
    
    if t1 == 1 and t2 == -1:
      ans = min(ans, x2 - x1)
  return 5*ans


ud = [(x, y, 1) for x, y in planes['U']] + [(x, y, -1) for x, y in planes['D']]
lr = [(y, x, 1) for x, y in planes['R']] + [(y, x, -1) for x, y in planes['L']]

ur = [(x+y, y-x, 1) for x, y in planes['U']] + [(x+y, y-x, -1) for x, y in planes['R']]
ul = [(x-y, y+x, 1) for x, y in planes['U']] + [(x-y, y+x, -1) for x, y in planes['L']]
rd = [(x-y, y+x, 1) for x, y in planes['R']] + [(x-y, y+x, -1) for x, y in planes['D']]
ld = [(x+y, y-x, 1) for x, y in planes['L']] + [(x+y, y-x, -1) for x, y in planes['D']]

ans = min(time(ud), time(lr), time(ur), time(ul), time(rd), time(ld))
if ans >= BIG:
  print("SAFE")
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = map(int, raw_input())

S = raw_input().strip()
L = len(S)

P = 10**9 + 7

facts = [0 for _ in xrange(L + N)]
finvs = [0 for _ in xrange(L + N)]
facts[0] = 1
for i in xrange(1, L+N):
  facts[i] = (i*facts[i-1]) % P

finvs[L+N-1] = pow(facts[L+N-1], P-2, P)
for i in xrange(L+N-2, -1, -1):
  finvs[i] = (finvs[i+1]*(i+1)) % P

ans = 0
for k in xrange(0, K+1):
  ncr = (facts[k+L-1]*finvs[k]*finvs[L-1]) % P
  ans += ncr * pow(25, k, P) * pow(26, K-k, P)
  ans %= P

print ans

Fixed submission:
K = int(raw_input())
S = raw_input().strip()
L = len(S)

P = 10**9 + 7

facts = [0 for _ in xrange(L + K)]
finvs = [0 for _ in xrange(L + K)]
facts[0] = 1
for i in xrange(1, L+K):
  facts[i] = (i*facts[i-1]) % P

finvs[L+K-1] = pow(facts[L+K-1], P-2, P)
for i in xrange(L+K-2, -1, -1):
  finvs[i] = (finvs[i+1]*(i+1)) % P

ans = 0
for k in xrange(0, K+1):
  ncr = (facts[k+L-1]*finvs[k]*finvs[L-1]) % P
  ans += ncr * pow(25, k, P) * pow(26, K-k, P)
  ans %= P

print ans
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, raw_input().split())
while k > 0:
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  k -= 1
print a, b

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

na = max(0, a-k)
nb = max(0, b-(k-(a-na)))
print na, nb
Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())

return A*B if A <= 9 and B <= 9 else -1

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

print A*B if A <= 9 and B <= 9 else -1
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())

found = False
for i in xrange(1, 10):	
  for j in xrange(1, 10):
  	if i*j == N:
      found = True
      
print "Yes" if found else "No"


Fixed submission:
N = int(raw_input())

found = False
for i in xrange(1, 10):	
  for j in xrange(1, 10):
    if i*j == N:
      found = True
      
print "Yes" if found else "No"

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

found = False
for i in xrange(1, 10):	
  for j in xrange(1, 10):
  	if i*j == N and not found:
      print "Yes"
      found = True
      
if not found:
  print "No"


Fixed submission:
N = int(raw_input())

found = False
for i in xrange(1, 10):	
  for j in xrange(1, 10):
    if i*j == N:
      found = True
      
print "Yes" if found else "No"

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

for i in xrange(1, 10):	
  for j in xrange(1, 10):
  	if i*j == N:
      print "Yes"
else:
	print "No"

Fixed submission:
N = int(raw_input())

found = False
for i in xrange(1, 10):	
  for j in xrange(1, 10):
    if i*j == N:
      found = True
      
print "Yes" if found else "No"
Buggy python submission (verdict: Runtime Error):
n = int(input())
ds = map(int, input().split())
t = 0
for i in range(n):
  for j in range(i, n):
    t += d[i] * d[j]
print(t)

Fixed submission:
n = int(raw_input())
ds = map(int, raw_input().split())
t = 0
for i in range(n):
  for j in range(i+1, n):
    t += ds[i] * ds[j]
print(t)
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

x = lambda: map(int, raw_input().strip().split())

A = x()
B = x()
C = x()

points = 0
for i in xrange(n):
  points += B[A[i]-1]
  if i > 0 and A[i] == A[i-1] + 1:
    points += C[A[i]-1]

print points

Fixed submission:
n = int(raw_input())

x = lambda: map(int, raw_input().strip().split())

A = x()
B = x()
C = x()

points = 0
for i in xrange(n):
  points += B[A[i]-1]
  if i > 0 and A[i] == A[i-1] + 1:
    points += C[A[i]-2]

print points
Buggy python submission (verdict: Runtime Error):
n =  int(raw_input())
B = map(int, raw_input().split())
print sum(B) - sum([abs(B[i] - B[i-1]) for i in xrange(1, n)])

Fixed submission:
n =  int(raw_input())
B = map(int, raw_input().split())
B = [1000000] + B + [1000000]
print sum(min(B[i-1], B[i]) for i in range(1, n+1))
Buggy python submission (verdict: Runtime Error):
forecast = raw_input().strip()
real = raw_input().strip()
assert len(forecast) == len(real)
print sum([1 for i in xrange(len(forecast)) if forecast[i] == real[i] else 0])

Fixed submission:
forecast = raw_input().strip()
real = raw_input().strip()
assert len(forecast) == len(real)
print sum([1 for i in xrange(len(forecast)) if forecast[i] == real[i]])

Buggy python submission (verdict: Runtime Error):
forecast = raw_input().strip()
real = raw_input().strip()
assert len(forecast) == len(real)
print sum([1 for i in xrange(len(forecast)) if forecast[i] == real[i] else 0])

Fixed submission:
forecast = raw_input().strip()
real = raw_input().strip()
assert len(forecast) == len(real)
print sum([1 for i in xrange(len(forecast)) if forecast[i] == real[i]])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
total = 0
for i in xrange(1, n+1):
  total += i % (i+1) if i < n else 0
print total

Fixed submission:
n = int(raw_input())
print (n*(n-1))/2
Buggy python submission (verdict: Runtime Error):
import heapq

n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values)
h = []
for v in values:
  heapq.heappush(h, -v)

while len(h) > 1:
  a = heapq.heappop()
  b = heapq.heappop()
  c = (a+b)/2
  heapq.heappush(h, c)
 
print -heapq.heappop()


Fixed submission:
import heapq
 
n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values, reverse=True)
 
print sum(((0.5)**(i+1))*v for i, v in enumerate(values)) + ((0.5)**(len(values)))*values[-1]

Buggy python submission (verdict: Runtime Error):
import heapq

n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values)
h = []
for v in values:
  heapq.heappush(h, v)

while len(h) > 1:
  a = heapq.heappop()
  b = heapq.heappop()
  c = (a+b)/2
  heapq.heappush(h, c)
 
print heapq.heappop()


Fixed submission:
import heapq
 
n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values, reverse=True)
 
print sum(((0.5)**(i+1))*v for i, v in enumerate(values)) + ((0.5)**(len(values)))*values[-1]

Buggy python submission (verdict: Runtime Error):
import heapq

n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values)
h = []
for v in values:
  heapq.heappush(h, v)

while len(h) > 0:
  a = heapq.heappop()
  b = heapq.heappop()
  c = (a+b)/2
  heapq.heappush(h, c)
 
print heapq.heappop()

Fixed submission:
import heapq
 
n = int(raw_input())
values = map(int, raw_input().split())
values = sorted(values, reverse=True)
 
print sum(((0.5)**(i+1))*v for i, v in enumerate(values)) + ((0.5)**(len(values)))*values[-1]
Buggy python submission (verdict: Runtime Error):
import heapq
from collections import defaultdict

read = lambda: map(int, raw_input())
n, m = read()
jobs = [read() for _ in xrange(n)]
jobs_by_time = defaultdict(list)
for (a, b) in jobs:
  jobs_by_time[a].append(b)

ans = 0
q = [] # heapq
for t in xrange(0, m):
  day = t+1
  for job in jobs_by_time[day]:
    heapq.heappush(q, -job)
  
  if q:
    val = -heapq.heappushpop(q)
    ans += val
print ans
   

Fixed submission:
import heapq
from collections import defaultdict

read = lambda: map(int, raw_input().strip().split())
n, m = read()
jobs = [read() for _ in xrange(n)]
jobs_by_time = defaultdict(list)
for (a, b) in jobs:
  jobs_by_time[a].append(b)

ans = 0
q = [] # heapq
for t in xrange(0, m):
  day = t+1
  for job in jobs_by_time[day]:
    heapq.heappush(q, -job)
  
  if q:
    val = -heapq.heappop(q)
    ans += val
print ans
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(raw_input())

points = [map(int, raw_input().split()) for _ in xrange(N)]

# print N, points

dist = lambda p1, p2: (p1[0]-p2[0], p1[1]-p2[1])

vecs = []
for i in xrange(N):
    for j in xrange(i+1, N):
        vecs.append(dist(points[i], points[j]))

vecs_cnt = Counter(vecs)
# print Counter(vecs)
ans = max(vecs_cnt.values())

print N-ans

Fixed submission:
from collections import Counter

N = int(raw_input())

points = [map(int, raw_input().split()) for _ in xrange(N)]

if N == 1:
    print 1
else:
    dist = lambda p1, p2: (p1[0]-p2[0], p1[1]-p2[1])

    vecs = []
    for i in xrange(N):
        for j in xrange(N):
            if j == i:
                continue
            vecs.append(dist(points[i], points[j]))

    vecs_cnt = Counter(vecs)
    # print Counter(vecs)
    ans = max(vecs_cnt.values())

    print N-ans
Buggy python submission (verdict: Runtime Error):
D,T,S = (int(x) for x in input().split())

disable = D - T*S

if disable>0:
    print("No")
else 
    print("Yes")

Fixed submission:
D,T,S = (int(x) for x in input().split())

disable = D - T*S

if disable>0:
    print("No")
else:
    print("Yes")