Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
x = C - A + B
if X < 0:
    X = 0
print(X)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
x = C - A + B
if X < 0:X = 0
print(X)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
x = C-A+B
if X < 0:
X = 0
print(X)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
x = C-A+B
print(X)
if X < 0
print(0)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
x = C-A+B
print(X)
if X < 0
print(X)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input.split)
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int(),input().split())
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C=map(int(),input().split())
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input(),split())
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C=map(int(),input(),split())
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C=input()
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)

Buggy python submission (verdict: Runtime Error):
A,B,C=(int,input().split()))
print(C-A+B)

Fixed submission:
A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
K = (A+B)//2
if type(K) is int:
  print(K)
else:
  print("Impossible")

Fixed submission:
A,B = map(int,input().split())
K = (A+B)
if K%2 == 0 :
  print(K//2)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
K = (A+B)//2
if type(K) is int:
  print(K)
else:
  print("Impossible")

Fixed submission:
A,B = map(int,input().split())
K = (A+B)
if K%2 == 0 :
  print(K//2)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
A = input(a)
B = input(b)
K == (A+B)/2
if type(K) is int:       
    print(K)
else:
    print("Impossible")

Fixed submission:
A,B = map(int,input().split())
K = (A+B)
if K%2 == 0 :
  print(K//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N=int(input())
cardlist=list(map(int,input().split())).sort(reverse=True)
Alist=cardlist[0:,2]
Blist=cardlist[1:,2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)

Fixed submission:
N=int(input())
cardmap=map(int,input().split())
card=list(cardmap)
card.sort(reverse=True)
Alist=card[0::2]
Blist=card[1::2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)
Buggy python submission (verdict: Runtime Error):
s,t,u=map(int,input().split(','))
print(s,t,u)

Fixed submission:
s,t,u=map(str,input().split(','))
print(s,t,u)

Buggy python submission (verdict: Runtime Error):
s,t,u=map(int,input().split(''))
print(s,t,u)

Fixed submission:
s,t,u=map(str,input().split(','))
print(s,t,u)
Buggy python submission (verdict: Runtime Error):
N,K,X,Y=map(int,input().split())
print(X*N if N<=K else X*K+Y*(N-K))



Fixed submission:
N,K,X,Y=[int(input()) for i in range(4)]
print(X*N if N<=K else X*K+Y*(N-K))
Buggy python submission (verdict: Runtime Error):
price = int(input())
x = price // 100
y = price % 100
if y / x <= 5:
	val = 1
else:
  	val = 0
print(val)

Fixed submission:
price = int(input())
x = price // 100
y = price % 100
if price < 100:
  	val = 0
elif y / x <= 5:
	val = 1
else:
  	val = 0
print(val)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = "No"

for x in range(1,10):
	if n/x in [1,2,3,4,5,6,7,8,9]:
		ans = "Yes"

print(ans)

Fixed submission:
a, b = map(int,input().split())
if(a > 9 or b > 9):
	print("-1")
else:
	print(a * b)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
a = []
for x in range(n):
    a.append(input())
a.sort()
print("".join(a))



Fixed submission:
a = sorted(list(map(int,input().split())))
if a == [5,5,7]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
n, l = map(int,input().split())
a = []
for x in range(n):
    a.append(input())
a.sort()
print("".join(a))

Fixed submission:
a = sorted(list(map(int,input().split())))
if a == [5,5,7]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
n, l = map(int,input().split())
a = []
for x in range(n):
    a.append(input())
a.sort()
print(""join(a))

Fixed submission:
a = sorted(list(map(int,input().split())))
if a == [5,5,7]:
	print("YES")
else:
	print("NO")

Buggy python submission (verdict: Runtime Error):
n, l = map(int,input().split())
a = []
for x in range(n):
    a.append(input())
a.sorted()
print(''.join(a))

Fixed submission:
a = sorted(list(map(int,input().split())))
if a == [5,5,7]:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
import sys
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
if m > sum(np.ceil(np.log2(a))):
  print(0)
  sys.exit()
used = 0
while used < m:
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
used = 0
zero = np.zeros(a.shape)
while used < m:
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
used = 0
zero = np.zeros(a.shape)
while used < m and not np.all(a==0):
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

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

used = 0
for _ in range(m):
  tmp = heapq.heappop(a)
  heapq.heappush(a, -1*(-tmp//2))
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
import sys
import collections
w,h,x,y = map(int, input().split())

if (x,y) in [(w,0), (0,h), (0,0), (w,h)] or x/w+y/h==1 or y/x==h/w:
    print(w*h/2, 0)
    sys.exit()

s1 = min(x*h, (w-x)*h)
s2 = min(y*w, (h-y)*w)

if s1==s2:
    print(s1, 1)
else:
    print(max(s1,s2), 0)

Fixed submission:
w,h,x,y = map(int, input().split())
print(w*h/2, int(2*x==w and 2*y==h))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
x=[(i,i%10) for i in [a,b,c,d,e] if i%10!=0]
y=[i for i in [a,b,c,d,e] if i%10==0]
x=sorted(x,key=lambda x:x[1])
ans = sum(y)
ans += sum((i[0]//10+1)*10 for i in x[1:])
ans+=x[0][0]
print(ans)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
x=[(i,i%10) for i in [a,b,c,d,e] if i%10!=0]
y=[i for i in [a,b,c,d,e] if i%10==0]
x=sorted(x,key=lambda x:x[1])
ans = sum(y)
if len(x)==0:
  print(ans)
else:
  ans += sum((i[0]//10+1)*10 for i in x[1:])
  ans+=x[0][0]
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re
import numpy as np
n,q=map(int,input().split())
s=input()
a=np.zeros(n+1,dtype=int)
for m in re.finditer("AC", s):
  a[m.start()+2:]+=1

for _ in range(q):
  l,r=map(int,input().split())
  print(a[r]-a[l])


Fixed submission:
import re
import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=input()
a=[0]*(n+1)
tmp=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    tmp+=1
  a[i+2]=tmp

for _ in range(q):
  l,r=map(int,input().split())
  print(a[r]-a[l])

Buggy python submission (verdict: Time Limit Exceeded):
import re
n,q=map(int,input().split())
s=input()
a=[m.span() for m in re.finditer("AC", s)]

for _ in range(q):
  l,r=map(int,input().split())
  ans=sum(1 for x in a if l-1<=x[0] and x[1]<=r)
  print(ans)


Fixed submission:
import re
import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=input()
a=[0]*(n+1)
tmp=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    tmp+=1
  a[i+2]=tmp

for _ in range(q):
  l,r=map(int,input().split())
  print(a[r]-a[l])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools
n = int(input())
s = list(input())
count = collections.Counter(s).most_common()

ans = 0
for p in itertools.product([0,1],repeat=len(count)):
  tmp =1
  for i,x in enumerate(p):
    tmp = tmp*count[i][1]**x
  ans += tmp
print((ans-1)%(10**9+7))

Fixed submission:
import collections
n = int(input())
s = list(input())
count = collections.Counter(s).most_common()
ans = 1
for x in count:
  ans = ans*(x[1]+1)
print((ans-1)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  if b-a<10**7:
    for i in range(a+1,b+1):
      ans = ans^i
    print(ans)
  else:
    if a%2==0:
      if (b-a)%4==1:
        print(1)
      elif (b-a)%4==2:
        print(b+1)
      elif (b-a)%4==3:
        print(0)
      else:
        print(b)
    else:
      elif (b-a)%4==1:
        print(a^b)
      elif (b-a)%4==2:
        print(a-1)
      elif (b-a)%4==3:
        print((a-1)^b)
      else:
        print(a)

Fixed submission:
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  if b-a<10**7:
    for i in range(a+1,b+1):
      ans = ans^i
    print(ans)
  else:
    if a%2==0:
      if (b-a)%4==1:
        print(1)
      elif (b-a)%4==2:
        print(b+1)
      elif (b-a)%4==3:
        print(0)
      else:
        print(b)
    else:
      if (b-a)%4==1:
        print(a^b)
      elif (b-a)%4==2:
        print(a-1)
      elif (b-a)%4==3:
        print((a-1)^b)
      else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  for i in range(a+1,b+1):
    ans = ans^i
  print(ans)

Fixed submission:
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  if b-a<10**7:
    for i in range(a+1,b+1):
      ans = ans^i
    print(ans)
  else:
    if a%2==0:
      if (b-a)%4==1:
        print(1)
      elif (b-a)%4==2:
        print(b+1)
      elif (b-a)%4==3:
        print(0)
      else:
        print(b)
    else:
      if (b-a)%4==1:
        print(a^b)
      elif (b-a)%4==2:
        print(a-1)
      elif (b-a)%4==3:
        print((a-1)^b)
      else:
        print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import re
s = input()
ans = 0
while True:
  st1 = re.split("10|01",s)
  if len(st1)==1:
    break
  ans += len(st1)-1
  s = "".join(st1)
print(ans*2)

Fixed submission:
a,b=0,0
for s in input():
  if s=="0": a+=1
  else: b+=1
print(min(a,b)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while True:
  st1 = s.split("01")
  st2 = ("".join(st1)).split("10")
  if len(st1)==1 and len(st2)==1:
    break
  ans += len(st1)-1+len(st2)-1
  s = "".join(st2)
print(ans*2)

Fixed submission:
a,b=0,0
for s in input():
  if s=="0": a+=1
  else: b+=1
print(min(a,b)*2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def main():
    n,m = map(int, input().split())

    if n >= m:
        print(0)
        sys.exit()

    x = sorted(list(map(int, input().split())))
    if n==1:
        print(x[-1]-x[0])
        sys.exit()

    dp = [[x[-1]-x[0]]*(n) for _ in range(m)]
    for i in range(1,m):
        for j in range(n-2, -1, -1):
            dp[i][j] = min(dp[i-1][j], dp[i-1][j+1]-(x[i]-x[i-1]))
    print(dp[m-1][0])

if __name__=="__main__":
    main()

Fixed submission:
import sys
def main():
    n,m = map(int, input().split())

    if n >= m:
        print(0)
        sys.exit()

    x = sorted(list(map(int, input().split())))
    y = sorted([x[i]-x[i-1] for i in range(m-1,0,-1)])[::-1]
    s = sum(y)

    print(s-sum(y[:n-1]))
    
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
print('second' if all(a[i] % 2 == 0 for i in range(N)) else 'first')

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
print('second' if all(a[i] % 2 == 0 for i in range(n)) else 'first')
Buggy python submission (verdict: Runtime Error):
def main():
    n,x = map(int, input().split())
    a = "P"
    for i in range(n):
        a = "B" + a + "P" + a + "B"
    c = 0
    for s in a[:x]:
        if s == "P":
            c+=1
    print(c)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
def qwe(n,x,ans):
    n1 = "BPPPB"
    n2 = "BBPPPBPBPPPBB"
    if n==1:
        for s in n1:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()
    else:
        for s in n2:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()

def main():
    n,x = map(int, input().split())
    if n<=2:
        qwe(n,x,0)
    a = [1]
    b = [1]
    for i in range(n-1):
        a.append(2*a[-1]+3)
        b.append(2*b[-1]+1)
    ans = 0
    if x== 2*a[n-1]+3:
        print(2*b[n-1]+1)
        sys.exit()
    elif x==2*a[n-1]+2:
        print(2*b[n-1]+1)
        sys.exit()
    elif x == a[n-1]+2:
        print(b[n-1]+1)
        sys.exit()
    elif x== a[n-1]+1:
        print(b[n-1])
        sys.exit()
    elif x > a[n-1]+2:
        ans += b[n-1]+1
        x -= a[n-1]+2
        n = n-1
    else:
        x -=1
        n = n-1
    while n>2 or x > 0:
        if x== 2*a[n-1]+3:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        elif x==2*a[n-1]+2:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        if x == a[n-1]+2:
            ans += b[n-1]+1
            print(ans)
            sys.exit()
        elif x== a[n-1]+1:
            ans+=b[n-1]
            print(ans)
            sys.exit()
        elif x > a[n-1]+2:
            ans += b[n-1]+1
            x -= a[n-1]+2
            n = n-1
        else:
            x -=1
            n = n-1
    if x==0:
        print(ans)
        sys.exit()
    qwe(n,x,ans)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    x = [sum(a[i:j+1]) for i in range(n) for j in range(i,n)]
    x.sort()
    x = x[::-1]
    ans = []
    for ls in itertools.combinations(range(k**2), k):
        y = x[ls[0]]
        for i in ls[1:]:
            y = y & x[i]
        ans.append(y)
    print(max(ans))
    # for i in range(k-1):
    #     ans = ans & x[i+1]
    # print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import itertools
import numpy as np
def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    x = [sum(a[i:j+1]) for i in range(n) for j in range(i,n)]
    x.sort()
    x = x[::-1]

    MAX = x[0]
    two = 1
    POW = 1
    while(MAX>=two*2):
        two*=2
        POW+=1

#MAXBITソート
    for p in range(POW)[::-1]:
        C = list(filter(lambda y:y>=two,x))
        if len(C)>=k:
            break
        else:
            two//=2

    POW = p+1

    for p in range(POW):
        D = list(filter(lambda x:(x//two)%2==1,C))
        LEN = len(D)
        if LEN>=k:
            C = D[:]
            if LEN==k:break
        two//=2

    ans = C[0]
    for c in C[1:k]:
        ans &= c

    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import collections
n,k = map(int, input().split())
a = collections.deque(list(map(int, input().split())))

ans = sum(a)
for i in range(k-1):
    if a[0] >= a[-1]:
        a.pop()
        ans = ans & sum(a)
    else:
        a.popleft()
        ans = ans & sum(a)
print(ans)

Fixed submission:
import itertools
import numpy as np
def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    x = [sum(a[i:j+1]) for i in range(n) for j in range(i,n)]
    x.sort()
    x = x[::-1]

    MAX = x[0]
    two = 1
    POW = 1
    while(MAX>=two*2):
        two*=2
        POW+=1

#MAXBITソート
    for p in range(POW)[::-1]:
        C = list(filter(lambda y:y>=two,x))
        if len(C)>=k:
            break
        else:
            two//=2

    POW = p+1

    for p in range(POW):
        D = list(filter(lambda x:(x//two)%2==1,C))
        LEN = len(D)
        if LEN>=k:
            C = D[:]
            if LEN==k:break
        two//=2

    ans = C[0]
    for c in C[1:k]:
        ans &= c

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k = map(int,input().split())
if k%2!=0:
  ans = len(list(itertools.product(range(1,n//k+1),repeat=3)))
  print(ans)
else:
  ans = len(list(itertools.product(range(1,n//k+1),repeat=3))) + len(list(itertools.product(range(1,(2*n)//k-n//k+1),repeat=3)))
  print(ans)

Fixed submission:
import itertools
n,k = map(int,input().split())
if k%2!=0:
  ans = (n//k)**3
  print(ans)
else:
  ans = (n//k)**3 + ((2*n)//k - n//k)**3
  print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()

if a[0]=="A":
  if a[2:-1].count("C")==1:
    b,c = a[2:-2].split("C")
    q = b=="" or b.islower()
    r = c=="" or c.islower()
    if a[1].islower() and q and r:
      print("AC")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")

Fixed submission:
a = input()

if a[0]=="A":
  if a[2:-1].count("C")==1:
    s = a[2:-1].replace("C","") + a[-1]
    if a[1].islower() and s.islower():
      print("AC")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
xs,ys,zs = [], [], []
for _ in range(n):
  a,b,c = map(int, input().split())
  xs.append(a)
  ys.append(b)
  zs.append(c)

ans = 0
for com in itertools.combinations(range(n), m):
  x = sum(xs[c] for c in com)
  y = sum(ys[c] for c in com)
  z = sum(zs[c] for c in com)
  ans = max(abs(x)+abs(y)+abs(z),ans)
print(ans)

Fixed submission:
from operator import itemgetter
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
xs = []
for _ in range(n):
  x,y,z = map(int, input().split())
  xs.append([x, y, z, x+y+z, x+y-z, x-y+z, x-y-z, -x+y+z, -x+y-z, -x-y+z, -x-y-z])

ans = 0
xs.sort(key=itemgetter(3))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(4))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(5))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(6))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(7))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(8))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(9))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

xs.sort(key=itemgetter(10))
tot = abs(sum(xs[i][0] for i in range(m))) + abs(sum(xs[i][1] for i in range(m))) + abs(sum(xs[i][2] for i in range(m)))
ans = max(ans, tot)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
s = np.array([True if i=='E' else False for i in input()])
w = 0
e = np.sum(s[1:])
ans = w+e
for i in range(1,n):
  w = w + (not s[i-1])
  e = e - s[i]
  ans = min(ans,w+e)
print(ans)

Fixed submission:
import numpy as np
n = int(input())
s = np.array([True if i=='E' else False for i in input()])
t = np.array([False if i else True for i in s])
t = np.cumsum(t)
t = np.hstack(([0], t[1:]))
s = np.cumsum(s[::-1])[::-1]
s = np.hstack((s[1:], [0]))
print(np.min(s+t))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
import sys
input = sys.stdin.readline

n,c = map(int,input().split())
x1,v1 = [0],[0]
x2,v2 = [],[]
for _ in range(n):
  a,b = map(int, input().split())
  x1.append(a)
  x2 = [c-a] + x2
  v1.append(b)
  v2 = [b] + v2
x2 = [0] + x2
v2 = [0] + v2

v1, v2 = list(accumulate(v1)), list(accumulate(v2))

f1 = [v1[i] - x1[i] for i in range(n+1)]
f2 = [v2[i] - x2[i] for i in range(n+1)]
g1,x1_ = f1[0],x1[0]
g2,x2_ = f2[0],x2[0]
val = max(v1[n]-x1[n] + g2 - min(x1[n],x2_), v2[n]-x2[n] + g1 - min(x2[n],x1_))
for i in range(1,n+1):
  if g1<f1[i]:
	  g1,x1_ = f1[i], x1[i]
  if g2<f2[i]:
	  g2,x2_ = f2[i], x2[i]
  val = max(val, v1[n-i]-x1[n-i] + g2 - min(x1[n-i],x2_), v2[n-i]-x2[n-i] + g1 - min(x2[n-i],x1_))

print(val)

Fixed submission:
s = input()
print(700+100*sum([1 for x in s if x=='o']))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    x = list(map(int,input().split()))

    a = x[1:]
    a.sort()
    print(a[n//2-1])

    for i in range(1,n-1):
        a = x[:i] + x[i+1:]
        a.sort()
        print(a[n//2-1])

    a = x[:n-1]
    a.sort()
    print(a[n//2-1])

if __name__ == "__main__":
    main()

Fixed submission:
import copy
def main():
    n = int(input())
    x = list(map(int,input().split()))

    a = copy.deepcopy(x)
    a.sort()
    a1 = a[(n-1)//2]
    a2 = a[(n+1)//2]

    for i in range(0,n):
        if x[i]<=a1:
            print(a2)
        else:
            print(a1)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ab = [abs(a[0]) if i==0 else abs(a[-1]) if i==n else abs(a[i]-a[i-1]) for i in range(n+1)]

for i in range(n):
    if i==0:
        print(sum(ab) - abs(a[i]-a[i+1])-abs(a[i])+abs(a[i+1]))
    elif i==n-1:
        print(sum(ab) - abs(a[i-1]-a[i])-abs(a[i])+abs(a[i-1]))
    else:
        print(sum(ab) - abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ab = abs(a[0])+abs(a[-1])
    for i in range(n-1):
        ab += abs(a[i]-a[i+1])

    for i in range(n):
        if i==0:
            print(ab - abs(a[i]-a[i+1])-abs(a[i])+abs(a[i+1]))
        elif i==n-1:
            print(ab - abs(a[i-1]-a[i])-abs(a[i])+abs(a[i-1]))
        else:
            print(ab - abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))

if __name__ == "__main__":
    main()