Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
D1=[int(i) for i in input().split(" ")]

D2=[int(i) for i in input().split(" ")]

dts={

  "28":[2],

  "30":[4,6,9,11],

  "31":[1,3,5,7,8,10,12]

}

print(int(D1[0] in dts.get(str(D1[1]),[]))

Fixed submission:
try:

  D1=[int(i) for i in input().split(" ")]

  D2=[int(i) for i in input().split(" ")]

  dts={

    "28":[2],

    "30":[4,6,9,11],

    "31":[1,3,5,7,8,10,12]

  }

  print(int(D1[0] in dts.get(str(D1[1]),[])))

except:

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

ans_list = [0]*N+1
pen_num = 0
cor_num = 0

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      pen_num += 1
    elif(S_i == "AC"):
      cor_num += 1
      ans_list[p_i] = 1
      
print("{} {}".format(cor_num,pen_num))
  
  


Fixed submission:
import itertools
N, M = map(int, input().split())

ans_list = [0]*(N+1)
pen_list = [0]*(N+1)

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      a = pen_list[p_i]
      a += 1
      pen_list[p_i] = a
    elif(S_i == "AC"):
      ans_list[p_i] = 1

pen_lis_ans = list(itertools.compress(pen_list, ans_list))
cor_num = sum(ans_list)
pen_num = sum(pen_lis_ans)
                   
print("{} {}".format(cor_num,pen_num))

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

ans_list = [0]*N
pen_num = 0
cor_num = 0

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      pen_num += 1
    elif(S_i == "AC"):
      cor_num += 1
      ans_list[p_i] = 1
      
print("{} {}".format(cor_num,pen_num))
  
  


Fixed submission:
import itertools
N, M = map(int, input().split())

ans_list = [0]*(N+1)
pen_list = [0]*(N+1)

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      a = pen_list[p_i]
      a += 1
      pen_list[p_i] = a
    elif(S_i == "AC"):
      ans_list[p_i] = 1

pen_lis_ans = list(itertools.compress(pen_list, ans_list))
cor_num = sum(ans_list)
pen_num = sum(pen_lis_ans)
                   
print("{} {}".format(cor_num,pen_num))
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input.split())

if(500 * K >= X):
  print("Yes")
else:
  print("No")

Fixed submission:
K, X = map(int, input().split())
 
if(500 * K >= X):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split(" "))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
#print(math.gcd(a, b))
# 2

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a,b=map(int,input().split(" "))
print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
l=input()
if(l=="Sunny"):
    ans="Cloudy"
if(l=="Cloudy"):
    ans="Rainny"
if(l=="Rainny"):
    ans="Sunny"
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
l=input()
if(l=="Sunny"):
    ans="Cloudy"
if(l=="Cloudy"):
    ans="Rainy"
if(l=="Rainy"):
    ans="Sunny"
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
l=list(input())
ans="Yes"
for i in range(len(l)):
    if(i%2==0):
        if(l[i]=="L"):
            ans="No"
    else:
        if(l[i]=="R"):
            ans="No"
print(ans)# coding: utf-8
# Your code here!
l=list(input())
ans="Yes"
for i in range(len(l)):
    if(i%2==0):
        if(l[i]=="L"):
            ans="No"
    else:
        if(l[i]=="R"):
            ans="No"
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
l=list(input())
ans="Yes"
for i in range(len(l)):
    if(i%2==0):
        if(l[i]=="L"):
            ans="No"
    else:
        if(l[i]=="R"):
            ans="No"
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
x,n=map(int,input().split())
l=input().split(" ")
c=0
ans=0
for i in range(x):
    t=int(l[i])
    if(c>n):
        break
    c+=t
    ans+=1
   
print(ans)
        

Fixed submission:
# coding: utf-8
# Your code here!
x,a=map(int,input().split())
ans=0
if(x>=a):
    ans=10
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,m=map(int,input().split(" "))
mae=0
usiro=1000000000
for i in range(m):
    s,t=map(int,input().split(" "))
    if(mae<=s):
        mae=s
    if(usiro>=t):
        usiro=t
#print(mae,usiro)
ans=usiro-mae+1
if(ans<0):
    ans=0
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
n,ans=map(int,input().split(" "))
if(n<=12):
    ans/=2
if(n<6):
    ans=0
print(round(ans))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

a =input()
N=list(a)

count=[]
def search(x):
    n=len(N)
    if(x+1>=n):
        return 
    
    if(N[x]=="0" and N[x+1]=="1"):
        #print(N)
        del N[x]
        del N[x+1]
        #print(N)
        count.append(0)
        x=0
    if(N[x]=="1" and N[x+1]=="0"):
        #print(N)
        del N[x]
        del N[x+1]
        #print(N)
        count.append(0)
        x=0    
        
    search(x+1)
ans=search(0)
#print(N)
if(len(count)!=0):
    print(len(count)*2+2)
else:
    print(0)

Fixed submission:
# coding: utf-8
# Your code here
# coding: utf-8
# Your code here!

a =input()
N=list(a)
b=0
r=0
for i in N:
    if(i=="0"):
        b+=1
    else:
        r+=1
ans=r
if(r>b):
    ans=b
print(ans*2)
Buggy python submission (verdict: Runtime Error):
 = int(input())
mon =[int(i)for i in input().split()]

def gcd(x,y):
    if y ==0:
        return x
    else:
        return gcd(y,x%y)
mon.sort()
mini = mon[0]
for i in range(1,N):
    ans = gcd(mini,mon[i])
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
x=gcd(a[0],a[1])
for i in range(2,len(a)):
  x=gcd(x,a[i])
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

N = int(input())
mon = input().split(" ")
for i in range(N):
    a = int(mon[i])
    mon[i]=a
def gcd(x,y):
    if y ==0:
        return x
    else:
        return gcd(y,x%y)
for i in range(N):
    for m in range(N):
        if i !=m:
            k = gcd(mon[i],mon[m])
            mon[i] =k
            mon[m] = k

print(min(mon))

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
x=gcd(a[0],a[1])
for i in range(2,len(a)):
  x=gcd(x,a[i])
print(x)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
num =[]
ans =0
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,5):
    if num.count(i)==3:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")


Fixed submission:
# coding: utf-8
# Your code here!
N,K =map(int, input().split(" "))
ans =0
for i in range(1,N+1):
    if i%2==1:
        ans +=1
if ans>=K:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys
num =[]
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,4):
    if num.count(i)=3:
        print("NO")
        sys.exit()
print("YES")


Fixed submission:
# coding: utf-8
# Your code here!
num =[]
ans =0
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,5):

    if num.count(i)==3:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
import collections
A= int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
primelist=make_divisors(A)
S = primelist[-1]
G = int(A/S)
print((G-1)+(S-1))

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):
print((input()-2)*180)

Fixed submission:
a = int(input())
print((a-2)*180)
Buggy python submission (verdict: Runtime Error):
n=int(input())
i = 1
alllist = []
while i < n :
  a,b=map(str, input().split())
  c = [a ,int(b),i]
  alllist.append(c)
  i += 1
alllist.sort(key=lambda x:-x[1],reverse=True)
#print(alllist[0][2])
j = 0
while j < n :
  print(alllist[j][2])
  j += 1

Fixed submission:
n=int(input())
i = 1
alllist = []
while i < n+1 :
  a,b=map(str, input().split())
  c = [a ,int(b),i]
  alllist.append(c)
  i += 1
alllist.sort(key=lambda x:(x[0],-x[1]),reverse=True)
alllist.reverse()
j = 0
while j < n :
  print(alllist[j][2])
  j += 1

Buggy python submission (verdict: Runtime Error):
n=int(input())
i = 1
alllist = []
while i < n :
  a,b=map(str, input().split())
  c = [a ,int(b),i]
  alllist.append(c)
  i += 1
alllist.sort(key=lambda x:-x[1],reverse=True)
#print(alllist[0][2])
j = 0
while j < n :
  print(alllist[j-1][2])
  j += 1

Fixed submission:
n=int(input())
i = 1
alllist = []
while i < n+1 :
  a,b=map(str, input().split())
  c = [a ,int(b),i]
  alllist.append(c)
  i += 1
alllist.sort(key=lambda x:(x[0],-x[1]),reverse=True)
alllist.reverse()
j = 0
while j < n :
  print(alllist[j][2])
  j += 1
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
diff = []
for i in range(N):
    for j in range(i+1, N):
        diff.append((abs(ball[i][n]-ball[j][n]) for n in range(2)))
k = Counter(diff).most_common()[0][1]
print(max(1,N-1-k))


Fixed submission:
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
ball.sort(key=lambda x: x[1])
ball.sort()
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append([(ball[j][n]-ball[i][n]) for n in range(2)])
    k = Counter(map(tuple, diff)).most_common()[0][1]
#    print(diff)
    print(max(1,N-k))
Buggy python submission (verdict: Runtime Error):
A, P = map(int,input().split())
print((3A+P)//2)

Fixed submission:
A, P = map(int,input().split())
print((3*A+P)//2)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for j in range(M)]
K.sort()
K.sort(key=itemgetter(1))
#B_C = list(map(list, zip(*K)))
A.sort()

ans = 0
changed = []
for i in K[::-1]:
    changed += [i[1]]*i[0]
    if len(changed) < N:
        continue
    else:
        while(len(changed) > N):
            changed.pop()
        break

print(changed.__len__(),A.__len__())
for i in range(N):
    if changed[i] <= A[i]:
        SUM = sum(changed[:i]) + sum(A[i:])
        print(SUM)
        exit()
else:
    print(sum(changed))


Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for j in range(M)]
K.sort()
K.sort(key=itemgetter(1))
#B_C = list(map(list, zip(*K)))
A.sort()

changed = []
for i in K[::-1]:
    changed += [i[1]]*i[0]
    if len(changed) < N:
        continue
    else:
        while(len(changed) > N):
            changed.pop()
        break
if len(changed) < N:
    changed += [0]*(N-len(changed))
#print(changed.__len__(),A.__len__())
for i in range(N):
    if changed[i] <= A[i]:
        SUM = sum(changed[:i]) + sum(A[i:])
        print(SUM)
        exit()
else:
    print(sum(changed))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for j in range(M)]

K.sort()
K.sort(key=lambda x:x[1])
#B_C = list(map(list, zip(*K)))
A.sort()

ans = 0
changed = []
for i in K[::-1]:
    changed += [i[1]]*i[0]
    if len(changed) < N:
        continue
    else:
        while(len(changed) > N):
            changed.pop()
        break

#print(changed,A)
SUM = [sum(changed[:i+1] + A[i+1:]) for i in range(N-1)]
#print(SUM)
print(max(max(SUM), sum(A), sum(changed)))


Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for j in range(M)]
K.sort()
K.sort(key=itemgetter(1))
#B_C = list(map(list, zip(*K)))
A.sort()

changed = []
for i in K[::-1]:
    changed += [i[1]]*i[0]
    if len(changed) < N:
        continue
    else:
        while(len(changed) > N):
            changed.pop()
        break
if len(changed) < N:
    changed += [0]*(N-len(changed))
#print(changed.__len__(),A.__len__())
for i in range(N):
    if changed[i] <= A[i]:
        SUM = sum(changed[:i]) + sum(A[i:])
        print(SUM)
        exit()
else:
    print(sum(changed))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [int(input()) for _ in range(5)]

m = min(L)
print(4 + (L+m-1)//m)


Fixed submission:
N = int(input())
L = [int(input()) for _ in range(5)]

m = min(L)
print(4 + (N+m-1)//m)
Buggy python submission (verdict: Runtime Error):
N , Q = map(int, input().split())
S = input()
LR = [[int(i) for i in input().split()] for j in range(Q)]
T = list(S)
AC_list = []

for i in range(len(T)):
    if T[i] == "A" and T[i+1] == "C":
        AC_list.append(i)

for i in LR:
    n = len([k for k in AC_list if k>=i[0]-1 and k<i[1]-1])
    print(n)


Fixed submission:
N , Q = map(int, input().split())
S = input()
LR = [[int(i)-1 for i in input().split()] for j in range(Q)]
T = list(S)
ACtimes = [0] * len(T)

for i in range(1,len(T)):
    if T[i-1] == "A" and T[i] == "C":
        ACtimes[i] = ACtimes[i-1] + 1
    else:
        ACtimes[i] = ACtimes[i-1]

for k in LR:
    print(ACtimes[k[1]] - ACtimes[k[0]])

Buggy python submission (verdict: Time Limit Exceeded):
N , Q = map(int, input().split())
S = input()
LR = [[int(i) for i in input().split()] for j in range(Q)]
T = list(S)

for i in LR:
    ct = 0
    for k in range(i[0]-1, i[1]-1):
        if T[k] == "A" and T[k+1] == "C":
            ct += 1
    else:
        print(ct)



Fixed submission:
N , Q = map(int, input().split())
S = input()
LR = [[int(i)-1 for i in input().split()] for j in range(Q)]
T = list(S)
ACtimes = [0] * len(T)

for i in range(1,len(T)):
    if T[i-1] == "A" and T[i] == "C":
        ACtimes[i] = ACtimes[i-1] + 1
    else:
        ACtimes[i] = ACtimes[i-1]

for k in LR:
    print(ACtimes[k[1]] - ACtimes[k[0]])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  S = set(A[i], B[i], C[i])
  ans += S.__len__() - 1

print(ans)

Fixed submission:
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  S = {A[i], B[i], C[i]}
  ans += S.__len__() - 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
SORT = sorted(YL)

for i in range(1,N+1):
    ct = 1
    for j in SORT:
        if j[0] == i:
            j.append('{:0=6}'.format(i))
            j.append('{:0=6}'.format(ct))
            ct += 1
        else:
            continue
SORT.sort(key=lambda x:x[2])
for i in SORT:
    print('%s%s' % (i[3], i[4]))


Fixed submission:
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
YL.sort()
ct = 1
for i in range(M):
    if YL[i][0] != YL[i-1][0]:
        ct = 1
    YL[i].append('{:0=6}'.format(YL[i][0]))
    YL[i].append('{:0=6}'.format(ct))
    ct += 1
YL.sort(key=lambda x:x[2])
for i in YL:
    print('%s%s' % (i[3], i[4]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
SORT = sorted(YL)

for i in range(1,N+1):
    ct = 1
    for j in SORT:
        if j[0] == i:
            j.append('{:0=6}'.format(i))
            j.append('{:0=6}'.format(ct))
            ct += 1
        else:
            continue
SORT.sort(key=lambda x:x[2])
for i in SORT:
    print('%s%s' % (i[3], i[4]))


Fixed submission:
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
YL.sort()
ct = 1
for i in range(M):
    if YL[i][0] != YL[i-1][0]:
        ct = 1
    YL[i].append('{:0=6}'.format(YL[i][0]))
    YL[i].append('{:0=6}'.format(ct))
    ct += 1
YL.sort(key=lambda x:x[2])
for i in YL:
    print('%s%s' % (i[3], i[4]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
SORT = sorted(YL)

for i in range(1,N+1):
    ct = 1
    for j in SORT:
        if j[0] == i:
            j.append('{:0=6}'.format(i))
            j.append('{:0=6}'.format(ct))
            ct += 1
        else:
            continue
SORT.sort(key=lambda x:x[2])
for i in SORT:
    print('%s%s' % (i[3], i[4]))


Fixed submission:
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
YL.sort()
ct = 1
for i in range(M):
    if YL[i][0] != YL[i-1][0]:
        ct = 1
    YL[i].append('{:0=6}'.format(YL[i][0]))
    YL[i].append('{:0=6}'.format(ct))
    ct += 1
YL.sort(key=lambda x:x[2])
for i in YL:
    print('%s%s' % (i[3], i[4]))
Buggy python submission (verdict: Runtime Error):
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-1] + A[N-P2] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1+S)
    else:
        print(S2+S)


Fixed submission:
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-2] + A[N-P2-1] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1+S)
    else:
        print(S2+S)

Buggy python submission (verdict: Runtime Error):
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-1] + A[N-P2] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1)
    else:
        print(S2)


Fixed submission:
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-2] + A[N-P2-1] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1+S)
    else:
        print(S2+S)

Buggy python submission (verdict: Runtime Error):
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
elif N % 4 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += 2 * A[N-1-P2] - A[P2] - A[P2+1]
else:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[N-P2-1] + A[N-P2] - 2 * A[P2]
print(S)


Fixed submission:
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-2] + A[N-P2-1] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1+S)
    else:
        print(S2+S)
Buggy python submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
L_X = [int(i) for i in input().split()]
L_Y = [int(i) for i in input().split()]

S = set(L_X, )
S.add(L_Y, )
if X in S or Y in S:
    print("War")
elif max(L_X) < min(L_Y) and X < min(L_Y) and max(L_X) < Y:
    print("No War")
else:
    print("War")


Fixed submission:
N, M, X, Y = map(int, input().split())
L_X = [int(i) for i in input().split()]
L_Y = [int(i) for i in input().split()]

if max(L_X) < min(L_Y) and X < min(L_Y) and max(L_X) < Y:
    print("No War")
else:
    print("War")
Buggy python submission (verdict: Runtime Error):
ch_S = input()
ch_T = input()

ind_S = []
ind_T = []
for i in list("abcdefghijklmnopqrstuvwxyz"):
    L = [ch_S.find(i)]
    ind_S.append(L, )
    R = [ch_T.find(i)]
    ind_T.append(R,)

if set(ind_S) == set(ind_T):
    print("Yes")
else:
    print("No")


Fixed submission:
S = input()
T = input()
ls = [0]*26
lt = [0]*26
al = [chr(ord('a')+i) for i in range(26)]
for i in range(S.__len__()):
    si = al.index(S[i])
    ti = al.index(T[i])
    ls[si] += 1
    lt[ti] += 1
ls.sort()
lt.sort()
if ls == lt:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
l = [int(s) for s in S if s != "1"]
print(l[0])

Fixed submission:
S = input()
K = int(input())
l = [int(i) for i in S]
for i in range(min(S.__len__(), K)):
    if l[i] != 1:
        print(l[i])
        break
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i input().split()]
print(sum(a) - N)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]

print(sum(a) - N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        t = max(t, ST[j][1])
        while (t-ST[j][1])%ST[j][2] != 0:
            t += 1
        else:
            t += ST[j][0]
    else:
        print(t)
print(0)


Fixed submission:
import math
N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        t = max(t, ST[j][1])
        k = math.ceil((t-ST[j][1])/ST[j][2])
        t = k * ST[j][2] + ST[j][1] + ST[j][0]
    else:
        print(t)
print(0)
Buggy python submission (verdict: Runtime Error):
S = input()
S.set()
alp = [chr(ord('a') + i) for i in range(26)]
for i in alp:
  if i not in S:
    print(i)
    break

Fixed submission:
S = input()
S = set(S)
alp = [chr(ord('a') + i) for i in range(26)]
for i in alp:
  if i not in S:
    print(i)
    break
else:
  print("None")
Buggy python submission (verdict: Runtime Error):
S = input()
l = S.__len__()
print('%s%s%s' % [S[0], l-2, S[l-1]] 

Fixed submission:
S = input()
l = S.__len__()
print('%s%s%s' % (S[0], l-2, S[l-1]))
Buggy python submission (verdict: Runtime Error):
L = [int(i) for i in input().split()]
L.sorted()
print(L[0] + L[1])

Fixed submission:
L = [int(i) for i in input().split()]
L.sort()
print(L[0] + L[1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = 0
if N > M//2:
  print(M//2)
else:
  p = M - 2*N
  print(N + p//4

Fixed submission:
N, M = map(int, input().split())
ans = 0
if N > M//2:
  print(M//2)
else:
  p = M - 2*N
  print(N + p//4)