Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W+1,-1,-1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])

Fixed submission:
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W,-1,-1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

def judge(now,weight,value):

    if now == N-1:
        if weight+w[now] <= W:
            return value+v[now]
        elif weight <= W:
            return value
        else:
            return 0
    else:
        return max(judge(now+1,weight+w[now],value+v[now]),judge(now+1,weight,value))


r=judge(0,0,0)
print(r)

Fixed submission:
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W,-1,-1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

def judge(now,weight,value):
    if weight > W:
        return 0
    if now == N-1:
        if weight+w[now] <= W:
            return value+v[now]
        elif weight <= W:
            return value
        
    else:
        return max(judge(now+1,weight+w[now],value+v[now]),judge(now+1,weight,value))


r=judge(0,0,0)
print(r)

Fixed submission:
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W,-1,-1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = [int(input()) for i in range(n)]

gra = [1]*n


for i in range(1,n):
    Max = 1
    for j in range(i):
        if num[j]<num[i] and gra[j]>=Max:
            Max = gra[j]
            gra[i] = Max+1

print(max(gra))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import bisect
#D2
n = int(input())
a = [int(input()) for j in range(n)]
 
dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        #print(0,dp)
 
    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        #print(1,bisect.bisect_left(dp, a[i]),dp)
print(len(dp))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = [int(input()) for i in range(n)]

gra = [1]*n

for i in range(1,n):
    Max = 1
    for j in range(i):
        if num[j]<num[i] and gra[j]>=Max:
            Max = gra[j]
            gra[i] = Max+1

print(max(gra))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import bisect
#D2
n = int(input())
a = [int(input()) for j in range(n)]
 
dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        #print(0,dp)
 
    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        #print(1,bisect.bisect_left(dp, a[i]),dp)
print(len(dp))
Buggy python submission (verdict: Time Limit Exceeded):
N,V = map(int,input().split())
cnt = 0

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = list(map(int,input().split()))

for alist in a:
    for blist in b:
        for clist in c:
            for dlist in d:
                if alist + blist + clist + dlist == V:
                    cnt += 1

print(cnt)

Fixed submission:
from collections import Counter

N,V = map(int,input().split())
cnt = 0

a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
d = tuple(map(int,input().split()))

ab = Counter(ai+bi for ai in a for bi in b)
cd = Counter(ci+di for ci in c for di in d)

cnt = sum(ab[V-i]*t for i,t in cd.items() if V-i in ab)

print(cnt)

Buggy python submission (verdict: Runtime Error):
from collections import Counter

N,V = map(int,input().split())
cnt = 0

a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
d = tuple(map(int,input().split()))

ab = Counter(ai+bi for ai in a for bi in b)
cd = Counter(ci+di for ci in c for di in d)

cnt = sum(ab[v-i]*t for i,t in cd.items() if v-i in ab)

print(cnt)

Fixed submission:
from collections import Counter

N,V = map(int,input().split())
cnt = 0

a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
d = tuple(map(int,input().split()))

ab = Counter(ai+bi for ai in a for bi in b)
cd = Counter(ci+di for ci in c for di in d)

cnt = sum(ab[V-i]*t for i,t in cd.items() if V-i in ab)

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
    r = x%y
    if r==0:
        return y
    else:
        return gcd(y,r)
input = int(input())
cnt = 1
for i in range(2,input):
    if gcd(input,i) == 1:
        cnt += 1

print(cnt)

Fixed submission:
def phi(n):
    r = n
    i = 2
    while i*i <= n:
        if n%i==0:
            r -= r/i
            while n%i==0:
                n /= i
        i += 1
    if n>1: r-= r/n
    return r

n = int(input())
print(int(phi(n)))

Buggy python submission (verdict: Time Limit Exceeded):
input = int(input())
buf = input
result = 1
for i in range(2,input+1):
    if buf%i==0:
        result *= (1 - 1/i)
    while buf%i==0:
        buf /= i
result *= input
print(int(result))

Fixed submission:
def phi(n):
    r = n
    i = 2
    while i*i <= n:
        if n%i==0:
            r -= r/i
            while n%i==0:
                n /= i
        i += 1
    if n>1: r-= r/n
    return r

n = int(input())
print(int(phi(n)))

Buggy python submission (verdict: Time Limit Exceeded):
input = int(input())
buf = input
result = 1
for i in range(2,input+1):
    if buf%i==0:
        result *= (1 - 1/i)
    while buf%i==0:
        buf /= i
result *= input
print(int(result))

Fixed submission:
def phi(n):
    r = n
    i = 2
    while i*i <= n:
        if n%i==0:
            r -= r/i
            while n%i==0:
                n /= i
        i += 1
    if n>1: r-= r/n
    return r

n = int(input())
print(int(phi(n)))

Buggy python submission (verdict: Time Limit Exceeded):
input = int(input())
buf = input
result = 1
for i in range(2,input+1):
    if buf%i==0:
        result *= (1 - 1/i)
    while buf%i==0:
        buf /= i
result *= input
print(int(result))

Fixed submission:
def phi(n):
    r = n
    i = 2
    while i*i <= n:
        if n%i==0:
            r -= r/i
            while n%i==0:
                n /= i
        i += 1
    if n>1: r-= r/n
    return r

n = int(input())
print(int(phi(n)))
Buggy python submission (verdict: Runtime Error):
a = int(input())
h = int(a / 3600)
m = int(a - h * 3600) / 60
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s % (h, m, s)

Fixed submission:
a = int(input())
h = int(a / 3600)
m = int((a - h * 3600) / 60)
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s" % (h, m, s))

Buggy python submission (verdict: Runtime Error):
a = int(input())
h = int(a / 3600)
m = int((a - h * 3600) / 60)
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s % (h, m, s)

Fixed submission:
a = int(input())
h = int(a / 3600)
m = int((a - h * 3600) / 60)
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s" % (h, m, s))

Buggy python submission (verdict: Runtime Error):
a = int(input())
h = int(a / 3600)
m = int(a - h * 3600) / 60
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s % (h, m, s))

Fixed submission:
a = int(input())
h = int(a / 3600)
m = int((a - h * 3600) / 60)
s = int(a - (h * 3600) - (m * 60))
print("%s:%s:%s" % (h, m, s))
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,3):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)


Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,n):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)
Buggy python submission (verdict: Runtime Error):
o,p,q,r = [int(i) for i in input().split()]
print(format(((q-o)**2+(r-p)**2)**(1/2), '.8f'))

Fixed submission:
o,p,q,r = [float(i) for i in input().split()]
print(format(((q-o)**2+(r-p)**2)**(1/2), '.8f'))
Buggy python submission (verdict: Runtime Error):
import random

class Dice():
    
    def __init__(self, *n):
       self.rolls = n

    def spin(self, order):
        if order == "N":
            self.rolls = [
                self.rolls[1],
                self.rolls[5],
                self.rolls[2],
                self.rolls[3],
                self.rolls[0],
                self.rolls[4]
            ]
        if order == "E":
            self.rolls = [
                self.rolls[3],
                self.rolls[1],
                self.rolls[0],
                self.rolls[5],
                self.rolls[4],
                self.rolls[2]
            ]
        if order == "S":
            self.rolls = [
                self.rolls[4],
                self.rolls[0],
                self.rolls[2],
                self.rolls[3],
                self.rolls[5],
                self.rolls[1]
            ]
        if order == "W":
            self.rolls = [
                self.rolls[2],
                self.rolls[1],
                self.rolls[5],
                self.rolls[0],
                self.rolls[4],
                self.rolls[3]
            ]
        return self.rolls[0]

d = Dice(*[int(i) for i in input().split()])
directions = ['N','E','S','W']
for _ in range(int(input())):
    a,b = [int(i) for i in input().split()]
    while a != d.rolls[0] or d.rolls[1] != b:
        d.spin(directions[random.randint(0,3)])
    print(d.rolls[2])

Fixed submission:
class Dice():

    def __init__(self, *n):
       self.rolls = n

    def spin(self, order):
        if order == "N":
            self.rolls = [
                self.rolls[1],
                self.rolls[5],
                self.rolls[2],
                self.rolls[3],
                self.rolls[0],
                self.rolls[4]
            ]
        if order == "E":
            self.rolls = [
                self.rolls[3],
                self.rolls[1],
                self.rolls[0],
                self.rolls[5],
                self.rolls[4],
                self.rolls[2]
            ]
        if order == "S":
            self.rolls = [
                self.rolls[4],
                self.rolls[0],
                self.rolls[2],
                self.rolls[3],
                self.rolls[5],
                self.rolls[1]
            ]
        if order == "W":
            self.rolls = [
                self.rolls[2],
                self.rolls[1],
                self.rolls[5],
                self.rolls[0],
                self.rolls[4],
                self.rolls[3]
            ]
        return self.rolls[0]


d = Dice(*[int(i) for i in input().split()])
for order in list(input()):
    l = d.spin(order)
print(l)
Buggy python submission (verdict: Runtime Error):
print(int(input())/int(input()))

Fixed submission:
a,b = map(float, input().split())
print(int(a/b), int(a%b), format(a/b, '.5f'))
Buggy python submission (verdict: Runtime Error):
import math

i = int(input())
print(i**2*math.pi, i*2*math.pi)

Fixed submission:
import math

i = float(input())
print(i**2*math.pi, i*2*math.pi)
Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
import sys
def main():
    N = input()
    a = []
    for i in range(N):
        a.append(input())
    for i in range(3):
        m = max(a)
        a.remove(m)
        print (m)
        return 0    
if __name__ == "__main__":
    sys.exit(main())


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(input())
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [input() for i in range(n)]
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(3):
    m = max(a)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [input() for i in range(n)]
for i in range(3):
    m = max(l)
    a.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)

Buggy python submission (verdict: Runtime Error):
import sys
e = sys.stdin.readlines():
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)


Fixed submission:
import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a = []
for i in range(M):
    a.append(map(int, raw_input().split()))
    print len(N + M)


Fixed submission:
import sys
for e in sys.stdin.readlines():
 print(len(str(sum(map(int,e.split())))))

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin.readlines():
 print(len(sum(map(int,e.split()))))


Fixed submission:
import sys
for e in sys.stdin.readlines():
 print(len(str(sum(map(int,e.split())))))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a**2 + b**2 == c**2:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
a, b, c = sorted(map(int, input().split()))
if a**2 + b**2 == c**2:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
import sys
for e in int().input():
    a, b, c = sorted(int(sys.stdin.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(int(e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')


Fixed submission:
import sys
input()
for e in sys.stdin:
    a, b, c = sorted(map(int, e.split()))
    if a**2 + b**2 == c**2:
        print('YES')
    else:
        print('NO')
Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    a * (e*y-f) / d + b * y = c
    x = (e*y-f) / d
    print round(x, 3)+' '+round(y, 3)


Fixed submission:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    a * (e*y-f) / d + b * y = c
    x = (e*y-f) / d
    print (round(x, 3)+' '+round(y, 3))


Fixed submission:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    a * (-e*y+f) / d + b * y = c
    -x = (e*y-f) / d
    print (round(x, 3)+' '+round(y, 3))


Fixed submission:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (e*y-f) / -d
    print (round(x, 3)+' '+round(y, 3))


Fixed submission:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))

Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    print (round(x, 3)+' '+round(y, 3))


Fixed submission:
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))
Buggy python submission (verdict: Runtime Error):
print(input[::-1])


Fixed submission:
print(input()[::-1])
Buggy python submission (verdict: Runtime Error):
import sys
for e in sys.stdin:
 e=int(e);x=range(10);ff=0
ff+=1 for a in x for b in x for c in x for d in x if a+b+c+d==e
print (ff)


Fixed submission:
import sys
for e in sys.stdin:
 e=int(e);x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split(' '))
d = a // b
r = a % b
f = a / b

print(d,r,f, sep='\n' )


Fixed submission:
a,b =  (int(i) for i in input().split(' '))
d = a // b
r = a % b
f = a / b

print("{} {} {:.5f}".format(d,r,f))

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split(' '))
d = a // b
r = a % b
f = a / b

print(d,r,f, sep='\n' )


Fixed submission:
a,b =  (int(i) for i in input().split(' '))
d = a // b
r = a % b
f = a / b

print("{} {} {:.5f}".format(d,r,f))
Buggy python submission (verdict: Runtime Error):
w = int(input())
n = int(input())
nums = [1, 2, 3, 4, 5]
ab = []
for i in range(n):
    a, b = map(int, input().split(','))
    nums[a-1], nums[b-1] = nums[b-1], nums[a-1]
for i in nums:
    print(i)


Fixed submission:
w = int(input())
n = int(input())
nums = [i for i in range(1, w+1)]
ab = []
for i in range(n):
    a, b = map(int, input().split(','))
    nums[a-1], nums[b-1] = nums[b-1], nums[a-1]
for i in nums:
    print(i)
Buggy python submission (verdict: Runtime Error):
while True:
    g = int(input())
    now = 512
    ans = []
    while True:
        if g == 0:
            break
        elif g >= now:
            g -= now
            ans.append(now)
        now //= 2
    temp = ''
    for i in ans[::-1]:
        temp += str(i) + ' '
    print(temp[:-1])


Fixed submission:
import sys
bundo = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
bundo.reverse()
for line in sys.stdin:
    n = int(line)
    ans = ''
    for i in bundo:
        if n >= i:
            n -= i
            ans = str(i) + ' ' + ans
    print(ans[:-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(' ')))

A.sort()
A.reverse()

list = []
ans = 0
for i in range(len(A)):
    if i == 0:
        list.append(A[i])
    elif list:
        ans += list[0]
        list.pop(0)
        list.append(A[i])
        list.append(A[i])

print(ans)

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

A.sort()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(1, len(A)):
        ans += list[i - 1]
        list.append(A[i])
        list.append(A[i])

print(ans)