Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

A, B = map(int input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)
    



Fixed submission:
#!/usr/bin/env python3

A, B = map(int, input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

A B = map(int input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)
    



Fixed submission:
#!/usr/bin/env python3

A, B = map(int, input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = int(input())
L = input().split()
L_num = []

for i in range(len(L)):
    L_num.append(int(L[i]))

L_num.sort()

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

if total <= L_num[N-1]:
    print("No")
else:
    print("Yes")




Fixed submission:
#!/usr/bin/env python3

T, X = map(int,input().split())

print(T/X)
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
w_li = [list(map(int,input().split())) for _ in range(N)]

li = [[0 for _ in range(N+1)] for _ in range(W+1)]

for n in range(1,N+1):
    for w in range(W+1):
        if w>=w_li[n-1][0]:
            li[w][n] = max(li[w][n-1] , li[w-w_li[n-1][0]][n-1]+w_li[n-1][1])
        else:
            li[w][n] = li[w][n-1]
print(li[W][N])

Fixed submission:
N,W = map(int,input().split())
w_li = [list(map(int,input().split())) for _ in range(N)]

li = [[0 for _ in range(N+1)] for _ in range(W+1)]

for n in range(1,N+1):
    for w in range(W+1):
        if w>=w_li[n-1][0]:
            li[w][n] = max(li[w][n-1] , li[w-w_li[n-1][0]][n-1]+w_li[n-1][1])
        else:
            li[w][n] = li[w][n-1]
print(li[W][N])
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

li = [["" for _ in range(len(S)+1)] for _ in range(len(T)+1)]

for s in range(1,len(S)+1):
    for t in range(1,len(T)+1):
        if S[s-1] == T[t-1]:
            if len(li[t-1][s]) == max(len(li[t-1][s]), len(li[t][s-1]), len(li[t-1][s-1])+1):
                li[t][s] = li[t-1][s]
            elif len(li[t][s-1]) == max(len(li[t-1][s]), len(li[t][s-1]), len(li[t-1][s-1])+1):
                li[t][s] = li[t][s-1]
            elif len(li[t-1][s-1])+1 == max(len(li[t-1][s]), len(li[t][s-1]), len(li[t-1][s-1])+1):
                li[t][s] = li[t-1][s-1] + S[s-1]

        else:
            if len(li[t-1][s]) == max(len(li[t-1][s]), len(li[t][s-1])):
                li[t][s] = li[t-1][s]
            elif len(li[t][s-1]) == max(len(li[t-1][s]), len(li[t][s-1])):
                li[t][s] = li[t][s-1]
            
print(li[t][s])

Fixed submission:
S = list(input())
T = list(input())

li = [[0 for _ in range(len(S)+1)] for _ in range(len(T)+1)]

for s in range(1,len(S)+1):
    for t in range(1,len(T)+1):
        if S[s-1] == T[t-1]:
            li[t][s] = max(li[t-1][s], li[t][s-1], li[t-1][s-1]+1)
        else:
            li[t][s] = max(li[t-1][s],li[t][s-1])

s = len(S)
t = len(T)
ans = ""
while(s and t):
    if (S[s-1]==T[t-1]) and (li[t][s]-1==li[t-1][s-1]):
        ans = S[s-1]+ans
        s-=1
        t-=1
    elif li[t-1][s] >= li[t][s-1]:
        t-=1
    elif li[t-1][s] < li[t][s-1]:
        s-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = [0 for _ in range(d)]

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] += 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] += dp2[l]
            dp1[(l+j)%d] %= mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] += 1
            dp1[(mm1+j)%d] %= mod
    #print(dp1,dp2)
    mm1 = (mm1+li[i])%d
    dp2 = [dp1[i] for i in range(d)]
    dp1 = [0 for _ in range(d)]
dp2[sum(li)%d]+=1
print((dp2[0]-1)%mod)   








Fixed submission:
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = [0 for _ in range(d)]

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] += 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] += dp2[l]
            dp1[(l+j)%d] %= mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] += 1
            dp1[(mm1+j)%d] %= mod
    #print(dp1,dp2)
    mm1 = (mm1+li[i])%d
    dp2 = [dp1[i] for i in range(d)]
    dp1 = [0 for _ in range(d)]
dp2[sum(li)%d]+=1
print((dp2[0]-1)%mod)

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

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = dp1.copy()

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] = 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] = (dp1[(l+j)%d]+dp2[l])%mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] = (dp1[(mm1+j)%d]+1)%mod
    #print(dp1)
    

    mm1 = (mm1+li[i])%d
    dp2 = dp1.copy()
    dp1 = [0 for _ in range(d)]


print((dp2[0]-1)%mod)   








Fixed submission:
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = [0 for _ in range(d)]

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] += 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] += dp2[l]
            dp1[(l+j)%d] %= mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] += 1
            dp1[(mm1+j)%d] %= mod
    #print(dp1,dp2)
    mm1 = (mm1+li[i])%d
    dp2 = [dp1[i] for i in range(d)]
    dp1 = [0 for _ in range(d)]
dp2[sum(li)%d]+=1
print((dp2[0]-1)%mod)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


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

print(x+y//2)

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


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

print(n+k//2)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

for a in range(m):
    memo = n+a
    if (m/memo) == (m//memo):
        ans = m//memo
        break
    if (m/memo) < 2:
        ans = 1

print(ans)
    

Fixed submission:
import math

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

q = int(math.sqrt(m))+1
li = [0 for i in range(10**6)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = max(i,ans)
        
    if (li[i]==1) and (m*n<=m*i):
        ans = max((m/i),ans)
    

print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(111,222,333,444,555,666,777,888,999)

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break


Fixed submission:
n = int(input())
li =[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)


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

mm1=0
mm2=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)

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

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm+=1
    if i%k==k//2 and k%2==0:
        mm+=1

print(C(mm**3))

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

mm1=0
mm2=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)
Buggy python submission (verdict: Runtime Error):
if n%k==0:
    print(0)
else:
    print(1)

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

if n%k==0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())
ans = True
li = list("abcdefghijklmnopqrstuvwxyzC")

if s[0]!="A":
    ans = False
memo = s[2:-1]
if not("C" in memo):
    ans = False
C_cnt = 0
for i in range(1,len(li)):
    if not(memo[i] in li):
        ans = False
    if memo[i] == "C":
        C_cnt += 1

if ans and C_cnt==1:
    print("AC")
else:
    print("WA")










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


s = list(input())
ans = True
li = list("abcdefghijklmnopqrstuvwxyzC")

if s[0]!="A":
    ans = False
memo = s[2:-1]
if not("C" in memo):
    ans = False
C_cnt = 0
for i in range(1,len(s)):
    if not(s[i] in li):
        ans = False
    if s[i] == "C":
        C_cnt += 1

if ans and C_cnt==1:
    print("AC")
else:
    print("WA")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

li = []

for i in range(n):
    memo = a[i]-(i+1)
    li.append(memo)

li.sort()

memo = len(li)
memo2 = li[memo//2]

li2 = [memo2 for i in range(len(li))]
li = li - li2

ttl = 0
for i in range(n):
    ttl += abs(li[i])

print(ttl)


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

li = []

for i in range(n):
    memo = a[i]-(i+1)
    li.append(memo)

li.sort()
#print(li)
memo = len(li)
memo2 = li[memo//2]

li2 = [-(memo2) for i in range(len(li))]
for i in range(n):
    li[i] = li[i] + li2[i]
#print(li)
ttl = 0
for i in range(n):
    ttl += abs(li[i])

print(ttl)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


n,k = map(int,input().split())
print(max(m+k,n-k,n*k))

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
 
 
n,k = map(int,input().split())
print(max(n+k,n-k,n*k))
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(H)]

for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h>0 ans s[h-1][w]=="#":
                continue
            elif h<H-1 ans s[h+1][w]=="#":
                continue
            elif w>0 ans s[h][w-1]=="#":
                continue
            elif h<W-1 ans s[h][w+1]=="#":
                continue
            else:
                print("No")
                break
else:
    print("Yes")

Fixed submission:
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]

bre = False
for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h>0 and s[h-1][w]=="#":
                continue
            elif h<H-1 and s[h+1][w]=="#":
                continue
            elif w>0 and s[h][w-1]=="#":
                continue
            elif w<W-1 and s[h][w+1]=="#":
                continue
            else:
                #print(h,w)
                print("No")
                bre = True
                break
    if bre:
        break
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())

cnt = 700
for i in range(3):
    if s[i] == "o"
    cnt += 100

print(cnt)



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


s = list(input())

cnt = 700
for i in range(3):
    if s[i] == "o":
        cnt += 100

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

li = sorted(a)
memo = li[n//2]

for i in range(n):
    if a[i] > memo:
        print(li[(n//2)]) 
    else:
        print(li[(n//2)+1])


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

li = sorted(a)
memo = li[n//2-1]

for i in range(n):
    if a[i] > memo:
        print(li[(n//2)-1]) 
    else:
        print(li[(n//2)])
Buggy python submission (verdict: Time Limit Exceeded):
def N(a): #階乗 n!
    ans = 1
    for i in range(1,a+1):
        ans *= i
    return ans

def C(n,k): #組み合わせ nCk
    memo1 = N(n)
    memo2 = N(k)
    memo3 = N(n-k)
    return (memo1)//(memo2*memo3)


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

ans = 0
for i in range(n):
    memo = ans
    ans = max(C(a[n-1],a[i]),ans)
    if ans != memo:
        memo2 = a[i]

print(a[n-1],memo2)

Fixed submission:
def N(a): #階乗 n!
    ans = 1
    for i in range(1,a+1):
        ans *= i
    return ans

def C(n,k): #組み合わせ nCk
    memo1 = N(n)
    memo2 = N(k)
    memo3 = N(n-k)
    return (memo1)//(memo2*memo3)


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

ans = 0
aim = a[n-1]//2

if a[n-1]%2!=0:
    aim2 = a[n-1]//2+1
else:
    aim2 = a[n-1]//2

memo = abs(a[0]-aim)
memo2 = 0
for i in range(n-1):
    if abs(memo) > abs(a[i]-aim):
        memo = abs(a[i]-aim)
        memo2 = a[i]

memo = abs(a[0]-aim2)
memo3 = 0
for i in range(n-1):
    if abs(memo) > abs(a[i]-aim2):
        memo = abs(a[i]-aim2)
        memo3 = a[i]

if abs(memo2-aim) > abs(memo3-aim2):
    ans = memo3
else:
    ans = memo2



print(a[n-1],ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("four")
        break
        elif i == n-1:
            print("Tree")

Fixed submission:
n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("Four")
        break
    elif i == n-1:
        print("Three")
Buggy python submission (verdict: Runtime Error):
N = list(input())
print(len(N)*9+N[0]-1)

Fixed submission:
N = list(input())

flg = 0
for i in range(1,len(N)):
    if N[i]=="9":
        continue
    else:
        flg = 1
        break

if flg:
    print((len(N)-1)*9+int(N[0])-1)
else:
    print((len(N)-1)*9+int(N[0]))
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

m = a +b -c-d

if m>0:
    print("Left")
elif m =0:
    print("Balanced")
else:
    print("Right")

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

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

m = a +b -c-d

if m>0:
    print("Left")
elif m ==0:
    print("Balanced")
else:
    print("Right")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

cnt = 0
for i in range(n):
    memo = 0
    while(a[i]%2==0):
        a[i]%=2
        memo += 1
    cnt = max(memo,cnt)
print(cnt)


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

cnt = 10**10
for i in range(n):
    memo = 0
    while(a[i]%2==0):
        a[i]/=2
        memo += 1
    cnt = min(memo,cnt)
print(cnt)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input())
li = ["A","B","C","D","E","F"]

for i in range(6):
    if a[0] == li[i]:
        a[0] = i
    if a[1] == li[i]:
        a[1] = i

if a[0] > a[1]:
    print(">")
elif a[0] == a[1]:
    print("=")
else:
    print("<")




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

a = list(input().split())
li = ["A","B","C","D","E","F"]



if a[0] > a[1]:
    print(">")
elif a[0] == a[1]:
    print("=")
else:
    print("<")
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

x,y,z map(int,input().split())

ans = 1
memo = y+2*z

while(memo<=x):
    ans += 1
    memo += y+z

print(ans-1)

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

x,y,z = map(int,input().split())

ans = 1
memo = y+2*z

while(memo<=x):
    ans += 1
    memo += y+z

print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(); B.sort(); C.sort()

ans = 0


for a in range(n):
    for b in range(n-1,-1,-1):
        if A[a] >= B[b]:
            break
        index = bisect.bisect_left(C, B[b]+1)
        ans += n-index
        
    

print(ans)




Fixed submission:
import bisect

n = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(); B.sort(); C.sort()

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

for b in range(n):    
    index = bisect.bisect_left(C, B[b]+1)
    b_li[b] = n-index

for b in range(n-2,-1,-1):
    b_li[b] += b_li[b+1]
b_li.append(0)

for a in range(n):    
    index = bisect.bisect_left(B, A[a]+1)

    ans += b_li[index]
    
        
    

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

con = True
for h in range(1,3500):
    for n in range(h,3500):
        memo1 = N*h*n
        memo2 = 4*h*n-N*n-N*h
        if memo2 != 0:
            memo3 = memo1/memo2
            memo4 = memo1%memo2
            if (memo4==0) and (memo3>=1):
                print(h,n,int(memo3))
                con = False
                break
    if not(con):
        break


Fixed submission:
N = int(input())

con = True
for h in range(1,3500):
    for n in range(h,3500):
        memo1 = N*h*n
        memo2 = 4*h*n-N*n-N*h
        if memo2 != 0:
            memo3 = memo1/memo2
            memo4 = memo1%memo2
            if (memo4==0) and (memo3>=1):
                print(h,n,int(memo3))
                con = False
                break
    if not(con):
        break
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

if (n//10 == 9) or (n%10==9):
    print("Yes")
else:
    print("No")

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

n = int(input())



if (n//10 == 9) or (n%10==9):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

li = [0 for i in range(n)]
for i in range(n):
    li[a[i]] += 1

x = 0
for i in range(1,n-1):
    x = max(li[i-1]+li[i]+li[i+1])

print(x)

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

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

li = [0 for i in range(10**5)]
for i in range(n):
    li[a[i]] += 1

x = 0
for i in range(1,10**5-1):
    x = max(li[i-1]+li[i]+li[i+1],x)

print(x)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().spliy())
print((n-1)*(m-1))

Fixed submission:
n,m = map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    li[a][b] = 1
    li[b][a] = 1

ans = False
for i in range(1,n-1):
    if li[0][i] and li[i][n-1]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n,m = int(input())
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = map(int,input())
    a-=1
    b-=1
    li[a][b] = 1
    li[b][a] = 1

ans = False
for i in range(1,n-1):
    if li[0][i] and li[i][n-1]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


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

memo = sum(a)

a=a[0]
b=memo-a[0]

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

    ans = min(ans,abs(a-b))
    
print(ans)

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


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

memo = sum(a)



q=a[0]
b=memo-a[0]

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

    ans = min(ans,abs(q-b))
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())

def cnt(a): #階乗の計算
    res = 1
    for i in range(1,a+1):
        res *= i

    return res


if abs(n-m) >= 2:
    print(0)

else:
    if n==m:
        ans1 = cnt(n)
        ans2 = cnt(m)
        print(2*ans1*ans2)
    

    else:
        ans1 = cnt(n)
        ans2 = cnt(m)
        print(ans1*ans2)
        

Fixed submission:
p = 10 ** 9 + 7
N = (10 ** 5)*2 +10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

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

n,m = map(int,input().split())
if abs(n-m) > 1:
    print(0)
elif n==m:
    m1 = fact[n]
    print(((m1**2)*2)%p)
else:
    m1 = fact[n]
    m2 = fact[m]
    print((m1*m2)%p)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = int(input())
b = int(input())

if a+b >= 10:
    print("error")
else:
    print(a+b)



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

a,b =  map(int,input().split())

if a+b >= 10:
    print("error")
else:
    print(a+b)
Buggy python submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a,b,c = input().split()

if (c-a >=0) and (b-c >= 0):
    
    print("Yes")
else:
    print("No")



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

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

if (a <= c) and (c <= b):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += ab[i][j]
    print(cnt)


Fixed submission:
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += ab[i][j]
    print(cnt)


Fixed submission:
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)