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

Fixed submission:
import itertools

N, X, Y = map(int, input().split())

# dp = [[float('inf')] * (N+1) for _ in range(N+1)]
# # dp[Y][X] = 1
# dp[X][Y] = 1

# for i in range(1,N+1):
#     for j in range(i,N+1):
#         if i == j:
#             dp[i][j] = 0
#         elif i == X and j == Y:
#             dp[X][Y] = 1
#         elif i <= X:
#             dp[i][j] = min(dp[i][j-1] + 1, dp[i][X] + abs(Y - j) + 1)
#         else:
#             dp[i][j] = min(dp[i][j-1]+ 1, abs(i - X)+ abs(Y - j) + 1 )

# dp = list(itertools.chain.from_iterable(dp))
# for i in range(1,N):
#     print(dp.count(i))

result = [0] * N

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = min(abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i)+1+abs(j-X))
        result[dist] += 1

for i in range(1, N):
    print(result[i])

Buggy submission (verdict: Runtime Error):
result = []

for i in range(1, N+1):
    for j in range(i, N+1):
        result.append(min(abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i)+1+abs(j-X)))

for i in range(1, N):
    print(result.count(i))
Problem p02831 (python)

Fixed submission:
import fractions

A, B = map(int, input().split())
def lcm(a, b):
    g = fractions.gcd(a, b)
    L = a * b // g
    return L

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
def lcm(a, b):
    g = math.gcd(a, b)
    L = a * b // g
    return L

print(lcm(A, B))
Problem p02891 (python)

Fixed submission:
S = list(input())
K = int(input())

if len(set(S)) == 1:
    print((len(S)*K)//2)
    exit()

def n_change(sss):
    s = sss.copy()
    x = 0
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            s[i] = "X"
            x += 1
    return x

print(n_change(S) + (K-1) * (n_change(2*S) - n_change(S)))

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
L = len(S)
count = 0
changed = [0]*L

i = 0
while i < L-1:
    if S[i] == S[i+1]:
        changed[i+1] = 1
        i += 2
        count += 1
    else:
        i += 1

if changed[1] == 0 and changed[L-1] == 0 and S[0] == S[L-1]:
    ans = count * K + K -1
else:
    ans = count * K


print(ans)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q=list(map(int, input().split()))
result = {i+1:0 for i in range(n)}
ar = np.eye(n)

for i in range(n-1):
    a,b = list(map(int, input().split()))
    ar[0:a,a-1:b] += 1
for i in range(q):
    a,b = list(map(int, input().split()))
    m = ar[a-1]
    for j in range(len(m)):
        if m[j] != 0:
            result[j+1] += b
        else:
            result[j+1] += 0
r = list(result.values())
res = map(str, r)
print(' '.join(res))
Problem p02948 (python)

Fixed submission:
import sys
import heapq
 
N, M = list(map(int, input().split()))
jobs = []

#上限内で報酬を得られる単発を一度リストに入れる。
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))

#逆順にsort
jobs.sort(reverse=True)

#heatpqでpriority quene，最大値を取り出すときは-qを加えて挿入し，-1をかけて取り出す
q = []
ans = 0
#後ろの日にちから回す
for i in range(1, M + 1):
    #日数が足りる単発をheatpqのリストに加えていく
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)
 
    if q:
        #できる仕事がある場合，最大の給料のを取り出す
        ans += -heapq.heappop(q)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]

l = M
result = 0
while l > 0:
    index_lis = [i for i, v in enumerate(X) if v[1] == max(X, key=lambda xx: xx[1])[1]]
    if len(index_lis) >= 2:
        a = max(X, key=lambda xx: xx[index_lis][0])
    else:
        a = X[index_lis[0]]
    if a[0] > l:
        X.remove(a)
    elif a[0] <= l:
        result += a[1]
        l -= 1
        X.remove(a)
print(result)
Problem p02951 (python)

Fixed submission:
A,B,C = map(int, input().split())
print(C-min(A-B, C))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int, input().strip())
print(C-(A-B))
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

N = int(input())
A = list(map(int, input().split()))

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(A))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
A = list(map(int, input().split()))

def gcd(*numbers):
    return reduce(math.gcd, numbers)

print(gcd(*A))
Problem p02689 (python)

Fixed submission:
n, m = map(int,input().split())
h = list(map(int,input().split()))
dic = {}
for i in range(len(h)):
    dic[i] = 0
for i in range(m):
    a, b = map(int,input().split())
    if h[a-1] > h[b-1]:
        dic[b-1] = 1
    elif h[a-1] < h[b-1]:
        dic[a-1] = 1
    elif h[a-1] == h[b-1]:
        dic[b-1] = 1
        dic[a-1] = 1
ans = 0
for i in range(len(h)):
    if dic[i] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
h = list(map(int,input().split()))
max = max(h)
count = [0 for i in range(max)]
for i in range(m):
    a, b = map(int,input().split())
    if a >= b:
        A = a
        a = b
        b = A
    count[a-1] = 1
ans = 0
for i in h:
    if count[i-1] == 0:
        ans += 1
print(ans)
Problem p02773 (python)

Fixed submission:
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(len(ans)):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(n):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])
Problem p03011 (python)

Fixed submission:

def main(P, Q, R):
    print(min([P+Q, Q+R, P+R]))

if __name__ == "__main__":
    P, Q, R = [int(x) for x in input().split()]

    main(P, Q, R)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)

def main(N, M, a_list):
    div = 10**9 + 7
    @lru_cache(maxsize=None)
    def fib(n):
        if n in a_list:
            return 0
        else:
            if n == -1:
                return 0
            elif n == 0 or n == 1:
                return 1
            else:
                return fib(n-2) % div + fib(n-1) % div
    
    
    print(fib(N) % div )


if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)
Problem p02793 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(a, b):
    return a * b // gcd(a, b)

L = 1
for a in A:
    L = lcm(L, a)

L %= MOD
coef = 0
for a in A:
    coef += pow(a, MOD - 2, MOD)
print((L * coef) % MOD)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]*pow(math.gcd(kbs,A[i]),mod-2,mod)
  kbs %= mod
  
ans = 0
for i in range(N):
  ans += kbs*pow(A[i],mod-2,mod)
  ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]*pow(math.gcd(kbs,A[i]),mod-2,mod)
  kbs %= mod
  
ans = 0
for i in range(N):
  ans += kbs*pow(A[i],mod-2,mod)
  ans %= mod
print(ans)
Problem p02831 (python)

Fixed submission:
[A,B] = map(int,input().split())
max_ab = max(A,B)
min_ab = min(A,B)

r = max_ab
s = min_ab

while s != 0:
  r,s = s,r % s
  if s == 0:
    break
print(int(r*(A/r)*(B/r)))

Buggy submission (verdict: Runtime Error):
[A,B] = input().split()
max_ab = max(A,B)
min_ab = min(A,B)

r = max_ab
s = min_ab

while s != 0:
  r,s = s,r % s
  if s == 0:
    break
print(int(r*(A/r)*(B/r)))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
max_ab = max(A,B)
min_ab = min(A,B)

r = max_ab
s = min_ab

while s != 0:
  r,s = s,r % s
  if s == 0:
    break
print(int(r*(A/r)*(B/r)))
Problem p02833 (python)

Fixed submission:
import math

N = int(input())
if N % 2 == 1:
  print(0)
else:
  zero_count = 0
  if N == 0:
    print(0)
  else:  
    for i in range(1,1+int(math.log(N//2,5)//1)):#ここのN//2がN/2にしてただけで計算が狂った。floatの扱いの問題か
      zero_count += (N//2)//(5**i)
    print(int(zero_count))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
if N % 2 == 1:
  print(0)
else:
  zero_count = 0
  for i in range(1,1+int(math.log(N//2,5)//1)):#ここのN//2がN/2にしてただけで計算が狂った。floatの扱いの問題か
    zero_count += (N//2)//(5**i)
  print(int(zero_count))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
if N % 2 == 1:
  print(0)
else:
  zero_count = 0
  for i in range(1,1+int(math.log(N/2,5)//1)):
    zero_count += (N/2)//5**i
  print(int(zero_count))
Problem p03053 (python)

Fixed submission:
import copy
from collections import deque

####入力
H,W = map(int,input().split())

#gridの定義
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
####入力終了

#distの設定
dist = [[0 for i in range(W)] for j in range(H)]

#l_blackの設定
l_black = deque([])
for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      l_black.append( [i,j] ) # [行,列]

#探索
max_d = 0

while len(l_black) > 0:
  #vは黒マスの座標 
  while len(l_black) > 0:
    v = l_black.popleft()
    #iはvの上下左右のマスの座標[行,列]
    for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
      #場外アウトの場合はスルー
      if (i[1]<0 or i[0] <0 or i[0]>=H or i[1] >= W ):
        continue
      #移動先がもう黒マスの場合スルー
      if grid[i[0]][i[1]] == "#":
        continue
      #移動先が白マスならばそこの座標を黒マスにして距離を記録する
      if grid[i[0]][i[1]] == ".":
        #黒マスにする
        grid[i[0]][i[1]] = "#"
        #新たに黒鱒となった座標をl_blackに追加
        l_black.append(i)
        #距離の記録
        dist[i[0]][i[1]] = dist[v[0]][v[1]] + 1
        max_d = max(max_d,dist[i[0]][i[1]])
print(max_d)

Buggy submission (verdict: Runtime Error):
import copy

####入力
H,W = map(int,input().split())

#gridの定義
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
####入力終了


#l_blackの設定
l_black = []
for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      l_black.append( [i,j] ) # [行,列]


#探索
cnt = 0

while len(l_black) > 0:

  l_change = []

  #vは黒マスリスト #新たに黒マスになる白マスの座標をl_changeに詰めていく
  for v in l_black:
    #iはvの上下左右のマスの座標[行,列]
    for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
      #場外アウトの場合はスルー
      if (i[0]<0 or i[1] <0 or i[1]>=H or i[0] >= W ):
        continue
      #移動先がもう黒マスの場合スルー
      if grid[i[1]][i[0]] == "#":
        continue
      #移動先が白マスならばそこの座標をl_changeに追加
      if grid[i[1]][i[0]] == ".":
        l_change.append( i )
  
  #l_changeの中の白マスを黒にする
  for i in l_change:
    grid[i[0]][i[1]] = "#" 
  #l_blackの中を新たに黒鱒になったやつの座標だけにする
  l_black = copy.deepcopy( l_change )
  if len(l_black) > 0:
    cnt = cnt + 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import copy

####入力
H,W = map(int,input().split())

#gridの定義
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
####入力終了


#l_blackの設定
l_black = []
for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      l_black.append( [i,j] ) # [行,列]


#探索
cnt = 0

while len(l_black) > 0:

  l_change = []

  #vは黒マスリスト #新たに黒マスになる白マスの座標をl_changeに詰めていく
  for v in l_black:
    #iはvの上下左右のマスの座標[行,列]
    for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
      #場外アウトの場合はスルー
      if (i[0]<0 or i[1] <0 or i[1]>=H or i[0] >= W ):
        continue
      #移動先がもう黒マスの場合スルー
      if grid[i[1]][i[0]] == "#":
        continue
      #移動先が白マスならばそこの座標をl_changeに追加
      if grid[i[1]][i[0]] == ".":
        l_change.append( i )
  
  #l_changeの中の白マスを黒にする
  for i in l_change:
    grid[i[0]][i[1]] = "#" 
  print(grid)
  #l_blackの中を新たに黒鱒になったやつの座標だけにする
  l_black = copy.deepcopy( l_change )
  if len(l_black) > 0:
    cnt = cnt + 1
print(cnt)
Problem p02816 (python)

Fixed submission:
####################################### Define
maxN = int(6e5 + 100)
a = [0] * maxN
b = [0] * maxN
ans = [0] * maxN
####################################### Functions
def solve() :
    L = R = 0
    for i in range(2, 3 * n + 1) :
        if i > R :
            L = R = i
            while R + 1 <= 3 * n and (a[i] ^ a[1]) == (a[R + 1] ^ a[R - L + 2]): R += 1
#            print(a[i] ^ a[1], a[R + 1] ^ b[R - L + 2], R, L, "\n")
            ans[i] = R - L + 1
        else :
            k = i - L + 1
            if ans[k] < R - i + 1 : ans[i] = ans[k]
            else :
                L = i
                while R + 1 <= 3 * n and (a[i] ^ a[1]) == (a[R + 1] ^ a[R - L + 2]): R += 1
                ans[i] = R - L + 1
####################################### Main
n = int(input())
inp = input().split()
for i in range(n + 1, 2 * n + 1) : a[i] = int(inp[i - n - 1])
for i in range(2 * n + 1, 3 * n + 1) : a[i] = a[i - n]
inp = input().split()
for i in range(1, n + 1) : a[i] = int(inp[i - 1])

solve()

for i in range(n + 1, 2 * n + 1):
    if ans[i] >= n:
        print(i - n - 1, (a[i] ^ a[1]))

Buggy submission (verdict: Runtime Error):
####################################### Define
maxN = int(2e5 + 100)
a = [0] * maxN
b = [0] * maxN
ans = [0] * maxN
####################################### Functions
def solve() :
    L = R = -1
    for i in range(1, n + 1) :
        if i > R :
            L = R = i
            while R + 1 <= 2 * n and a[i] ^ b[1] == a[R + 1] ^ b[R - L + 2]: R += 1
#            print(a[i] ^ b[1], a[R + 1] ^ b[R - L + 2], "\n")
            ans[i] = R - L + 1
        else :
            k = i - L
            if ans[k] < R - i + 1 : ans[i] = ans[k]
            else :
                L = i
                while R + 1 <= 2 * n and a[i] ^ b[1] == a[R + 1] ^ b[R - L + 2]: R += 1
                ans[i] = R - L + 1
####################################### Main
n = int(input())
inp = input().split()
for i in range(1, n + 1) : a[i] = int(inp[i - 1])
for i in range(n + 1, 2 * n + 1) : a[i] = a[i - n]
inp = input().split()
for i in range(1, n + 1) : b[i] = int(inp[i - 1])
for i in range(n + 1, 2 * n + 1) : b[i] = b[i - n]

solve()

for i in range(1, n + 1):
    if ans[i] >= n:
        print(i - 1, a[i] ^ b[1])
Problem p02682 (python)

Fixed submission:
a,b,c,k = map(int,input().split())

aa = min(a,k)
bb = min(b,k - aa)
cc = min(c,k - aa - bb)

print(aa - cc)

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

L = [1] * A + [0] * B + [-1] * C

ans = 0

AB = A + B

if AB > K:
  print(A)
else:
  print(A + (K - AB) * -1)

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

L = [1] * A + [0] * B + [-1] * C

ans = 0

for i in range(K):
  ans += L[i]
  
print(ans)
Problem p02859 (python)

Fixed submission:
r = int(input())

print(r ** 2)

Buggy submission (verdict: Runtime Error):
import math

X,Y = map(int,input().split())

if (X + Y) % 3 != 0:
  print(0)
  
else:
  a = Y - (X + Y) // 3
  b = X - (X + Y) // 3
  total = a + b
  m = min(a,b)
  def permod(n, r):
    return (math.factorial(n) // math.factorial(n - r)) % (10 ** 9 + 7)
  
  ans = permod(total,m)
  print(ans)
Problem p02862 (python)

Fixed submission:
def cmb(n, k, mod, fac, infac):
  k = min(k,n-k)
  return fac[n] * infac[k] * infac[n-k] % mod

def tables(mod, n):
  fac = [1, 1] 
  infac = [1, 1] 
  inverse = [0, 1] 
  for i in range(2, n+1):
    fac.append((fac[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    infac.append((infac[-1] * inverse[-1]) % mod)
  return fac,infac

X,Y = map(int, input().split())

if X > Y:
  X, Y = Y, X

move = X + Y

if move % 3 != 0:
  print(0)
else:
  total = move // 3
  n = X - total
  
  if n < 0:
    print(0)
    
  else:
    MOD = 10 ** 9 + 7
    fac, infac = tables(MOD, total)
    ans = cmb(total, n, MOD, fac, infac)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, k, mod, fac, infac):
  k = min(k,n-k)
  return fac[n] * infac[k] * infac[n-k] % mod

def tables(mod, n):
  fac = [1, 1] 
  infac = [1, 1] 
  inverse = [0, 1] 
  for i in range(2, n+1):
    fac.append((fac[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    infac.append((infac[-1] * inverse[-1]) % mod)
  return fac,infac

X,Y = map(int, input().split())

if X > Y:
  X, Y = Y, X

move = X + Y

if move % 3 != 0:
  print(0)
else:
  total = move // 3
  n = X - total
  
  if n > 0:
    print(0)
  else:
    MOD = 10 ** 9 + 7
    fac, infac = tables(MOD, total)
    ans = cmb(total, n, MOD, fac, infac)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
from scipy.special import comb

#def permod(n, r):
  #return (math.factorial(n) // math.factorial(n - r)) % (10 ** 9 + 7)

from operator import mul
from functools import reduce

def com(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
  X,Y = map(int,input().split())
  
  if (X + Y) % 3 != 0:
    print(0)
    
  else:
    a = Y - (X + Y) // 3
    b = X - (X + Y) // 3
    
    ans = com(a + b,b)
    
    print(ans)
    
main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
from operator import mul

X,Y = map(int,input().split())

if (X + Y) % 3 != 0:
  print(0)
  
else:
  a = Y - (X + Y) // 3
  b = X - (X + Y) // 3
  total = a + b
  m = min(a,b)
  nums = [i for i in range(m,total + 1)]
  div = [i for i in range(1,m + 1)]
  M = reduce(mul,div)
  N = reduce(mul,nums) * M
  print((N // M) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
X,Y = map(int,(input().split()))

mod = 10 ** 9 + 7

def recur(x,y):
  if x == X and y == Y:
    return 1 % mod
  
  elif x > X or y > Y:
    return 0
  
  else:
    ret1 = recur(x + 1,y + 2)
    ret2 = recur(x + 2,y + 1)
    
    return ret1 + ret2
    
print(recur(0,0))
Problem p02915 (python)

Fixed submission:
n = int(input())

ans = n ** 3

print(ans)

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

A = [0] * N

for i in range(N-1):
  A[i] = min(B[i-1],B[i])

A[0] = B[0]
A[N-1] = B[N-2]

print(sum(A))

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

A = [0] * N


for i in range(N-1):
  A[i] = min(B[i-1],B[i])

A[0] = min(B[0],B[1])
A[N-1] = B[N-2]

print(sum(A))
Problem p02933 (python)

Fixed submission:
A = int(input())
B = input()

if A < 3200:
  print("red")
else:print(B)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = input()

if A >= 3200:
  print(red)
else:print(B)
Problem p02989 (python)

Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split())))
  
print(L[int(N/2)] - L[int((N/2))-1])

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

def sort(L):
  if len(L) < 2:
    return(L)
  p = L[0]
  X,Y = divide(p,L[1:])
  return sort(X) + [p] + sort(Y)

def divide(p,L):
  if len(L) < 1:
    return([],[])
  X,Y = divide(p,L[1:])
  l = L[0]
  if l < p:
    return([l] + X,Y)
  else:
    return(X,[l]+Y)
  
L = sort(L)
cut = L[int(N/2)] - L[int((N/2))-1]
print(cut)
Problem p03013 (python)

Fixed submission:
N,M = map(int, input().split())
A = [int(input()) for a in range(M)]
A = set(A)
	
DP = [0] * (N + 1)	
DP[0] = 1

mod = (10 ** 9) + 7

for i in range(1,N+1):
	if i in A:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[N] % (mod))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]

def recur(step):
  if step == N:
    return 1
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return (ret1 + ret2) % (10 ** 9 + 7) 
    
print(recur(0))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]

def recur(step):
  if step == N:
    return 1　
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return (ret1 + ret2) % (10 ** 9 + 7) 
    
print(recur(0))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]

def recur(step):
  if step == N:
    return 1　
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return (ret1 + ret2) / (10 ** 9 + 7) 
    
print(recur(0))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]

def recur(step):
  if step == N:
    return 1
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return ret1 + ret2
    
print(recur(0) % (10 ** 9 + 7) )

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = [int(input()) for a in range(M)]
A = set(A)
	
DP = [0] * (N + 1)	
DP[0] = 1

mod = (10 ** 9) + 7

for i in range(1,N+1):
	if i in A:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[n] % (mod))
Problem p03038 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

i = 0

for B,C in BC:
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

for B,C in BC:
  print(B,C)
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = []
for _ in range(M):
  b,c = map(int,input().split())
  BC.append([b,c])

totals = [sum(A)]

for i in range(M):
  b = BC[i][0]
  part = A[:b]
  c = [BC[i][1]] * b
  print(part,c)
  if sum(part) < sum(c):
    left = c
    right = A[b:]
    total = sum(left) + sum(right)
    totals.append(total)
    
print(max(totals))
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

N = int(input())

A = list(map(int,input().split()))

print(gcd(A))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

A = list(map(int,input().split()))

A = sorted(A)[0:2]

print(math.gcd(A[0],A[1]))
Problem p03221 (python)

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

L = [list(map(int,input().split())) for i in range(M)]

for i in range(M):
  L[i].append(i + 1)

sortL = sorted(L)

ID = ""

order = 0

for i in range(0,len(L)):
  if sortL[i][0] > sortL[i-1][0]:
    order = 0
  order += 1
  pref = str(sortL[i][0])
  ID = "0" *  (6 - len(pref))
  ID += pref
  ID += "0" * (6 - len(str(order)))
  ID += str(order)
  sortL[i].append(ID)

sortL.sort(key=lambda x: x[2])

for i in range(0,len(L)):
  print(sortL[i][-1])

Buggy submission (verdict: Runtime Error):
import bisect

def main():
  N,M = map(int,input().split())
  pref = [[] for i in range(N)]
  id = [[]] * M
  
  for i in range(M):
    p,y = map(int,input().split())
    id[i] = [p,y]
    pref[p - 1].append(y)
    #pref[p - 1] = sorted(pref[p - 1])
  
  for i in range(N):
    pref[i] = sorted(pref[i])
  
  orders = [0] * N
  
  for i in range(M):
    p = id[i][0] - 1
    y = id[i][1]
    order = str(bisect.bisect_left(pref[p],y) + 1)
    city = str(p + 1)
    ID = ""
    ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order
    print(ID)

if __init__ == '__main__':
  main()