Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
S=sys.stdin.readline().strip()
if int(S)<=10**9:
    A=["0","0",S,"0","0","1"]
    print(" ".join(A))
else:
    for a in range(0,10**9):
        for b in range(0,10**9):
            for c in range(0,10**9):
                for d in range(0,10**9):
                    for e in range(0,10**9):
                        for f in range(0,10**9):
                            T=abs((c-a)*(f-b)-(d-b)*(e-a))
                            if S==T:
                                A=[str(a),str(b),str(c),str(d),str(e),str(f)]
                                print(" ".join(A))
                                exit()

Fixed submission:
s=int(input());l=10**9;n=0--s//l;print(0,0,1,l,n,n*l-s)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
S=sys.stdin.readline().strip()
if int(S)<=10**9:
    A=["0","0",S,"0","0","1"]
    print(" ".join(A))
else:
    for a in range(0,10**9):
        for b in range(0,10**9):
            for c in range(0,10**9):
                for d in range(0,10**9):
                    for e in range(0,10**9):
                        for f in range(0,10**9):
                            T=abs((c-a)*(f-b)-(d-b)*(e-a))
                            if S==T:
                                A=[str(a),str(b),str(c),str(d),str(e),str(f)]
                                print(" ".join(A))


Fixed submission:
s=int(input());l=10**9;n=0--s//l;print(0,0,1,l,n,n*l-s)

Buggy python submission (verdict: Runtime Error):
import sys
S=sys.stdin.readline().strip()
A=["0","0"]
if int(S)<=10**9:
    A.extend([S,"0","0","1"])
    print(" ".join(A))
else:
    for i in range(2,10**9):
        for j in range(2,10**9):
            T=S-i*j
            if T==0:
               A.extend([str(i),"0","0",str(j)])
               print(" ".join(A))
               exit()

Fixed submission:
s=int(input());l=10**9;n=0--s//l;print(0,0,1,l,n,n*l-s)
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
if n%(2*d+1)!=0:
   print(n//(2*d+1)+1)
else:
    print(n//(2*d+1

Fixed submission:
n,d=map(int,input().split())
if n%(2*d+1)!=0:
   print(n//(2*d+1)+1)
else:
    print(n//(2*d+1))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
for j in range(0,n):
    B=copy.copy(A)
    s=A[j]
    A.pop(j)
    print(max(A))
    A = copy.copy(B)

Fixed submission:
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
z=max(A)
B=sorted(A)
o=B[n-2]
for j in range(0,n):
    if A[j]<z:
       print(z)
    else:
        if B[n-2]==B[n-1]:
           print(z)
        else:
           print(o)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
A=[]
B=[]
for i in range(0,n):
    A.extend([int(input())])
for j in range(0,n):
    B=copy.copy(A)
    s=A[j]
    A.pop(j)
    print(max(A))
    A = copy.copy(B)

Fixed submission:
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
z=max(A)
B=sorted(A)
o=B[n-2]
for j in range(0,n):
    if A[j]<z:
       print(z)
    else:
        if B[n-2]==B[n-1]:
           print(z)
        else:
           print(o)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for i in range(0,n):
    A.extend([int(input())])
for j in range(0,n):
    s=A[j]
    A.pop(j)
    print(max(A))
    A.insert(j,s)

Fixed submission:
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
z=max(A)
B=sorted(A)
o=B[n-2]
for j in range(0,n):
    if A[j]<z:
       print(z)
    else:
        if B[n-2]==B[n-1]:
           print(z)
        else:
           print(o)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for i in range(0,n):
    A.append(int(input()))
for j in range(0,n):
    s=A[j]
    A.pop(j)
    print(max(A))
    A.insert(j,s)

Fixed submission:
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
z=max(A)
B=sorted(A)
o=B[n-2]
for j in range(0,n):
    if A[j]<z:
       print(z)
    else:
        if B[n-2]==B[n-1]:
           print(z)
        else:
           print(o)
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
a=0
b=2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        a=i*j%2019
        if b>a:
           b=a
print(b)

Fixed submission:
l,r=map(int,input().split())
a=0
b=2019
if r-l>=2018:
   b=0
else:
   for i in range(l,r+1):
        for j in range(i+1,r+1):
            a=i*j%2019
            if b>a:
               b=a
print(b)
Buggy python submission (verdict: Runtime Error):
import collections
s=list(input())
a=collections.Counter(s)
values, counts = zip(*a.most_common())
if counts[0]==counts[1]==2 and len(values)==2:
   print("Yes")
else:
   print("No")

Fixed submission:
s=list(input())
if s.count(s[0])==s.count(s[1])==s.count(s[2])==s.count(s[3])==2:
   print("Yes")
else:
   print("No")

Buggy python submission (verdict: Runtime Error):
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if counts[0]==counts[1]==2 and len(values)==2:
    print("Yes")
else:
   print("No")

Fixed submission:
s=list(input())
if s.count(s[0])==s.count(s[1])==s.count(s[2])==s.count(s[3])==2:
   print("Yes")
else:
   print("No")

Buggy python submission (verdict: Runtime Error):
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if counts[0]==counts[1] and len(values)==2:
    print("Yes")
else:
   print("No")

Fixed submission:
s=list(input())
if s.count(s[0])==s.count(s[1])==s.count(s[2])==s.count(s[3])==2:
   print("Yes")
else:
   print("No")

Buggy python submission (verdict: Runtime Error):
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if values[0]==values[1] and len(b)==2:
    print("Yes")
else:
   print("No")

Fixed submission:
s=list(input())
if s.count(s[0])==s.count(s[1])==s.count(s[2])==s.count(s[3])==2:
   print("Yes")
else:
   print("No")
Buggy python submission (verdict: Runtime Error):
[X,K,D]=list(map(int, input().split()))
abx=int(abs(X))
n=abx//D
if n>K:
    if X>0:
        ans=X-K*D
    else:
        ans=X+K*D
else:
    x2=abx-n*D
    x1=(n+1)*D-abx
    if x2>=x1:
        if n+1<=K:
            if (K-n-1)%2==0:
                ans=x1
            else:
                ans=x2
    else:
        if (K-n)%2==0:
            ans=x2
        else:
            ans=x1
print(ans)


Fixed submission:
[X,K,D]=list(map(int, input().split()))
abx=round(abs(X))
n=round(abx//D)
if n>K:
    ans=abx-K*D
else:
    x2=abx-n*D
    x1=(n+1)*D-abx
    if x2>=x1:
        if (K-n-1)%2==0:
            ans=x1
        else:
            ans=x2
    else:
        if (K-n)%2==0:
            ans=x2
        else:
            ans=x1
print(ans)

Buggy python submission (verdict: Runtime Error):
[X,K,D]=list(map(int, input().split()))
n=abs(X)//D
abx=abs(X)
if n>K:
    if X>0:
        ans=X-K*D
    else:
        ans=X+K*D
else:
    x2=abx-n*D
    x1=(n+1)*D-abx
    if x2>=x1:
        if n+1<=K:
            if (K-n-1)%2==0:
                ans=x1
            else:
                ans=x2
    else:
        if (K-n)%2==0:
            ans=x2
        else:
            ans=x1
print(ans) 


Fixed submission:
[X,K,D]=list(map(int, input().split()))
abx=round(abs(X))
n=round(abx//D)
if n>K:
    ans=abx-K*D
else:
    x2=abx-n*D
    x1=(n+1)*D-abx
    if x2>=x1:
        if (K-n-1)%2==0:
            ans=x1
        else:
            ans=x2
    else:
        if (K-n)%2==0:
            ans=x2
        else:
            ans=x1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
alist=list(map(int, input().split()))

alist.sort()
#print(alist)
ans=0
for i in range(1,N):
    a=alist[i]
    aaa=[a]*i
    x=np.array(aaa)
    y=np.array(alist[0:i])
    amari=x%y
    if list(amari).count(0)==1:
        ans+=1
print(ans)


Fixed submission:
xlist=list(map(int, input().split()))
i=xlist.index(0)
print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
alist=list(map(int, input().split()))
ans=1
for a in alist:
    ans=ans*a
if ans>10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
n=int(input())
alist=list(map(int, input().split()))
ans=1
for a in alist:
    ans=ans*a
    if ans>10**18:
        ans=-1
        break
if 0 in alist:
    ans=0
print(ans)
Buggy python submission (verdict: Runtime Error):
ab=input().split()
a=int(ab[0])
b=ab[1].replace('.','')
ans=a*b//100
print(ans)


Fixed submission:
ab=input().split()
a=int(ab[0])
b=ab[1].replace('.','')
b=int(b)
ans=a*b//100
print(ans)
Buggy python submission (verdict: Runtime Error):
abhm=tuple(map(float, input().split()))
a=abhm[0]
b=abhm[1]
h=abhm[2]
m=abhm[3]

import math as mt

pi=mt.pi
print(pi)

c=pi*(h+m/60)/6
d=pi*m/30

print(mt.sqrt((a*mt.cos(c)-b*mt.cos(d))**2+(a*mt.sin(c)-b*mt.sin(d))**2))


Fixed submission:
n=int(input())
m=n%10
if m in [2, 4,5,7,9]:
    print('hon')
elif m in [0,1,6,8]:
    print('pon')
else:
    print('bon')
Buggy python submission (verdict: Time Limit Exceeded):
list=list(map(int, input().split()))
A=list[0]
B=list[1]
C=list[2]
K=list[3]
ls=[]
for a in range(A+1):
    sum=0
    for b in range(K-a+1):
        c=K-a-b
        if b<=B and c<=C:
            sum=a-c
            ls.append(sum)
        else:
            continue
print(max(ls))


Fixed submission:
list=list(map(int, input().split()))
A=list[0]
B=list[1]
C=list[2]
K=list[3]
if K<=A:
    print(K)
elif K-A<=B:
    print(A)
else:
    print(A-(K-A-B))
Buggy python submission (verdict: Runtime Error):
nmq=list(map(int, input().split()))
N=nmq[0]
M=nmq[1]
Q=nmq[2]
ablist=[list(map(int, input().split())) for i in range(Q)]
sumlist=[]
alist=[i for i in range(1,M+1)]
import itertools as ite
case=list(ite.combinations_with_replacement(alist,N))
for nowcase in case:
    sumd=0
    for i in range(Q):
        a=ablist[i][0]
        b=ablist[i][1]
        c=ablist[i][2]
        d=ablist[i][3]
        aa=nowcase[a-1]
        ab=nowcase[b-1]
        if ab-aa==c:
            sumd+=d
    sumlist.append(sumd)
print(max(sumlist))


Fixed submission:
K=int(input())
ab=list(map(int, input().split()))
A=ab[0]
B=ab[1]
flg=False
for i in range(A,B+1):
    if i%K==0:
        flg=True
if flg:
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
nmq=list(map(int, input().split()))
N=nmq[0]
M=nmq[1]
Q=nmq[2]
ablist=[list(map(int, input().split())) for i in range(Q)]
sumlist=[]
alist=[i for i in range(1,M+1)]
import itertools as ite
case=list(ite.combinations_with_replacement(alist,N))
for nowcase in case:
    sumd=0
    for i in range(Q):
        a=ablist[i][0]
        b=ablist[i][1]
        c=ablist[i][2]
        d=ablist[i][3]
        aa=nowcase[a-1]
        ab=nowcase[b-1]
        if ab-aa==c:
            sumd+=d
    sumlist.append(sumd)
sumlist.sort(reverse=True)
print(sumlist[0])


Fixed submission:
K=int(input())
ab=list(map(int, input().split()))
A=ab[0]
B=ab[1]
flg=False
for i in range(A,B+1):
    if i%K==0:
        flg=True
if flg:
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
nmq=list(map(int, input().split()))
N=nmq[0]
M=nmq[1]
Q=nmq[2]
ablist=[list(map(int, input().split())) for i in range(Q)]
sumlist=[]
alist=[i for i in range(1,M+1)]
import itertools as ite
case=list(ite.combinations_with_replacement(alist,N))
for nowcase in case:
    sumd=0
    for i in range(Q):
        a=ablist[i][0]
        b=ablist[i][1]
        c=ablist[i][2]
        d=ablist[i][3]
        aa=nowcase[a-1]
        ab=nowcase[b-1]
        if ab-aa==c:
            sumd+=d
    sumlist.append(sumd)
sumlist.sort(reverse=True)
print(sumlist[0])


Fixed submission:
K=int(input())
ab=list(map(int, input().split()))
A=ab[0]
B=ab[1]
flg=False
for i in range(A,B+1):
    if i%K==0:
        flg=True
if flg:
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
nmq=list(map(int, input().split()))
N=nmq[0]
M=nmq[1]
Q=nmq[2]
ablist=[list(map(int, input().split())) for i in range(Q)]
sumlist=[]
alist=[]
for i in range(1,M+1):
    alist.append(i)
import itertools as ite
case=list(ite.combinations_with_replacement(alist,N))
for nowcase in case:
    sumd=0
    for i in range(Q):
        a=ablist[i][0]
        b=ablist[i][1]
        c=ablist[i][2]
        d=ablist[i][3]
        aa=nowcase[a-1]
        ab=nowcase[b-1]
        if ab-aa==c:
            sumd+=d
    sumlist.append(sumd)
sumlist.sort(reverse=True)
print(sumlist[0])


Fixed submission:
K=int(input())
ab=list(map(int, input().split()))
A=ab[0]
B=ab[1]
flg=False
for i in range(A,B+1):
    if i%K==0:
        flg=True
if flg:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alist=list(map(int, input().split()))
alist.sort()
aa=alist[0]
anslist=[0]*N
for i in range(1,N+1):
    anslist[i-1]=alist.count(i)
for ans in anslist:
    print(ans)


Fixed submission:
N=int(input())
alist=list(map(int, input().split()))
anslist=[0]*N
for a in alist:
    anslist[a-1]+=1
for ans in anslist:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alist=list(map(int, input().split()))
alist.sort()
for i in range(1,N+1):
    if i in alist:
        ans=alist.count(i)
        print(ans)
        alist=alist[ans:]
    else:
        print(0)


Fixed submission:
N=int(input())
alist=list(map(int, input().split()))
anslist=[0]*N
for a in alist:
    anslist[a-1]+=1
for ans in anslist:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alist=list(map(int, input().split()))
alist.sort()
for i in range(1,N+1):
    ans=alist.count(i)
    print(ans)
    alist=alist[ans:]


Fixed submission:
N=int(input())
alist=list(map(int, input().split()))
anslist=[0]*N
for a in alist:
    anslist[a-1]+=1
for ans in anslist:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alist=list(map(int, input().split()))
for i in range(1,N+1):
    print(alist.count(i))
    


Fixed submission:
N=int(input())
alist=list(map(int, input().split()))
anslist=[0]*N
for a in alist:
    anslist[a-1]+=1
for ans in anslist:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools as itool
N=int(input())
plist=list(map(int, input().split()))
qlist=list(map(int, input().split()))
mylist=list(itool.permutations(range(1,n+1)))
print(abs(mylist.index(p)-mylist.index(q)))


Fixed submission:
import itertools as itool
N=int(input())
plist=list(map(int, input().split()))
qlist=list(map(int, input().split()))
mylist=list(itool.permutations(range(1,N+1)))

print(abs(mylist.index(tuple(plist))-mylist.index(tuple(qlist))))
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input())
D2=D*D
c=0
for i in range(N):
  x,y =sprit(int,input())
  if x*x+y*y<=D2:
    c+=1
print(c)
  
  

Fixed submission:
N,D=map(int,input().split())
D2=D*D
c=0
for i in range(N):
  x,y =map(int,input().split())
  if x*x+y*y<=D2:
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())
A=[map(int,input().split())]
a=sum(A)
if H<=a:
  print("Yes")
else:
  print("No")

Fixed submission:
H,N=map(int,input().split())
A=list(map(int,input().split()))
a=sum(A)
if H<=a:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=[map(int,input().split())]


if N<=K:
  print(0)
else:
  H.sort()
  a=sum(H[0:N-K])
  print(a)

Fixed submission:
N,K=map(int,input().split())
H=list(map(int,input().split()))

if N<=K:
  print(0)
else:
  H.sort()
  a=sum(H[0:N-K])
  print(a)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(math.gcd(a,b))

Fixed submission:

def fx(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b=map(int,input().split())
a,b=max(a,b),min(a,b)
print(a*b//fx(a,b))
Buggy python submission (verdict: Runtime Error):
def fx(X, n):
    if (int(X/n)):
        return fx(int(X/n), n)+(X//n)
    return 0

N=int(input())
if N%2==1:
  print(0)
else:
  print(fx(N/2,0))


Fixed submission:
def fx(X, n):
    if (X//n):
      #print(X//5)
      return fx(X//n, n)+X//n
    return 0

N=int(input())
if N%2==1:
  print(0)
else:
  print(fx(N//2,5))

Buggy python submission (verdict: Runtime Error):
def fx(X, n):
    if (int(X/n)):
        return fx(int(X/n), n)+(X//n)
    return 0

N=int(input())
if N%2==1:
  print(0)
else:
  print(fx(n/2,0))

Fixed submission:
def fx(X, n):
    if (X//n):
      #print(X//5)
      return fx(X//n, n)+X//n
    return 0

N=int(input())
if N%2==1:
  print(0)
else:
  print(fx(N//2,5))
Buggy python submission (verdict: Runtime Error):
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=max(a,-1000000)
b=min(b,1000000)
c=[k for k in range(a,b+1)]
c=' '.join(c)
print(c)


Fixed submission:
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=max(a,-1000000)
b=min(b,1000000)
c=[k for k in range(a,b+1)]
for i in c:
  print('%d '%i),

Buggy python submission (verdict: Runtime Error):
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=min(a,-1000000)
b=max(b,1000000)
c=range(a,b+1)
c=' '.join(c)
print(c)


Fixed submission:
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=max(a,-1000000)
b=min(b,1000000)
c=[k for k in range(a,b+1)]
for i in c:
  print('%d '%i),

Buggy python submission (verdict: Time Limit Exceeded):
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=min(a,-1000000)
b=max(b,1000000)
c=range(a,b+1)
for i in c:
  print(i,end=" ")

Fixed submission:
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=max(a,-1000000)
b=min(b,1000000)
c=[k for k in range(a,b+1)]
for i in c:
  print('%d '%i),
Buggy python submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())
A -= 1
CD = C*D // math.gcd(C,D)
a = A - (A//C + A//D - A//CD)
b = B - (B//C + B//D - B//CD)
print(b-a)

Fixed submission:
def gcd(x,y):
	x, y = max(x,y), min(x,y)
	while(y):
		x, y = y, x%y
	return x
A,B,C,D = map(int,input().split())
A -= 1
CD = C*D // gcd(C,D)
a = A - (A//C + A//D - A//CD)
b = B - (B//C + B//D - B//CD)
print(b-a)
Buggy python submission (verdict: Runtime Error):
x,a = int(input.split())
if x < a:
	print(0)
else:
	print(10)

Fixed submission:
x, a = map(int,input().split())
if x < a:
	print(0)
else:
	print(10)
Buggy python submission (verdict: Time Limit Exceeded):
L = input()
length = len(L)
ans = 3 ** (length - 1)
a = 3 ** (length-1)
for q in range(1,length):
	if L[q]  == '1':
		a = a // 3 *2
		ans += a%1000000007
	else:
		a //= 3
print((ans + a * 2)%1000000007)

Fixed submission:
L = input()
length = len(L)
a = 2
b = 1
c = 4
for l in L[1:]:
	if l  == '1':
		a = (a * 3) % 1000000007
		b = (b * 3) % 1000000007
		c = (c * 2) % 1000000007
	else:
		a = (a * 3 - c) % 1000000007
		b = (b * 3) % 1000000007
print((a + b)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
L = int(input(),2)
t = 0
c = 0
ans = 0
while(L > 0):
	if L % 2 == 1:
		t = t+1
		ans *= 2
		ans += 3 ** c
	L //= 2
	c += 1
print(((ans + 2**t))%1000000007)

Fixed submission:
L = input()
length = len(L)
a = 2
b = 1
c = 4
for l in L[1:]:
	if l  == '1':
		a = (a * 3) % 1000000007
		b = (b * 3) % 1000000007
		c = (c * 2) % 1000000007
	else:
		a = (a * 3 - c) % 1000000007
		b = (b * 3) % 1000000007
print((a + b)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
B = []
L = int(input(),2)
c = 0
ans = 0
while(L > 0):
	if L % 2 == 1:
		B.append(c)
	L //= 2
	c += 1
leng = len(B)-1
for i in B:
	ans = (ans + (2**leng)*(3**i))%1000000007
	leng -= 1
print((ans+2**(len(B)))%1000000007)

Fixed submission:
L = input()
length = len(L)
a = 2
b = 1
c = 4
for l in L[1:]:
	if l  == '1':
		a = (a * 3) % 1000000007
		b = (b * 3) % 1000000007
		c = (c * 2) % 1000000007
	else:
		a = (a * 3 - c) % 1000000007
		b = (b * 3) % 1000000007
print((a + b)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
L = int(input(),2)
K = 2**100000
ans = 0
t = 0
c = 100001
for p in [None]*100001:
	c -= 1
	if (L & K):
		ans = (ans + (2**t)*(3**c)%1000000007)%1000000007
		t += 1
	K //= 2
print((ans+2**t)%1000000007)

Fixed submission:
L = input()
length = len(L)
a = 2
b = 1
c = 4
for l in L[1:]:
	if l  == '1':
		a = (a * 3) % 1000000007
		b = (b * 3) % 1000000007
		c = (c * 2) % 1000000007
	else:
		a = (a * 3 - c) % 1000000007
		b = (b * 3) % 1000000007
print((a + b)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
b = 10**9+7
L = int(input(),2)
K = 2**100000
ans = 0
t = 0
c = 100001
for p in [None]*100001:
	c -= 1
	if K == (L & K):
		ans += (2**t)*(3**c)%b
		t += 1
	K //= 2
print((ans+2**t)%b)

Fixed submission:
L = input()
length = len(L)
a = 2
b = 1
c = 4
for l in L[1:]:
	if l  == '1':
		a = (a * 3) % 1000000007
		b = (b * 3) % 1000000007
		c = (c * 2) % 1000000007
	else:
		a = (a * 3 - c) % 1000000007
		b = (b * 3) % 1000000007
print((a + b)%1000000007)
Buggy python submission (verdict: Runtime Error):
import sys
from operator import itemgetter
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
def main():
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while(e[0] > d):
			if cont == True:
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			else:
				mini = min(kouho)
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			cont = True
			if q < Q-1:
				q = q + 1
				d = int(inputs())
			else:
				flag = True
				q = q + 1
				break
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			cont = False
	for t in [None]*(Q-q):
		print(-1)
		
def sub():
	V = [list(map(int,inputs().split())) for p in [0]*N]
	M = [int(inputs()) for p in [0]*Q]
	V.sort(key = lambda x:(x[2],x[0],x[1]))
	for v in V:
		v[0] -= v[2]
		v[1] -= v[2] + 1
	for m in M:
		for n in range(N):
			if V[n][0] <=m and m <= V[n][1]:
				print(V[n][2])
				break
		else:
			print(-1)


if N>200000:
	sub()
else:
	main()

Fixed submission:
import sys
input = sys.stdin.readline
a,p = map(int,input().split())
ans = (3*a + p)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
V = [None]*N
E = []
for n in range(N):
	V[n] = list(map(int,inputs().split()))
	V[n][0] -= V[n][2]
	V[n][1] -= V[n][2]
	E.append([V[n][0],1,V[n][2]])
	E.append([V[n][1],-1,V[n][2]])
D = [int(inputs()) for p in [0]*Q]
E.sort(key = lambda x:x[0])
mini = 1000000001
kouho = [1000000001]
q = 0
d = D[0]
for e in E:
	flag = 0
	if e[0] <= d:
		if  e[1] == 1:
			kouho.append(e[2])
		elif e[1] == -1:
			kouho.remove(e[2])
	if e[0] > d:
		for k in kouho:
			mini = min(k,mini)
		if mini < 1000000001:
			print(mini)
			mini = 1000000001
		else:
			print(-1)
			mini = 1000000001
		flag = 1
		if q < Q-1:
			q = q + 1
			d = D[q]
		else:
			break
	if e[0] <= d and flag == 1:
		if  e[1] == 1:
			kouho.append(e[2])
		elif e[1] == -1:
			kouho.remove(e[2])
for t in [None]*(Q-q):
	print(-1)

Fixed submission:
import sys
input = sys.stdin.readline
a,p = map(int,input().split())
ans = (3*a + p)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
V = [list(map(int,inputs().split())) for p in [0]*N]

for q in [0]*Q:
	m = int(inputs())
	for n in range(N):
		if V[n][0] - V[n][2] <=m and m <= V[n][1] - V[n][2] -1:
			print(V[n][2])
			break
	else:
		print(-1)


Fixed submission:
import sys
input = sys.stdin.readline
a,p = map(int,input().split())
ans = (3*a + p)//2
print(ans)