Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

N = int(input())
xy = []
for count in range(N):
    xy.append(input().split())
    itertools.permutations(xy)
XY = []
sum = 0
ave = 0
count = 0
for XY in itertools.permutations(xy):
    for i in range(N-1):
        leng = math.sqrt(((int(XY[i+1][0]) - int(XY[i][0])) ** 2) +
                         ((int(XY[i + 1][1]) - int(XY[i][1])) ** 2))
        sum += leng

ave = sum / math.factorial(N)
print(ave)


Fixed submission:
import itertools
import math
N = int(input())
xy = []
for count in range(N):
    xy.append(input().split())
    itertools.permutations(xy)
XY = []
sum = 0
ave = 0
count = 0
for XY in itertools.permutations(xy):
    for i in range(N-1):
        leng = math.sqrt(((int(XY[i+1][0]) - int(XY[i][0])) ** 2) +
                         ((int(XY[i + 1][1]) - int(XY[i][1])) ** 2))
        sum += leng

ave = sum / math.factorial(N)
print(ave)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
  max_item = A.index(max(A))
  A[max_item] //= 2
print(sum(A))

Fixed submission:
S = input()
weather = ['Sunny', 'Cloudy','Rainy']
if S == weather[0]:
  print(weather[1])
elif S == weather[1]:
  print(weather[2])
else:
  print(weather[0])
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
point = [K]*N
for i in range(Q):
  a = A[i]
  for p in range(N):
    if p+1 != a:
      point[p] -= 1
for p in range(N):
  if point[p] <= 0:
    print("No")
  else:
    print("Yes")

Fixed submission:
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
point = [0]*N
for i in range(Q):
  a = A[i]
  point[a-1] += 1
for i in range(N):
  point[i] -= (Q-K)
for p in range(N):
  if point[p] <= 0:
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
index = 0
for i in range(M):
  A.sort(reverse=True)
  A[0] = int(A[0]/2)
print(sum(A))

Fixed submission:
import heapq

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

#全要素に-1かける
for i in range(len(A)):
    A[i] *= -1 

heapq.heapify(A) 
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
index = 0
for i in range(M):
  max_value = max(A)
  index = A.index(max_value)
  A[index] = int(A[index]/2)
print(sum(A))

Fixed submission:
import heapq

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

#全要素に-1かける
for i in range(len(A)):
    A[i] *= -1 

heapq.heapify(A) 
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
  max_item = A.index(max(A))
  A[max_item] //= 2
print(sum(A))

Fixed submission:
import heapq

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

#全要素に-1かける
for i in range(len(A)):
    A[i] *= -1 

heapq.heapify(A) 
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
sum_A = 0
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(bc)):
  if A[i] < bc[i]:
    sum_A += bc[i]
  else:
    sum_A += A[i]
print(sum_A)
  
  

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = [0]*N
sum_A = 0
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(A)):
  if A[i] < bc[i]:
    sum_A += bc[i]
  else:
    sum_A += A[i]
print(sum_A)
  
  

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(bc)):
  if A[i] < bc[i]:
    A[i] = bc[i]
print(sum(A))
  
  

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int,input().split())
A = list(map(int,input().split()))
bc = []
for _ in range(M):
  A.sort()
  bc = list(map(int,input().split()))
  n = sum(a < bc[1] for a in A)
  if n >= bc[0]:
    for i in range(bc[0]):
      A[i] = bc[1]
  else:
    for i in range(n):
      A[i] = bc[1]
print(sum(A))
  
  

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
cost = [1000000]*N
cost[0] = 0
cost[1] = abs(h([1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

Buggy python submission (verdict: Runtime Error):
6
30 10 60 10 60 50

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])
Buggy python submission (verdict: Runtime Error):
print(int(input()) + int(input()) if int(input()) == 2 else "Hello World
")

Fixed submission:
N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1:
  print('Hello World')
elif:
  A,B = int(input())
  print(A+B)

Fixed submission:
N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
ct = list()
for _ in range(N):
  s, t = map(int,i)nput().split
  if t <= T:
    ct.append(s, t)
#ct = [input().split() for _ in range(N)]


Fixed submission:
N,T = map(int,input().split())
c = 0
for _ in range(N):
  _c, _t = map(int,input().split())
  if _t <= T:
    if c == 0:
      c = _c
    elif c != 0 and _c <= c:
      c = _c
print(c if c != 0 else "TLE")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1
for i in range(N):
  power *= (i + 1)
print(power % (10**9 + 7))

Fixed submission:
import math
N = int(input())
n = 10**9 + 7
power = math.factorial(N)
print(power % n)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int,input().split())
X = 0
Y = 0
Z = 0
count = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        count = count + 1
print(count)

Fixed submission:
K, S = map(int,input().split())
count = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if z <= K and z >= 0:
      count = count + 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map,(int,input().split()))
a.sort()
c = int(a[-1])
if n%2 == 0:
  n1 = n//2-1
  for i in range(n1):
    a1 = int(a[n-2-i])
    c += a1*2
else:
  n2 = n//2
  a3 = int(a[n-n2-1])
  c += a3
  for i in range(n2-1):
    a2 = int(a[n-2-i])
    c += a2*2
print(c)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = a[-1]
if n%2 == 0:
  n1 = n//2-1
  for i in range(n1):
    a1 = a[n-2-i]
    c += a1*2
else:
  n2 = n//2
  a3 = a[n-n2-1]
  c += a3
  for i in range(n2-1):
    a2 = a[n-2-i]
    c += a2*2
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
  if 10**18 < int(ans):
    print(-1)
  else:
  	print(ans)


Fixed submission:
a,b = map(int,input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
from math import cos, radians, sqrt
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if 180 <= int(r):
  r1 = 360 - int(r)
else:
  r1 = r
cos = cos(radians(r1))
d = int(a1) + int(b1) - 2 * int(ab) * float(cos)
ans = d ** (1/2)
print(ans)

Fixed submission:
l = input()
s = [int(i) for i in l]
l1 = len(l)
l2 = l[int(l1) - 1]
if int(l2) == 3:
  print("bon")
elif int(l2) == 0:
  print("pon")
elif int(l2) == 1:
  print("pon")
elif int(l2) == 6:
  print("pon")
elif int(l2) == 8:
  print("pon")
else:
  print("hon")

Buggy python submission (verdict: Runtime Error):
import math
 
a,b,h,m = map(int, input().split())
h1 = int(h) * 30
m1 = int(m) * 5.5
r = abs(float(h1) - float(m1))
a1 = int(a) ** 2
b1 = int(b) ** 2
ab = int(a) * int(b)
if 180 <= int(r):
  r1 = int(r) -180
else:
  r1 = r
cos = math.cos(math.radians(int(r1)))
d = int(a1) + int(b1) - 2 * int(ab) * float(cos)
ans = d ** (1/2)
print(ans)

Fixed submission:
l = input()
s = [int(i) for i in l]
l1 = len(l)
l2 = l[int(l1) - 1]
if int(l2) == 3:
  print("bon")
elif int(l2) == 0:
  print("pon")
elif int(l2) == 1:
  print("pon")
elif int(l2) == 6:
  print("pon")
elif int(l2) == 8:
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Runtime Error):
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  	r1 = r -180
    cos = math.cos(math.radians(r1))
 	d = a1 + b1 - 2 * ab * cos
  	ans = d ** (1/2)
  	print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)

Fixed submission:
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  r1 = 360 - r
  cos = math.cos(math.radians(r1))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
Buggy python submission (verdict: Runtime Error):
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
  elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))

Fixed submission:
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))
Buggy python submission (verdict: Runtime Error):
list = ['ABC','ARC']
if s == 'ABC':
	print(list[1])
else:
  print(list[0])

Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int, input().split())
l = []
for i in range(n + 1):
  c = math.floor(a * i / b) - a * math.floor(i / b)
  l.append(c)
print(max(l))

Fixed submission:
from math import floor

a,b,n = map(int, input().split())

if n < b:
  c = floor(a * n / b) - a * floor(n / b)
else:
  c = floor(a * (b - 1) / b) - a * floor((b - 1) / b)
print(c)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().spit())
i = a
c = 1
while i < b:
  i += a - 1
  c += 1
if b == 1:
  print(0)
else:
  print(c)

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

i = a
c = 1
while int(i) < int(b):
  i += int(a) - 1
  c += 1
if int(b) == 1:
  print(0)
else:
  print(c)
Buggy python submission (verdict: Runtime Error):
s = [int(input()) for i in range(3)]
n = s[0]
a = n[1]
b = n[2]
c = n-a
d = int(c/b)
print(c-b*d)

Fixed submission:
s = [int(input()) for i in range(3)]
n = s[0]
a = s[1]
b = s[2]
c = n-a
d = int(c/b)
print(c-b*d)
Buggy python submission (verdict: Runtime Error):


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	prinrt(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)


Fixed submission:


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy python submission (verdict: Runtime Error):


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS' or L[0] == 'RSS':
	prinrt(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)


Fixed submission:


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy python submission (verdict: Runtime Error):


L = []
 
for i in range(3):
	L.append(input())
 
    
c=0
ans=0
 
for i in range(3):
	if L[i] == 'R':
     		 if c != 0:
        			ans = 1
	else:
      		ans += 1

	if L[i] == 'S':
      		c += 1
      
print(ans)

Fixed submission:


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)

Buggy python submission (verdict: Runtime Error):
L = []

for i in range(3):
	L.append(input())

    
c=0
ans=0

for i in range(3):
	if L[i] == 'R':
      if c !=0:
        ans = 1
      else:
      	ans += 1
    if L[i] == 'S':
      c += 1
      
print(ans)
      	

Fixed submission:


L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)
Buggy python submission (verdict: Runtime Error):

L = input()
L2 = L.split()

X = float(L2[0]) #float
K = int(L2[1])
D = int(L2[2])

A = [0]*(K+1)
A[0] = X

for i in range(1,K+1):
	if A[i-1]>0:
		A[i] = A[i-1] - D
	else:
		A[i] = A[i-1] +D

if A[K] > 0:
	print(int(A[K]))
else:
	print(int(-1 *A[K]))

Fixed submission:

A = input().split()
X = float(A[0])
K = int(A[1])
D = int(A[2])

if abs(X) - K * D > 0:
	print(int(abs(X) - K*D))
else:
	K2 = abs(X)//D
	if (K - K2) % 2 == 0:
		print(int(abs(abs(X) - D * K2)))
	else:
		print(int(abs(abs(abs(X) - D * K2) - D)))
Buggy python submission (verdict: Runtime Error):
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 #辞書型だから[]内のkeyに対応するvalueの値を+1している。ここでは10^9-nの値をCに加えていっている。
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

int(print(ans))
			
	
	

Fixed submission:
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):

from fractions import Fraction
from decimal import Decimal
n = int(input())
a = []
b = []
for i in range(0,n):
	c = float(input())
	a.append(c)
	d = str(a[i])
	f = Fraction(Decimal(d))
	b.append(f)

x = []
y = []

for i in range(0,n):
	x.append(b[i].numerator)
	y.append(b[i].denominator)

count = 0

for i in range(0,n)	:
	for j in range(i+1,n):
		if (x[i]*x[j]) % (y[i]*y[j]) == 0:
			count += 1

print(count)

Fixed submission:
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(2*(math.log2(N)))+1)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))


Fixed submission:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N))+1)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))


Fixed submission:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N)+1))):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))


Fixed submission:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(math.log2(N)))):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))


Fixed submission:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
temp = N
arr = []
for i in range(2,int(-(-N**0.5//1))+1):
	if temp % i==0:
		cnt = 0
		while temp%i==0:
			cnt+=1
			temp//=i
		arr.append([i,cnt])
if temp!=1:
	arr.append([temp,1])
if arr == []:
	arr.append([n,1])
sum = 0
for i in range(len(arr)):
  p = arr[i][1]
  q = 1
  while p > 0:
    p -= q
    if p >= 0:
      sum += 1
      q += 1
print(sum)

Fixed submission:
import math
import sys
N = int(input())
temp = N
arr = []
if N == 1:
  print('0')
  sys.exit()
for i in range(2,int(-(-N**0.5//1))+1):
	if temp % i==0:
		cnt = 0
		while temp%i==0:
			cnt+=1
			temp//=i
		arr.append([i,cnt])
if temp!=1:
	arr.append([temp,1])
if arr == []:
	arr.append([n,1])
sum = 0
for i in range(len(arr)):
  p = arr[i][1]
  q = 1
  while p > 0:
    p -= q
    if p >= 0:
      sum += 1
      q += 1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
def warshall_floyd(d):
	for k in range(N):
		for i in range(N):
			for j in range(N):
				d[i][j] = min(d[i][j], d[i][k] + d[k][j])
	return d
	
N,M = map(int,input().split())
d = [[float("inf")]*N for i in range(N)]
lines = []
for i in range(M):
	lines.append(list(map(int,input().split())))
	d[lines[i][0]-1][lines[i][1]-1] = 1
	d[lines[i][1]-1][lines[i][0]-1] = 1
for i in range(N):
	d[i][i] = 0
warshall_floyd(d)

count1 = 0
count2 = 1
H = [-1]*N
H[0] = 0
P = [-1]*N
l = []
while count1 < N-1:
	lnext =[]
	if count2 == 1:
		l.append(0)
	for i in range(M):
		if (lines[i][0]-1 in l and H[lines[i][1]-1] == -1):
			count1 += 1
			lnext.append(lines[i][1]-1)
			P[lines[i][1]-1] = lines[i][0]
			H[lines[i][1]-1] = count2
		if lines[i][1]-1 in l and H[lines[i][0]-1] == -1:
			count1 += 1
			lnext.append(lines[i][0]-1)
			P[lines[i][0]-1] = lines[i][1]
			H[lines[i][0]-1] = count2
	count2 += 1
	l = lnext
count3 = 0
for i in range(1,N):
	if H[i] == d[0][i]:
		count3 += 1
if count3 == N-1:
	print('Yes')
	for i in range(1,N):
		print(P[i])
else:
	print('No')
		
		
	
	


Fixed submission:
import queue
import math
q = queue.Queue()
A = []
B = []
N,M = map(int,input().split())
check = [-1]*N
graph = [[] for i in range(N+1)]
flag = [0]*N
for i in range(M):
	lines = list(map(int,input().split()))
	A.append(lines[0])
	B.append(lines[1])
	graph[lines[0]].append(lines[1])
	graph[lines[1]].append(lines[0])

q.put(1)
check[0] = 0
while not q.empty():
	p = q.get()
	for np in graph[p]:
		if check[np-1] == -1:
			check[np-1] = check[p-1] + 1
			q.put(np)

for i in range(M):
	if check[A[i]-1] - check[B[i]-1] == 1:
		flag[A[i]-1] = B[i]
	if check[B[i]-1] - check[A[i]-1] == 1:
		flag[B[i]-1] = A[i]

print('Yes')
for i in range(1,N):
	print(flag[i])