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

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    # n, m = map(int, input().split())
    # a = [int(input()) for i in range(m)]
    n, m = map(int, readline().split())
    a = set(map(int, read().split()))
    mod = 1000000007

    # フィボナッチ数列を作る要領で行う
    d = [0] * (n+1)
    # 2回0が続く状況aに連番があったら即座に終了する
    cnt = 0 
    # d[0]とd[1]を規定。aに1が含まれていることを考慮して場合分けしておく
    d[0] = 1
    if 1 not in a:
        d[1] = 1
    # else:
    #     d[1] = 1
    # 階段番号は2~nまでを見る必要がある
    for i in range(2, n+1):
        if i in a:
            d[i] = 0
            cnt += 1
            if cnt == 2:
                print('0')
                exit()
        else:
            d[i] = (d[i-1] + d[i-2]) % mod
            cnt = 0
    # print(d)  
    ans = d[n]        
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
	n, m = map(int, input().split())
    a = set(int(input()) for i in range(m))
    mod = 1000000007
 
    # フィボナッチ数列を作る要領で行う
    d = [0] * (n+1)
    # 2回0が続く状況aに連番があったら即座に終了する
    cnt = 0 
    # d[0]とd[1]を規定。aに1が含まれていることを考慮して場合分けしておく
    d[0] = 1
    if 1 not in a:
        d[1] = 1
    # else:
    #     d[1] = 1
    # 階段番号は2~nまでを見る必要がある
    for i in range(2, n+1):
        if i in a:
            d[i] = 0
            cnt += 1
            if cnt == 2:
                print('0')
                exit()
        else:
            d[i] = (d[i-1] + d[i-2]) % mod
            cnt = 0
    # print(d)  
    ans = d[n]        
    print(ans)
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
  
    # n, m = map(int, input().split())
    # a = [int(input()) for i in range(m)]
	n, m = map(int, input().split())
    a = set(int(input()) for i in range(m))
    mod = 1000000007

    # フィボナッチ数列を作る要領で行う
    d = [0] * (n+1)
    # 2回0が続く状況aに連番があったら即座に終了する
    cnt = 0 
    # d[0]とd[1]を規定。aに1が含まれていることを考慮して場合分けしておく
    d[0] = 1
    if 1 not in a:
        d[1] = 1
    # else:
    #     d[1] = 1
    # 階段番号は2~nまでを見る必要がある
    for i in range(2, n+1):
        if i in a:
            d[i] = 0
            cnt += 1
            if cnt == 2:
                print('0')
                exit()
        else:
            d[i] = (d[i-1] + d[i-2]) % mod
            cnt = 0
    # print(d)  
    ans = d[n]        
    print(ans)

if __name__ == '__main__':
    main()
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())
print(min([p + q, q + r, r + p]))

Buggy submission (verdict: Runtime Error):
p, q, r = map(int, input().split())
print(min([p + q, q + r. r + p]))
Problem p03207 (python)

Fixed submission:
a = 0
c = 0
for i in range(int(input())):
    b = int(input())
    if b > a:
        c += a
        a = b
    else:
        c += b
c += (a/2)
print (round(c))

Buggy submission (verdict: Runtime Error):
a = 0
c = 0
for i in range(int(input())):
	b = int(input())
	if b > a:
        a = b
        c += a
    else:
        c += b
c += (a/2)
print (round(c))
Problem p03209 (python)

Fixed submission:
def m(n): # n次元バーガーの層数
    if n == 0:
        return 1
    else:
        a = 1
        for i in range(n):
            a = a * 2 + 3
        return a

def paty(n): # n次元バーガーのパティの数
    a = 1
    if n >= 1:
        for i in range(n):
            a = a * 2 + 1
    return a

def a(n, x): #これが答えを返す
    x = x - 1
    if x == 0 and n == 0:
        return 1
    elif x == 0:
        return 0
    elif x == m(n-1) + 1:
        return paty(n-1) + 1
    elif x == m(n):
        return paty(n)
    elif x > m(n-1):
        return paty(n-1) + 1 + a(n - 1, x - m(n-1) - 1)
    else:
        n = n - 1
        return a(n, x)

n, x= map(int, input().split())
print(a(n, x))

Buggy submission (verdict: Runtime Error):
def b(n): # n次元バーガー
    if n == 0:
        return("P")
    else:
        return("B",b(n-1),"P",b(n-1),"B")
n, x= map(int, input().split())
print(b(n).split("", x).count("P"))
Problem p02831 (python)

Fixed submission:
from fractions import gcd
 
def lcm(a, b):
    return abs(a*b) // gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import fractions
 
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math
 
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))
Problem p02833 (python)

Fixed submission:
n = int(input())
if n == 0:
  ans = 0
elif n % 2 == 1:
  ans = 0
else:
  pwr = 10
  ans = 0
  while pwr <= n:
    ans += n // pwr
    pwr *= 5
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(x)
if n % 2 == 1:
  ans = 0
else:
  ans = int(n // 10) + int(n // 50) + int(n // 250)
print(ans)
Problem p02897 (python)

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

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

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
total = sum(b)
last_dish = a[0]
for d in a[1:]:
  if d-last_dish == 1:
    total += c[last_dish-1]
  last_dish = d
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

total = sum(b)
last_dish = a[0]
for d in a[1:]:
	if d-last_dish == 1:
    	total += c[last_dish-1]
	last_dish = d
print(total)
Problem p02984 (python)

Fixed submission:
n = int(input())
bs = [int(x) for x in input().split()]
sign = 1
a_2 = bs[0]
for b in bs[1:]:
    a_2 += sign*b
    sign *= -1

ans = str(a_2) + ' '
for i in range(n-2):
    a_2 = 2*bs[i+1] - a_2
    ans += str(a_2) + ' '
ans = str(2*bs[i+2] - a_2) + ' ' + ans
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
b = 2*np.array([int(x) for x in input().split()])
A = np.eye(n)
for i in range(n-1):
    A[i, i+1] = 1
A[-1,0] = 1
print(' '.join(str(int(val)) for val in np.linalg.solve(A,b)))
Problem p03073 (python)

Fixed submission:
s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))

Buggy submission (verdict: Runtime Error):
s = input()
option1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 = 0
print(min(ans_1, ans_2))
Problem p02627 (python)

Fixed submission:
def main():
    c = input()
    if c>='a' and c<='z':
        print('a')
    else:
        print('A')

main()

Buggy submission (verdict: Runtime Error):
def main():
    nmax = 100000
    n = int(input())
    values = [0] * nmax
    a = [int(v) for v in input().split()]
    for v in a:
        values[v-1] += 1
    asum = sum(a)

    q = int(input())
    for _ in range(q):
        b, c = [int(v) for v in input().split()]
        asum += values[b-1] * (c - b)
        values[c-1] += values[b-1]
        values[b-1] = 0
        print(asum)

main()
Problem p02629 (python)

Fixed submission:
N = int(input())
alphabet_lst = list('abcdefghijklmnopqrstuvwxyz')
#print(alphabet_lst)

keta = 0
keta_lst = []
sum_lst = []
while N>=sum(keta_lst):
    keta_lst.append(26**keta)
    sum_keta = sum(keta_lst)
    sum_lst.append(sum_keta)
    keta += 1
    
keta -= 1
keta_lst = keta_lst[:keta]
#print(keta_lst)
#print(keta)

ans_lst = []
for i in range(keta):
    ans_n = (N - sum(keta_lst[:-(i+1)])) // keta_lst[-(i+1)]
    #print(ans_n)
    #print(keta_lst[-(i+1)])
    N -= ans_n*keta_lst[-(i+1)]
    ans_lst.append(alphabet_lst[ans_n-1])

for i in range(keta):
    print(ans_lst[i],end="")

Buggy submission (verdict: Runtime Error):
N = int(input())
alphabet_lst = list('abcdefghijklmnopqrstuvwxyz')
#print(alphabet_lst)

keta = 0
keta_lst = []
while N>=sum(keta_lst):
    keta_lst.append(26**keta)
    keta += 1
    
keta -= 1
keta_lst = keta_lst[:keta]
#print(keta_lst)
#print(keta)

ans_lst = []
for i in range(keta):
    ans_n = N // keta_lst[-(i+1)]
    #print(ans_n)
    #print(keta_lst[-(i+1)])
    N -= ans_n*keta_lst[-(i+1)]
    ans_lst.append(alphabet_lst[ans_n-1])

for i in range(keta):
    print(ans_lst[i],end="")
Problem p02726 (python)

Fixed submission:

def D_160():
    N, X, Y = map(int, input().split())
    #count_list = [[0]*N for i in range(N)]
    ans = [0 for i in range(N-1)]
    for i in range(0,N):
        for j in range(1+i,N):
            ans_i = min(j-i,abs((X-1)-i) + abs(j-(Y-1)) + 1)
            ans[ans_i-1] += 1
    
    
    for i in ans:
        print(i)

D_160()

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import njit
@nJit
def D_160():
    N, X, Y = map(int, input().split())
    count_list = [[0]*N for i in range(N)]
    for i in range(0,N):
        for j in range(i,N):
            count_list[i][j] = min(j-i,abs(X-1-i) + abs(j-(Y-1)) + 1)
    
    #print(count_list)
    count_list = sum(count_list,[])
    
    for i in range(1,N):
        print(count_list.count(i))

D_160()

Buggy submission (verdict: Runtime Error):
from numba import njit
@nJit
def D_160():
    N, X, Y = map(int, input().split())
    count_list = [[0]*N for i in range(N)]
    for i in range(0,N):
        for j in range(i,N):
            count_list[i][j] = min(j-i,abs(X-1-i) + abs(j-(Y-1)) + 1)
    
    #print(count_list)
    count_list = sum(count_list,[])
    
    for i in range(1,N):
        print(count_list.count(i))

D_160()
Problem p02729 (python)

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

print(int((A*(A-1))/2+(B*(B-1))/2))

Buggy submission (verdict: Runtime Error):

def main():
    from itertools import product

    H,W,K = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    
    i = 0
    while i < len(S):
        if '1' in S[i]:
            i += 1
        else:
            del S[i]
    H = len(S)
 
    S = [[int(s[i]) for s in S] for i in range(W)]

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()
Problem p03012 (python)

Fixed submission:
weight_num = int(input())
weight_list = input().split(" ")
heavy_list = []
light_list = []
s1 = 0
s2 = 0
for i in range(len(weight_list)):
    weight_list[i] = int(weight_list[i])
max_sum = sum(weight_list)
for i in range(len(weight_list)):
    s1 += weight_list[i]
    s2 = sum(weight_list[i+1:])
    if (s1-s2)>0:
        absolute_num1 = s1-s2 
        s1 -= weight_list[i]
        s2 = sum(weight_list[i:])
        absolute_num2 = s2-s1
        if absolute_num1>absolute_num2:
            print(absolute_num2)
        else:
            print(absolute_num1)
        break
    else:
        pass

Buggy submission (verdict: Runtime Error):
weight_num = int(input())
weight_list = input().split(" ")
t = int(input())
heavy_list = []
light_list = []
for i in range(len(weight_list)):
    weight_list[i] = int(weight_list[i])

    if i>=t:
        heavy_list.append(weight_list[i])
    else:
        light_list.append(weight_list[i])

s1=sum(heavy_list)
s2=sum(light_list)
if (s1-s2)>0:
    print(s1-s2)
else:
    print(s2-s1)

Buggy submission (verdict: Runtime Error):
weight_num = int(input())
weight_list = input().split(" ")
t = int(input())
heavy_list = []
light_list = []
for i in range(len(weight_list)):
    weight_list[i] = int(weight_list[i])

    if i>=t:
        heavy_list.append(weight_list[i])
    else:
        light_list.append(weight_list[i])

s1=sum(heavy_list)
s2=sum(light_list)
if s1-s2>0:
    print(s1-s2)
else:
    print(s2-s1)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a<=k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if b-a<k:
  if c-a<k:
    if d-a<k:
      if e-a<k:
        print("Yay!")
      else:
        print(":(")
        break
    else:
      print(":(")
      break
  else:
    print(":(")
    break
else:
  print(":(")
  break
Problem p03077 (python)

Fixed submission:
import math
population = int(input())
a2b = int(input())
b2c = int(input())
c2d = int(input())
d2e = int(input())
e2f = int(input())
city = [population,0,0,0,0,0]
vehicle = [a2b,b2c,c2d,d2e,e2f]
print(math.ceil(population/min(vehicle)) + 4)

Buggy submission (verdict: Runtime Error):
population = int(input())
a2b = int(input())
b2c = int(input())
c2d = int(input())
d2e = int(input())
e2f = int(input())
vehicle_min = min(vehicle)
vehicle = [a2b,b2c,c2d,d2e,e2f]

print(int(population/vehicle_min) + 5)

Buggy submission (verdict: Runtime Error):
population = int(input())
a2b = int(input())
b2c = int(input())
c2d = int(input())
d2e = int(input())
e2f = int(input())

vehicle = [a2b,b2c,c2d,d2e,e2f]

print(int(population/vehicle_min) + 5)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal

A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A*B))

Buggy submission (verdict: Runtime Error):
A, B = input().split()
B.replace('.', '')
print(int(A)*int(B)//100)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(int(A*B))
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
Good_Peak = []
for i in range(N):
  Good_Peak.append(True)
for i in range(M):
  A, B = map(int, input().split())
  if height[A-1] <= height[B-1]:
    Good_Peak[A-1] = False
  if height[B-1] <= height[A-1]:
    Good_Peak[B-1] = False
print(Good_Peak.count(True))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
roads = [list(map(int, input().split())) for _ in range(N)]
alone=[]
ans={}
b_list=[]
for i in range(1, N+1):
  alone.append(i)
for road in roads:
  if max(road) not in b_list:
    ans[max(road)]='Yes'
    b_list.append(min(road))
  elif road[0] in alone:
    alone.remove(road[0])
  elif road[1] in alone:
    alone.remove(road[1])
print(len(ans)+len(alone))
Problem p02701 (python)

Fixed submission:
N=int(input())
list=[input() for i in range(N)]
list.sort()
n=1
s=list[0]
for i in range(N):
  if list[i] != s:
    n+=1
    s=list[i]
print(n)

Buggy submission (verdict: Runtime Error):
N=int(input())
list=list(input().split())
list.sort()
n=0
s=list[0]
for i in range(N):
  if list[i] != s:
    n+=1
    s=list[i]
print(n)
Problem p02707 (python)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for a in A:
  ans[a-1]+=1
for n in ans:
  print(n)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for a in A:
  ans[a-1]+=1
for n in ans:
print(n)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N-2):
  m=list.count(str(i)
  answer.append(m)
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N):
	answer.append(str(list.count(str(i))))
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N-2):
	answer.append(list.count(str(i)))
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N-2):
	answer.append(list.count(i))
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N):
	answer.append(list.count(i))
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N+1):
	answer.append(list.count(i))
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N+1):
	m=0
	for j in range(0, len(list)):
  		if list[j] is str(i):
      		m=m+1
    	else:
      		m=m+0
	answer.append(m)
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer={}
for i in range(1, N+1):
	m=0
	for j in range(0, len(list)):
  		if list[j] is str(i):
      		m=m+1
    	else:
      		m=m+0
	answer.append(m)
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer={}
for i in range(1, N+1):
  m=0
  for j in range(0, len(list)):
  	if list[j] is str(i):
      m=m+1
    else:
      m=m+0
answer.append(m)
a_s='\n'.join(answer)
print(a_s)

Buggy submission (verdict: Runtime Error):
N=map(int, input())
list=list(map(str, input().split()))
answer={}
for i in range(1, N+1):
  m=0
  for j in range(0, len(list)):
  	if list[j] is str(i):
      m=m+1
    else:
      m=m+0
  answer.append(m)
a_s='\n'.join(answer)
print(a_s)
Problem p02711 (python)

Fixed submission:
N=input()
if '7' in N:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
if '7' in str(N):
	print ('Yes')
else:
  	print ('No')
Problem p02753 (python)

Fixed submission:
s = input()
print('Yes' if len(set(s))==2 else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
print('Yes' if len(set(s)==2 else 'No')
Problem p02759 (python)

Fixed submission:
N = int(input())
print(-((-N)//2))

Buggy submission (verdict: Runtime Error):
n = input()
print(-(-n//2))

Buggy submission (verdict: Runtime Error):
N = input()
print(-((-N)//2))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
o = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if o.get(s,-1)==-1:
        o[s]=c
    elif o.get(s,-1)!=-1 and o[s]!=c:
        print(-1)
        break
  else:
    m = [1]+[0]*(N-1)
    for k in o.keys():
        m[k-1]=o[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in m]))
Problem p02779 (python)

Fixed submission:
N = int(input())
A = set(input().split())
print('YNEOS'[len(A)!=N::2])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = {input().split()}
print('YNEOS'[len(A)==N::2])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = {input().split()}
print('YNEOS'[len(A)==N::2]
Problem p02847 (python)

Fixed submission:
s = input()
d = ['SUN','MON','TUE','WED','THU','FRI','SAT','a']  
d.reverse()
print(d.index(s))

Buggy submission (verdict: Runtime Error):
s = input()
d = ['SUN','MON','TUE','WED','THU','FRI','SAT','a']  
print(d.index(s)[::-1])
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n%2==1:
  print('No')
else:
  m = n//2
  print('Yes' if s[:m]==s[m:] else 'No')

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

Fixed submission:
x,y = map(int,input().split())
mod = 10**9+7
def comb(a,b):
  comb = 1
  chld = 1
  for i in range(b):
    comb = comb*(a-i)%mod
    chld = chld*(b-i)%mod
  return (comb*pow(chld,mod-2,mod))%mod
if (x+y)%3!=0:
  print(0)
else:
  nm = (x+y)//3
  n = y-nm
  m = x-nm
  if n>=0 and m>=0:
    print(comb(n+m,m))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
mod = 10**9+7
def count_route(x,y):
  if x<=0 or y<=0:
    return 0
  elif x/y>2 or y/x>2:
    return 0
  elif x%y==0 and x//y==2:
    return 1
  elif y%x==0 and y//x==2:
    return 1
  else:
    return sum([count_route(x-1,y-2)%mod,count_route(x-2,y-1)%mod])
print(count_route(x,y))
Problem p02912 (python)

Fixed submission:
import heapq
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
  maxv = heapq.heappop(a)*(-1)
  heapq.heappush(a,(maxv//2)*(-1))
print(sum(a)*(-1))

Buggy submission (verdict: Runtime Error):
import heapq as hq
m=input()
hq.heapify(a:=[-int(x) for x in input().split()])
for i in range(int(m[2])):hq.heappush(a,-(v:=-hq.heappop(a)//2))
print(-sum(a))
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
def Fib(n):
  seq = []
  a,b = 0,1
  for i in range(1,n+10):
    if i == 1:
      seq.append(0)
    elif i == 2:
      seq.append(1)
    else:
      a, b = b, a + b
      seq.append(b)
  return seq
table = Fib(n)
temp = -1
route = 1
mod = 10**9+7
for _ in range(m):
  a = int(input())
  dif = a-temp-1
  temp = a
  route = route*table[dif]%mod
print(route*table[n-temp]%mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
dp = [0]*(n+1)
dp[1],dp[2] = 1,1

for _ in range(m):
  a = int(input())
  dp[a] = -1

for i in range(1,n-1):
  if dp[i+2]==-1:
    continue
  if dp[i]==-1 and dp[i+1]==-1:
    dp[i+2] = -1
  elif dp[i]==-1:
    dp[i+2] = dp[i+1]
  elif dp[i+1]==-1:
    dp[i+2] = dp[i]
  else:
    dp[i+2] = dp[i] + dp[i+1]
    
print(dp[n]%(10**9+7) if dp[n]!=-1 else 0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
def Fib(n):
  seq = []
  a,b = 0,1
  for i in range(1,n+1):
    if i == 1:
      seq.append(0)
    elif i == 2:
      seq.append(1)
    else:
      a, b = b, a + b
      seq.append(b)
  return seq
table = Fib(n)
temp = -1
route = 1
mod = 10**9+7
for _ in range(m):
  a = int(input())
  dif = a-temp-1
  temp = a
  route = route*table[dif]%mod
print(route*table[n-temp]%mod)