Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02629 (python)

Fixed submission:
N = int(input())
a = list('abcdefghijklmnopqrstuvwxyz')
name = 0
while N!=0:
  N-=1
  M = N%26
  N = N//26
  if name ==0:
    name = a[M]
  else:
    name = a[M]+name

print(name)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
N = int(input())
a=list(map(int, input().split()))
Q = int(input())
b=[]
c=[]
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
def index(lst, e):
    i = bisect_left(lst, e)
    if i == len(lst):
        raise ValueError
    if lst[i] != e:
        raise ValueError
    return i
for i in range(Q):
  first=0
  last = 0
  a.sort()
  if b[i] not in a:
    print(sum(a))
  else:
    last = a.count(b[i])
    first = index(a,b[i])
    del a[first:first+last]
    list_c = [c[i]]*last
    a = a+list_c
    print(sum(a))
Problem p02707 (python)

Fixed submission:
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100001
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100000
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])
Problem p03803 (python)

Fixed submission:
M,N = map(int,input().split())

if M == N:
  print('Draw')
elif (M>N and N!=1) or M==1:
  print('Alice')
else:
  print('Bob')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-(i%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
Problem p03804 (python)

Fixed submission:
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  if M>1 and i//N==N-1:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-(i)<M*M:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
Problem p02597 (python)

Fixed submission:
n=int(input())
s=input()
if s.count('R')==n:
    print(0)
else:
    w=s.index('W')
    s=s[w:]
    a= s.count('W')
    b=s[len(s)-a:].count('W')
    print(a-b)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
w=s.index('W')
s=s[w:]
a= s.count('W')
b=s[len(s)-a:].count('W')
print(a-b)
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split(" "))

a = [0]+list(map(int, input().split(" ")))
b = [0]+list(map(int, input().split(" ")))

for i in range(1, n+1):
    a[i] += a[i - 1]
for i in range(1, m+1):
    b[i] += b[i - 1]

j,mx= m,0
for i in range(n+1):
    if a[i]>k:
        break
    while(b[j]>k-a[i]):
        j-=1
    if (i+j>mx):
        mx=i+j
print(mx)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split(" "))

a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

for i in range(1, n):
    a[i] += a[i - 1]
for i in range(1, m):
    b[i] += b[i - 1]

j,mx= m-1,0
for i in range(n):
    if a[i]>k:
        break
    while(b[j]>k-a[i]):
        j-=1
    if (i+j+2>mx):
        mx=i+j+2
print(mx)
Problem p02682 (python)

Fixed submission:
a,b,c,k= map(int,input().split(' '))
if k<=a:
    print(k)
else:
    if k<=(a+b):
        print(a)
    else:
        print(a+(a+b-k))

Buggy submission (verdict: Runtime Error):
    a,b,c,k= map(int,input().split(' '))
    if k<a:
        print(k)
    else:
        k-=a
        if k<b:
            print(a)
        else:
            k-=b
            print(a-k)
Problem p02759 (python)

Fixed submission:
n=int(input())
if n%2==0:
  print(int(n/2))
else:
  print(int((n+1)/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==:
  print(n/2)
else:
  print(int(n/2)+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==:
  print(n/2)
else:
	print(n//2+1)
Problem p02552 (python)

Fixed submission:
x = int(input())
if x ==1:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
print(-(int(inpuut())-1))

Buggy submission (verdict: Runtime Error):
x = int(inpuut())
if x ==1:
  print(0)
else:
  print(1)
Problem p02829 (python)

Fixed submission:
a=int(input())
b=int(input())
if(a+b==3):
  print("3")
elif(a+b==4):
  print("2")
else:
  print("1")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().sprit())
if(a+b==3):
  print("3")
elif(a+b==4):
  print("2")
else:
  print("1")
Problem p02831 (python)

Fixed submission:
import math
a,b=map(int,input().split())
x=a*b
if(a<b):
    a,b=b,a
r=a%b
while(r!=0):
    a=b
    b=r
    r=a%b
print(int(x/b))

Buggy submission (verdict: Runtime Error):
import math
x,y=map(int,input().split())
print((x * y) // math.gcd(x, y))
Problem p02832 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
mn=min(h)
cnt=0
if(mn!=1):
    print("-1")
    exit()
i=1
for k in h:
    if(k==i):
        i=i+1
    else:
        cnt=cnt+1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
mn=min(h)
cnt=1
if(mn!=1):
    print("-1")
    exit()
r=len(h)
for i in range(len(h)):
    if(len(h)==1):
        break
    cnt=cnt+h.index(i+1)-1
    del h[0:h.index(i+1)]
print(cnt)
Problem p02685 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m,k = map(int, input().split())
mod = 998244353
ans = 0
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
combi = [0 for i in range(n)]
combi[0] = 1
for i in range(1,n):
    combi[i] = (combi[i-1]*(n-i)*mod_inv(i,mod)) % mod
for i in range(k+1):
    plus = m * pow(m-1,n-1-i,mod)
    plus *= combi[n-i-1]
    plus %= mod
    ans += plus
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n,m,k = map(int, input().split())
mod = 998244353
ans = 0
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
combi = [0 for i in range(n)]
combi[0] = 1
combi[1] = n-1
for i in range(2,n):
    combi[i] = (combi[i-1]*(n-i)*mod_inv(i,mod)) % mod
for i in range(k+1):
    plus = m * pow(m-1,n-1-i,mod)
    plus *= combi[n-i-1]
    plus %= mod
    ans += plus
    ans %= mod
print(ans)
Problem p02762 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m,k = map(int, input().split())
class UnionFind:
    def __init__(self, n):
        #親ノードの番号を格納
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)
    def find(self, x):
        #根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        #同じかどうかの確認
        return self.find(x) == self.find(y)
    def union(self, x, y):
        #統合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
        else:
            self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
    def getsize(self, x):
        p = self.find(x)
        return self.size[p]
u = UnionFind(n)
ans_li = [-1 for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    u.union(a,b)
    ans_li[a] -= 1
    ans_li[b] -= 1
for i in range(k):
    a,b = map(int, input().split())
    if u.find(a) == u.find(b):
        ans_li[a] -= 1
        ans_li[b] -= 1
for i in range(1,n+1):
    ans_li[i] += u.getsize(i)
    print(ans_li[i], end = " ")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m,k = map(int, input().split())
class UnionFind:
    def __init__(self, n):
        #親ノードの番号を格納
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)
    def find(self, x):
        #根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        #同じかどうかの確認
        return self.find(x) == self.find(y)
    def union(self, x, y):
        #統合する
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0

        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0

        else:
            self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0

    def getsize(self, x):
        p = self.find(x)
        return self.size[p]
u = UnionFind(n+1)
ans_li = [-1 for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    u.union(a,b)
    ans_li[a] -= 1
    ans_li[b] -= 1
for i in range(k):
    a,b = map(int, input().split())
    if u.find(a) == u.find(b):
        ans_li[a] -= 1
        ans_li[b] -= 1
for i in range(1,n+1):
    p = u.find(i)
    ans_li[i] += len(u.group[p])
    print(ans_li[i], end = " ")
Problem p02862 (python)

Fixed submission:
import math
x,y = list(map(int, input().split()))
mod = 7 + (10**9)
ans = 0
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit()
else:
    m = (2*x - y)//3
    n = (2*y - x)//3
    if n < 0 or m < 0:
        print(0)
        exit()
    #m+n C m を計算
    #(m+n)! / n! * m!を計算したいが、mod上で割り算できない。
    #逆元を使う
    factorial = [1]*(m+n+1)
    for i in range(1,m+n+1):
        factorial[i] = (factorial[i - 1] * i) % mod
    ans = factorial[m+n] * mod_inv(factorial[m], mod)
    ans %= mod
    ans *= mod_inv(factorial[n], mod)
    ans %= mod
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
x,y = list(map(int, input().split()))
mod = 7 + (10**9)
ans = 0
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit()
else:
    m = (2*x - y)//3
    n = (2*y - x)//3
    #m+n C m を計算
    #(m+n)! / n! * m!を計算したいが、mod上で割り算できない。
    #逆元を使う
    factorial = [1]*(m+n+1)
    for i in range(1,m+n+1):
        factorial[i] = (factorial[i - 1] * i) % mod
    ans = factorial[m+n] * mod_inv(factorial[m], mod)
    ans %= mod
    ans *= mod_inv(factorial[n], mod)
    ans %= mod
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(10**7)
x,y = list(map(int, input().split()))
mod = 7 + (10**9)
ans = 0
def factorial(x):
    if x == 0 or x == 1:
        return 0
    k = (x * factorial(x)) % mod
    return k
if (x + y) % 3 != 0:
    print(0)
else:
    for i in range(x+1):
        if (x - i) % 2 != 0:
            continue
        else:
            l = (x - i) // 2
            if y == 2 * i + l:
                #print("k {},l {}".format(k,l))
                ans += factorial(i+l) / (factorial(i) * factorial(l))
                ans %= mod
print(ans)
Problem p02925 (python)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n = int(input())
A = []
M = [[-1 for _ in range(n)] for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1
ans = 0
nodes = []
adjacent_list = [[] for i in range(n*(n-1)//2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in tmp[1:]:
        adjacent_list[M[i][pre]].append(M[i][j-1])
        pre = j - 1
#まず、閉路検
seen = defaultdict(lambda: False)
visited = defaultdict(lambda: False)
def check(node):
    if visited[node]:
        return
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if not adjacent_list[node]:
        return 1
    if finish[node]:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = tmp
    return finish[node]
finished = set()
finish = [0 for i in range(n*(n-1)//2)]
for i in range(n*(n-1)//2):
    check(i)
    dfs_path(i)
print(max(max(finish), 1))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
n = int(input())
A = []
ans = 0
adjacent_list = [[] for i in range((n + 2) * n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in range(1, len(tmp)):
        l, g = min(i, tmp[j] - 1), max(i, tmp[j] - 1 )
        pre_l, pre_g = min(i, pre), max(i, pre) 
        adjacent_list[pre_l * n + pre_g].append(l * n + g)
        pre = tmp[j] - 1
not_candidate = set([])
for i in range((n + 2) * n):
    if len(adjacent_list) == 0:
        not_candidate.add(i)
        continue
    for j in adjacent_list[j]:
        not_candidate.add(j)
#まず、閉路検
seen = [False for i in range((n + 2) * n)]
visited = [False for i in range((n + 2) * n)]
def check(node):
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if len(adjacent_list[node]) == 0:
        return 1
    if node in finish:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = max(tmp, finish[node])
    return finish[node]
finished = set()
for i in range((n + 2) * n):
    check(i)
finish = defaultdict(int)
for i in range((n + 2) * n):
    if i not in not_candidate :
        dfs_path(i)
print(max(finish.values(), 1))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print(red)
Problem p02984 (python)

Fixed submission:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
s = 0
x = [-1 for i in range(n)]
for i in range(1,n):
    if i % 2 == 1:
        s += a[i]
x[0] = sum(a) - s * 2
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
for i in x:
    print(i,end = "")
    print(" ", end = "")

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

n = int(input())
a = list(map(int, input().split()))
sum = 0
x = [-1 for i in range(n)]
for i in range(n):
    if a[i % n] == 0:
        x[i % n] = 0
        x[(i + 1) % n] = 0
i = 0
while (-1 in x):
    if a[i % n] == nun and a[i + 2] != -1:
        x[i] = a[i] * 2 - a[i + 1] * 2 - x[i + 2]
    i += 1
for i in x:
    print(i,end = "")
    print(" ", end = "")
Problem p03012 (python)

Fixed submission:
N = int(input())
data = list(map(int,input().split()))
dataSum = sum(data)
min = 10000
for i in range(N):
    sumT = sum(data[0:i + 1])
    if abs(sumT * 2 - dataSum)  < min:
        min = abs(sumT * 2 - dataSum)
    else:
        print (min)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
data = list(map(int,input().split()))
dataSum = sum(data)
min = 100
for i in range(N):
    sumT = sum(data[0:i + 1])
    if abs(dataSum - sumT)  < min:
        min = abs(dataSum - sumT)
    else:
        print min
        break
Problem p03013 (python)

Fixed submission:
N, M = map(int,input().split())
data = []
dp = ['.' for i in range(N + 1)]
dp[0] = 1
dp[1] = 1
for i in range(M):
    k = int(input())
    data.append(k)
    dp[k] = 0
mod = 10**9 + 7
for i in range(2,N + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[N] % mod)

Buggy submission (verdict: Runtime Error):
def calc_Stairs_Patterns(num):
    if num >= 2:
        return calc_Stairs_Patterns(num - 1) + calc_Stairs_Patterns(num - 2)
    elif num == -1:
        print(0)
        exit()
    else:
        return 1
N, M = map(int,input().split())
data = []
for i in range(M):
    data.append(int(input()))
ans = 1
stair = 0
for i in data:
    ans *= calc_Stairs_Patterns(i  - 1 - stair)
    stair = i + 1
ans *= calc_Stairs_Patterns(N - stair)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def calc_Stairs_Patterns(num):
    if num >= 2:
        return calc_Stairs_Patterns(num - 1) + calc_Stairs_Patterns(num - 2)
    elif num == -1:
        print(0)
        exit()
    else:
        return 1
N, M = map(int,input().split())
data = []
for i in range(M):
    data.append(int(input()))
ans = 1
stair = 0
for i in data:
    ans *= calc_Stairs_Patterns(i  - 1 - stair)
    stair = i + 1
ans *= calc_Stairs_Patterns(N - stair)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def calc_Stairs_Patterns(num):
    if num >= 2:
        return calc_Stairs_Patterns(num - 1) + calc_Stairs_Patterns(num - 2)
    elif num == -1:
        print(0)
        exit()
    else:
        return 0
N, M = map(int,input().split())
data = []
for i in range(M):
    data.append(int(input()))
ans = 1
stair = 0
for i in data:
    ans *= calc_Stairs_Patterns(i  - 1 - stair)
    stair = i + 1
ans *= calc_Stairs_Patterns(N - stair)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def calc_Stairs_Patterns(num):
    if num >= 2:
        return calc_Stairs_Patterns(num - 1) + calc_Stairs_Patterns(num - 2)
    elif num == 1:
        return 1
    else :
        return 1
N, M = map(int,input().split())
data = []
for i in range(M):
    data.append(int(input()))
bef = 0
for i in data:
    if bef + 1 == i:
        print(0)
        exit()

ans = 1
stair = 0
for i in data:
    ans *= calc_Stairs_Patterns(i  - 1 - stair)
    stair = i + 1
ans *= calc_Stairs_Patterns(N - stair)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
data = []
for i in range(M):
    data.append(int(input()))
bef = 0
for i in data:
    if bef + 1 == i:
        print(0)
        exit()
    bef = i
print(int(2 ** ((N - M * 2) / 2)) % 1000000007)
Problem p03015 (python)

Fixed submission:
L = input()
#dp1[k] := k桁目までを確定させ、その時点でA+BがL以下が確定
#dp2[k] := k桁目までを確定させ、その時点でA+BがL以下が確定していない
dp1 = [0 for i in range(len(L))]
dp2 = [0 for i in range(len(L))]
mod = 10**9 + 7
dp1[0] = 1 # A,Bの最上位bitが(0,0)
dp2[0] = 2 # A,Bの最上位bitが(0,1), (1,0)の二通り
#最上位bitを(1,1)にしてしまうと、Lを超えてしまうのでない
for i in range(1,len(L)):
    #dp1の更新から行う
    if L[i] == '1':
        dp1[i] = dp1[i-1] * 3 + dp2[i-1]
        dp2[i] = dp2[i-1] * 2
    else:
        dp1[i] = dp1[i-1] * 3
        dp2[i] = dp2[i-1]
    dp1[i] %= mod
    dp2[i] %= mod
print((dp1[-1] + dp2[-1]) % mod)

Buggy submission (verdict: Runtime Error):
def judge(a, b):
    k = 0
    while 2 ** k  - 1 <= a + b:
        if 2 ** k - 1 == a + b:
            return True
        k += 1
    return False

L = int(input(),2)
count = (L + 1) * 2 - 1
for i in range(1,L + 1):
    for j in range(1,L - i + 1):
        if Judge(i, j):
            count += 1


print(count % (10 ** 9 + 7))
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
flag = False
for i in range(a,c):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
for i in range(b,d):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            print("Yes")
            exit()
    print("No")

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = input().split()
s = input()
flag = False
for i in range(n-1):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b+1, d):
        if s[i-1] == s[i+1] == s[i]:
            print("Yes")
            exit()
    print("No")