Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n):
    p[i] = (p[i]+1)*(p[i]/2)/p[i]
for j in range(n-k+1):
    ans = max(ans,sum(p[j:j+k]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[(1+i)/2 for i in range(1,1001)]
l=[0,s[p[0]-1]]
for i in range(1,n):
    l.append(l[-1]+s[p[i]-1])
ans=0
for j in range(n-k+1):
    ans=max(ans,l[j+k]-l[j])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
print(sum(l[:n-k]))
//print(l)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
print(sum(h[:max(0,n-k)]))

Buggy python submission (verdict: Runtime Error):
n,k=map(input().split())
l=list(map(int,input().split()))
l.sort()
print(sum(l[:n-k-1]))

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
print(sum(h[:max(0,n-k)]))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(k):
    if a>0:
        a-=1
    elif b>0:
        b-=1
    else:
        pass
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
a-=k
if a<0:
    b+=a
print(max(0,a),max(0,b))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(6-a-b)

Fixed submission:
a=int(input())
b=int(input())
print(6-a-b)

Buggy python submission (verdict: Runtime Error):
a,b=int(input())
print(6-a-b)

Fixed submission:
a=int(input())
b=int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
from numpy import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))

Buggy python submission (verdict: Runtime Error):
from math import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

l=["SUN","MON","TUE","WED","THU","FRI","SAT"]
s=input()
print(7-l.index(s))


Fixed submission:

s=input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

l=["A",'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',"A",'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
n=int(input())
s=input()
ans=""
for i in range(len(s)):
    ans+=l[l.index(s[i])+n]
print(ans)

Fixed submission:
l=["A",'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',"A",'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
n=int(input())
s=input()
ans=""
for i in range(len(s)):
    ans+=l[l.index(s[i])+n]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n=int(input())
l=[]
i=1
ans=10000000000000
while i<n**(1/2):
    if n%i==0:
        ans=n//i+i-2
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

n=int(input())
l=[]
i=int(n**(0.5))+1
ans=0
while 1:
    if n%i==0:
        ans=n//i+i-2
        break
    i-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math

a,b,x=map(int,input().split())
cm2=a*a*b
long1=(cm2-x)/(a*a)
if b-long1*2>=0:
    ans=(math.degrees(math.atan((b-long1*2)/a)))
else:
    ans=math.degrees(math.atan(a**3/2(a*a*b-x)))
print(ans)


Fixed submission:
import math

a,b,x=map(int,input().split())
x/=a
half=a*b/2
if x>half:
    print(math.degrees(math.atan(2*(a*b-x)/a/a)))
else:
    print(math.degrees(math.atan(b/(2*x/b))))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    a=l[i]
    for j in range(i+1,n-1):
        b=l[j]
        for k in range(j+1,n):
            c=l[k]
            if a<b+c and b<a+c and c<a+b:
              ans+=1
print(ans)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):#jはi未満
        m = L[i]-L[j]#上記c-bを計算
        k = bisect_right(L, m)#二分探索
        #aに相当するkは、上記の通り、mよりも大きい(つまり、右側)
        #同じものがあったら右側
        n = max(0, j-k)#j-kの区間の数は大丈夫
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    a=l[i]
    for j in range(i+1,n-1):
        b=l[j]
        for k in range(j+1,n):
            c=l[k]
            if a<b+c and b<a+c and c<a+b:
              ans+=1
print(ans)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):#jはi未満
        m = L[i]-L[j]#上記c-bを計算
        k = bisect_right(L, m)#二分探索
        #aに相当するkは、上記の通り、mよりも大きい(つまり、右側)
        #同じものがあったら右側
        n = max(0, j-k)#j-kの区間の数は大丈夫
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            a=l[i]
            b=l[j]
            c=l[k]
            if a<b+c and b<a+c and c<a+b:
              ans+=1
print(ans)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):#jはi未満
        m = L[i]-L[j]#上記c-bを計算
        k = bisect_right(L, m)#二分探索
        #aに相当するkは、上記の通り、mよりも大きい(つまり、右側)
        #同じものがあったら右側
        n = max(0, j-k)#j-kの区間の数は大丈夫
        ans+=n
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

h,w,a,b=map(int,input().split())
l=[]
for i in range(b):
    l.append([0]*a+[1]*(h-a))
for _ in range(w-b):
    l.append([1]*a+[0]*(h-a))
for k in range(h):
    s=""
    for v in range(w):
        s+=str(l[k][v])
    print(s)

Fixed submission:
import sys
input = sys.stdin.readline

h,w,a,b=map(int,input().split())
l=[]
for i in range(b):
    l.append([0]*a+[1]*(w-a))
for _ in range(h-b):
    l.append([1]*a+[0]*(w-a))
for k in range(h):
    s=""
    for v in range(w):
        s+=str(l[k][v])
    print(s)
Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
m=[0]*n
ans=0
for i in range(q):
    answer=int(input())
    m[answer-1]+=1
for _ in range(q):
    if k-q+m[_]>0:
        print("Yes")
    else:
        print("No")


Fixed submission:
n,k,q=map(int,input().split())
m=[0]*n
ans=0
for i in range(q):
    answer=int(input())
    m[answer-1]+=1
for _ in range(n):
    if k-q+m[_]>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
l=[k]*n
m=[0]*n
ans=0
for i in range(q):
    answer=int(input())
    m[answer-1]+=1
for _ in range(q):
    if l[_]-q+m[_]>0:
        ans+=1
print(ans)


Fixed submission:
n,k,q=map(int,input().split())
m=[0]*n
ans=0
for i in range(q):
    answer=int(input())
    m[answer-1]+=1
for _ in range(n):
    if k-q+m[_]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
while m>0:
    l[0]//=2
    m-=1
    l.sort(reverse=True)
print(sum(l))

Fixed submission:
import sys
input = sys.stdin.readline

import heapq

n,m=map(int,input().split())
a=list(map(lambda x: int(x)*-1,input().split()))
heapq.heapify(a)

for _ in range(m):
    Min=heapq.heappop(a)
    Min=(-Min//2)*-1
    heapq.heappush(a,Min)
print(sum(a)*-1)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in range(m):
    l[l.index(max(l))]//=2
print(sum(l))

Fixed submission:
import sys
input = sys.stdin.readline

import heapq

n,m=map(int,input().split())
a=list(map(lambda x: int(x)*-1,input().split()))
heapq.heapify(a)

for _ in range(m):
    Min=heapq.heappop(a)
    Min=(-Min//2)*-1
    heapq.heappush(a,Min)
print(sum(a)*-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
m=[]
o=[1]
ans=0
for i in range(n):
    s=input()
    l=[0]*26
    for v in range(10):
        if s[v]=="a":
            l[0]+=1
        elif s[v]=="b":
            l[1]+=1
        elif s[v]=="c":
            l[2]+=1
        elif s[v]=="d":
            l[3]+=1
        elif s[v]=="e":
            l[4]+=1
        elif s[v]=="f":
            l[5]+=1
        elif s[v]=="g":
            l[6]+=1
        elif s[v]=="h":
            l[7]+=1
        elif s[v]=="i":
            l[8]+=1
        elif s[v]=="j":
            l[9]+=1
        elif s[v]=="k":
            l[10]+=1
        elif s[v]=="l":
            l[11]+=1
        elif s[v]=="n":
            l[12]+=1
        elif s[v]=="m":
            l[13]+=1
        elif s[v]=="o":
            l[14]+=1
        elif s[v]=="p":
            l[15]+=1
        elif s[v]=="q":
            l[16]+=1
        elif s[v]=="r":
            l[17]+=1
        elif s[v]=="s":
            l[18]+=1
        elif s[v]=="t":
            l[19]+=1
        elif s[v]=="u":
            l[20]+=1
        elif s[v]=="v":
            l[21]+=1
        elif s[v]=="w":
            l[22]+=1
        elif s[v]=="x":
            l[23]+=1
        elif s[v]=="y":
            l[24]+=1
        else:
            l[25]+=1
    m.append(l)
m.sort()
for k in range(1,n):
    if m[k]==m[k-1]:
        o[-1]+=1
    else:
        o.append(1)
for _ in range(len(o)):
    if o[_]==1:
        pass
    else:
        c=(o[_]*(o[_]-1))//2
        ans+=c
print(ans)

Fixed submission:
n=int(input())
d={}
ans=0
for i in range(n):
    s=sorted(list(input()))
    e=""
    for v in range(10):
        e+=s[v]
    if e in d:
        d[e]+=1
    else:
        d[e]=1
for _ in d:
    if d[_]==1:
        pass
    else:
        ans+=d[_]*(d[_]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
print("Bad" if ans==1 else "Good")


Fixed submission:
s=input()
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
        break
    else:
        ans=0
print("Bad" if ans==1 else "Good")
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
pop=0
i=0
while(pop<=x or i<n):
    pop+=l[i]
    ans+=1
    i+=1
print(ans)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=1
place=0
for i in l:
    place+=i
    if place>x:
        break
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
pop=0
i=0
while(pop<=x):
    pop+=l[i]
    i+=1
    ans+=1
print(ans)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=1
place=0
for i in l:
    place+=i
    if place>x:
        break
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

W,H,x,y=map(int,input().split())
l=[0,0]
if H/W==y/x or -H/W==(H-h)/x or (x==0 and y==H) or (x==0 and y==0) or (x==W and y==0) or (x==W and y==H):
    l.append(H*W/2)
v=min(x*H,(W-x)*H)
l.append(v)
h=min(y*W,(H-y)*W)
l.append(h)
l.sort()
if l[-1]==l[-2]:
    print(l[-1],1)
else:
    print(l[-1],0)

Fixed submission:
W,H,x,y=map(int,input().split())
print(W*H/2,1 if x==W/2 and y==H/2 else 0)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

W,H,x,y=map(int,input().split())
l=[0]
if H/W==y/x:
    l.append(H*W/2)
v=min(x*H,(W-x)*H)
l.append(v)
h=min(y*W,(H-y)*W)
l.append(h)
l.sort()
if l[-1]==l[-2]:
    print(l[-1],1)
else:
    print(l[-1],0)

Fixed submission:
W,H,x,y=map(int,input().split())
print(W*H/2,1 if x==W/2 and y==H/2 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
memo=[]
l,r=map(int,input().split())
for i in range(r-l+1):
    memo.append(l+i)
for v in range(m-1):
    memo1=[]
    l,r=map(int,input().split())
    for k in range(len(memo)):
        if l<=memo[k]<=r:
            memo1.append(memo[k])
    memo=memo1
print(len(memo))

Fixed submission:
n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
    l1,r1=map(int,input().split())
    l.append(l1)
    r.append(r1)
print(0 if min(r)-max(l)+1<0 else min(r)-max(l)+1)
Buggy python submission (verdict: Runtime Error):
l=[]
for i in range(5):
    l.append(int(input()))
indexn=10
indx=0
for v in range(5):
    if l[v]%10==0:
        pass
    else:
        if l[v]%10<indexn:
            indexn=l[v]%10
            indx=v
for k in range(5):
    if k!=indx:
        l[v]=((l[v]-1)//10+1)*10
    else:
        
print(sum(l))

Fixed submission:
l=[]
for i in range(5):
    l.append(int(input()))
indexn=10
indx=0
for v in range(5):
    if l[v]%10==0:
        pass
    else:
        if l[v]%10<indexn:
            indexn=l[v]%10
            indx=v
for k in range(5):
    l[k]=((l[k]-1)//10+1)*10
        
print(sum(l)-10+indexn)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=input()
for i in range(Q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=input()
for i in range(Q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=input()
for i in range(Q):
    num=0
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=input()
for i in range(Q):
    num=0
    l,r=map(int,input().split())
    while l<r:
        if s[l-1]+s[l]=="AC":
            num+=1
        l+=1
    print(num)

Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l={}
nedan=[]
ans=0
num=0
small=0
for i in range(n):
    kane,kazu=map(int,input().split())
    if kane in nedan:
        l[kane]+=kazu
    else:
        l[kane]=kane
    nedan.append(kane)
nedan.sort()
set(nedan)
while True:
    if num+l[nedan[small]]<m:
        ans+=nedan[small]*l[nedan[small]]
        num+=l[nedan[small]]
        small+=1
    else:
        ans+=(m-num)*nedan[small]
        break
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
money=0
bottle=0
for i in range(n):
    if bottle+l[i][1]<=m:
        bottle+=l[i][1]
        money+=l[i][0]*l[i][1]
    else:
        money+=l[i][0]*(m-bottle)
        break
print(money)
Buggy python submission (verdict: Runtime Error):
import functools
import math
n=int(input())
a=list(map(int,input().split()))
gcd=functools.reduce(math.gcd, a)
print(gcd)

Fixed submission:
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))

Buggy python submission (verdict: Runtime Error):
import functools
import math
n=int(input())
a=list(map(int,input().split()))
gcd = functools.reduce(math.gcd, a)
print(gcd)

Fixed submission:
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
set(a)
v=a[-1]
a[-1]=a[-1]%a[-2]
a.sort()
l=a[-1]
i=1
while i<=n:
    while v!=l:
        v=a[-1]
        a[-1]=a[-1]%a[-(i+1)]
        a.sort()
        l=a[-1]
    if a[-1]==0 or a[-1]==1:
        break
    i+=1
if a[-1]==0:
    print(v)
else:
    print(a[0])

Fixed submission:
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
v=a[-1]
a[-1]=a[-1]%a[-2]
a.sort()
l=a[-1]
while v!=l:
    a.sort()
    v=a[-1]
    a[-1]=a[-1]%a[-2]
    a.sort()
    l=a[-1]
if a[-1]==0:
    print(v)
else:
    print(a[-1])

Fixed submission:
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if a.count(a[0])==n:
    print(a[0])
else:
    a.sort()
    v=a[-1]
    a[-1]=a[-1]%a[-2]
    a.sort()
    l=a[-1]
    while v!=l:
        a.sort()
        v = a[-1]
        a[-1] = a[-1] % a[-2]
        a.sort()
        l = a[-1]
    if min(a)==0:
        print(v)
    else:
        print(min(a))

Fixed submission:
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
    print(max(x)-min(x))
elif m==1 or n>=m:
    print(0)
else:
    goukei=0
    l=[0]
    i=0
    x.sort()
    a=0
    b=0
    while i<m-1:
        a=x[i]
        b=x[i+1]
        goukei+=b-a
        l.append(b-a)
        i+=1
    for v in range(n-1):
        goukei-=max(l)
        l.remove(max(l))
    print(goukei)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
m=l[-1]
s=0
for i in range(n-1):
    s+=l[i]
print("Yes" if m<s else "No")
Buggy python submission (verdict: Runtime Error):
la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a-b)
while la!=[]:
    if max(kari)+min(kari)>0:
        tak+=la[kari.index(max(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
    else:
        tak+=la[kari.index(min(kari))]
        kari.remove(min(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    if la==[]:
        break
    if max(kari)+min(kari)>0:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    else:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
print(int(tak-ao))

Fixed submission:
la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
s=-1
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a+b)
    ao+=b
kari.sort()
if n%2==0:
    for v in range(int(n/2)):
        tak+=kari[s]
        s+=-2
else:
    for k in range(int(n/2)+1):
        tak+=kari[s]
        s+=-2
print(tak-ao)

Buggy python submission (verdict: Runtime Error):
la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a-b)
while la!=[]:
    if max(kari)+min(kari)>0:
        tak+=la[kari.index(max(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
    else:
        tak+=la[kari.index(min(kari))]
        kari.remove(min(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    if max(kari)+min(kari)>0:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    else:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
print(int(tak-ao))

Fixed submission:
la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
s=-1
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a+b)
    ao+=b
kari.sort()
if n%2==0:
    for v in range(int(n/2)):
        tak+=kari[s]
        s+=-2
else:
    for k in range(int(n/2)+1):
        tak+=kari[s]
        s+=-2
print(tak-ao)
Buggy python submission (verdict: Runtime Error):
import sys

s=input()
a,b,c,d,e,f,g=0
while s[a]!="k":
    a+=1
    if a==len(s):
        print("NO")
        sys.exit()
b=a+1
while s[b]!="e":
    b+=1
    if b==len(s):
        print("NO")
        sys.exit()
c=b+1
while s[c]!="y":
    c+=1
    if c==len(s):
        print("NO")
        sys.exit()
d=c+1
while s[d]!="e":
    d+=1
    if d==len(s):
        print("NO")
        sys.exit()
e=d+1
while s[e]!="n":
    e+=1
    if e==len(s):
        print("NO")
        sys.exit()
f=e+1
while s[f]!="c":
    f+=1
    if f==len(s):
        print("NO")
        sys.exit()
g=f+1
while s[g]!="e":
    g+=1
    if not "e" in s[g]:
        print("NO")
        sys.exit()
if s=="keyence":print("YES")
else:
    if b+g==c+f==d+e:
        print("YES")
    elif a==0 and b!=1 and(c==b+1 and d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c!=2 and(d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d!=3 and (e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e!=4 and (f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g==f+1:
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g!=6:
        print("YES")
    else:
        print("NO")

Fixed submission:
s=input()
if (s[:7]=="keyence" or s[:6]+s[-1:]=="keyence" or s[:5]+s[-2:]=="keyence" or s[:4]+s[-3:]=="keyence" or s[:3]+s[-4:]=="keyence" or s[:2]+s[-5:]=="keyence" or s[:1]+s[-6:]=="keyence" or s[-7]=="keyence"):
    print("YES")
else:
    print("NO")