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

Fixed submission:
n, m = map(int, input().split())
a, b = [0]*m, [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
for j in range(1,n+1):
    print(a.count(j)+b.count(j))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
for _ in range(M):
    a, b = map(int, input().split())
for i in range(1,N+1):
    print(a.count("i")+b.count("i"))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
for _ in range(M):
    a, b = map(int, input().split())
for i in range(1,N+1):
    print(a.count(i)+b.count(i))

Buggy submission (verdict: Runtime Error):
N, M = input().split()
for _ in range(M):
    a, b = input().split()
for i in range(1, N+1):
    print(a.count("i")+b.count("i"))

Buggy submission (verdict: Runtime Error):
N, M = input().split()
for i in range(1, M+1):
    a, b = input().split()
for i in range(1, N+1):
    print(a.count("i")+b.count("i"))

Buggy submission (verdict: Runtime Error):
N, M = input().split()
for i in range(1, M+1):
    a, b = input().split()
for i in range(1, N+1):
    print(a.count("i")+b.count("i")

Buggy submission (verdict: Runtime Error):
N, M = input().split()
for _ in range(M):
    a, b = input().split()
for _ in range(1, N+1):
    print(a.count("i")+b.count("i")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
for _ in range(M):
    a, b = input().split()
for _ in range(1, N+1):
    print(a.count("i")+b.count("i")
Problem p02607 (python)

Fixed submission:
N = int(input().rstrip())
a = input().rstrip().split(' ')
num = 0
for i in range(0, N, 2):
  if int(a[i]) % 2 == 1:
    num += 1
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
a = input().rstrip().split(' ')
num = 0
for i in range(0, N, 1):
  if a[i] % 2 == 1:
    num += 1
print(num)
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().rstrip().split(' '))
frog_lst = list(map(int, input().rstrip().split(' ')))
frog_jump_lst = []

def frog_jump(frog_jump_lst=[], index=0):
  if not frog_jump_lst:
    frog_jump_lst.append(0)
  else:
    now_pos = frog_lst[index]
    k = min(K, len(frog_jump_lst))
    pattern = [abs(now_pos - frog_lst[index-i]) + frog_jump_lst[-i] for i in range(1,k+1)]
    frog_jump_lst.append(min(pattern))

for j in range(N):
  frog_jump(frog_jump_lst, j)
print(frog_jump_lst[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().rstrip().split(' '))
h = list(map(int, input().rstrip().split(' ')))
def frog_jump(n, height=h):
  if len(height[:n]) == 1:
    return 0
  now_height = height[n-1]
  start = n-1-K
  if start < 0:
    start = 0
  min_lst = [frog_jump(i) + abs(now_height-j) for i, j in enumerate(height[start:n-1], start+1)]
  # print(min_lst)
  min_cost = min(min_lst)
  return min_cost

print(frog_jump(N))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().rstrip().split(' '))
h = list(map(int, input().rstrip().split(' ')))
def frog_jump(n, height=h):
  if len(height[:n]) == 1:
    return 0
  now_height = height[n-1]
  start = n-1-K if n-1-K >= 0 else 0
  min_lst = [frog_jump(i) + abs(now_height-j) for i, j in enumerate(height[start:n-1], start+1)]
  # print(min_lst)
  min_cost = min(min_lst)
  return min_cost

print(frog_jump(N))
Problem p03162 (python)

Fixed submission:
N = int(input().rstrip())
judge = []
for _ in range(N):
  hap_lst = list(map(int, input().rstrip().split(' ')))
  if not judge:
    judge = hap_lst
  else:
    a_0, b_0, c_0 = judge
    a_1, b_1, c_1 = hap_lst
    judge = [a_1 + max(b_0, c_0), b_1 + max(a_0, c_0), c_1 + max(a_0, b_0)]
print(max(judge))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
N = int(input())
hap_list = [list(map(int, input().rstrip().split(' '))) for _ in range(N)]
@lru_cache(maxsize=None)
def happiness(days=N):
  if not days:
    return 0, 0, 0
  last_result = happiness(days-1)
  choice_a = hap_list[days-1][0] + max(last_result[1], last_result[2])
  choice_b = hap_list[days-1][1] + max(last_result[0], last_result[2])
  choice_c = hap_list[days-1][2] + max(last_result[0], last_result[1])
  return choice_a, choice_b, choice_c
print(max(happiness(N)))

Buggy submission (verdict: Runtime Error):
N = int(input())
hap_list = [list(map(int, input().rstrip().split(' '))) for _ in range(N)]
def happiness(days=N):
  if not days:
    return 0, 0, 0
  last_result = happiness(days-1)
  choice_a = hap_list[days-1][0] + max(last_result[1], last_result[2])
  choice_b = hap_list[days-1][1] + max(last_result[0], last_result[2])
  choice_c = hap_list[days-1][2] + max(last_result[0], last_result[1])
  return choice_a, choice_b, choice_c
print(max(happiness(N)))
Problem p03565 (python)

Fixed submission:
from copy import deepcopy
S = input()
T = input()
s_num = len(S)
t_num = len(T)
ans = []
if s_num < t_num:
  print('UNRESTORABLE')
else:
  for i in range(s_num-t_num+1):
    s_key = S[i:i+t_num]
    judge = 0
    for s, t in zip(s_key, T):
      if s=='?':
        judge += 1
      elif s == t:
        judge += 1
    if judge == t_num:
      tmp = S[:i] + T + S[i+t_num:]
      tmp = tmp.replace('?', 'a')
      ans.append(tmp)
  if ans:
    print(sorted(ans)[0])
  else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
S = list(input())
T = list(input())
s_num = len(S)
t_num = len(T)
S_copy = deepcopy(S)
if s < t:
  print('UNRESTORABLE')
else:
  for i in range(s_num-t_num, -1, -1):
    s_key = S[i:i+t_num]
    judge = 0
    for s, t in zip(s_key, T):
      if s=='?':
        judge += 1
      elif s == t:
        judge += 1
    if judge == t_num:
      S_copy[i:i+t_num] = T
  if S == S_copy:
    print('UNRESTORABLE')
  else:
    for i in S_copy:
      if i == '?':
        print('a', end='')
      else:
        print(i, end='')
Problem p02641 (python)

Fixed submission:
import sys
X,N=map(int,input().split())
if N==0:
    print(X)
    sys.exit()
p=list(map(int,input().split()))

def abs_search(o,*l):
    if X  not in p:
        print(X)
        return
    
    for pl_num in range(X+1,102):
        if pl_num not in p:
            break
            
    for mi_num in range(X-1,-1,-1):
        if mi_num not in p:
            break
            
    abs_pl=abs(pl_num-X)
    abs_mi=abs(mi_num-X)
    
    if abs_pl<abs_mi:
        print(pl_num)
    else:
        print(mi_num)
        
abs_search(*p)

Buggy submission (verdict: Runtime Error):
X,N=map(int,input().split())
p=list(map(int,input().split()))
  
def abs_search(o,*l):
    if X  not in p:
        print(X)
        return
    
    for pl_num in range(X+1,102):
        if pl_num not in p:
            break
            
    for mi_num in range(X-1,-1,-1):
        if mi_num not in p:
            break
            
    abs_pl=abs(pl_num-X)
    abs_mi=abs(mi_num-X)
    
    if abs_pl<abs_mi:
        print(pl_num)
    else:
        print(mi_num)
        
abs_search(*p)
Problem p02642 (python)

Fixed submission:
#青の人の解答（hir35）

from collections import Counter
n = int(input())
a = list(map(int, input().split()))

#それぞれの数字が何回ずつ出現したかをカウント
c = Counter(a)

#リストpに10＾6+1個のTrueを格納
p = [True] * (10 ** 6 + 1)

#list(set())で重複したものを取り除いてからリストにできる
s = list(set(a))

#sの要素一つ一つを見ていく
for x in s:
    t = x * 2
    #tが10^6以下ならば，p[t]にFalseを代入
    #つまり，x(aに格納されている数)の倍数がfalseに
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0

for x in a:
    #もしその数が一つしかなくて，倍数がないならans+1
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)

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

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

rcnt=0
length=len(A)
def length(n,*A):
    
    for i in range(length):
        if A[i]==A[i+1]:
            cnt+=1
        if cnt==N:
            print(0)
            return

    for i in range(length):
        cnt=0
        for j in range(length):
            if A[i]%A[j]!=0 and A[i]!=A[j]:
                cnt+=1
        if cnt==N-1:
            rcnt+=1
    print(rcnt)
length(*A)
Problem p02660 (python)

Fixed submission:
import collections
def factorization(n):
    if n<2:
        return []
    
    prime_factor=[]
    
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            prime_factor.append(i)
            n//=i
            
    if n>1:
        prime_factor.append(n)
    return prime_factor

count=0
n=int(input())
 
c=collections.Counter(factorization(n))
d=list(c.values())
 
for v in c.values():
    for i in range(1,n):
        v-=i
        if v>=0:
            count+=1
        else:
            break
print(count)

Buggy submission (verdict: Runtime Error):
import collections
def factorization(n):
    if n<2:
        return []
    
    prime_factor=[]
    
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            prime_factor.append(i)
            n//=i
            
    if n>1:
        prime_factor.append(n)

        
    return prime_factor

n=int(input())

c=collections.Counter(factorization(n))
d=list(c.values())

for v in c.values():
    for i in range(1,n):
        v-=i
        if v>=0:
            count+=1
        else:
            break
print(count)
Problem p02663 (python)

Fixed submission:
h1,m1,h2,m2,k=map(int,input().split())
h_d=h2-h1
m_d=m2-m1
if m_d<0:
    h_d-=1
    m_d=60+m2-m1
    
sum=60*h_d+m_d
sum-=k
 
if sum<0:
    print(0)
else:
    print(sum)

Buggy submission (verdict: Runtime Error):
h1,m1,h2,m2,k=map(int,input().split())
h_d=h2-h
m_d=m2-m1
if m_d<0:
    h_d-=1
    m_d=60+m2-m1
    
sum=60*h_d+m_d
sum-=k
 
if sum<0:
    print(0)
else:
    print(sum)

Buggy submission (verdict: Runtime Error):
h1,m1,h2,m2,k=map(int,input().split())
h_d=h2-h
m_d=m2-m1
if m_d<0:
    h_d-=1
    m_d=60+m2-m1
   
sum=60*h_d+m_d
sum-=k

if sum<0:
    print(0)
else:
    print(sum)
Problem p02675 (python)

Fixed submission:
N=input()
num=len(N)
a={"2","4","5","7","9"}
b={"0","1","6","8"}
c={"3"}
if N[num-1] in a:
    print("hon")
elif N[num-1] in b:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    rad=0
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad=rad-180
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
else:
    length=abs(a-b)
    
print(length)
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    rad=0
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad=360-rad
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
else:
    length=abs(a-b)
    
print(length)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    length=abs(a-b)
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad-=180
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
print(length)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())

dh=30*h+m/2
dm=6*m

if dm=dh:
    length=abs(a-b)
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad-=180
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))

elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))

elif rad==180:
    length=a+b
    
print(length)
Problem p02681 (python)

Fixed submission:
name=input()
len_n=len(name)
name2=input()
len_n2=len(name2)
 
if name==name2[:-1] and len_n+1==len_n2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
name=input()
len_n=len(name)
name2=input()
len_n2=len(name2)

if name==name2[:-2] && len_n+1==len_n2:
  print("Yes")
else:
  print("No")
Problem p02848 (python)

Fixed submission:
N=int(input())
S=input()
a=list(S)
alpha=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
SS2=[]
for i in range(len(a)):
    x=alpha.index(a[i])
    SS2.append(x)
 
for j in range(len(SS2)):
    SS2[j]+=N
 
SS3=[]
for k in range(len(SS2)):
    y=alpha[SS2[k]]
    SS3.append(y)
 
moji="".join(SS3)
print(moji)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
a=list(S)
alpha=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A"]
SS2=[]
for i in range(len(a)):
    x=alpha.index(a[i])
    SS2.append(x)
 
for j in range(len(SS2)):
    SS2[j]+=N
 
SS3=[]
for k in range(len(SS2)):
    y=alpha[SS2[k]]
    SS3.append(y)
 
moji="".join(SS3)
print(moji)
Problem p02988 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
 
cnt=0
for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
  elif p[i+1]<p[i] and p[i]<p[i-1]:
    cnt+=1
print(cnt)

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

for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
  elif p[i+1]<p[i] and p[i]<p[i-1]:
    cnt+=1
print(cnt)
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
l=[list(map(int,input().split())) for i in range(M)]
maxL=1
minR=N
for j in range(M):
  maxL=max(maxL,l[j][0])
  minR=min(minR,l[j][1])

ans=minR-maxL+1
ans=max(ans,0)
print(ans)

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

for m in range(M):
  code="name{}=[]".format(m)
  exec(code)

for j in range(M):
  "name{}=range(l[j][0],l[j][1]+1)".format(j)
  codea=print("name{}").format(j)
  exec(codea)
  
  
for k in range(M):
  co="kyotu=set(name{}) & set(name{})".format(k,k+1)
  za="name{}=kyotu".format(k+1)
  exec(co)
  exec(za)
  
  
print(kyotu)
Problem p03059 (python)

Fixed submission:
a,b,t=map(int,input().split())
i=1
while i*a<t+0.5:
  i+=1
print((i-1)*b)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input().split())
i=1
while i*a<t+0.5:
  i++
print((i-1)*b)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input().split())
i=1
while i*a<t+0.5:
  i++
print{(i-1)*b}
Problem p03060 (python)

Fixed submission:
N=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
for i in range(N):
  m=v[i]-c[i]
  if m>0:
    d.append(m)
print(sum(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
for i in N-1:
  m=v[i]-c[i]
  if m>0:
    d.append(m)
print(sum(d))
Problem p03449 (python)

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

ans=0
for i in range(N):
    sumn=sum(A[:i+1])+sum(B[i:])
    ans=max(sumn,ans)
print(ans)

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

maxn=0
for i in range(n):
  maxn=max(maxn,sum(a[:i+1],b[i:]))
print(maxn)
Problem p03557 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)

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

al=sorted(a)
bl=sorted(b)
cl=sorted(c)
print(al)
print(bl)
print(cl)
j=0
k=0
ans=0
saved_j=0
saved_k=0
for i in range(n):
    j=saved_j
    while al[i]>=bl[j]:
        j+=1
        saved_j=j
    #print("j",j)
    while j!=n:
        k=saved_k
        while bl[j]>=cl[k]:
            if k==n-1:
                break
            k+=1
        if j==saved_j:
            saved_k=k
        #print("k",k)
        ans+=n-k
        j+=1
        #print("暫定",ans)
print(ans)
Problem p04019 (python)

Fixed submission:
s = input()


def walk(s):
    ls = len(s)
    nc = 0
    sc = 0
    wc = 0
    ec = 0
    l=[]
    for i in range(ls):
        if s[i] == "W":
            wc += 1
            l.append(wc)
        elif s[i] == "E":
            ec += 1
            l.append(ec)
        elif s[i] == "N":
            nc += 1
            l.append(nc)
        else:
            sc += 1
            l.append(sc)
    if (wc>0 and ec==0) or (wc==0 and ec>0) or (nc==0 and sc>0) or (nc>0 and sc==0):
        print("No")
        return
    
    else:
        print("Yes")
        return
walk(s)

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

def walk(s):
  ls=len(s)
  if ls%2==1:
    print("NO")
    return
  nc=0
  sc=0
  wc=0
  ec=0
  for i in range(ls):
    if s[i]="W":
      wc+=1
    elif s[i]="E":
      ec+=1
    elif s[i]="N":
      nc+=1
    else:
      sc+=1
  if wc==ec and nc==sc:
    print("YES")
    return
  else:
    print("NO")
    return
walk(s)
Problem p02645 (python)

Fixed submission:
S = input()

nickname = S[0:3]
print(nickname)

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

# Calculate intensity
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))
print("0")
exit()
def Luminate(A_arr, i):
  isLuminated = np.abs(step - i) < A_arr
  return isLuminated

def get_Intensity(A_arr):
  return np.array([np.sum(Luminate(A_arr, i)) for i in range(len(A_arr))])
Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity+1)
  if np.sum(Intensity) == N**2:
    break
print(" ".join([str(v) for v in Intensity]))
Problem p02647 (python)

Fixed submission:
import numpy as np
 
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)
 
dp = np.zeros(shape=N + 1, dtype=np.int64)
 
for k in range(K):
    np.add.at(dp, np.maximum(0, indexes - A), 1)
    np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
    A = dp.cumsum()[:-1]
    if np.all(A == N):
        break
    dp *= 0
 
print(' '.join(map(str, A)))

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

# Get input
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))

# Trivial solution
if K > N//2+1:
  print(" ".join([str(N)]*N))
  exit()

def get_Intensity(A_arr):
  inten = np.zeros(len(A_arr))
  for i in range(len(A_arr)):
    isLuminated = np.abs(step - i) < A_arr
    inten[i] = np.sum(isLuminated)
  return inten
def loop(N, K, A_arr):
  Intensity = A_arr
  for i in range(K):
    Intensity = get_Intensity(Intensity+1)
    # Termination of calculation (stable solution)
    if np.all(Intensity == N):
      break
  return
#print(" ".join([str(v) for v in Intensity.astype(int)]))
print(' '.join(map(str, A)))

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

# Get input
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))

# Trivial solution
if K > N//2+11:
  print(" ".join([str(N)]*N))
  exit()

def get_Intensity(A_arr):
  inten = np.zeros(shape=N + 1, dtype=np.int64)
  for i in range(len(A_arr)):
    isLuminated = np.abs(step - i) < A_arr
    inten[i] = np.sum(isLuminated)
  return inten

Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity+1)
  # Termination of calculation (stable solution)
  if np.sum(Intensity) == N**2:
    break
#print(" ".join([str(v) for v in Intensity.astype(int)]))
print(' '.join(map(str, A)))

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

# Get input
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))

# Trivial solution
if K > N//2+11:
  print(" ".join([str(N)]*N))
  exit()

def get_Intensity(A_arr):
  inten = np.zeros(len(A_arr))
  for i in range(len(A_arr)):
    isLuminated = np.abs(step - i) < A_arr
    inten[i] = np.sum(isLuminated)
  return inten

Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity+1)
  # Termination of calculation (stable solution)
  if np.sum(Intensity) == N**2:
    break
#print(" ".join([str(v) for v in Intensity.astype(int)]))
print(' '.join(map(str, A)))

Buggy submission (verdict: Runtime Error):
import numpy as np
# Calculate intensity
N, K = [int(v) for v in input().split(" ")]
A_arr = [int(v) for v in input().split(" ")]
start = time.time()
step = np.arange(len(A_arr))
def Luminate(A_arr, i):
  isLuminated = np.abs(step - i) < np.array(A_arr)+1
  return isLuminated
def get_Intensity(A_arr):
  return [np.sum(Luminate(A_arr, i)) for i in range(len(A_arr))]
Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity)

print(" ".join([str(v) for v in Intensity]))
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
list_Connect=[]
for i in range(M):
    A = list(map(int, input().split()))
    A.pop(0)
    list_Connect.append( A )

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

i = 0



state = []#スイッチ点灯の全組み合わせを入れる
sum=0

def func(i):
    global sum
    if i == N:
        flag = True
        for i in range(M):
            cnt= 0
            for j in list_Connect[i]:
                cnt += state[j-1]
            if cnt %2 != list_p[i]:
                flag = False
                break
        if flag == True:
           sum+=1
    else:
        state.append(1)
        func(i+1)
        state.pop(-1)
        state.append(0)
        func(i+1)
        state.pop(-1)

    return


func(0)
print (sum)

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

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

i = 0



list_func = []#スイッチ点灯の全組み合わせを入れる
cnt=0

def func(i):
    if (i == N):
        flag = True
        for k in range(M):
            sum = 0
            for j in list_A[k]:
                sum += j
            sum = sum - list_A[k][0]
            if sum %2 != list_p[k]:
                flag = False
        if flag == True:
            cnt+=1
        return
    list_func.append(1)
    func(i+1)
    list_func.pop(-1)

    list_func.append(0)
    func(i+1)
    list_func.pop(-1)

    return


func(0)
print (cnt)