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

Fixed submission:
n = int(input())
s = input()
if s[:n//2] == s[n//2:]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n / 2 % == 1:
  print("No")
  exit()
s = input()
if s[:n/2] == s[n/2:]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())  
s = input()
if s[:n/2] == s[n/2:]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n / 2 % == 1:
  print("No")
  return
s = input()
if s[:n/2] == s[n/2:]:
  print("Yes")
else:
  print("No")
Problem p02881 (python)

Fixed submission:
from math import sqrt

n = int(input())
for i in range(int(sqrt(n)), 1, -1):
  if n % i == 0:
    print(i + n//i -2)
    break
else:
  print(n-1)

Buggy submission (verdict: Runtime Error):
from math import sqrt

n = int(input())
for i in range(sqrt(n), 1, -1):
  if n % i == 0:
    print(i + n/i -2)
    break
else:
  print(n-1)
Problem p03013 (python)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    
    one = memo[n-1] if memo[n-1] != -1 else steps(n-1)    
    two = memo[n-2] if memo[n-2] != -1 else steps(n-2)

    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1
for b in broken:
    memo[b] = 0

print(steps(n) % (10**9+7))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
dp = [-1 for i in range(n+1)]
dp[0] = 1
dp[1] = 1
for b in broken:
    dp[b] = 0
for i in range(2, n+1):
    if memo[i] == -1:
      memo[i] = memo[i-1] + memo[i-2]
print(memo[n] % (10**9+7))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    if n-1 not in broken:
        one = memo[n-1] if memo[n-1] != -1 else steps(n-1)
    else:
        one = 0
        
    if n-2 not in broken:
        two = memo[n-2] if memo[n-2] != -1 else steps(n-2)
    else:
        two = 0
    
    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1

print(steps(n) % (10**9+7))
Problem p02701 (python)

Fixed submission:
n=int(input())
d=dict()

for i in range(n):
  s="".join(input())
  #print(s)
  if s in d:
    d[s]+=1
  else:
    d[s]=1
ans=0
for x in d.values():
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
kk=set()
for i in range(n):
  s=input()
  kk.add()
print(len(kk))
Problem p02773 (python)

Fixed submission:
n=int(input())

dic=dict()
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
a=(max(dic, key=dic.get))
b=dic[a]
keys = [k for k, v in dic.items() if v == b]
keys.sort()

for i in range(len(keys)):
  print(keys[i])

Buggy submission (verdict: Runtime Error):
n=int(input())

dic=dict()
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
a=max(dic)
b=dic[a]
keys = [k for k, v in dic.items() if v == b]
keys.sort()
for i in range(n):
  print(keys[i])
Problem p03042 (python)

Fixed submission:
s=input()
a=int(s[:2])
b=int(s[2:])
if a==0:
  if 1<=b<=12:
    print("YYMM")
  else:
    print("NA")
elif 1<=a<=12:
  if 1<=b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
    if 1<=b<=12:
      print("YYMM")
    else:
      print("NA")

Buggy submission (verdict: Runtime Error):
s=input()
a=int(s[:2])
b=int(s[2:])
if a==0:
  if 1<=b<=12:
    print("MMYY")
  else:
    print("NA")
elif 1<=a<=12:
  if 1<=b<=12:
    print("AMBIGUOUS")
  else:
    print("NA")
else:
    if 1<=b<=12:
    print("YYMM")
  else:
    print("NA")
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2= map(int,input().split())
a=x2-x1
b=y2-y1

x3=x2-b
y3=y2+a

x4=x3-a
y4=y3-b

print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
sal
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x3 + y2 - y3
y4 = y3 + x3 - x2
print(x3, y3, x4, y4)
Problem p03774 (python)

Fixed submission:
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(m)]

for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(n)]
for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(n)]
for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn+=1
  print(pn)

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

student = []

for i in range(n):
    a, b = map(int, input().split())
    student.append((a, b))

point = []

for j in range(m):
    c, d = map(int, input().split())
    point.append((c, d))

for a, b in student:
    length = 10 ** 10
    pn = 0
    for j in range(m):
        c, d = point[j]
        if abs(a-c) + abs(b-d) < length:
            length = abs(a-c) + abs(b-d)
            pn = j + 1
    print(pn)
Problem p03804 (python)

Fixed submission:
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for k in range(n-m+1):
  for j in range(n-m+1):
    h="true"
    for i in range(m):
      if a[k+i][j:j+m]!=b[i]:
        h="false"    
    if h=="true":
      print("Yes")
      exit()
else:
  print("No")

Buggy submission (verdict: Runtime Error):
yandy
N, M = map(int, input().split())
A = [''] * N
B = [''] * M

for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()

for i in range(N-M+1):
    for j in range(N-M+1):
        NO = False
        for x in range(M):
            a = A[i+x][j:j+M]
            if a != B[x]:
                NO = True
                break
        if not NO:
            print('Yes')
            exit()

print('No')
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

Buggy submission (verdict: Runtime Error):
yandy
K, S = map(int, input().split())

ans = 0
for z in range(K+1):
    for y in range(K+1):
        if 0 <= S - z - y <= K:
            ans += 1

print(ans)
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
countlist = [0 for i in range(n)]
for j in range(n-1):
    countlist[a[j]-1]+=1
for i in range(n):
    print(countlist[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
countlist = [0 for i in range(n)]
for j in range(n):
    countlist[a[j]-1]+=1
for i in range(n):
    print(countlist[i])
Problem p02712 (python)

Fixed submission:
N=int(input())
P=0
for i in range(N+1):
    if i%3!=0 and i%5!=0:
        P+=i
print(P)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N=input()
n=list()
m=list()
for i in range(N-1):
    if(i%3==0 or i%5==0):
        n.append(i)
    else:
        m.append(i)
print(sum(m))
Problem p02831 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())

print(A*B//fractions.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A, B))
Problem p03774 (python)

Fixed submission:
def distance(ab, cd):
  return abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])

N, M = map(int, input().split())
AB = []
for _ in range(N):
  a, b = map(int, input().split())
  AB.append((a, b))

CD = []
for _ in range(M):
  c, d = map(int, input().split())
  CD.append((c, d))

check_index = []
for i, ab in enumerate(AB):
  min_index = 0
  for j, cd in enumerate(CD):
    check_dis = distance(ab, cd)
    min_dis = distance(ab, CD[min_index])
    if(min_dis > check_dis):
      min_index = j
  
  check_index.append(min_index)

for ci in check_index:
  print(ci + 1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = []
for _ in range(N):
  a, b = map(int, input().split())
  AB.append((a, b))

CD = []
for _ in range(M):
  c, d = map(int, input().split())
  CD.append((c, d))

check_index = []
for i, ab in enumerate(AB):
  min_index = 0
  for j, cd in enumerate(CD):
    check_dis = distance(ab, cd)
    min_dis = distance(ab, CD[min_index])
    if(min_dis > check_dis):
      min_index = j
  
  check_index.append(min_index)

for ci in check_index:
  print(ci + 1)
Problem p03803 (python)

Fixed submission:
A, B = map(int, input().split())

result = ''
if (A == 1 and B != 1):
  result = 'Alice'
elif (B == 1 and A != 1):
  result = 'Bob'
elif (A > B):
  result = 'Alice'
elif (B > A):
  result = 'Bob'
elif (B == A):
  result = 'Draw'

print(result)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = []
for _ in range(N):
  a = input()
  A.append(a)

B = []
for _ in range(M):
  b = input()
  B.append(b)

existed = False
for i in range(N - M + 1):
  for j in range(N - M + 1):
    match = True
    for mi in range(M):
      for mj in range(M):
        x = i + mi
        y = j + mj

        if (A[y][x] != B[mj][mi]):
          match = False
          break
      
      if (match == False):
        break

    if (match):
      existed = True
      break
  
  if (existed):
    break

result = 'Yes' if (existed) else 'No'
print(result)
Problem p03127 (python)

Fixed submission:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)

Buggy submission (verdict: Runtime Error):
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
n = int(raw_input())
a = list(map(int,raw_input().split()))
g = 0
for i in range(len(a)):
    g = math.gcd(g,a[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = math.gcd(g,a[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
g = 0
for _ in range(len(a)):
    g = math.gcd(g,a[_])
print(g)
Problem p02711 (python)

Fixed submission:
s = list(input())
for i in s:
  if i == "7":
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
s = list(map(int,input()))
for i in s:
  if i == "7":
    print("Yes")
    return
print("No")
Problem p02831 (python)

Fixed submission:
from fractions import gcd
x,y = map(int,input().split())
print((x * y) // gcd(x, y))

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

Fixed submission:
s = list(input())
s.sort()
if s[0]==s[1] and  s[2]==s[3] and s[0]!=s[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(input())
s.sort()
if s[0]==s[1] and  s[2]==s[3]:
  print(Yes)
else:
  print("No")
Problem p03107 (python)

Fixed submission:
s = list(map(int, input()))
c1,c0=0,0
for i in s:
  if i==1:
    c1+=1
  if i==0:
    c0+=1  
print(len(s)-abs(c1-c0))

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
c = 0
count = 0
while(c==0):
  for i in range(len(s)):
    if sum(s) == len(s) or sum(s) == 0:
      c=1
      break
    if i == len(s)-1:
      break
    if len(s) == 2 and sum(s) == 1:
      count+=2
      c=1
      break  
    if s[i] + s[i+1] == 1:
      del s[i]
      del s[i]
      count += 2
      if len(s) == i+1:
        break

print(count)
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, heapq.heappop(a) * (-1) // 2 * (-1))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import copy
n,m=map(int, input().split())
a=sorted([int(i) for i in input().split()],reverse=True)
if n==1:
    print(a[0]//(2**m))
    exit()
def solve(cnt, coupon, now):
    ans = 10 ** 10
    if cnt==m:
        tmp=0
        for i in range(n):
            tmp+=a[i]//(2**coupon[i])
        return tmp
    nowcp=coupon
    for i in range(1,m-cnt+1):
        temp=copy.copy(nowcp)
        temp[now]=i
        ans=min(ans,solve(cnt+i,temp, now+1))
    return ans
print(solve(0,[0 for _ in range(n)], 0))
Problem p03042 (python)

Fixed submission:
s=input()
a=int(s[:2])
b=int(s[2:])
print("AMBIGUOUS" if 1<=a<=12 and 1<=b<=12 else "YYMM" if 1<=b<=12 else "MMYY" if 1<=a<=12 else "NA")

Buggy submission (verdict: Runtime Error):
s=int(input())
l=[]
while s>0:
  l.append(s%100)
  s//=100
print("AMBIGUOUS" if 1<=l[0]<=12 and 1<=l[1]<=12 else "YYMM" if 1<=l[0]<=12 else "MMYY" if 1<=l[1]<=12 else "NA")
Problem p03207 (python)

Fixed submission:
max=0
k=0
N=int(input())
for i in range(1,N+1):
    p=int(input())
    if p>max:max=p
    k=k+p
print((k-max)+(max//2))

Buggy submission (verdict: Runtime Error):
max=0
for i in range(1,n+1):
    p=int(input())
    if p>max:
        max=p//2
        print(max)
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 = int(input())

if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = int(input())

if a > 3200:
  print(s)
else:
  print("red")
Problem p03041 (python)

Fixed submission:
a, b = map(int, input().split())
c = input()
 
print(c[:b-1] + c[b-1].lower() + c[b:])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = input()
 
print(c[:b-1] + c[b-1].lower() + c[b:]
Problem p02829 (python)

Fixed submission:
print("".join(str(a) for a in ({1,2,3}-{int(input()), int(input())})))

Buggy submission (verdict: Runtime Error):
string = input().split()
print(string[1]+string[0])

Buggy submission (verdict: Runtime Error):
string = input().split()
print(string[1]+string[0])
Problem p02701 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
print(len(set(S)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
return len(set(S))
Problem p02935 (python)

Fixed submission:
n = int(input())
vv = list(map(int, input().split(' ')))
 
vv.sort()
 
ans = vv[0]
for v in vv[1:]:
  ans += v
  ans /= 2
  
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
vv = list(map(int, input().split(' ')))
 
vv.sort()
 
ans += vv[0]
for v in vv[1:]:
  ans += v
  ans /= 2
  
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
vv = list(map(int, input().split(' ')))

vv.sort()

ans += vv[0]
for v in vv:
  ans += v
  ans /= 2
  
print(ans)
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())
print('bust' if a+b+c > 21 else 'win')

Buggy submission (verdict: Runtime Error):
a,b.c=map(int,input().split())
print('bust' if a+b+c>21 else 'win')
Problem p03135 (python)

Fixed submission:
t, x = map(int, input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t, x = map(int, input.split())
print(t/x)
Problem p02701 (python)

Fixed submission:
N = int(input())
L = set([input() for _ in range(N)])
print(len(L))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [input()]
 
for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0
 
    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin)       
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))
N = int(input())
L = [input()]

for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0

    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin):     
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [input()]

for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0

    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin)       
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [input()]

for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0

    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
        print(imin,imax,L)
    
    l = (imin+imax)//2       
    if (a>L[l]):
        L.insert(l+1,a)
    elif (a<L[l]):
        L.insert(l,a)
            
print(len(L))
Problem p02773 (python)

Fixed submission:
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  if d[-1] in dic:
  	dic[d[-1]]+=1
  else:
    dic[d[-1]]=1
mx=max(dic.values())
for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Buggy submission (verdict: Runtime Error):
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  if d[-1] in dic:
  	dic[d[-1]]+=1
  else:
    dic[d[-1]]=1
mx=max(mx,dic.values())
for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Buggy submission (verdict: Runtime Error):
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
mx=0
for w in d:
  dic[w]=d.count(w)
  mx=max(mx,dic[w])

for k,v in sorted(dic.items(),key=lambda x:(x-[1],x[0])):
  if mx==v:
    print(k)
Problem p03745 (python)

Fixed submission:
# coding: utf-8
n=int(input())
data=list(map(int,input().split()))
index=0
ans=1
v=0
while index<len(data):
    if index+1<len(data):
        if data[index]==data[index+1]:
            pass
        elif data[index]<data[index+1]:
            if v==1 or v==0:
                v=1
            else:
                ans+=1
                v=0
        else:
            if v==-1 or v==0:
                v=-1
            else:
                ans+=1
                v=0
    index+=1
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n=int(input())
data=list(map(int,input().split()))
ans=1
def check(index,v=0):
    global data
    global ans
    if index+1<len(data):
        if data[index]==data[index+1]:
            check(index+1,v)
        elif data[index]<data[index+1]:
            if v==1 or v==0:
                check(index+1,1)
            else:
                ans+=1
                check(index+1,0)
        else:
            if v==-1 or v==0:
                check(index+1,-1)
            else:
                ans+=1
                check(index+1,0)
check(0)
print(ans)
Problem p02879 (python)

Fixed submission:
A, B = map(int, input().split())

if 1 <= A <= 9 and 1 <= B <= 9:
    print(A*B)
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit(0)
print('No')
Problem p02880 (python)

Fixed submission:
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit(1)
print('No')
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
dp = [0 for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
if dp[1] != -1:
    dp[1] = 1
else:
    dp[1] = 0
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[j] = dp[j-2] + dp[j-1]

print(dp[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [int(input()) for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[j] = dp[j-2] + dp[j-1]

print(dp[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [int(input()) for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[i] = dp[i-2] + dp[i-1]

print(dp[N] % 1000000007)
Problem p02954 (python)

Fixed submission:
direction = input()

def next(direction, current):
	output = [0] * len(current)

	for i in range(len(direction)):
		if direction[i] == 'R':
			output[i+1] += current[i]
		if direction[i] == 'L':
			output[i-1] += current[i]

	return output

def s(inp):
	r = len([x for x in inp if x == 'R'])
	l = len([x for x in inp if x == 'L'])

	R = L = 0
	for i in range(0, r, 2):
		R += 1
	for i in range(1, r, 2):
		L += 1
	for i in range(0, l, 2):
		L += 1
	for i in range(1, l, 2):
		R += 1
	
	output = [0 for _ in range(len(inp))]
	output[r-1] = R
	output[r] = L
	return output

def solve(inp):
	r = len([x for x in inp if x == 'R'])
	l = len([x for x in inp if x == 'L'])

	output = [0] * len(inp)
	if r == l:
		output[r-1] = output[r] = r
	else:
		m = max(l-1, r-1)
		if m % 2 == 1:
			output[r-1] = r
			output[r] = l
		else:
			output[r-1] = l
			output[r] = r
		


def solve(direction, start, end, output):
	original = [1] * (end-start)

	sub_direction = direction[start:end]

	prev2 = next(sub_direction, original)
	prev1 = next(sub_direction, prev2)

	count = 2

	output.append(s(direction[start:end]))

	# while True:
	# 	next_state = next(sub_direction, prev1)
	# 	count += 1
	# 	if next_state == prev2:
	# 		if count % 2 == 0:
	# 			output.append(prev2)
	# 			# print(' '.join(map(str, prev2)))
	# 			return
	# 		else:
	# 			output.append(prev1)
	# 			# print(' '.join(map(str, prev1)))
	# 			return
	# 	prev2 = prev1
	# 	prev1 = next_state

# direction = 'RRRLLRLLRRRLLLLL'
parts = []
prev = 0
for i in range(len(direction)-1):
	if direction[i] == 'L' and direction[i+1] == 'R':
		parts.append((prev,i+1))
		prev = i+1

parts.append((prev,len(direction)))

# print(parts)
output = []
for start,end in parts:
	solve(direction, start, end, output)

# print(output)
final = [x for  y in output for x in y]
print(' '.join(map(str, final)))


# print(solve('RRLRL'))
# print(solve('RRLLLLRLRRLL'))

Buggy submission (verdict: Runtime Error):
direction = input()

def next(direction, current):
	output = [0] * len(current)

	for i in range(len(direction)):
		if direction[i] == 'R':
			output[i+1] += current[i]
		if direction[i] == 'L':
			output[i-1] += current[i]

	return output

def solve(direction):
	original = [1] * len(direction)

	prev2 = next(direction, original)
	prev1 = next(direction, prev2)

	count = 2
	while True:
		next_state = next(direction, prev1)
		count += 1
		if next_state == prev2:
			if count % 2 == 0:
				print ' '.join(map(str, prev2))
				return
			else:
				print ' '.join(map(str, prev1))
				return
		prev2 = prev1
		prev1 = next_state