Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    s=input()
    l1=[0]*(n)
    l2=[0]*(n)
    l3=[0]*(n)
    for i in range(1,n):
        if s[i]=="R":
            l1[i-1]+=1
        elif s[i]=="G":
            l2[i-1]+=1
        else:
            l3[i-1]+=1
    for i in range(n-1,0,-1):
        l1[i-1]+=l1[i]
        l2[i-1]+=l2[i]
        l3[i-1]+=l3[i]
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            if set([s[i],s[j]])=={"G","B"}:
                ans+=l1[j]
                if 2*j-i<n and s[2*j-i]=="R":
                    ans-=1
            elif set([s[i],s[j]])=={"R","B"}:
                ans+=l2[j]
                if 2*j-i<n and s[2*j-i]=="G":
                    ans-=1
            elif set([s[i],s[j]])=={"R","G"}:
                ans+=l3[j]
                if 2*j-i<n and s[2*j-i]=="B":
                    ans-=1
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n=int(input())
    s=input()
    l1=[0]*(n)
    l2=[0]*(n)
    l3=[0]*(n)
    for i in range(1,n):
        if s[i]=="R":
            l1[i-1]+=1
        elif s[i]=="G":
            l2[i-1]+=1
        else:
            l3[i-1]+=1
    for i in range(n-1,0,-1):
        l1[i-1]+=l1[i]
        l2[i-1]+=l2[i]
        l3[i-1]+=l3[i]
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            if set([s[i],s[j]])=={"G","B"}:
                ans+=l1[j]
                if 2*j-i<n and s[2*j-i]=="R":
                    ans-=1
            elif set([s[i],s[j]])=={"R","B"}:
                ans+=l2[j]
                if 2*j-i<n and s[2*j-i]=="G":
                    ans-=1
            elif set([s[i],s[j]])=={"R","G"}:
                ans+=l3[j]
                if 2*j-i<n and s[2*j-i]=="B":
                    ans-=1
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n,k,c=map(int,input().split())
    S=input()
    l1=[[0,0] for _ in range(n)]
    l2=[0]*n
    memo=[0]*n
    x=0
    for i in range(n):
        if S[i]=="o" and memo[i]==0:
            x+=1
            l1[i][0]=x
            l1[i][1]=i+c+1
            for j in range(i,i+c+1):
                if j<n:
                    memo[j]=1
        elif S[i]=="o" and memo[i]==1:
            l1[i][0]=x
            l1[i][1]=l1[i-1][1]
        elif S[i]=="x" and memo[i]==0:
            l1[i][0]=x
            l1[i][1]=i+1
        else:
            l1[i][0]=x
            l1[i][1]=l1[i-1][1]
    S_=S[::-1]
    memo=[0]*n
    x=0
    for i in range(n):
        if S_[i]=="o" and memo[i]==0:
            x+=1
            l2[i]=x
            for j in range(i,i+c+1):
                if j<n:
                    memo[j]=1
        else:
            l2[i]=x
    l2=l2[::-1]
    ans=0
    for i in range(n):
        if S[i]=="o":
            x=0
            if i!=0:
                x+=l1[i-1][0]
            if i==0:
                x+=l2[1]
            else:
                if l1[i-1][1]<n and i<n-1:
                    x+=l2[max(l1[i-1][1],i+1)]
            if x<k:
                print(i+1)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n,k,c=map(int,input().split())
    S=input()
    l1=[[0,0] for _ in range(n)]
    l2=[0]*n
    memo=[0]*n
    x=0
    for i in range(n):
        if S[i]=="o" and memo[i]==0:
            x+=1
            l1[i][0]=x
            l1[i][1]=i+c+1
            for j in range(i,i+c+1):
                if j<n:
                    memo[j]=1
        elif S[i]=="o" and memo[i]==1:
            l1[i][0]=x
            l1[i][1]=l1[i-1][1]
        elif S[i]=="x" and memo[i]==0:
            l1[i][0]=x
            l1[i][1]=i+1
        else:
            l1[i][0]=x
            l1[i][1]=l1[i-1][1]
    S_=S[::-1]
    memo=[0]*n
    x=0
    for i in range(n):
        if S_[i]=="o" and memo[i]==0:
            x+=1
            l2[i]=x
            for j in range(i,i+c+1):
                if j<n:
                    memo[j]=1
        else:
            l2[i]=x
    l2=l2[::-1]
    ans=0
    for i in range(n):
        if S[i]=="o":
            x=0
            if i!=0:
                x+=l1[i-1][0]
            if i==0 and n!=1:
                x+=l2[1]
            else:
                if l1[i-1][1]<n and i<n-1:
                    x+=l2[max(l1[i-1][1],i+1)]
            if x<k:
                print(i+1)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input=sys.stdin.readline
    n,s=map(int,input().split())
    A=list(map(int,input().split()))
    mod=998244353
    dp=[[0]*(s+1) for _ in range(n+1)]
    dp[0][0]=1
    for i in range(1,n+1):
        for j in range(s+1):
            a=A[n-i]
            if j-a>0:
                dp[i][j]=(dp[i-1][j]+dp[i-1][j-a])%mod
            elif j==a:
                dp[i][j]=(dp[i-1][j]+i)%mod
            else:
                dp[i][j]=dp[i-1][j]
    ans=0
    for i in range(1,n+1):
        a=A[i-1]
        ans=(ans+dp[n-i][s-a]*i)%mod
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input=sys.stdin.readline
    n,s=map(int,input().split())
    A=list(map(int,input().split()))
    mod=998244353
    dp=[[0]*(s+1) for _ in range(n+1)]
    dp[0][0]=1
    for i in range(1,n+1):
        for j in range(s+1):
            a=A[n-i]
            if j-a>0:
                dp[i][j]=(dp[i-1][j]+dp[i-1][j-a])%mod
            elif j==a:
                dp[i][j]=(dp[i-1][j]+i)%mod
            else:
                dp[i][j]=dp[i-1][j]
    ans=0
    for i in range(1,n+1):
        a=A[i-1]
        if s>a:
            ans=(ans+dp[n-i][s-a]*i)%mod
        elif s==a:
            ans=(ans+(n-i+1)*i)%mod
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a=input()
a_l=len(a)
b=input()
b_l=len(b)
c=input()
c_l=len(c)
def check(s1,s2):
    l1=len(s1)
    l2=len(s2)
    ret=[0]*(l1+l2-1)
    for i in range(l1+l2-1):
        flag=True
        if i-l2+1<0:
            for j in range(i+1):
                if s1[j]!="?" and s2[l2-i+j-1]!="?" and s1[j]!=s2[l2-i+j-1]:
                    flag=False
                    break
        elif i-l2+1>=0 and i<=l1-1:
            for j in range(l2):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        else:
            for j in range(l1+l2-i-1):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        ret[i]=flag
    return ret
ab=check(a,b)
ab_l=len(ab)
ac=check(a,c)
ac_l=len(ac)
bc=check(b,c)
bc_l=len(bc)
ans=a_l+b_l+c_l
for i in range(-3000,ab_l+3000):
    if i<0 or i>=ab_l or ab[i]:
        for j in range(-3000,ac_l+3000):
            if j<0 or j>=ac_l or ac[j]:
                if (0<=j-i+b_l+1<bc_l and bc[j-i+b_l+1]) or j-i+b_l+1<0 or j-i+b_l+1>=bc_l:
                    l=max(a_l-1,i,j)-min(0,i-b_l+1,j-c_l+1)+1
                    ans=min(ans,l)
print(ans)

Fixed submission:
k=int(input())
l=[1 ,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c-a-b<=0:
    print("No")
else:
    l=a*b*4
    r=(c-a-b)**2
    if r>l:
        print("Yes")
    else:
        print("No")


Fixed submission:
k=int(input())
l=[1 ,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
N=2*10**6+1
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
    fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
    inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
    if n<=0 or r<0 or r>n:
        return 0
    return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod

r1,c1,r2,c2=map(int,input().split())
w=r2-r1
h=c2-c1
ans=nCr(r1+c1,r1)
for i in range(r1+1,r2+1):
    ans=(ans+(nCr(i+c1,i)*nCr(r2-i+1+h,h)%mod))%mod
for i in range(c1+1,c2+1):
    ans=(ans+(nCr(i+r1,i)*nCr(c2-i+1+w,w)%mod))%mod
print(ans)

Fixed submission:
N=2*10**6+1
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
    fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
    inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
    if n<=0 or r<0 or r>n:
        return 0
    return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod

r1,c1,r2,c2=map(int,input().split())
w=r2-r1
h=c2-c1
ans=nCr(r1+c1,r1)
for i in range(r1+1,r2+1):
    ans=(ans+(nCr(i+c1,i)*nCr(r2-i+1+h,h)%mod))%mod
for i in range(c1+1,c2+1):
    ans=(ans+(nCr(i+r1,i)*nCr(c2-i+1+w,w)%mod))%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
h=int(input())
ans=0
c=1
while h>1:
    ans+=c
    c*=2
    h//=2
ans+=c
print(ans)

Fixed submission:
import math
h,a=map(int,input().split())
print(math.ceil(h/a))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
AB=[]
for _ in range(n):
    AB.append(list(map(int,input().split())))
dp=[0]+[float("INF")]*h
for i in range(1,h+1):
    for a,b in AB:
        if i<=a:
            dp[i]=min(dp[i],b)
        else:
            dp[i]=min(dp[i],b+dp[i-a])
print(dp[-1])

Fixed submission:
h,n=map(int,input().split())
AB=[]
for _ in range(n):
    AB.append(list(map(int,input().split())))
dp=[0]+[float("INF")]*h
for i in range(1,h+1):
    for a,b in AB:
        if i<=a:
            dp[i]=min(dp[i],b)
        else:
            dp[i]=min(dp[i],b+dp[i-a])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import math
n,d,a=map(int,input().split())
XH=[]
for _ in range(n):
    x,h=map(int,input().split())
    h=math.ceil(h/a)
    XH.append([x,h])
XH.sort()
l=0
r=0
left=XH[0][0]
right=left+2*d
ans=XH[0][1]
c=XH[0][1]
L=[c]
while l<=n-1:
    left=XH[l][0]
    right=left+2*d
    if XH[r+1][0]<=right:
        cc=max(0,XH[r+1][1]-c)
        L.append(cc)
        c+=cc
        ans+=cc
        r+=1
        if r>=n-1:
            r-=1
            l+=1
    else:
        c-=L[l]
        l+=1
print(ans)

Fixed submission:
import math
n,d,a=map(int,input().split())
XH=[]
for _ in range(n):
    x,h=map(int,input().split())
    h=math.ceil(h/a)
    XH.append([x,h])
XH.sort()
if n==1:
    print(XH[0][1])
    exit()
l=0
r=0
ans=XH[0][1]
c=XH[0][1]
L=[c]
while l<=n-1:
    left=XH[l][0]
    right=left+2*d
    if XH[r+1][0]<=right:
        cc=max(0,XH[r+1][1]-c)
        L.append(cc)
        c+=cc
        ans+=cc
        r+=1
        if r>=n-1:
            r-=1
            l+=1
    else:
        c-=L[l]
        l+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
ans=[]
if s==10**9:
    ans=[s]*k+[1]*[n-k]
else:
    ans=[s]*k+[s+1]*(n-k)
print(*ans)

Fixed submission:
n,k,s=map(int,input().split())
ans=[]
if s==10**9:
    ans=[s]*k+[1]*(n-k)
else:
    ans=[s]*k+[s+1]*(n-k)
print(*ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%3==0:
    for i in range(n//3):
        print("a.."*n//3)
        print("a.."*n//3)
        print(".aa"*n//3)
else:
    if n%2==0 and n>=4:
        x="aacd"+"."*(n-4)
        y="bbcd"+"."*(n-4)
        for i in range(n//2):
            print(x)
            print(y)
            x=x[2:]+x[:2]
            y=y[2:]+y[:2]
    else:
        print(-1)

Fixed submission:
n=int(input())
if n%3==0:
    for i in range(n//3):
        print("a.."*(n//3))
        print("a.."*(n//3))
        print(".aa"*(n//3))
elif n%2==0 and n>=4:
    x="aacd"+"."*(n-4)
    y="bbcd"+"."*(n-4)
    for i in range(n//2):
        print(x)
        print(y)
        x=x[2:]+x[:2]
        y=y[2:]+y[:2]
elif n>=13:
    x="aacd"+"."*(n-13)
    y="bbcd"+"."*(n-13)
    for i in range((n-9)//2):
        print(x+"."*9)
        print(y+"."*9)
        x=x[2:]+x[:2]
        y=y[2:]+y[:2]
    for i in range(3):
        print("."*(n-9)+"a..a..a..")
        print("."*(n-9)+"a..a..a..")
        print("."*(n-9)+".aa.aa.aa")   
elif n==5:
    print("aabba")
    print("bc..a")
    print("bc..b")
    print("a.ddb")
    print("abbaa")
elif n==7:
    print("aabbcc.")
    print("dd.dd.a")
    print("..e..ea")
    print("..e..eb")
    print("dd.dd.b")
    print("..e..ec")
    print("..e..ec")
elif n==11:
    print("aabbcc.....")
    print("dd.dd.a....")
    print("..e..ea....")
    print("..e..eb....")
    print("dd.dd.b....")
    print("..e..ec....")
    print("..e..ec....")
    print(".......aacd")
    print(".......bbcd")
    print(".......cdaa")
    print(".......cdbb")
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=input()
def check(a,S):
    c=0
    ret=0
    for s in S:
        if s==a[c]:
            c+=1
        if c==3:
            ret=1
            break
    return ret
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if check(str(i)+str(j)+str(k),S):
                ans+=1
print(ans)

Fixed submission:
n=int(input())
S=input()
ans=0
for i in range(10):
    if str(i) in S:
        T=S[S.index(str(i))+1:]
        for j in range(10):
            if str(j) in T:
                U=T[T.index(str(j))+1:]
                for k in range(10):
                    if str(k) in U:
                        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
E=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append([b,i])
    E[b].append([a,i])
k=0
for e in E:
    k=max(k,len(e))
ans=[0]*(n-1)
def dsf(v,p,vp_c):
    c=1
    for u,i in E[v]:
        if u!=p:
            if c==vp_c:
                c+=1
            ans[i]=c
            dsf(u,v,c)
            c+=1
dsf(1,0,0)
print(k)
for i in range(n-1):
    print(ans[i])

Fixed submission:
import sys
sys.setrecursionlimit(500000)
n=int(input())
E=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append([b,i])
    E[b].append([a,i])
k=0
for e in E:
    k=max(k,len(e))
ans=[0]*(n-1)
def dsf(v,p,vp_c):
    c=1
    for u,i in E[v]:
        if u!=p:
            if c==vp_c:
                c+=1
            ans[i]=c
            dsf(u,v,c)
            c+=1
dsf(1,0,0)
print(k)
for i in range(n-1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
else:
    a=y-(x+y)//3
    b=x-(x+y)//3
    if a<0 or b<0:
        print(0)
    else:
        p=1000000007
        def comb(n,k,p):
            from math import factorial
            if n<0 or k<0 or n<k:
                return 0
            if n==0 or k==0:
                return 1
            a=factorial(n)%p
            b=factorial(k)%p
            c=factorial(n-k)%p
            return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p 
        def power_func(a,b,p):
            if b==0:
                return 1
            if b%2==0:
                d=power_func(a,b//2,p)
                return d*d %p
            if b%2==1:
                return (a*power_func(a,b-1,p))%p
        ans=comb(a+b,a,p)
        print(ans)

Fixed submission:
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
else:
    a=y-(x+y)//3
    b=x-(x+y)//3
    if a<0 or b<0:
        print(0)
    else:
        def cmb(n, r, mod):
            if ( r<0 or r>n ):
                return 0
            r = min(r, n-r)
            return g1[n] * g2[r] * g2[n-r] % mod
        mod = 10**9+7
        N = 10**6
        g1 = [1,1]
        g2 = [1,1]
        inverse = [0, 1]
        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )
        ans=cmb(a+b,a,mod)
        print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
a,b=min(a,b),max(a,b)
ans=1
is_prime = [True]*(a+1)
is_prime[0]=False
is_prime[1]=False
for i in range(2,a+1):
  if is_prime[i]:
    if a%i==0 and b%i==0:
      ans+=1
    while a%i==0:
      a//=i
    if a==1:
      break
    for j in range(i*2,a+1,i):
      is_prime[j] = False
print(ans)

Fixed submission:
from fractions import gcd
import math
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
for i in range(2,math.floor(g**.5)+1):
  if g%i==0:
    ans+=1
    while g%i==0:
      g//=i
if g!=1:
  ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b=map(int,input().split())
a,b=min(a,b),max(a,b)
ans=1
for i in range(2,a+1):
  if a%i==0:
    if b%i==0:
      ans+=1
    while a%i==0:
      a//=i
    if a==1:
      break
print(ans)

Fixed submission:
from fractions import gcd
import math
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
for i in range(2,math.floor(g**.5)+1):
  if g%i==0:
    ans+=1
    while g%i==0:
      g//=i
if g!=1:
  ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,a,b=map(int,input().split())
l=[(w-a)*i+a*(h-i) for i in range(h+1)]
for j in list(range(w))[::-1]:
  if (h-b)*j+b*(w-j) in l:
    x=l.index((h-b)*j+b*(w-j))
    y=j
    ans=[[0]*w for _ in range(h)]
    goalh=[w-a]*x+[a]*(h-x)
    goalw=[h-b]*y+[b]*(w-y)
    nowh=[0]*h
    noww=[0]*w
    for i in range(h):
      for j in range(w):
        if nowh[i]<goalh[i] and noww[j]<goalw[j]:
          ans[i][j]=1
          nowh[i]+=1
          noww[j]+=1
    if nowh!=goalh or noww!=goalw:
      continue
    for i in range(h):
      print(*ans[i],sep="")
    exit()
print("No")

Fixed submission:
h,w,a,b=map(int,input().split())
for i in range(b):
  print(*([0]*a+[1]*(w-a)),sep="")
for i in range(h-b):
  print(*([1]*a+[0]*(w-a)),sep="")
Buggy python submission (verdict: Runtime Error):
import bisect
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
c=A.pop()//2
l=[c]
for _ in range(m-1):
  c=l.pop()
  if c>=A[-1]:
    c//=2
    bisect.insort_left(l,c)
  else:
    l+=[c]
    c=A.pop()//2
    bisect.insort_left(l,c)
print(sum(A)+sum(l))

Fixed submission:
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))
hq=[]
for i in A:
  heapq.heappush(hq,-i)
for _ in range(m):
  m=-((-heapq.heappop(hq))//2)
  heapq.heappush(hq,m)
print(-sum(hq))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
A=list(map(int,input().split()))
for _ in range(m):
  A[A.index(max(A))]//=2
print(sum(A))

Fixed submission:
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))
hq=[]
for i in A:
  heapq.heappush(hq,-i)
for _ in range(m):
  m=-((-heapq.heappop(hq))//2)
  heapq.heappush(hq,m)
print(-sum(hq))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
for _ in range(m):
  m=A.pop()//2
  bisect.insort_left(A,m)
print(sum(A))

Fixed submission:
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))
hq=[]
for i in A:
  heapq.heappush(hq,-i)
for _ in range(m):
  m=-((-heapq.heappop(hq))//2)
  heapq.heappush(hq,m)
print(-sum(hq))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
      dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
      dp[i]=0
print(dp[n])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
fib=[0]*(n+1)
fib[0]=0
fib[1]=1
for i in range(n-1):
  fib[i+2]=fib[i]+fib[i+1]
ans=1
k=0
for i in range(m):
  a=int(input())
  ans*=fib[a-k]
  k=a+1
ans*=fib[n-k+1]
print(ans%1000000007)

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
      dp[i]=0
print(dp[n])
Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
for i in range(len(s)):
  l=0
  for j in range(i:len(s)):
    if s[j] in ["A","T","G","C"]:
      l+=1
    else:
      break
  ans=max(ans,l)
print(ans)

Fixed submission:
s=input()
ans=0
for i in range(len(s)):
  l=0
  for j in range(i,len(s)):
    if s[j] in ["A","T","G","C"]:
      l+=1
    else:
      break
  ans=max(ans,l)
print(ans)
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[l-1:r].count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()
T=[0]*(n+1)
for i in range(n-1):
  T[i+2]=T[i+1]+[0,1][s[i:i+2]=="AC"]
for _ in range(q):
  l,r=map(int,input().split())
  print(T[r]-T[l-1]-[0,1][s[l-2:l]=="AC"])
Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split())
B=list(input().split())
right_answer=0
for i in range(N):
  A=list(input().split())
  if sum(a*b for a,b in zip(A,B))+C>0:
    right_answer+=1
print(right_answer)

Fixed submission:
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
right_answer=0
for i in range(N):
  A=list(map(int,input().split()))
  if sum(a*b for a,b in zip(A,B))+C>0:
    right_answer+=1
print(right_answer)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input(),split())
print(a+b if b%a==0 else b-a)

Fixed submission:
a,b=map(int,input().split())
print(a+b if b%a==0 else b-a)
Buggy python submission (verdict: Runtime Error):
n=int(input())
price_list=[int(input()) for i in range(n)]
print(sum(price_list)-max(price_list)//2)

Fixed submission:
print("Christmas"+" Eve"*(25-int(input())))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n-1):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
  if n==0 and x==1:
    return 1
  elif n==0:
    return 0
  elif x<=1:
    return 0
  elif x<=1+a[n-]:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

Fixed submission:
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:return f(n-1,x-1)
    else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n-1):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
  if n==0 and x=1:
    return 1
  elif n==0:
    return 0
  elif x<=1+a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

Fixed submission:
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:return f(n-1,x-1)
    else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))
Buggy python submission (verdict: Runtime Error):
n=int(input())
def dsf(s):
  if int(s)>n:
    return0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))

Fixed submission:
n=int(input())
def dsf(s):
  if int(s)>n:
    return 0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
g=gcd(n,m)
l=n*m//g
ans=l
L=[0]*l
p=0
for i in s:
  L[p]=i
  p+=l//n
p=0
for j in t:
  if L[p]!=0 and L[p]!=j:
    ans=-1
    break
  p+=l//m
print(ans)

Fixed submission:
from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
L=gcd(N,M)
print(N*M//L if all([S[i*N//L]==T[i*M//L] for i in range(L)]) else "-1")
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
cost_list=[]
for i in range(n):
  cost,time=map(int,input().split())
  if time<=t:
    cost_list+=[cost]
if cost_list!=[]:
  print(min(cost_list))
else:
  print(TLE)

Fixed submission:
if input()=="1":
  print("Hello World")
else:
  print(sum([int(input()) for i in range(2)]))