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

Fixed submission:

# -*- coding: utf-8 -*-
N,M=map(int, input().split())
As=list(map(int, input().split()))


tot=sum(As)
if tot>N:
    print(-1)
else:
    print(N-tot)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

	print(max(-1,N-sum(A)))




if __name__ == "__main__":
    main()
Problem p02709 (python)

Fixed submission:

# -*- coding: utf-8 -*-

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

inds=sorted(range(len(As)), key=lambda k: As[k])[::-1]
#ds=[[0 for j in range(N+1-i)] for i in range(N+1)]

ds=[0]
for xy in range(1,N+1):
    i=inds[xy-1]
    a=As[i]
    nds=[0]*(xy+1)
    nds[-1]=ds[-1]+a*(i-(xy-1))
    nds[0]=ds[0]+a*(N-xy-i)

    for x in range(1,xy):
        y=xy-x
        c1=ds[x-1]+a*abs(i-(x-1))
        c2=ds[x]+a*abs(N-y-i)
        nds[x]=max(c1,c2)
    ds=nds.copy()
    #print(ds)


print(max(ds))
#print(ds)
#print(inds)

Buggy submission (verdict: Runtime Error):

# -*- coding: utf-8 -*-
import numpy as np
N=int(input())
As=list(map(int, input().split()))

As=np.array(As)
inds=np.argsort(As)[::-1]
As=As[inds]

ds=np.empty((N+1,N+1),dtype=np.int64)

ds[0][0]=0
for i in range(1,N+1):
    ds[i][0]=ds[i-1][0]+As[i-1]*(inds[i-1]-(i-1))
    ds[0][i]=ds[0][i-1]+As[i-1]*(N-i-inds[i-1])

for xy in range(2,N+1):
    a=As[xy-1]
    i=inds[xy-1]
    for x in range(1,xy):
        y=xy-x
        c1=ds[x-1,y]+a*(i-(x-1))
        c2=ds[x,y-1]+a*(N-y-i)
        ds[x,y]=max(c1,c2)

ans=0
for x in range(0,N+1):
    =ds[x,N-x]
    ans=max(c,ans)
print(ans)
#print(ds)
#print(inds)
Problem p02721 (python)

Fixed submission:

# -*- coding: utf-8 -*-

import numpy as np
N, K, C=map(int, input().split())
s=list(input())

forward=np.zeros(K)
back=np.zeros(K)

day=0
count=0
while day <N and count<K:
    if s[day]=='o':
        forward[count]=day
        count+=1
        day+=C+1
    else:
        day+=1

day=N-1
count=0
while day<N and count<K:
    if s[day]=='o':
        back[count]=day
        count+=1
        day-=C+1
    else:
        day-=1

#print(forward)
#print(back[::-1])

for i in range(K):
    if forward[i]==back[K-1-i]:
        print(int(forward[i])+1)

Buggy submission (verdict: Runtime Error):
for i in range(N):
    if s[i]=='o':
        si=copy.copy(s)
        si[i]='x'
        day=N
        count=0
        flag=False
        while day>K-1 and count<K:
            if si[day-1]=='x':
                day-=1
            else:
                count+=1
                day-=C+1
                if count==K:
                    flag=True
        if flag==False:
            print(i+1)
Problem p02743 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c=map(int,input().split())


if c>a+b and int(4*a*b)<int((c-a-b)**2):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from demical import Demical
a,b,c=input().split()
a=Demical(a)
b=Demical(b)
c=Demical(c)
if a**0.5+b**0.5<c**0.5:
  print('Yes')
else:
  print('No')
Problem p02795 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    import math
    H=int(input())
    W=int(input())
    N=int(input())
    m=max(H,W)
    print(math.ceil(N/m))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
H=input()
W=input()
N=input()
m=max(H,W)
print(math.ceil(N/m))
Problem p03125 (python)

Fixed submission:
[a, b] = map(int, input().split())
print(a + b if b % a == 0 else b - a)

Buggy submission (verdict: Runtime Error):
a

Buggy submission (verdict: Runtime Error):
a
Problem p02642 (python)

Fixed submission:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time


def main():

    N = int(input())
    A = [int(i) for i in input().split()]
    D = set()
    S = set()
    for i in range(N):
        if A[i] in S:
            D.add(A[i])
        else:
            S.add(A[i])
    M = max(S)
    X = [1 for i in range(M+1)]
    for a in S:
        if a in D:
            X[a] = 0
        for i in range(2*a, M+1, a):
            X[i] = 0
    ans = 0
    for i in range(N):
        if X[A[i]] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    max_a = max(a)
    arr = [1] * (max_a + 1)

    for num in a:
        if a.count(num) > 1:
            arr[num] = 0
        for i in range(num*2, max_a+1, num):
            arr[i] = 0

    for i in range(n):
        if arr[a[i]] == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    max_a = max(a)
    arr = [1] * (max_a + 1)

    for num in a:
        if a.count(num) > 1:
            arr[num] = 0
        for i in range(num*2, max_a+1, num):
            arr[i] = 0

    for i in range(n):
        if arr[a[i]] == 1:
            ans += 1

    print(ans)


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

Fixed submission:
import bisect


def main():
    n = int(input())
    l = sorted(list(int(i) for i in input().split()))

    cnt = 0

    for i in range(n - 2):
        a = l[i]
        for j in range(i + 1, n-1):
            b = l[j]
            cnt += bisect.bisect_left(l, a+b)-(j+1)

    print(cnt)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect

n = int(input())
l = list(int(i) for i in input().split())
l = sorted(l, reverse=True)

cnt = 0

for i in range(n - 2):
    a = l[i]
    for j in range(i + 1, n-1):
        b = l[j]
        cnt += bisect.bisectright(l, a-b)-(j+1)

print(cnt)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n = int(input())
l = list(int(i) for i in input().split())

cnt = 0

for bars in comb(l, 3, exact=True):
    a, b, c = bars[0], bars[1], bars[2]
    if a < b + c and b < a + c and c < b + a:
        cnt += 1

print(cnt)
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
from math import gcd
ans=0
def main(n):
    e=n//c+n//d-n//((c*d)//gcd(c,d))
    return n-e

print(main(b)-main(a-1))

Buggy submission (verdict: Runtime Error):
import math


# def calc(n, c, d):
#     return n-(math.floor(n / c) +
#               math.floor(n / d) - math.floor(n / (c * d / math.gcd(c, d))))
def calc(n, c, d):
    return n-(n / c +
              n / d - n / (c * d / gcd(c, d)))


def main():
    a, b, c, d = map(int, input().split())

    print(calc(b, c, d)-calc(a-1, c, d))


if __name__ == "__main__":
    main()
Problem p03035 (python)

Fixed submission:
A,B = map(int, input().split())
 
if A < 6:
  B = 0
elif (6 <= A) and (A < 13):
  B /= 2
else :
  pass
  
print(int(B))

Buggy submission (verdict: Runtime Error):
r,D,x = map(int, input().split())

for i in range(10):
  x = r*x - D
  print(x)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
 
if 6 <= A and A < 13:
  B /= 2
else if A < 6:
  B = 0
  
print(B)

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

if A >= 13:
  print(B)
else if A > 5:
  print(B/2)
else :
  print(0)

Buggy submission (verdict: Runtime Error):
if age >= 13 :
    return money
else if age > 5 :
    return money / 2
else:
    return 0

Buggy submission (verdict: Runtime Error):
def fun(A,B):
  if A >= 13 :
    return B
  else if A > 5 :
    return B / 2
  else:
    return 0

Buggy submission (verdict: Runtime Error):
def fun(age,money):
  if age >= 13 :
    return money
  else if age > 5 :
    return money / 2
  else:
    return 0
Problem p03060 (python)

Fixed submission:
import numpy as np
n = int(input())
v = np.array(list(map(int,input().split())))
c = np.array(list(map(int,input().split())))

profit = v - c

max_profit = np.sum(profit[profit>0])
print(max_profit)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
v = np.array(list(map(int,input().split())))
c = np.array(list(map(int,input().split())))

for i in range(n):
  profit = v[i] - c[i]

max_profit = np.sum(profit[profit>0])
print(max_profit)
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
coins=0

for i in range(2):
  if a > b:
    coins += a
    a-=1
  else:
    coins += b
    b-=1
  
print(coins)

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

no_ocean = 0

for i in range(1,n):
  for k in range(i):
    if height[k] > height[i]:
      	no_ocean += 1
      	break
    else:
        continue
        
print(n - no_ocean)

Buggy submission (verdict: Runtime Error):
a,b = input().split()

if a >= b + 2:
  coins = 2 * a - 1
elif b + 2 >= a:
  coins = 2 * b - 1
else:
  coins = a + b
  
print(coins)
Problem p03126 (python)

Fixed submission:
n,m = map(int, input().split())
ans = list(input().split())
ans = set(ans[1:])
for i in range(n-1):
    b = list(input().split())
    b = set(b[1:])
    ans = ans & b
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
for i in range(n):
  k,a = input().split()[0] , input().split()[1:]
count = 0
for i in range(n):
  if a.count(k[i]) == n:
    count += 1
print(count)
Problem p03136 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
if max(l) < sum(l) - max(l):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(i) for _ in input().split()]
if max(l) < sum(l) - max(l):
  print("Yes")
else:
  print("No")
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
i = 1001
 
for _ in range(N):
  c, t = map(int, input().split())
  if t <= T:
    i = min(i, c)

if i == 1001:
  print('TLE')
else:
  print(i)

Buggy submission (verdict: Runtime Error):
n,T = map(int, input().split())
i = 1001
 
for _ in range(N):
  c, t = map(int, input().split())
  if t <= T:
    i = min(i, c)

if i == 1001:
  print('TLE')
else:
  print(i)
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2*10**9)

N, M = map(int, input().split())
friends = [[] for _ in range(N)]
for k in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  friends[A].append(B)
  friends[B].append(A)
group = []
sgn = [0 for _ in range(N)] #0なら未所属
def make_group(person, groupnum):
  sgn[person] = 1
  for f in friends[person]:
    if sgn[f] == 0:
      group[groupnum].append(f)
      make_group(f, groupnum)
  return None

c = 0
for k in range(N):
  if sgn[k] == 0:
    group.append([k])
    make_group(k, c)
    c += 1
ans = 0
for g in group:
  ans = max(len(g), ans)
print(ans)

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

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')
Problem p02574 (python)

Fixed submission:
from math import gcd

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')

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

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
primecounter = [0 for _ in range(len(primenum))]
biggerprime = [0 for _ in range(mA//2+1)]
def factorization(n):
  M = n
  for k in range(len(primenum)):
    p = primenum[k]
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if primecounter[k] == 0:
          primecounter[k] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if biggerprime[M] == 0:
      biggerprime[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)
  if flag == False:
    if g == 1:
      break


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')

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

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while k**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')
Problem p02615 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0 
if N %2 ==1:
    ans += A[0]
    k = 0
    for j in range(1, N//2):
        k += 1
        ans += 2*A[k]
    ans += A[k+1]
if N%2 == 0:
    ans += A[0]
    k = 0
    for j in range(1, N//2):
        k += 1
        ans += 2*A[k]
print(ans)

Buggy submission (verdict: Runtime Error):
N , K = map(int, input().split())
A =list(map(int, input().split()))
mod = 10**9 + 7
count =0
for k in range(len(A)):
    if A[k] == 0:
        count +=1
        A[k] = float("inf")
if N-count < K:
    print(0)
    exit()
A.sort()
A = A[:N-count]
A.sort(reverse=True)
#print(A)
ans = 1
plus = 0
minus = -1
countp = 0
countm = 0
if A[0] >0:
    for k in range(K):
        if abs(A[plus]) >= abs(A[minus]):
            ans = ans*A[plus]%mod
            plus+=1
        else:
            ans = ans*A[minus]%mod
            if A[minus] <0:
                lasm = 0+minus
            minus-=1
            
    if minus%2 == 1:
        print(ans%mod)
    else:
        print(ans//A[lasm]*max(A[plus], A[minus])%mod)
else:
    for k in range(K):
        ans = ans*A[k]%mod
    print(ans%mod)
Problem p02639 (python)

Fixed submission:
A = list(map(int, input().split()))
for k in range(5):
    if A[k] == 0:
        print(k+1)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
A.sort()
c=0
for k in range(len(A)-1):
    if A[k] == A[k+1]:
        del A[k]
        A.insert(0,0)
        c+=1
        if k <len(A)-2:
            if A[k+1] != A[k+2]:
                del A[k+1]
                A.insert(0,0)
                c+=1
        else:
            del A[k+1]
            A.insert(0,0)
            c+=1
del A[:c]
if len(A)>0:
    saidai = A[-1]
else:
    saidai=0
print(A)
foo = [0 for k in range(saidai+1)]
for k in range(len(A)):
    if foo[A[k]] == 1:
        continue
    else:
        count+=1
        for j in range(A[k], saidai+1, A[k]):
            foo[j] = 1
print(count)
Problem p02647 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = [[0 for k in range(N)] for k in range(42)]
for k in range(len(A)):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        unko = [0 for k in range(N)]
        for k in range(N):
            if k + foo[q][k]+1 < N:
                unko[k + foo[q][k]+1] -=1
            unko[max(k - foo[q][k], 0)] +=1
        unchi = 0
        for k in range(N):
            unchi += unko[k]
            foo[q+1][k] = unchi
        #print(unko)
        #print(foo[q+1])
        count =0
        for l in range(N):
            if foo[q+1][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q+1])))

     
else:
    print((str(N)+" ")*(N-1)+str(N))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = np.ones((42, N), dtype = "int64")
for k in range(len(A)):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        for k in range(N):
            for j in range(1, min(foo[q][k]+1, N-k)):
                foo[q+1][k+j] +=1
            for j in range(1, min(foo[q][k]+1, k+1)):
                foo[q+1][k-j] +=1
        count =0
        for l in range(N):
            if foo[q+1][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q+1])))

     
else:
    print((str(N)+" ")*(N-1)+str(N))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = [[1 for k in range(N)] for k in range(41)]
for k in range(N):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        for k in range(N):
            for j in range(1, min(foo[q-1][k]+1, N-k)):
                foo[k+j][q] +=1
            for j in range(1, min(foo[q-1][k]+1, k+1)):
                foo[k-j][q] +=1
        count =0
        for l in range(N):
            if foo[q][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q])))

     
else:
    print("N "*(N-1)+"N")