Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = []
for i in Alist[:k]:
    for j in Blist[:k]:
        ABlist.append(i + j)

ABlist.sort(reverse=True)

ABClist = []
for i in ABlist[:k]:
    for j in Clist[:k]:
        ABClist.append(i + j)

ABClist.sort(reverse=True)

for i in range(k):
    print(ABClist[i])


Fixed submission:
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = [i + j for i in Alist[:k] for j in Blist[:k]]

ABlist.sort(reverse=True)

ABClist = [l + m for l in ABlist[:k] for m in Clist[:k]]

ABClist.sort(reverse=True)

print(*ABClist[:k], sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = []
for i in Alist:
    for j in Blist:
        ABlist.append(i + j)

ABlist.sort(reverse=True)

if len(ABlist) > 3000:
    ABlist = ABlist[0:3000]

ABClist = []
for i in ABlist:
    for j in Clist:
        ABClist.append(i + j)

ABClist.sort(reverse=True)

for i in range(k):
    print(ABClist[i])


Fixed submission:
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = [i + j for i in Alist[:k] for j in Blist[:k]]

ABlist.sort(reverse=True)

ABClist = [l + m for l in ABlist[:k] for m in Clist[:k]]

ABClist.sort(reverse=True)

print(*ABClist[:k], sep = '\n')
Buggy python submission (verdict: Runtime Error):
def main():
    if(1 <= b and b <= a and a <= 20 and 1 <= c and c <= 20): 
        i = list(map(int, input().split()))
        a = i[0]
        b = i[1]
        c = i[2]

        

        k = c - a + b

        print(k)


if __name__ == "__main__":
    main()


Fixed submission:
def main():

    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]

    if  not (1 <= b and b <= a and a <= 20 and 1 <= c and c <= 20):      
        return

    if c >= a - b:
        k = c - a + b
    else:
        k = 0

    print(k)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if not (1 <= n and n <= 10**5):
        return

    num = 0
    for j in range(n):
        if(len(n) % 2 != 0):
            num += 1

    print(num)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if not (1 <= n and n <= 10**5):
        return

    num = 0
    for j in range(n):
        if(len(str(j+1)) % 2 != 0):
            num += 1

    print(num)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if n < 100 or 999 < n or isinstance(n, int) == False:
        return

    if(str(n[0]) == str(n[2])):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if n < 100 or 999 < n or isinstance(n, int) == False:
        return

    if(str(n)[0] == str(n)[2]):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return

    alice = b - a
    bob = d -c

    if(b <= c or c < b):
        print(0)
    elif(c < b and b < d):
        print(b - c)
    elif(a < c and d < b):
        print(d - c)
    elif(a < d and d < b):
        print(d - a)
    elif(c < a and b < d):
        print(b - a)


if __name__ == "__main__":
    main(

Fixed submission:
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return
    if not (isinstance(a, int) and isinstance(b, int) and isinstance(c, int) and isinstance(d, int)):
        return
    
    if(b <= c or d <= a):
        print(0)
    elif(a <= c and c < b and b <= d):
        print(b - c)
    elif(c <= a and a < d and d <= b):
        print(d - a)
    elif(a <= c and d <= b):
        print(d - c)
    elif(c <= a and b <= d):
        print(b - a)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def main():
    n = int(input())  #nは入力回数
    t = [int(input()) for _ in range(n)]

    if not (1 <= n and n <= 100 and isinstance(n, int)):
        return
    for i in t:
        if not (1 <= i and i <= 10**18 and isinstance(i, int)):
            return

    k = lcm_list(t)
    if k <= 10**18:
        print(k)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

if __name__ == "__main__":
    main()

Fixed submission:
import fractions

def main():
    n = int(input())  #nは入力回数
    t = [int(input()) for _ in range(n)]

    if not (1 <= n and n <= 100 and isinstance(n, int)):
        return
    for i in t:
        if not (1 <= i and i <= 10**18 and isinstance(i, int)):
            return

    k = t[0]
    for i in range(1, n):
        k = k * t[i] // fractions.gcd(k, t[i])

    if k <= 10**18:
        print(k)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def main():
    n = int(input())  #nは入力回数
    t = [int(input()) for _ in range(n)]

    if not (1 <= n and n <= 100 and isinstance(n, int)):
        return
    for i in t:
        if not (1 <= i and i <= 10**18 and isinstance(i, int)):
            return

    k = lcm_list(t)
    if k <= 10**18:
        print(k)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

if __name__ == "__main__":
    main()

Fixed submission:
import fractions

def main():
    n = int(input())  #nは入力回数
    t = [int(input()) for _ in range(n)]

    if not (1 <= n and n <= 100 and isinstance(n, int)):
        return
    for i in t:
        if not (1 <= i and i <= 10**18 and isinstance(i, int)):
            return

    k = t[0]
    for i in range(1, n):
        k = k * t[i] // fractions.gcd(k, t[i])

    if k <= 10**18:
        print(k)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
s=input()   
if s[0]==s[1]:
	print("Bad")
elif s[1]==s[2]:
	print("Bad")
elif s[2]==s[3]:
	print("Bad")
else:
	print(good)

Fixed submission:
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
	print("Bad")
else:
	print("Good")

Buggy python submission (verdict: Runtime Error):
s=input()
if s[1:]==s[1:2]:
    print("Bad")
elif s[1:2]==s[2:3]:
    print("Bad")
elif s[2:3]==s[3:4]:
    print("Bad")
else:
    print(good)


Fixed submission:
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
	print("Bad")
else:
	print("Good")
Buggy python submission (verdict: Runtime Error):
s,t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
    print("YES")
else:
    print("NO")

Fixed submission:
s=input()
t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
s,t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]=t[0]:
    print("YES")
else:
    print("NO")

Fixed submission:
s=input()
t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
dp=[N]*(N+1)
#dp[i];=i個目まで選んで交換したときの最大
C=[B[i]-A[i] for i in range(3)]
for i in range(N):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(3):
        if i+1-A[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-A[j]]+C[j])
M=dp[N]
dp=[0]*(M+1)
C=[A[i]-B[i] for i in range(3) if A[i]-B[i]>=0]
for i in range(M):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(len(C)):
        if i+1-B[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-B[j]]+C[j])
print(M+dp[M])


Fixed submission:
N,K=map(int,input().split())
if K==1:
    print(0)
else:
    print(N-K)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
N=int(input())
A=list(map(int,input().split()))
K=deepcopy(A)
A.sort()
ans=10**(-20)
S=sum(A)
for i in range(N-1):
    S=S-A[i]+(-A[i])
    if ans<S:
        ans=S
        j=i
print(ans)
for i in range(j+1,N-1):
    print(A[0],A[i])
    A[0]-=A[i]
print(A[N-1],A[0])


Fixed submission:
from copy import deepcopy
N=int(input())
A=list(map(int,input().split()))
if N==2:
    print(max(A[0]-A[1],A[1],A[0]))
    print(max(A[0],A[1]),min(A[0],A[1]))
    quit()
A.sort()
ans=10**(-50)
S=sum(A)
for i in range(N-1):
    S=S-A[i]+(-A[i])
    if ans<S:
        ans=S
        j=i
print(ans)
for i in range(j+1,N-1):
    print(A[0],A[i])
    A[0]-=A[i]
for i in range(j+1):
    print(A[N-1],A[i])
    A[N-1]-=A[i]
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
dp=[N]*(N+1)
#dp[i];=i個目まで選んで交換したときの最大
C=[B[i]-A[i] for i in range(3)]
for i in range(N):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(3):
        if i+1-A[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-A[j]]+C[j])
M=dp[N]
dp=[M]*(M+1)
C=[A[i]-B[i] for i in range(3)]
for i in range(M):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(3):
        if i+1-B[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-B[j]]+C[j])
print(dp[M])


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
dp=[N]*(N+1)
#dp[i];=i個目まで選んで交換したときの最大
C=[B[i]-A[i] for i in range(3)]
for i in range(N):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(3):
        if i+1-A[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-A[j]]+C[j])
M=dp[N]
dp=[0]*(M+1)
C=[A[i]-B[i] for i in range(3) if A[i]-B[i]>=0]
C=[]
b=[]
a=[]
for i in range(3):
    if A[i]-B[i]>=0:
        C.append(A[i]-B[i])
        b.append(B[i])
        a.append(A[i])
B=b
A=a
for i in range(M):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(len(C)):
        if i+1-B[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-B[j]]+C[j])
print(M+dp[M])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)


Fixed submission:
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i:i+2]=="BC":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)


Fixed submission:
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i:i+2]=="BC":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
ans=0
for i in range(len(T)):
    if T[i]=="A":
        ans+=l[i]
print(ans)


Fixed submission:
s=input()
S=""
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S+="A"
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S+="B"
        i+=2
    else:
        S+="C"
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,Q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])


Fixed submission:
import bisect
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,Q=map(int,input().split())
STX=[list(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])


Fixed submission:
import bisect
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
import bisect
N,Q=map(int,input().split())
STX=[list(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=jump[k]
for i in range(Q):
    print(ans[i])


Fixed submission:
import bisect
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    B,C=map(int,input().split())
    A.extend([C]*B)
    A.sort(reverse=True)
    A=A[:N]
A.sort(reverse=True)
print(sum(A[:N]))


Fixed submission:
from collections import defaultdict
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=defaultdict(int)
s=set()
for i in A:
    BC[i]+=1
    s.add(i)
for i in range(M):
    B,C=map(int,input().split())
    BC[C]+=B
    s.add(C)
s=list(s)
s.sort(reverse=True)
res=0
ans=0
for i in s:
    k=min(N-res,BC[i])
    res+=k
    ans+=k*i
    if res==N:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    B,C=map(int,input().split())
    A.extend([C]*B)
A.sort(reverse=True)
print(sum(A[:N]))


Fixed submission:
from collections import defaultdict
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=defaultdict(int)
s=set()
for i in A:
    BC[i]+=1
    s.add(i)
for i in range(M):
    B,C=map(int,input().split())
    BC[C]+=B
    s.add(C)
s=list(s)
s.sort(reverse=True)
res=0
ans=0
for i in s:
    k=min(N-res,BC[i])
    res+=k
    ans+=k*i
    if res==N:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from math import ceil
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    k=ceil(math.log2(K/i))
    k=max(0,k)
    ans+=(1/N)*(1/2)**k
print(ans)


Fixed submission:
import math
from math import ceil
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    k=ceil(math.log(K/i,2))
    k=max(0,k)
    ans+=(1/N)*(1/2)**k
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    k=ceil(math.log2(K/i))
    k=max(0,k)
    ans+=(1/N)*(1/2)**k
print(ans)


Fixed submission:
import math
from math import ceil
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    k=ceil(math.log(K/i,2))
    k=max(0,k)
    ans+=(1/N)*(1/2)**k
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1 or N==2:
    print(0)
    quit()
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
table=prime_factor(N)
list=[1]
for fact,num in table.items():
    list_=[]
    for k in range(num+1):
        list_.extend([i*fact**k for i in list])
    list=list_
list.sort()
ans=0
for i in range(len(list)):
    if i==0:
        continue
    if list[i-1]+1==list[i]:
        continue
    m=list[i]-1
    if N//m==N%m:
        ans+=list[i]-1
print(ans)


Fixed submission:
from collections import defaultdict
N=int(input())
if N==1 or N==2:
    print(0)
    quit()
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
table=prime_factor(N)
list=[1]
for fact,num in table.items():
    list_=[]
    for k in range(num+1):
        list_.extend([i*fact**k for i in list])
    list=list_
list.sort()
ans=0
for i in range(len(list)):
    if i==0:
        continue
    if list[i-1]+1==list[i]:
        continue
    m=list[i]-1
    if N//m==N%m:
        ans+=list[i]-1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
n=0
i=0
while(n<N):
    i+=1
    n=2**i
INF=0
dat=[INF]*(2*n-1)
def update(i,x):
    i+=n-1
    dat[i]=x
    while(i>0):
        i=(i-1)//2
        dat[i]=gcd(dat[i*2+1],dat[i*2+2])
def find(a,b,k,l,r):
    if r<=a or b<=l:
        return INF
    if a<=l and r<=b:
        return dat[k]
    else:
        vl=find(a,b,k*2+1,l,(l+r)//2)
        vr=find(a,b,k*2+2,(l+r)//2,r)
        return gcd(vl,vr)
for i in range(N):
    update(i,A[i])
ans=0
for i in range(N):
    f=find(0,i,0,0,n)
    g=find(i+1,N,0,0,n)
    ans=max(gcd(f,g),ans)
print(ans)


Fixed submission:
from fractions import gcd

N=int(input())
A=list(map(int,input().split()))
X=[A[0]]
Y=[A[-1]]
for i in range(N):
    X.append(gcd(X[-1],A[i]))
    Y.append(gcd(Y[-1],A[N-1-i]))
X=X[1:]
Y=Y[1:]
Y=Y[::-1]
ans=1
for i in range(N):
    if i==0:
        ans_=Y[i+1]
    elif i==N-1:
        ans_=X[i-1]
    else:
        ans_=gcd(X[i-1],Y[i+1])
    ans=max(ans,ans_)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#A,B,C=map(int,input().split())
#A=list(map(int,input().split()))
T=""
whi=0
bla=0
S_=""
c1=0
for i in S:
    if i=="#":
        break
    c1+=1
for i in S:
    T=i+T
    if i==".":
        whi+=1
    else:
        bla+=1
c2=0
for i in T:
    if i==".":
        break
    c2+=1
"""
print(whi)
print(bla)
print(c1)
print(c2)
print(T)
"""
print(min(whi-c1,bla-c2))


Fixed submission:
N=int(input())
S=input()
whi=0
bla=0
c1=0
dp=[[0,0] for i in range(N+1)]
for i in range(N):
    s=S[i]
    if s=="#":
        dp[i+1][0]=dp[i][0]+1
    else:
        dp[i+1][0]=dp[i][0]
for i in range(N):
    s=S[N-1-i]
    if s==".":
        dp[N-i-1][1]=dp[N-i][1]+1
    else:
        dp[N-i-1][1]=dp[N-i][1]


ans=float("inf")
for i in range(N+1):
    ans=min(ans,dp[i][0]+dp[i][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
count=[0]*(N)
for i in range(N-1):
    if S[i:i+2]=="AC":
        count[i]=1
sums=list(accumulate([0]+count))

for i in range(Q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(sums[r]-sums[l])


Fixed submission:
N,Q=map(int,input().split())
S=input()
l=[]
r=[]
lst1=[0 for i in range(N)]
for i in range(N-1):
    i+=1
    if S[i-1:i+1]=="AC":
        lst1[i]=lst1[i-1]+1
    else:
        lst1[i]=lst1[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    l=l-1
    r-=1
    print(lst1[r]-lst1[l])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N=int(input())
S=input()
INF=1e9+7
dict=defaultdict(int)
for i in S:
    dict[i]+=1
l=list(dict.values())
ans=0
for i in range(1,2**len(l)):
    i=bin(i)[2:].zfill(len(l))
    tmp=1
    for j in range(len(l)):
        if i[j]=="1":
            tmp*=l[j]
            tmp%=INF
    ans+=tmp
    ans%=INF
print(int(ans))


Fixed submission:
from collections import defaultdict

N=int(input())
S=input()
INF=int(1e9+7)
dict=defaultdict(int)
for i in S:
    dict[i]+=1
l=list(dict.values())
ans=1
for i in l:
    ans*=(i+1)
    ans%=INF
print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
num=0
def left(S,num):
    ini=S[0]
    for i in range(len(S)):
        if i==0:
            continue
        if ini==S[i]:
            continue
        if ini!=S[i]:
            g=S[:i-1]
            h=S[i+1:]
            num+=1
            return (g+h,num)
    return ("",num)
def right(S,num):
    S=S[::-1]
    ini=S[0]
    for i in range(len(S)):
        if i==0:
            continue
        if ini==S[i]:
            continue
        if ini!=S[i]:
            g=S[:i-1]
            h=S[i+1:]
            num+=1
            return ((g+h)[::-1],num)
    return ("",num)  
for i in range(len(S)):
    S,num=left(S,num)
    if S=="":
        break
    S,num=right(S,num)
    if S=="":
        break
print(num*2)
    

Fixed submission:
S=input()
#N=int(input())
#H,W=map(int,input().split())
a=0
b=0
for i in range(len(S)):
    if S[i]=="0":
        a+=1
    else:
        b+=1
print(min([a,b])*2)