Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def modpow(a,n,mod=10**9+7):
    res=1
    while n>0:
        if n&1:
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res%mod

def modcmb(n,r,mod=10**9+7):
    res=1
    div=min(r,n-r)
    for i in range(div):
        res=res*(n-i)*modpow(div-i,mod-2)%mod
    return res%mod

n,a,b=[int(i) for i in input().split()]
ans=modpow(2,n)-1
ans-=modcmb(n,a)
ans%=10**9+7
ans-=modcmb(n,b)
ans%=10**9+7
print(ans)

Fixed submission:
def modpow(a,n,mod=10**9+7):
    res=1
    while n>0:
        if n&1:
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res%mod

def modcmb(n,r,mod=10**9+7):
    res=1
    div=min(r,n-r)
    for i in range(div):
        res=res*(n-i)*modpow(div-i,mod-2)%mod
    return res%mod

n,a,b=[int(i) for i in input().split()]
ans=modpow(2,n)-1
ans-=modcmb(n,a)
ans%=10**9+7
ans-=modcmb(n,b)
ans%=10**9+7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    while b:
        a,b==b,a%b
    return a
def lcm(a,b):
    return a//gcd(a,b)*b
 
n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    if L%i!=0:
        L=lcm(L,i)
L%=(10**9+7)
ans=0
for i in a:
    ans=(ans+L//i)%(10**9+7)
print(ans)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a//gcd(a,b)*b

def main():
    sys.setrecursionlimit(4100000)
    input = sys.stdin.readline
    n=int(input())
    a=[int(i) for i in input().split()]
    L=a[0]
    for i in a:
        if L%i!=0:
            L=lcm(L,i)
    ans=0
    for i in a:
        ans=(ans+L//i)%(10**9+7)
    print(ans)

if __name__=="__main__":
    main()

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    if L%i!=0:
        L=lcm(L,i)
ans=0
for i in a:
    ans=(ans+L//i)%(10**9+7)
print(ans)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    if L%i!=0:
        L=lcm(L,i)
ans=0
for i in a:
    ans=(ans+L//i)%(10**9+7)
print(ans)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in range(1,n):
    L=lcm(L,a[i])
ans=0
for i in range(n):
    ans+=(L//a[i])
    ans%=(10**9+7)
print(ans%(10**9+7))

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=[int(i) for i in input().split()]
L=a[0]
for i in a:
    L=lcm(L,i)
ans=0
for i in a:
    ans+=L//i
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[tuple(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Fixed submission:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
xl=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[0])
i=1
while(i<len(xl)):
    if xl[i-1][0]-xl[i-1][1]<xl[i][0]<xl[i-1][0]+xl[i-1][1]:
        xl.remove(xl[i])
    i+=1

print(len(xl))

Fixed submission:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
xl=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])[::-1]
count=[0]*n
for j in range(n):
    for i in range(n):
        if(i!=j and xl[j][0]-xl[j][1] < xl[i][0] < xl[j][0]+xl[j][1] and count[i]==0):
            count[j]=1
            break
print(n-sum(count))

Fixed submission:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
b=[int(i) for i in input().split()]
ans=b[-1]
for i in range(n-1):
    ans+=min(b[i],b[i+1])
print(ans)

Fixed submission:
n=int(input())
b=[10000000000]+[int(i) for i in input().split()]+[100000000000000]
ans=0
for i in range(n):
    ans+=min(b[i],b[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=0
def bfs(st,numQ):
    global ans
    if numQ==n:
        if int(st)%13==5:
            ans=(ans+1)%1000000007
    else:
        if st[numQ]=="?":
            for i in range(10):
                bfs(st[:numQ]+str(i)+st[numQ+1:],numQ+1)
        else:
            bfs(st,numQ+1)
bfs(s,0)
print(ans)

Fixed submission:
s=input()
n=len(s)
dp=[[0]*13 for _ in range(100010)]
dp[0][0]=1
for i in range(n):
    for j in range(10):
        if s[i]==str(j) or s[i]=="?":
            for h in range(13):
                dp[i+1][(h*10+j)%13]+=dp[i][h]
    for h in range(13):
        dp[i+1][h]%=1000000007
print(dp[n][5])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
for i in d:
    dif[i-1]+=1
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=sum(dif[:d[i]])
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)

Fixed submission:
n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
ruiseki=[0]*d[-1]
for i in d:
    dif[i-1]+=1
for i in range(d[-1]):
    ruiseki[i]=ruiseki[i-1]+dif[i]
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=ruiseki[d[i]-1]
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,x=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
i=0
dis=0
cnt=0
while dis<=x:
    dis+=l[i]
    i+=1
    cnt+=1
print(cnt)

Fixed submission:
n,x=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
i=0
dis=0
cnt=0
try:
    while dis<=x:
        dis+=l[i]
        i+=1
        cnt+=1
    print(cnt)
except:
    print(n+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
a=[int(input()) for _ in range(m)]
dp=[1]+[0]*100010
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        try:
            dp[i]=dp[i-1]+dp[i-2]
        except:
            dp[i]=dp[i-1]
        dp[i]%=1000000007
print(dp[n])

Fixed submission:
n,m=[int(i) for i in input().split()]
a=[int(input()) for _ in range(m)]
dp=[1]+[1]*100010
for i in a:
    dp[i]=0
for i in range(2,n+1):
    if dp[i]:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
a=[int(input()) for _ in range(m)]
dp=[1]+[0]*100010
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        try:
            dp[i]=dp[i-1]+dp[i-2]
        except:
            dp[i]=dp[i-1]
print(dp[n]%1000000007)

Fixed submission:
n,m=[int(i) for i in input().split()]
a=[int(input()) for _ in range(m)]
dp=[1]+[1]*100010
for i in a:
    dp[i]=0
for i in range(2,n+1):
    if dp[i]:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,k=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
tmp=v.copy()
res=0
for right in range(k+1):
    for left in range(k-right+1):
        v=tmp.copy()
        ans=[]
        ans+=v[:right]
        ans+=v[n-left:]
        v=v[right:n-left]
        ans.sort()
        for i in range(min(k-right-left,len(ans))+1):
            res=max(res,sum(ans[i:]))
print(res)

Fixed submission:
n,k=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
res=0
for right in range(k+1):
    for left in range(min(n,k)-right+1):
        ans=[]
        ans+=v[:right]
        ans+=v[n-left:]
        ans.sort()
        for i in range(min(k-right-left,len(ans))+1):
            res=max(res,sum(ans[i:]))
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
bc=sorted([[int(i) for i in input().split()] for _ in range(m)],key=lambda x:x[1])[::-1]
d=[]
ans=0
for b,c in bc:
    d+=[c]*b
for i in range(n):
    try:
        #元のカード列と置き換えるカード列で大きい方を選ぶ
        ans+=max(a[i],d[i])
    except:
        ans+=a[i]
print(ans)

Fixed submission:
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
bc=sorted([[int(i) for i in input().split()] for _ in range(m)],key=lambda x:x[1])[::-1]
d=[]
ans=0
for b,c in bc:
    d+=[c]*b
    if len(d)>=n:
        break
for i in range(n):
    try:
        #元のカード列と置き換えるカード列で大きい方を選ぶ
        ans+=max(a[i],d[i])
    except:
        ans+=a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
bc=sorted([[int(i) for i in input().split()] for _ in range(m)],key=lambda x:x[1])[::-1]
d=[]
ans=0
for b,c in bc:
    d+=[c]*b
for i in range(n):
    try:
        #元のカード列と置き換えるカード列で大きい方を選ぶ
        ans+=max(a[i],d[i])
    except:
        ans+=a[i]
print(ans)

Fixed submission:
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
bc=sorted([[int(i) for i in input().split()] for _ in range(m)],key=lambda x:x[1])[::-1]
d=[]
ans=0
for b,c in bc:
    d+=[c]*b
    if len(d)>=n:
        break
for i in range(n):
    try:
        #元のカード列と置き換えるカード列で大きい方を選ぶ
        ans+=max(a[i],d[i])
    except:
        ans+=a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
hoge=sorted([[int(j) for j in input().split()] for _ in range(m)],key=lambda x:x[1])
for b,c in hoge[::-1]:
    line=bisect(a,c)
    a[0:min(line,b)]=[c]*min(line,b)
    a=sorted(a)
print(sum(a))

Fixed submission:
n,m=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
bc=sorted([[int(i) for i in input().split()] for _ in range(m)],key=lambda x:x[1])[::-1]
d=[]
ans=0
for b,c in bc:
    d+=[c]*b
    if len(d)>=n:
        break
for i in range(n):
    try:
        #元のカード列と置き換えるカード列で大きい方を選ぶ
        ans+=max(a[i],d[i])
    except:
        ans+=a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted([int(i) for i in input().split()])
gcd1=[0]*n
gcd2=[0]*n
for i in range(n):
    if i!=0:
        gcd1[i]=gcd(a[0],a[i])
    if i!=1:
        gcd2[i]=gcd(a[1],a[i])
print(max(max(gcd1),max(gcd2)))

Fixed submission:
def gcd(num1,num2):
    if num2==0:
        return num1
    return gcd(num2,num1%num2)
from collections import deque
n=int(input())
a=[int(i) for i in input().split()]
left_gcd=a[0]
right_gcd=a[-1]
left=deque([])
right=deque([])
for i in a:
    left_gcd=gcd(left_gcd,i)
    left.append(left_gcd)
for i in a[::-1]:
    right_gcd=gcd(right_gcd,i)
    right.append(right_gcd)
right=deque(reversed(right))
Max=max(right[1],left[-2])
for i in range(1,n-1):
    Max=max(Max,gcd(left[i-1],right[i+1]))
print(Max)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for _ in range(q):
    l,r=map(int,input().split())
    st=s[l-1:r]
    print((len(st)-len([i for i in st.split("AC") if i!=""]))//2)

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

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

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=[int(i) for i in input().split()]
s=input()
place=tuple(tuple(int(i) for i in input().split()) for _ in range(q))
for i in place:
    print(s.count("AC",i[0]-1,i[1]))

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=[int(i) for i in input().split()]
s=input()
place=tuple(tuple(int(i) for i in input().split()) for _ in range(q))
for i in place:
    l,r=i[0],i[1]
    st=s[l-1:r]
    print(st.count("AC"))

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

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

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

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

Fixed submission:
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len({i for i in s})
for i in range(1,set_s+1):
    koho=[j for j in tuple(combinations(s,i)) if len(j)==len(tuple(set(j)))]
    ans+=len(koho)
print(ans%(10**9+7))

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len({i for i in s})
for i in range(1,set_s+1):
    koho=tuple(combinations(s,i))
    ex=tuple([j for j in koho if len(j)==len(tuple(set(j)))])
    ans+=len(ex)
print(ans%(10**9+7))

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len({i for i in s})
for i in range(1,set_s+1):
    koho=tuple(combinations((j for j in s),i))
    ex=tuple([j for j in koho if len(j)==len(tuple(set(j)))])
    ans+=len(ex)
print(ans%(10**9+7))

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len(set([i for i in s]))
for i in range(1,set_s+1):
    koho=tuple(combinations((j for j in s),i))
    for j in koho:
        if len(j)==len(tuple(set(j))):
            ans+=1
print(ans%(10**9+7))

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len(set([i for i in s]))
for i in range(1,set_s+1):
    koho=tuple(combinations([j for j in s],i))
    for j in koho:
        if len(j)==len(tuple(set(j))):
            ans+=1
print(ans%(10**9+7))

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations 
n=int(input())
s=input()
ans=0
for i in range(1,n+1):
    koho=tuple(combinations([j for j in s],i))
    for j in range(len(koho)):
        if len(koho[j])==len(tuple(set(koho[j]))):
            ans+=1
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
min_money=[10000000000]
min_buy=[0]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    if a<min_money[-1]:
        min_money.append(a)
        min_money.sort()
    if a in min_money:
        min_buy.insert(min_money.index(a),b)
ans=0
for i in range(len(min_buy)):
    if min_buy[i]>=m:
        ans+=min_money[i]*m
        break
    else:
        ans+=min_money[i]*min_buy[i]
        m-=min_buy[i]
print(ans)

Fixed submission:
n,m=[int(i) for i in input().split()]
hoge=[tuple([int(i) for i in input().split()]) for j in range(n)]
hoge.sort()
ans=0
for i in range(len(hoge)):
    if hoge[i][1]>m:
        ans+=hoge[i][0]*m
        break
    else:
        ans+=hoge[i][0]*hoge[i][1]
        m-=hoge[i][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
min_money=[10000000000]
min_buy=[0]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    if a<min_money[-1]:
        min_money.append(a)
        min_money.sort()
    if a in min_money:
        min_buy.insert(min_money.index(a),b)
ans=0
for i in range(len(min_buy)):
    if min_buy[i]>=m:
        ans+=min_money[i]*m
        break
    else:
        ans+=min_money[i]*min_buy[i]
        m-=min_buy[i]
print(ans)

Fixed submission:
n,m=[int(i) for i in input().split()]
hoge=[tuple([int(i) for i in input().split()]) for j in range(n)]
hoge.sort()
ans=0
for i in range(len(hoge)):
    if hoge[i][1]>m:
        ans+=hoge[i][0]*m
        break
    else:
        ans+=hoge[i][0]*hoge[i][1]
        m-=hoge[i][1]
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
min_money=[10000000000,1000000001,1000000002]
min_buy=[0,0,0]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    min_money.append(a)
    min_money.sort()
    min_money.pop()
    if a in min_money:
        min_buy[min_money.index(a)],min_buy[min_money.index(a)+1]=b,min_buy[min_money.index(a)]
ans=0
for i in range(3):
    if min_buy[i]>=m:
        ans+=min_money[i]*m
        break
    else:
        ans+=min_money[i]*min_buy[i]
        m-=min_buy[i]
print(ans)

Fixed submission:
n,m=[int(i) for i in input().split()]
hoge=[tuple([int(i) for i in input().split()]) for j in range(n)]
hoge.sort()
ans=0
for i in range(len(hoge)):
    if hoge[i][1]>m:
        ans+=hoge[i][0]*m
        break
    else:
        ans+=hoge[i][0]*hoge[i][1]
        m-=hoge[i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=[i for i in input()]
cnt=0
for i in range(100000000000000000):
    l=len(s)
    if l==0 or s.count("0")==l or s.count("1")==l:
        break
    else:
        for i in range(l):
            try:
                if int(s[i])+int(s[i+1])==1:
                    cnt+=2
                    s=s[0:i]+s[i+2:]
            except:
                pass
print(cnt)

Fixed submission:
s=[i for i in input()]
one=s.count("1")
zero=s.count("0")
print(len(s)-abs(one-zero))

Buggy python submission (verdict: Time Limit Exceeded):
s=[i for i in input()]
cnt=0
while True:
    if len(s)==0 or s.count("0")==len(s) or s.count("1")==len(s):
        break
    else:
        for i in range(len(s)):
            try:
                if int(s[i])+int(s[i+1])==1:
                    cnt+=2
                    s=s[0:i]+s[i+2:]
            except:
                pass
print(cnt)

Fixed submission:
s=[i for i in input()]
one=s.count("1")
zero=s.count("0")
print(len(s)-abs(one-zero))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
dp=[0]+[100000000000]*100010
for i in range(n):
    for j in range(1,k+1):
        try:
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        except:
            break
print(dp[n-1])

Fixed submission:
n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
dp=[0]+[100000000000]*100010
for i in range(n):
    for j in range(1,k+1):
        try:
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        except:
            break
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted([int(i) for i in input().split()])
cnt=0
while True:
    odd=[i for i in a if i%2==1]
    even=[i for i in a if i%2==0]
    if len(even)==0:
        break
    maxi=even[-1]
    even=[i*3 for i in even[0:-1]]
    even.append(maxi//2)
    a=odd+even
    cnt+=1
print(cnt)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
cnt=0
for i in range(n):
    while a[i]%2==0:
        a[i]=a[i]//2
        cnt+=1
print(cnt)