Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
ans=0
for i in range(a,b+1):
    if i%c!=0 and i%d!=0:
        ans+=1
print(ans)



Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
ans=0
ca=[]
da=[]
cda=[]
minimunc=-(-a//c)
minimund=-(-a//d)
minimuncd=-(-a//((c*d)//fractions.gcd(c,d)))
maximunc=b//c
maximund=b//d
maximuncd=b//((c*d)//fractions.gcd(c,d))
totalc=maximunc-minimunc+1
totald=maximund-minimund+1
totalcd=maximuncd-minimuncd+1

print((b-a+1)-(totalc+totald-totalcd))
Buggy python submission (verdict: Runtime Error):
import sys

a,b=int((x) for x in input().split())

if a>=b:
  print(10)
else:
  print(0)
  


Fixed submission:
import sys

a,b=(int(x) for x in input().split())

if a>=b:
  print(10)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
import sys

X,A=int((x) for x in input().split())

if X>=A:
  print(10)
else:
  print(0)
  

Fixed submission:
import sys

a,b=(int(x) for x in input().split())

if a>=b:
  print(10)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import sys
N,X=(int(x) for x in input().split())

L=int(y) for y in input().split()
count = 0
D=[0]
for k in range(0,N+1):
  if(D(k)<=X):
    count += 1
  D.append(D(k)+L(k))
  
print(count)
  
  


Fixed submission:
s=list(input().split())
l=list(input().split())
n=int(s[0])
x=int(s[1])
count=1
d=0
for i in range(n):
  d=d+int(l[i])
  if d<=x:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
import sys
N,X=(int(x) for x in input().split())
L=[]
L.append(int(y) for y in input().split())
count = 0
D=[0]
for k in range(0,N+1):
  if(D(k)<=6):
    count += 1
  D.append(D(k)+L(k))
  
print(count)
  
  

Fixed submission:
s=list(input().split())
l=list(input().split())
n=int(s[0])
x=int(s[1])
count=1
d=0
for i in range(n):
  d=d+int(l[i])
  if d<=x:
    count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
MOD=10**9+7
dp=[0]*(n+1)
a=[]
for i in range(m):
    tmp=int(input())
    a.append(tmp)
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if i-1 in a:
        if i-2 in a:
            print(0)
            exit()
        dp[i]=dp[i-2]
    elif i-2 in a:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1])

Fixed submission:
n,m=map(int,input().split())
MOD=10**9+7
dp=[0]*(n+1)
breakstair=[False]*(n+1)
a=[]
for i in range(m):
    tmp=int(input())
    breakstair[tmp]=True
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if breakstair[i-1]:
        if breakstair[i-2]:
            print(0)
            exit()
        dp[i]=dp[i-2]
    elif breakstair[i-2]:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
MOD=1000000007
a=[]
tmp2=10000000000000
for i in range(m):
    tmp=int(input())
    if (tmp-tmp2)==1:
        print(0)
        exit()
    a.append(tmp)
    tmp2=tmp
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if i-1 in a:
        dp[i]=dp[i-2]%MOD
    elif i-2 in a:
        dp[i]=dp[i-1]%MOD
    else:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1])

Fixed submission:
n,m=map(int,input().split())
MOD=10**9+7
dp=[0]*(n+1)
breakstair=[False]*(n+1)
a=[]
for i in range(m):
    tmp=int(input())
    breakstair[tmp]=True
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if breakstair[i-1]:
        if breakstair[i-2]:
            print(0)
            exit()
        dp[i]=dp[i-2]
    elif breakstair[i-2]:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import math
import fractions
n=int(input())
a=list(map(int,input().split()))
left=[0]*(n+1)
right=[0]*(n+1)
left[1]=a[0]
right[1]=a[n-1]
for i in range(2,n+1):
    left[i]=math.gcd(left[i-1],a[i-1])
    right[i]=math.gcd(right[i-1],a[n-i])
ans=0
for i in range(1,n-1):
    ans=max(ans,math.gcd(left[i],right[n-1-i]))
print(max(ans,right[n-1],left[n-1]))


Fixed submission:
import math
import fractions
n=int(input())
a=list(map(int,input().split()))
left=[0]*(n+1)
right=[0]*(n+1)
left[1]=a[0]
right[1]=a[n-1]
for i in range(2,n+1):
    left[i]=fractions.gcd(left[i-1],a[i-1])
    right[i]=fractions.gcd(right[i-1],a[n-i])
ans=0
for i in range(1,n-1):
    ans=max(ans,fractions.gcd(left[i],right[n-1-i]))
print(max(ans,right[n-1],left[n-1]))
Buggy python submission (verdict: Runtime Error):
x=[]
total=[]
for i in range(5):
  t=list(input())
  if t[-1]=='0':
    total.append(t)
  else:
    x.append(t)
x=sorted(x, key=lambda x: x[-1])
for i in range(1,len(x)):
  total.append(x[i])
last=int(''.join(x[0]))
for i in range(4):
  total[i]=int(''.join(total[i]))
  total[i]=-(-total[i]//10)*10

print(sum(total)+last)

Fixed submission:
x=[]
total=[]
for i in range(5):
  t=list(input())
  if t[-1]=='0':
    total.append(t)
  else:
    x.append(t)
x=sorted(x, key=lambda x: x[-1])
for i in range(1,len(x)):
  total.append(x[i])
if len(x)!=0:
  last=int(''.join(x[0]))

for i in range(4):
  total[i]=int(''.join(total[i]))
  total[i]=-(-total[i]//10)*10
if len(x)==0:
  total[-1]=int(''.join(total[-1]))
  print(sum(total))
else:
  print(sum(total)+last)
Buggy python submission (verdict: Runtime Error):
s=input()
word=list(s)
temp=[]
score=[]
for i in range(len(word)):
  if word[i]!='A' and word[i]!='C' and word[i]!='G' and word[i]!='T':
    temp.append(i+1)
if word[0]=='A' or word[0]=='C' or word[0]=='G' or word[0]=='T':
  temp.insert(0,0)
if word[-1]=='A' or word[-1]=='C' or word[-1]=='G' or word[-1]=='T':
  temp.append(len(word)+1)
print(temp)
for i in range(len(temp)-1):
  if temp[i]==0 or temp[i+1]==len(word)+1:
    score.append(temp[i+1]-temp[i]-1)
  else:
    score.append(temp[i+1]-temp[i]-1)
print(max(score))

Fixed submission:
S = input()
N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
      ans = max(ans, j - i + 1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=list(input())
actable=[]
for i in range(len(s)-1):
    if s[i]=="A":
        if s[i+1]=="C":
            actable.append(i+1)
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in actable:
        if j>=l and j<=r-1:
            ans+=1
    print(ans)

Fixed submission:
from bisect import bisect_left, bisect_right
n,q=map(int,input().split())
s=list(input())
actable=[]
for i in range(len(s)-1):
    if s[i]=="A":
        if s[i+1]=="C":
            actable.append(i+1)
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    ans=bisect_left(actable,r)-bisect_left(actable,l)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,m=map(int,input().split())
    drink=[]
    ans=0
    count=0
    for i in range(n):
        tmp=list(map(int,input().split()))
        drink.append(tmp)
    drink.sort()
    while(True):
        tmp=drink.pop(0)
        if m>tmp[1]:
            ans+=tmp[0]*tmp[1]
            m-=tmp[1]
        else:
            ans+=tmp[0]*m
            break
    print(ans)


resolve()

Fixed submission:
import heapq
def resolve():
    n,m=map(int,input().split())
    drink=[]
    ans=0
    count=0
    for i in range(n):
        tmp=list(map(int,input().split()))
        drink.append(tmp)
    heapq.heapify(drink)
    while(True):
        tmp=heapq.heappop(drink)
        if m>tmp[1]:
            ans+=tmp[0]*tmp[1]
            m-=tmp[1]
        else:
            ans+=tmp[0]*m
            break
    print(ans)


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a=list(map(int,input().split()))
for _ in range(n-1):
    a1=a.pop(0)
    a2=a.pop(0)
    a.append(fractions.gcd(a1,a2))
print(a[0])

Fixed submission:
import fractions
n=int(input())
a=list(map(int,input().split()))
ans=[0]*(n+1)
ans[1]=a[0]
for i in range(2,n+1):
    ans[i]=fractions.gcd(ans[i-1],a[i-1])
print(ans[-1])
Buggy python submission (verdict: Runtime Error):
dp={}
#これからかかる分のコストを計算
def dfs(pos,n,h):
    if pos >= n:
        return 999999999
    if pos == n-1:
        return 0
    if pos in dp:
        return dp[pos]
    step1 = dfs(pos+1,n,h) + abs(h[pos+1] - h[pos])
    step2 = dfs(pos+2,n,h) + abs(h[pos+2] - h[pos])
    dp[pos] = min(step1, step2)
    return dp[pos]

if __name__=="__main__":
    n = int(input())
    h = list(map(int, input().split()))
    h.append(0)
    print(dfs(0,n,h))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))

dp=[0]
dp.append(abs(h[1]-h[0]))

for i in range(2,n):
    step1=dp[i-1]+abs(h[i]-h[i-1])
    step2=dp[i-2]+abs(h[i]-h[i-2])
    dp.append(min(step1,step2))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n,w=map(int,input().split())
item=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    item.append(tmp)

dp=[[0]*(n+100) for i in range(w+100)]
for i in range(n):
    for j in range(w+1):
        if j >= item[i][0]:
            dp[i+1][j]=max(dp[i][j],dp[i][j-item[i][0]]+item[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][w])

Fixed submission:
n,w=map(int,input().split())
item=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    item.append(tmp)

dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j >= item[i][0]:
            dp[i+1][j]=max(dp[i][j],dp[i][j-item[i][0]]+item[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][w])

Buggy python submission (verdict: Runtime Error):
n,w=map(int,input().split())
item=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    item.append(tmp)

dp=[[0]*(n+10) for i in range(w+10)]
for i in range(n):
    for j in range(w+1):
        if j >= item[i][0]:
            dp[i+1][j]=max(dp[i][j],dp[i][j-item[i][0]]+item[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][w])

Fixed submission:
n,w=map(int,input().split())
item=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    item.append(tmp)

dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j >= item[i][0]:
            dp[i+1][j]=max(dp[i][j],dp[i][j-item[i][0]]+item[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
import sys, math, itertools, collections, bisect
n,k=map(int,input().split())
h=[]
for i in range(n):
    tmp=int(input())
    h.append(tmp)
h.sort()
min=10000000000
for i in range(len(h)-2):
    tmp2=h[i+k-1]-h[i]
    if min>tmp2:
        min=tmp2
print(min)


Fixed submission:
import sys, math, itertools, collections, bisect
n,k=map(int,input().split())
h=[]
for i in range(n):
    tmp=int(input())
    h.append(tmp)
h.sort()
min=10000000000
for i in range(len(h)-k+1):
    tmp2=h[i+k-1]-h[i]
    if min>tmp2:
        min=tmp2
print(min)
Buggy python submission (verdict: Runtime Error):
n=int(input())
e=[0]*(n+1)
count=0
ijklist={}
for i in range(2, n+1):
    cur = i
    for j in range(2, i + 1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
for i in range(n+1):
    for j in range(i+1,n+1):
        for k in range(j+1,n+1):
            if e[i]>=4 and e[j]>=4 and e[k]>=2:
                if i+j+k  not in ijklist:
                    ijklist.add(i+j+k)
                    count += 1
            elif e[i]>=14 and e[j]>=4 and e[k]==0:
                if i+j+k  not in ijklist:
                    ijklist.add(i+j+k)
                    count += 1
            elif e[i]>=24 and e[j]>=2 and e[k]==0:
                if i+j+k  not in ijklist:
                    ijklist.add(i+j+k)
                    count += 1
            elif e[i]>=74 and e[j]==0 and e[k]==0:
                if i+j+k  not in ijklist:
                    ijklist.add(i+j+k)
                    count += 1
print(count)



Fixed submission:
N = int(input())
e = [0] * (N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
         while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)+ num(5) * (num(5) - 1) * (num(3) - 2) // 2)
Buggy python submission (verdict: Runtime Error):
x=list(input().split())
x1=int(x[0])
y1=int(x[1])
x2=int(x[2])
y2=int(x[3])
xlength=abs(x1-x2)
ylength=abs(y1-y2)
if x1>x2 and y2>y1:
  x3=x2-ylength
  y3=y2-xlength
  x4=x3+xlength
  y4=y3-ylength
elif x1>x2 and y1>y2:
  x3=x2+xlength
  y3=y2-ylength
  x4=x3+ylength
  y4=y3+xlength
elif x1<x2 and y1>y2:
  x3=x2+ylength
  y3=y2+xlength
  x4=x3-xlength
  y4=y3+ylength
elif x1<x2 and y1<y2:
  x3=x2-xlength
  y3=y2+ylength
  x4=x3-ylength
  y4=y3-xlength
  
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Fixed submission:
x=list(input().split())
x1=int(x[0])
y1=int(x[1])
x2=int(x[2])
y2=int(x[3])
xlength=x2-x1
ylength=y2-y1
x3=x2-ylength
y3=y2+xlength
x4=x1-ylength
y4=y1+xlength

  
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))
Buggy python submission (verdict: Runtime Error):
n=int(input())
flag=0
if i in range(26):
    if j in  range(15):
        total=4*i+j*7
        if total==n:
            flag+=1
            break
if flag==0:
    print('No')
else:
    print('Yes')
        









Fixed submission:
n=int(input())
flag=0
for i in range(26):
    for j in  range(15):
        total=4*i+j*7
        if total==n:
            flag+=1
            break
if flag==0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
n=input()
total=0
for i in len(n):
    total=total+int(n[i])
if n%total==0:
    print('Yes')
else:
    print('No')
    




Fixed submission:
n=input()
total=0
for i in range(len(n)):
    total=total+int(n[i])
if int(n)%total==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=input()
kagami=[]
for i in range(n):
    d=input()
    if d not in kagami:
        kagami.append(d)
print(len(kagami))


Fixed submission:
n=int(input())
kagami=[]
for i in range(n):
    d=input()
    if d not in kagami:
        kagami.append(d)
print(len(kagami))
Buggy python submission (verdict: Runtime Error):
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
ans = 0
t=cnt.most_common()
if len(t) <= k:
    print(0)
    exit()
if 
for i in range(k):
    ans += t[i][1]
print(n - ans)

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
ans = 0
t=cnt.most_common()
if len(t) <= k:
    print(0)
    exit()

for i in range(k):
    ans += t[i][1]
print(n - ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
ans = 0
if len(cnt.most_common()) <= k:
    print(0)
    exit()
for i in range(k):
    ans += cnt.most_common()[i][1]
print(n - ans)

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
ans = 0
t=cnt.most_common()
if len(t) <= k:
    print(0)
    exit()

for i in range(k):
    ans += t[i][1]
print(n - ans)

Buggy python submission (verdict: Time Limit Exceeded):
import  collections
def resolve():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    cnt=collections.Counter(a)
    ans=0
    for i in range(len(cnt.most_common())-k):
        ans+=cnt.most_common()[-1-i][1]
    print(ans)
resolve()

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
ans = 0
t=cnt.most_common()
if len(t) <= k:
    print(0)
    exit()

for i in range(k):
    ans += t[i][1]
print(n - ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
total=0
leave=0
for i in range(len(str(n))-1,0,-1):
    total+=int(n/(10**i))
    leave=n%(10**i)
if n%total==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
total=0
leave=n
for i in reversed(range(0,len(str(n)))):
    total+=int(leave/(10**i))
    leave=n%(10**i)
if n%total==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
x=list(input().split())
x1=int(x[0])
y1=int(x[1])
x2=int(x[2])
if (x2-x1)==(x3-x2):
  print('YES')
else:
  print('NO')

Fixed submission:
x=list(input().split())
x1=int(x[0])
x2=int(x[1])
x3=int(x[2])
if (x2-x1)==(x3-x2):
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
x=list(input().split())
x1=int(x[0])
y1=int(x[1])
x2=int(x[2])
if x2-x1==x3-x2:
  print('YES')
else:
  print('NO')

Fixed submission:
x=list(input().split())
x1=int(x[0])
x2=int(x[1])
x3=int(x[2])
if (x2-x1)==(x3-x2):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
title=list(input.split())
word=list(title[1])
print('A'+word[0]+'C')

Fixed submission:
title=list(input().split())
word=list(title[1])
print('A'+word[0]+'C')
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007
L = input()
n = len(L)
ans = 0
one = 0
for i in range(n):
    c = L[i]
    if c == '1':
        m = n - i - 1
        # print('m =', m)
        t = pow(3, m, MOD) * pow(2, one)
        # print('t =', t)
        ans += t
        ans %= MOD
        one += 1
t = pow(2, one)
ans += t
ans %= MOD
print(ans)


Fixed submission:
MOD = 1000000007
L = input()
n = len(L)
ans = 0
one = 0
for i in range(n):
    c = L[i]
    if c == '1':
        m = n - i - 1
        # print('m =', m)
        t = pow(3, m, MOD) * pow(2, one, MOD)
        # print('t =', t)
        ans += t
        ans %= MOD
        one += 1
t = pow(2, one)
ans += t
ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
print(180*(n-2))


Fixed submission:
n = int(input())
print(180*(n-2))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
mn = min(*A)
mx = max(*A)
f = True
for x in A:
    if x % mn != 0:
        f = False
        break
if (f == False or K % mn == 0) and mx >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import random
import fractions

def solve(N, K, A):
    gcd = A[0]
    for x in A:
        gcd = fractions.gcd(gcd, x)
    if K % gcd == 0 and max(A) >= K:
        return 'POSSIBLE'
    else:
        return 'IMPOSSIBLE'

def solve2(N, K, A):
    mx = max(A)
    B = [False] * (mx + 1)
    for i in A:
        B[i] = True
    while True:
        update = False
        for i in range(mx + 1):
            if not B[i]:
                continue
            for j in range(i + 1, mx + 1):
                if not B[j]:
                    continue
                d = abs(i - j)
                if not B[d]:
                    update = True
                    B[d] = True
        if not update:
            break
    return 'POSSIBLE' if K <= mx and B[K] else 'IMPOSSIBLE'

#for i in range(100000):
#    N = random.randint(1, 5)
#    K = random.randint(1, 20)
#    A = [random.randint(1, 20) for i in range(N)]
#    if solve(N, K, A) != solve2(N, K, A):
#        print(N, K, A)
#        print(solve(N, K, A))
#        print(solve2(N, K, A))
#        break

N, K = map(int, input().split())
A = list(map(int, input().split()))
print(solve(N, K, A))
Buggy python submission (verdict: Runtime Error):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

mod = 1000000007

n, m = nm()
dp = [0] * (n + 2)
for i in range(m):
    tmp = ni()
    dp[tmp] = -1
dp[0] = 1
for i in range(n):
    if i + 1 <= n:
        if dp[i + 1] != -1 and dp[i] != -1:
            dp[i + 1] += dp[i] % mod
            dp[i + 1] %= mod
    if i + 2 <= n:
        if dp[i + 2] != -1 and dp[i] != -1:
            dp[i + 2] += dp[i] % mod
            dp[i + 2] %= mod
if dp[n] = -1:
    print(0)
else:
    print(dp[n] % mod)


Fixed submission:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

mod = 1000000007

n, m = nm()
dp = [0] * (n + 1)
for i in range(m):
    tmp = ni()
    dp[tmp] = -1
dp[0] = 1
for i in range(n):
    if i + 1 < n + 1 and dp[i + 1] != -1 and dp[i] != -1:
        dp[i + 1] += dp[i] % mod
        dp[i + 1] %= mod
    if i + 2 < n + 1 and dp[i + 2] != -1 and dp[i] != -1:
        dp[i + 2] += dp[i] % mod
        dp[i + 2] %= mod
print(dp[n] % mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
v = nl()
c = nl()
ans = 0
for i in range(2 ** n):
    lis = list(bin(i)[2:].zfill(n))
    tmp = 0
    for l in range(len(lis)):
        tmp += int(lis[l]) * (v[l] - c[l])
    ans = max(ans, tmp)
print(ans)


Fixed submission:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
v = nl()
c = nl()
ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import fractions
from functools import reduce
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = ni()
a = nl()
maxx = gcd_list(a)
for i in range(n):
    maxx = max(maxx, gcd_list(a[:i] + a[i + 1:]))
print(maxx)


Fixed submission:
import sys
from functools import reduce
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcd_list(numbers):
    return reduce(gcd, numbers)
n = ni()
a = nl()
if len(a) == 2:
    print(max(a))
    exit()
minn = 10 ** 9 + 1
idx = -1
for i in range(n - 2):
    if minn >= gcd_list([a[i], a[i + 1], a[i + 2]]):
        minn = gcd_list([a[i], a[i + 1], a[i + 2]])
        idx = i
gcd1 = 0
gcd2 = 0
gcd3 = 0
for i in range(n):
    if i != idx:
        gcd1 = gcd(gcd1, a[i])
    if i != idx + 1:
        gcd2 = gcd(gcd2, a[i])
    if i != idx + 2:
        gcd3 = gcd(gcd3, a[i])
print(max(gcd1, gcd2, gcd3))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
s = list(ns())
count = 0
minn = 10 ** 9
for i in range(n + 1):
    minn = min(minn, s[:i].count('#') + s[i:].count('.'))
print(minn)


Fixed submission:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
s = list(ns())
count1 = 0
count2 = 0
lis1 = [0 for i in range(n)]
lis2 = [0 for i in range(n)]
for i in range(len(s)):
    if s[i] == '.':
        count1 += 1
        lis1[i] = count1
    if s[i] == '#':
        count1 -= 1
        lis1[i] = count1
idx1 = lis1.index(max(lis1))
for i in range(len(s)-1, -1, -1):
    if s[i] == '#':
        count2 += 1
        lis2[i] = count2
    if s[i] == '.':
        count2 -= 1
        lis2[i] = count2
idx2 = lis2.index(max(lis2))
ans1 = s[:idx1 + 1].count('#') + s[idx1 + 1:].count('.')
ans2 = s[:idx2].count('#') + s[idx2:].count('.')
print(min(ans1, ans2))