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

Fixed submission:
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [IL()[::-1] for i in range(N)]

used = [-1]*N
updatelist = [i for i in range(N)]
total = N*(N-1)//2
cnt = 0
days = 0
ul = []
while updatelist:
  ul = []
  for i in updatelist:
    #print(a)
    #print(i+1)
    if len(a[i]) > 0 and used[i] != days:
      numIND = a[i][-1] -1
      #print(numIND+1)
      if a[numIND][-1] == i+1 and used[numIND] != days:
        a[i].pop(-1)
        a[numIND].pop(-1)
        used[i] = days
        used[numIND] = days
        ul.append(i)
        ul.append(numIND)
        cnt += 1
  else:
    updatelist = ul[:]
    if len(ul) != 0:
      days += 1
#print(a)
#print(cnt)
if cnt == total:
  print(days)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [IL()[::-1] for i in range(N)]

used = [-1]*N
total = N*(N-1)//2
flag = 1
cnt = 0
days = 0
while flag:
  flag = 0
  for i in range(N):
    #print(a)
    #print(i+1)
    if len(a[i]) > 0 and used[i] != days:
      numIND = a[i][-1] -1
      #print(numIND+1)
      if a[numIND][-1] == i+1 and used[numIND] != days:
        a[i].pop(-1)
        a[numIND].pop(-1)
        used[i] = days
        used[numIND] = days
        flag = 1
        cnt += 1
  else:
    if flag == 1:
      #days += 1
#print(a)
#print(cnt)
if cnt == total:
  print(days)
else:
  print(-1)
Problem p02987 (python)

Fixed submission:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

if len(ss) == 1:
  print("No")
elif s.count(ss[0]) == s.count(ss[1]) and len(ss) == 2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

if s.count(ss[0]) == s.count(ss[1]) and len(ss) == 2:
  print("Yes")
else:
  print("No")
Problem p03038 (python)

Fixed submission:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
            cnt += 1
            if cnt == tmp:
                break
        else:
            break
    else:
        continue
    break

print(sum(A))

Buggy submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
        else:
            break
    else:
        continue
    break

print(sum(A))
Problem p03042 (python)

Fixed submission:
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

f = 0
ff = 0
num = 12
if int(s[:2]) > num or int(s[:2]) == 0:
    f = 1
if int(s[2:]) > num or int(s[2:]) == 0:
    ff = 1

if f == 0 and ff == 0:
    print("AMBIGUOUS")
elif f == 1 and ff == 0:
    print("YYMM")
elif f == 0 and ff == 1:
    print("MMYY")
elif f == 1 and ff == 1:
    print("NA")

Buggy submission (verdict: Runtime Error):
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

f = 0
ff = 0
num = 12
if int(s[:2]) > num or int(s[:2]) == 0:
    f = 1
if int(s[2:]) > num or int(s[2:]) == 0:
    ff = 1

if f == 0 and ff == 0:
    print("AMBIGUOUS")
elif f == 1 and ff == 0:
    print("YYMM")
elif f == 0 and ff == 1:
    print("MMYY")
elif f == 1 and ff == 1:
    print("NA")
Problem p03077 (python)

Fixed submission:
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = [I() for i in range(5)]
num = min(A)

print(4 + math.ceil(N/num))

Buggy submission (verdict: Runtime Error):
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [I() for i in range(5)]

print(math.ceil(N/min(a))+4)

Buggy submission (verdict: Runtime Error):
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [I() for i in range(5)]

print(math.ceil(N/min(a))+4)
Problem p03127 (python)

Fixed submission:
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def gcd(a,b):
    while b % a:
        a,b = b, a % b
    return a

N = I()
A = IL()

ans = gcd(A[0],A[1])
for i in A:
  if i%ans != 0:
    ans = gcd(ans,i)
  if ans == 1:
    break

print(ans)

Buggy submission (verdict: Runtime Error):
import math
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = IL()

ans = math.gcd(A[0],A[1])
for i in A:
  if i%ans != 0:
    ans = math.gcd(ans,i)
  if ans == 1:
    break

print(ans)
Problem p03186 (python)

Fixed submission:
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C = IL()

if A+B < C:
    print(B*2+A+1)
else:
    print(B+C)

Buggy submission (verdict: Runtime Error):
#テストコード
import bisect
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

# 二分探索 #
def nibutan(list,n):
	list = [-int(10e10)]+list+[int(10e10)]
	left = 0
	right = len(list)
	while left+1 != right:
		middle = (left+right)//2
		if list[middle] <= n:
			left = middle
		else:
			right = middle
	return left

s = [i for i in S()] #初期配置
t = [i for i in S()] #目標配置

cnt = []
ans = 0
for i in s:
	tmp = t.index(i)+1
	bi = nibutan(cnt,tmp)
	cnt.insert(bi,tmp)
	ans += tmp-1-bi
print(ans)

#ご査収ください

Buggy submission (verdict: Runtime Error):
#テストコード
import bisect
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()] #初期配置
t = [i for i in S()] #目標配置

cnt = []
ans = 0
for i in s:
	tmp = t.index(i)+1
	bi = bisect.bisect_left(cnt,tmp)
	cnt.insert(bi,tmp)
	ans += tmp-1-bi
print(ans)

#ご査収ください
Problem p03209 (python)

Fixed submission:
N,X = map(int,input().split())
alist = [2**(i+2)-3 for i in range(N+1)]
cntlist = [2**(i+1)-1 for i in range(N+1)]
cnt = 0
i = 0

while True:
    i += 1
    if X <= N-i+1:
        break
    elif alist[-i] - (N-i+1) <= X:
        cnt += cntlist[-i]
        break
    elif alist[-i]//2 +1 < X: # 左
        cnt += cntlist[-i]//2 +1
        X -= alist[-i]//2 +1
    elif X == alist[-i]//2 +1: # 真ん中
        cnt += cntlist[-i]//2 + 1
        break
    elif X < alist[-i]//2 +1: # 右
        X -= 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
alist = [2**(i+2)-3 for i in range(N+1)]
cntlist = [2**(i+1)-1 for i in range(N+1)]
cnt = 0
i = 0

while True:
    i += 1
    if X <= N-i+1:
        break
    elif (alist[-1] - N) <= X:
        cnt += cntlist[-i]
        break
    elif alist[-i]//2 +1 < X: # 左
        cnt += cntlist[-i]//2 +1
        X -= alist[-i]//2 +1
    elif X == alist[-i]//2 +1: # 真ん中
        cnt += cntlist[-i]//2 + 1
        break
    elif X < alist[-i]//2 +1: # 右
        X -= 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
alist = [2**(i+2)-3 for i in range(N+1)]
cntlist = [2**(i+1)-1 for i in range(N+1)]
cnt = 0
i = 0

while True:
    i += 1
    if X <= N-i+1:
        break
    elif (alist[-1] - N) <= X:
        cnt += cntlist[-i]
        break
    elif alist[-i]//2 +1 < X: # 左
        cnt += cntlist[-i]//2 +1
        X -= alist[-i]//2 +1
    elif X == alist[-i]//2 +1: # 真ん中
        cnt += cntlist[-i-1] + 1
        break
    elif X < alist[-i]//2 +1: # 右
        X -= 1

print(cnt)
Problem p03242 (python)

Fixed submission:
n = input()
n = n.replace("1"," ").replace('9','1').replace(' ','9')
print(n)

Buggy submission (verdict: Runtime Error):
n = input()
for ans in range(111, 1000, 111):
    if n <= ans:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
n = n.replace("1"," ").replace('9','1').replace(' ','9')
print(n)

Buggy submission (verdict: Runtime Error):
s.replace('1','a')
s.replace('9','1')
s.replace('a','9')
print(str(n))
Problem p03272 (python)

Fixed submission:
N,i = list(map(int,input().split()))
print(N - i + 1)

Buggy submission (verdict: Runtime Error):
N,i = list(map(int,input()))
print(N-i+1)
Problem p03723 (python)

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

if A == B and A == C:
  if A%2==0:
    print(-1)
  else:
    print(0)
  exit()
else:
  cnt = 0
  while True:
    if A%2==0 and B%2==0 and C%2==0:
      A,B,C = (B+C)//2,(A+C)//2,(A+B)//2
      cnt += 1
      continue
    else:
      break
      
print(cnt)

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

if A == B and A == C:
  print(-1)
  exit(
else:
  cnt = 0
  while True:
    if A%2==0 and B%2==0 and C%2==0:
      A,B,C = (B+C)//2,(A+C)//2,(A+B)//2
      cnt += 1
      continue
    else:
      break
      
print(cnt)
Problem p03745 (python)

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

data = []
for i in range(N-1):
  if a[i+1]-a[i] == 0:
    continue
  else:
    data.append(a[i+1]-a[i])
#print(data)

if len(data) <= 1:
  print(1)
else:
  ans = 0
  left = 0
  i = 0
  while left < len(data)-1:
    if data[left]*data[left+1] < 0: # 極値
      ans += 1
      left += 1
      i = left
    left += 1
  else:
    if i == len(data):
      pass
    else:
      ans += 1
    print(ans)

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

data = []
for i in range(N-1):
  if a[i+1]-a[i] == 0:
    continue
  else:
    data.append(a[i+1]-a[i])

#print(data)
ans = 0
i = 0
while i<len(data)-1:
  if (data[i+1] * data[i]) < 0:
    ans += 1
    i += 1
    left = i
  i += 1
else:
  if left == len(data):
    pass
  else:
    ans += 1
  print(ans)
Problem p03803 (python)

Fixed submission:
Alice, Bob = list(map(int,input().split()))
ans = ["Bob", "Alice", "Draw"]

if Bob == Alice:
  print(ans[2])
elif Alice == 1:
  print(ans[1])
elif Bob == 1:
  print(ans[0])
elif Bob > Alice:
  print(ans[0])
else:
  print(ans[1])

Buggy submission (verdict: Runtime Error):
Bob, Alice = list(map(int,input().split()))
ans = ["Bob", "Alice", "Draw"]

if Bob == Alice:
  print(ans[2])
elif Bob = 1 or Bob > Alice:
  print(ans[0])
else:
  print(ans[1])
Problem p02753 (python)

Fixed submission:
S = input()
 
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')

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

if S == 'AAA' or S = 'BBB':
  print('No')
else:
  print('Yes')
Problem p02771 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
 
l = [0] * 10
 
l[A] += 1
l[B] += 1
l[C] += 1
 
if max(l) == 2:
  print('Yes')
else:
  print('No')

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

l = [0] * 9

l[A] += 1
l[B] += 1
l[C] += 1

if max(l) == 2:
  print('Yes')
else:
  print('No')
Problem p02779 (python)

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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        break
else:
    print('YES')

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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        print('NO')
        return

print('YES')

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

import math
from functools import reduce

print('YES' if reduce(math.gcd, A) == 1 else 'NO')

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

import math
from functools import reduce

print('YES' if reduce(math.gcd, A) == 1 else 'NO')
Problem p02552 (python)

Fixed submission:
x = int(input())

print(1 if x == 0 else 0)

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

print(1 if x == 0 else 0)
Problem p02594 (python)

Fixed submission:
X = int(input())
 
print("Yes" if X >= 30 else "No")

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

print("Yes" if X >= 30 else "No")
Problem p02623 (python)

Fixed submission:
import numpy as np

from numba import njit


@njit("i8[:](i8, i8[:], i8[:])", cache=True)
def cumsum(K, A, cA):
    for i, a in enumerate(A):
        cA[i] += cA[i - 1] + A[i]
        if cA[i] > K:
            break

    cA = cA[cA != 0]
    cA = np.append(0, cA)
    return cA


@njit("i8(i8, i8[:], i8[:])", cache=True)
def solve(K, cA, cB):
    ans = np.searchsorted(cA, K - cB, side="right") - 1
    ans += np.arange(len(cB))
    return ans.max()


N, M, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)

cA = np.zeros(N, dtype=np.int64)
cB = np.zeros(M, dtype=np.int64)

# np.cumsumだとoverflowする
cA = cumsum(K, A, cA)
cB = cumsum(K, B, cB)

ans = solve(K, cA, cB)
print(ans)

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

N, M, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)

# 累積和
A = np.cumsum(A)
B = np.cumsum(B)

# K以下を抽出
A = A[A <= K]
B = B[B <= K]

# Aを逆順にする
A = A[::-1]

c = 0
c_max = 0
for i, a in enumerate(A):
    c += len(A) - i

    for j, b in enumerate(B):
        if a + b <= K:
            cb = j + 1

    c += cb
    if c > c_max:
        c_max = c
    c = 0

print(c_max)

Buggy submission (verdict: Runtime Error):
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    sA = 0
    AA = []
    for a in A:
        sA += a
        if sA > K:
            break
        AA.append(sA)

    sB = 0
    BB = []
    for b in B:
        sB += b
        if sB > K:
            break
        BB.append(sB)

    AA = AA[::-1]

    M = max(len(AA), len(BB))

    for i in range(len(AA)):
        for j in range(len(BB)):
            if AA[i] + BB[i] <= K:
                m = len(AA) - i + j + 1
                if m > M:
                    M = m
    print(M)

main()
Problem p02762 (python)

Fixed submission:
import collections
import itertools
import sys

readline = sys.stdin.buffer.readline


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    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 unite(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
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M, K = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(M)]
    CD = [list(map(int, readline().split())) for _ in range(K)]

    E = UnionFind(N)

    ans = [0 for _ in range(N)]
    for a, b in AB:
        a -= 1
        b -= 1
        E.unite(a, b)
        ans[a] -= 1
        ans[b] -= 1

    for i in range(N):
        E.find(i)

    ll = collections.defaultdict(int)
    for i in E.par:
        ll[i] += 1

    for i in range(N):
        ans[i] += ll[E.par[i]] - 1

    for i, j in CD:
        i -= 1
        j -= 1
        if E.same(i, j):
            ans[i] -= 1
            ans[j] -= 1

    print(*ans)


main()

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

import numpy as np

readline = sys.stdin.buffer.readline


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    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 unite(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
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M, K = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(M)]
    CD = [list(map(int, readline().split())) for _ in range(K)]

    E = UnionFind(N)

    ans = [0 for _ in range(N)]
    for a, b in AB:
        a -= 1
        b -= 1
        E.unite(a, b)
        ans[a] -= 1
        ans[b] -= 1

    for i in range(N):
        E.find(i)

    ll = collections.defaultdict(int)
    for i in E.par:
        ll[i] += 1

    for i in range(N):
        ans[i] += ll[E.par[i]] - 1

    for i, j in CD:
        i -= 1
        j -= 1
        if E.same(i, j):
            ans[i] -= 1
            ans[j] -= 1

    print(*ans)


main()
Problem p02833 (python)

Fixed submission:
import math


def main():
    N = int(input())

    if N == 0 or N == 1:
        ans = 0

    elif N % 2 == 0:
        B = N // 2
        n = math.floor(math.log(B) / math.log(5))

        ans = 0
        for i in range(1, n + 1):
            ans += B // (5**i)

    else:
        ans = 0

    print(int(ans))


main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    N = int(input())

    if N % 2 == 0:
        B = N // 2
        n = math.floor(math.log(B) / math.log(5))

        ans = 0
        for i in range(1, n + 1):
            ans += B // (5**i)

    else:
        ans = 0

    print(int(ans))


main()
Problem p02984 (python)

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

ans = [0 for _ in range(N)]

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


for i in range(1, N):
    ans[i] = 2 * A[0] - ans[i - 1]

    t = A.pop(0)
    A.append(t)

print(*ans)

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


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))

    B = np.zeros([N, N])
    np.fill_diagonal(B, 1)
    ps = list(range(1, N)) + [0]
    B = B[ps, :]
    np.fill_diagonal(B, 1)
    iB = np.linalg.inv(B)

    X = np.dot(iB, A) * 2
    X = X.astype(np.int32)
    print(*X)


main()
Problem p03013 (python)

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

if N == 1:
    if M == 0:
        print(1)
    elif M == 1:
        print(0)
else:
    cost = [0 for _ in range(N + 1)]
    cost[0] = 1

    cnt = 0
    A.append([0])
    for i in range(1, N + 1):
        if i == A[cnt]:
            cost[i] = 0
            cnt += 1
        else:
            cost[i] = (cost[i - 1] + cost[i - 2]) % q

    print(cost[-1])

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

N, M = map(int, input().split())
A = np.array([int(input()) for _ in range(M)])
q = 1000000007

cost = np.zeros(N + 1, dtype=np.int64)
cost[0] = 1
cost[1] = 1
cost[A] = 0
cost[2] = cost[0] + cost[1]

for i in range(1, N + 1):
    cost[A] = 0
    cost[i] = (cost[i - 1] + cost[i - 2]) % q

print(cost[-1])

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

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

for i in range(M):
    A[i] = int(input())


# a が連続しているとだめ
for i in range(M-1):
    if A[i] == A[i+1]-1:
        print(0)
        sys.exit()

# 穴同士の間隔を考えて，積を取る
d = np.zeros(M+1)

for i in range(M-1):
    d[i+1] = A[i+1] - A[i] - 2

d[0] = A[0] - 1
d[-1] = N - A[-1] - 1


p = np.zeros(M+1)

for i in range(M+1):

    n = int(d[i] // 2)

    for j in range(1,n+1):
        # 2の数 j個
        # 1の数 n1 = d - 2j
        n1 = d[i] - 2*j
        pp = math.factorial(n1+j)/(math.factorial(j) * math.factorial(n1))
        p[i] += pp

    p[i] += 1

mm = 1000000007
p = p % mm

print(int(np.prod(p) % mm))