Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    n, k, q = LI()
    a = IR(q)
    sc = [0] * n
    for i in a:
        sc[i - 1] += 1
    for i in sc:
        print("Yes" if i > q - k else "No")
    return


# D
def D():
    n,m=LI()
    a=LI()
    for i in range(m):
        index = a.index(max(a))
        if a[index] > 0:
            a[index] = a[index]>>1
        else:
            break
    print(sum(a))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()


Fixed submission:
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    n, k, q = LI()
    a = IR(q)
    sc = [0] * n
    for i in a:
        sc[i - 1] += 1
    for i in sc:
        print("Yes" if i > q - k else "No")
    return


# D
def D():
    n, m = LI()
    a = LI()
    q = []
    for i in range(n):
        heappush(q, -a[i])
    for i in range(m):
        x = heappop(q)
        x *= -1
        x >>= 1
        heappush(q, -x)
    print(-sum(q))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()
Buggy python submission (verdict: Runtime Error):
import math
import fractions
a,b=map(int,input().split())
#mn=math.ceil(max(b/0.1,a/0.08))
mn=fractions.ceil(max(b/0.1,a/0.08))

mx=min((b+1)/0.1,(a+1)/0.08)
if mn<=mx:
    print(int(mn))
else:
    print(-1)

Fixed submission:
a,b=map(int,input().split())

mn=max(b*10,a*12.5)
if mn==a*12.5 and a%2==1:
    mn=int(mn)+1
mx=min((b+1)/0.1,(a+1)/0.08)
if mn<mx:
    print(int(mn))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ss=input()
dps=['a']*n
from collections import defaultdict
d=defaultdict(list)
for i in range(n):
    d[ss[i]].append(i)
    dps[i]=ss[i]
sorted(d.items())

Q=int(input())
import bisect
for i in range(Q):
    num,ii,c=input().split()
    #print(d)
    if num=='1':
        if c==dps[int(ii)-1]:
            continue
        idx=bisect.bisect_left(d[c],int(ii)-1)
        d[c].insert(idx,int(ii)-1)
        d[c].sort()
        d[dps[int(ii)-1]].remove(int(ii)-1)
        dps[int(ii)-1]=c
    else:
        l,r=int(ii)-1,int(c)-1
        count=0
        for k,lst in d.items():
            idx=bisect.bisect_left(lst,l)
            idx1=bisect.bisect_right(lst,r)
            count+=((idx1-idx)>0)
            #print(lst,l,r,count)
        print(count)
        pass

Fixed submission:
n=int(input())
ss=input()
dps=['a']*n
from collections import defaultdict
d=defaultdict(list)
for i in range(n):
    d[ss[i]].append(i)
    dps[i]=ss[i]
sorted(d.items())

Q=int(input())
import bisect
for i in range(Q):
    num,ii,c=input().split()
    #print(d)
    if num=='1':
        if c==dps[int(ii)-1]:
            continue
        bisect.insort_left(d[c],int(ii)-1)
        d[dps[int(ii)-1]].remove(int(ii)-1)
        dps[int(ii)-1]=c
    else:
        l,r=int(ii)-1,int(c)-1
        count=0
        for k,lst in d.items():
            idx=bisect.bisect_left(lst,l)
            idx1=bisect.bisect_right(lst,r)
            count+=((idx1-idx)>0)
            #print(lst,l,r,count)
        print(count)
        pass
Buggy python submission (verdict: Runtime Error):
r1,c1,r2,c2=map(int,input().split())
MOD=10**9+7
idx=r2+c2+3
perm=[1]*(idx+1)
for i in range(1,idx+1):
    perm[i]=perm[i-1]*i
    perm[i]%=MOD
def inv_mod(a):
  return pow(a,MOD-2,MOD)

def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
def g(i,j):
    return comb(i+j+2,i+1,mod)
def s(n,m):
    return comb(n+m+2, m+1, mod)
res=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)

mod = 10**9+7
ans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)
ans %= mod
print(res)

Fixed submission:
r1,c1,r2,c2=map(int,input().split())
MOD=10**9+7
idx=r2+c2+3
perm=[1]*(idx+1)
for i in range(1,idx+1):
    perm[i]=perm[i-1]*i
    perm[i]%=MOD
def inv_mod(a):
  return pow(a,MOD-2,MOD)

def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
def g(i,j):
    return comb(i+j+2,i+1,MOD)
def s(n,m):
    return comb(n+m+2, m+1, MOD)
res=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)
res%=MOD

ans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)
ans %= MOD
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=[0]*(n+1)

for i in range(n):
    s[i+1]=s[i]+a[i]
def test(x):
    count=0
    for i in range(n):
        idx=bisect.bisect_left(a,x-a[i])
        if i>=idx:
            count+=(i-idx)*2+1
    return count


def search():
    mn=-1
    mx=m*max(a)*2
    buf=0
    while mx-mn>1:
        buf=(mx+mn)//2
        count=test(buf)
        if count>=m:
            mn=buf
        else:
            mx=buf
    return mn
x=search()
y=test(x)
#print(x,y)
count=0
for i in range(n):
    idx=bisect.bisect_left(a,x-a[i])
    if i>=idx:
        count+=(2*i-2*idx)*a[i]+(s[i+1]-s[idx])*2
        #print(count,i-idx+1)
print(count-(y-m)*x)


Fixed submission:
import heapq
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=[0]*(n+1)
dp=[0]*(10**5+1)
h=0
for i in range(10**5+1):
    if h==n:
        dp[i]=h
        continue
    if i<=a[h]:
        dp[i]=h
    else:
        while h<n and i>a[h]:
            h+=1
        dp[i]=h



for i in range(n):
    s[i+1]=s[i]+a[i]
def test(x):
    count=0
    for i in range(n):
        buf=x-a[i]
        #idx=bisect.bisect_left(a,x-a[i])
        if buf<0:
            idx=0
        elif buf>=10**5+1:
            idx=n
        else:
            idx=dp[buf]
        if i>=idx:
            count+=(i-idx)*2+1
    return count


def search():
    mn=-1
    mx=m*max(a)*2
    buf=0
    while mx-mn>1:
        buf=(mx+mn)//2
        count=test(buf)
        if count>=m:
            mn=buf
        else:
            mx=buf
    return mn
x=search()
y=test(x)
#print(x,y)
count=0
for i in range(n):
    idx=bisect.bisect_left(a,x-a[i])
    if i>=idx:
        count+=(2*i-2*idx)*a[i]+(s[i+1]-s[idx])*2
        #print(count,i-idx+1)
print(count-(y-m)*x)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
x=math.gcd(a,b)
print(a*b//x)

Fixed submission:
import fractions
a,b=map(int,input().split())
x=fractions.gcd(a,b)
print(a*b//x)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    ab.append((a-1,b-1))
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
dfs(0,0,0)
for i in range(n-1):
    print(color[i])

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])
Buggy python submission (verdict: Runtime Error):
import sys
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
    sys.exit()
dx=x-(x+y)//3
dy=y-(x+y)//3
fact=[1]*(dx+dy+1)
MOD=10**9+7
def inv_mod(a):
  return pow(a,MOD-2,MOD)

for i in range(1,dx+dy+1):
  fact[i] = (i*fact[i-1])%MOD
fact_inv = [1] * (dx+dy+1)
fact_inv[-1] = inv_mod(fact[-1])
for i in range(dx+dy,0,-1):
  fact_inv[i-1] = (i*fact_inv[i])%MOD

def comb(n,k):
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x
print(comb(dx+dy,dx))

Fixed submission:
import sys
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
    sys.exit()
dx=x-(x+y)//3
dy=y-(x+y)//3
if dx<0 or dy<0:
    print(0)
    sys.exit()
fact=[1]*(dx+dy+1)
MOD=10**9+7
def inv_mod(a):
  return pow(a,MOD-2,MOD)

for i in range(1,dx+dy+1):
  fact[i] = (i*fact[i-1])%MOD
fact_inv = [1] * (dx+dy+1)
fact_inv[-1] = inv_mod(fact[-1])
for i in range(dx+dy,0,-1):
  fact_inv[i-1] = (i*fact_inv[i])%MOD

def comb(n,k):
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x
print(comb(dx+dy,dx))
Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
d=list(map(int,input().split()))
d.sort()
mx=d[-1]
count=[0]*(mx+1)
j=0
MOD=998244353
if d[0]!=0:
    print(0)
    sys.exit()
count[0]=1
j=1
for i in range(1,n):
    if d[i]==j:
        count[j]+=1
    elif d[i]==j+1 and count[i]>0:
        j+=1
        count[j]+=1
    else:
        print(0)
        sys.exit()
c=1
#print(d,count)
for i in range(1,mx+1):
    c*=pow(count[i-1],count[i],MOD)
    c%=MOD
print(c)

Fixed submission:
import sys
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    sys.exit()
d.sort()
mx=d[-1]
count=[0]*(mx+1)
MOD=998244353
for i in range(n):
    count[d[i]]+=1
c=1
#print(d,count)
if count[0]!=1:
    print(0)
    sys.exit()
for i in range(1,mx+1):
    c*=pow(count[i-1],count[i],MOD)
    c%=MOD
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
inf=10**12

ab=[]
cs=[]
for i in range(m):
    a,b=map(int,input().split())
    c=tuple(map(int,input().split()))
    ab.append((a,b))
    cs.append(c)
dp=[inf]*(2**n)
dp[0]=0
for i in range(m):
    x=0
    for h in cs[i]:
        x+=2**(h-1)
    for j in range(2**n):
        dp[j|x]=min(dp[j|x],dp[j]+ab[i][0])
print(dp[-1] if dp[-1]!=inf else -1)

Fixed submission:
n,m=map(int,input().split())
inf=10**12

ab=[]
cs=[]
for i in range(m):
    a,b=map(int,input().split())
    c=tuple(map(int,input().split()))
    ab.append((a,b))
    cs.append(c)
dp=[inf]*(2**n)
dp[0]=0
for i in range(m):
    x=0
    for h in cs[i]:
        x+=2**(h-1)
    for j in range(2**n):
        dp[j|x]=min(dp[j|x],dp[j]+ab[i][0])
print(dp[-1] if dp[-1]!=inf else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[[0]*n for i in range(n)]
buf=0
for i in range(n):
    for j in range(i+1,n):
        if i==0:
            if s[i]==s[j]:
                a[i][j]=1
            continue
        if s[i]==s[j]:
            a[i][j]=min(j-i,a[i-1][j-1]+1)
            buf=max(buf,a[i][j])
print(buf)

Fixed submission:
n=int(input())
s=input()
a=[[0]*n for i in range(n)]
buf=0
for i in range(n):
    for j in range(i+1,n):
        if i==0:
            if s[i]==s[j]:
                a[i][j]=1
            continue
        if s[i]==s[j]:
            a[i][j]=min(j-i,a[i-1][j-1]+1)
            buf=max(buf,a[i][j])
print(buf)
Buggy python submission (verdict: Runtime Error):
n,m,p=map(int,input().split())
A=[]
for i in range(m):
    a,b,c=map(int,input().split())
    A.append((a,b,p-c))

def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    buf=0
    for i in range(num_v*2):
        for edge in edges:
            if dist[edge[0]] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                if i>=num_v:
                    dist[edge[1]-1] =-inf
        if i==num_v-2:
            buf=dist[-1]
    if dist[-1]!=buf or dist[-1]==inf:
        return False
    return dist[-1]*-1

x=BellmanFord(A,n,1)
if x==False:
    print(-1) 
else:
    print(x if x>0 else 0)

Fixed submission:
"""解説を見てから解いたコード"""
N, M, P = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a, b, c-P))

INF = float('inf')

coin_map = [-INF] * (N+1)
coin_map[1] = 0

for i in range(2*N):
    for a, b, c in edges:
        if coin_map[b] < coin_map[a] + c:
            coin_map[b] = coin_map[a] + c
            if i >= N:
                coin_map[b] = INF

    if i == N - 1:
        ans = coin_map[N]

if ans != coin_map[N]:
    print(-1)
else:
    print(max(0, coin_map[N]))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
dp=[[0]*13 for i in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
    if s[i-1]=='?':
        for k in range(13):
           for j in range(10):
                dp[i][(k*10+j)%13]+=dp[i-1][k]
                dp[i][(k*10+j)%13]%=10**9+7
    else:
        idx=int(s[i-1])
        for j in range(13):
            dp[i][(j*10+idx)%13]=dp[i-1][j]
print(dp[-1][5]%(10**9+7))

Fixed submission:
s=input()
l=len(s)
dp=[[0]*13 for i in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
    if s[i-1]=='?':
        for k in range(13):
           for j in range(10):
                dp[i][(k*10+j)%13]+=dp[i-1][k]
                dp[i][(k*10+j)%13]%=10**9+7
    else:
        idx=int(s[i-1])
        for j in range(13):
            dp[i][(j*10+idx)%13]=dp[i-1][j]
print(dp[-1][5]%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
if l-r>2019:
    print(0)
else:
    s=2019
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            s=min(s,i*j%2019)
    print(s)


Fixed submission:
l,r=map(int,input().split())
x=l//2019
y=r//2019
if y-x>=1:
    print(0)
else:
    s=2019
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            s=min(s,i*j%2019)
    print(s)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
y=np.array(a)
A=np.eye(n)
for i in range(n):
    A[i-1][i]=1
#print(A)
x=np.linalg.solve(A,y)
for i in range(n):
    print(int(x[i])*2,end=' ')
print()   

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=sum(a)//2
d=0
for i in range(n//2+1):
    d+=a[2*i]
x1=d-s
print(2*x1,end=' ')
buf=x1
for i in range(0,n-1):
    buf=a[i]-buf
    print(2*buf,end=' ')
print()
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
nc=b//c-(a-1)//c
nd=b//d-(a-1)//d
x=c*d//math.gcd(c,d)
ncd=b//x-(a-1)//x
#print(nc,nd,x,ncd)
print(b-a+1-nc-nd+ncd)


Fixed submission:
a,b,c,d=map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a  
nc=b//c-(a-1)//c
nd=b//d-(a-1)//d
x=c*d//gcd(c,d)
ncd=b//x-(a-1)//x
#print(nc,nd,x,ncd)
print(b-a+1-nc-nd+ncd)
Buggy python submission (verdict: Runtime Error):
n=int(input())
z=[]
for i in range(n):
    x,y=map(int,input().split())
    z.append([x,y])
z.sort(reverse=True)
dif=[]
for i in range(n-1):
    x=z[i+1][0]-z[i][0]
    y=z[i+1][1]-z[i][1]
    dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=1
comp=dif[0]
ans=dif[0]
for i in range(1,n-1):
    if comp==dif[i]:
        #print(comp,dif[i])
        buf+=1
    else:
        #print(comp,dif[i],buf)
        if count<buf:
            count=buf
            ans=comp
        buf=0
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)

Fixed submission:
n=int(input())
z=[]
for i in range(n):
    x,y=map(int,input().split())
    z.append([x,y])
z.sort(reverse=True)
dif=[]
for i in range(n):
    for j in range(n):
        if i<j:
            x=z[j][0]-z[i][0]
            y=z[j][1]-z[i][1]
            dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=0
comp=[0,0]
ans=[0,0]
l=len(dif)
for i in range(l):
    if comp==dif[i]:
        buf+=1
    else:
        if count<buf:
            count=buf
            ans=comp
        buf=1
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
    x=int(input())
    if a:
        if x!=a[-1]:
            a.append(x)
    else:
        a.append(x)
count=[0]*(n+2)
count[1]=2
count[0]=1
i=0
s=a.pop(0)
if s==1:
    count[1]=1
    count[0]=0
    if a:
        s=a.pop(0)
if s==2:
    count[1]=0
    if a:
        s=a.pop(0)

while i<n:        
    if (i+2==s-1):
        i=i+1
        if a:
            s=a.pop(0)
    else:
        count[i+2]=(count[i]+count[i+1])%1000000007
        i=i+1
#print(count)
print(count[n-1])

Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
    x=int(input())
    if a:
        if x!=a[-1]:
            a.append(x)
    else:
        a.append(x)
count=[0]*(n+2)
count[1]=2
count[0]=1
i=0
s=0
if a:
    s=a.pop(0)
if s==1:
    count[1]=1
    count[0]=0
    if a:
        s=a.pop(0)
if s==2:
    count[1]=0
    if a:
        s=a.pop(0)

while i<n:        
    if (i+2==s-1):
        i=i+1
        if a:
            s=a.pop(0)
    else:
        count[i+2]=(count[i]+count[i+1])%1000000007
        i=i+1
#print(count)
print(count[n-1])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
count=[0]*(n+2)
count[1]=2
count[0]=1
i=0
s=a.pop(0)
if s==1:
    count[1]=1
    count[0]=0
    if a:
        s=a.pop(0)
if s==2:
    count[1]=0
    if a:
        s=a.pop(0)

while i<n:        
    if (i+2==s-1):
        i=i+1
        if a:
            s=a.pop(0)
    else:
        count[i+2]=(count[i]+count[i+1])%1000000007
        i=i+1
#print(count)
print(count[n-1])


Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
    x=int(input())
    if a:
        if x!=a[-1]:
            a.append(x)
    else:
        a.append(x)
count=[0]*(n+2)
count[1]=2
count[0]=1
i=0
s=0
if a:
    s=a.pop(0)
if s==1:
    count[1]=1
    count[0]=0
    if a:
        s=a.pop(0)
if s==2:
    count[1]=0
    if a:
        s=a.pop(0)

while i<n:        
    if (i+2==s-1):
        i=i+1
        if a:
            s=a.pop(0)
    else:
        count[i+2]=(count[i]+count[i+1])%1000000007
        i=i+1
#print(count)
print(count[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
a=[-1]*l
stack=[]
for i in range(l):
    if s[i]=='A':
        a[i]=1
        stack.append(i)
    elif s[i]=='B':
        a[i]=2
    else:
        a[i]=3
count=0
while stack:
    i=stack.pop(0)
    if i<l-2:
        if a[i]==1 and a[i+1]==2 and a[i+2]==3:
            count+=1
            a[i]=2
            a[i+1]=3
            a[i+2]=1
            stack.append(i+2)
            if (i-1>=0):
                if(a[i-1]==1):
                    stack.append(i-1)
            #print(a)
print(count)

Fixed submission:
s=input()
l=[]
i=0
while i < len(s):
    if i<len(s)-1:
        if s[i]=='B' and s[i+1]=='C':
            l.append('D')
            i+=2
        else:
            l.append(s[i])
            i+=1
    else:
        l.append(s[i])
        i+=1
n=len(l)
ca=0
count=0
for i in range(n):
    if l[i]=='A':
        ca+=1
    elif l[i]=='D':
        count+=ca
    else:
        ca=0
print(count)
Buggy python submission (verdict: Runtime Error):
d,g=map(int,input().split())
p=[]
c=[]
count=0
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    c.append(ci)
e=[]
for i in range(d):
    x=p[i]*(i+1)*100+c[i]
    y=x/p[i]
    e.append([y,x,i,p[i]])
e.sort(reverse=True)
for i in range(d):
    if g>=e[0][1]:
        count+=p[e[0][2]]
        g=g-e[0][1]
        aa=e.pop(0)
        #print(aa)
    else:
        break
e.sort(key=lambda x:x[3],reverse=True)
print(count+g//((e[0][2]+1)*100))

Fixed submission:
import sys
import math
d,g=map(int,input().split())
p=[]
c=[]
s=[]
count=0
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    c.append(ci)
    s.append((i+1)*100*pi+ci)

l=2**d
count=10**6*d
for i in range(l):
    buf=g
    x=0
    n=0
    for j in range(d):
        if i & 1 ==1:
            x+=p[j]
            buf-=s[j]
        else:
            n=j
        i=i>>1
    if buf>=0:
        y=math.ceil(buf/((n+1)*100))
        if y>p[n]:
            continue
        x=x+y
    count=min(count,x)
print(count)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

k=int(input())
a_t=1/k
a=a_t*10**(len(str(k))-1)
c=100
buf=0
index=0
b=a
for i in range(1,10):
        b=b-math.floor(b)
        buf=math.floor(b*10)
        #print(i,buf)
        if c>buf:
                index=i
        c=min(c,buf)
        b=b*10
#print(index)
m=math.ceil(a*10**index)
#print(m)
product=k*m
print(sum(int(i) for i in str(product)))

Fixed submission:
import numpy as np

s=input()
t=input()

print('YES' if s[0]==t[2] and s[1]==t[1] and s[2]==t[0] else 'NO')

Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools
import bisect

n=int(input())
a=sorted([int(i) for i in input().split()])
b=sorted([int(i) for i in input().split()])
c=sorted([int(i) for i in input().split()])

count=0
index_b=0
index_c=0
for i in range(n):
        index_c=bisect.bisect_left(b,c[i])
        for j in range(index_c):
                count+=bisect.bisect_left(a,b[j])
print(count)

Fixed submission:
import numpy as np

s=input()
t=input()

print('YES' if s[0]==t[2] and s[1]==t[1] and s[2]==t[0] else 'NO')