Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
"""
dp[与えたダメージ] = 使用した魔力
"""
h, n = map(int, input().split())
attacks = []
INF = 10000000000000
dp = [INF for _ in range(h + 1)]
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    attacks.append([a, b])
for i in range(h):
    for j in range(n):
        dp[min(h,i + attacks[j][0])] = min(dp[min(h, i + attacks[j][0])], dp[i] + attacks[j][1])
print(dp[h])


Fixed submission:
"""
dp[与えたダメージ] = 使用した魔力
"""
h, n = map(int, input().split())
attacks = []
INF = 10000000000000
dp = [INF for _ in range(h + 1)]
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    attacks.append([a, b])
    
for i in range(h):
    for j in range(n):
        dp[min(h,i + attacks[j][0])] = min(dp[min(h, i + attacks[j][0])], dp[i] + attacks[j][1])
print(dp[h])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(6 - a - b)
    
print(ans)

Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a  = np.sort(np.array(a))
f = np.sort(np.array(f))[::-1]

l ,r = 0, 10 ** 12
x = 0
while l <= r:
	x = (l + r) // 2
	if np.clip(a - f // x, 0, None).sum() <= k:
		l += 1
	else:
		r -= 1
print(l)

Fixed submission:
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a  = np.sort(np.array(a))
f = np.sort(np.array(f))[::-1]

l ,r = 0, 10 ** 12
while l <= r:
 x = (l + r) // 2
 if np.clip(a - x // f, 0, None).sum() <= k:
  r = x - 1
 else:
  l = x + 1
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(n):
    ans.append(str(a.index(i + 1) + 1))
print(' '.join(ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [i for i in range(n)]
a1 = sorted(a)
for i in range(n):
    num = a[i]
    ans[num - 1] = str(i + 1)
    
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
import fractions
a, b = map(int, input().split())
gc = fractions.gcd(a, b)

def prime_factorize(n):
    a = []
    if n % 2 == 0:
        a.append(2)
        while n % 2 == 0:
            n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            while n % f == 0:
                n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(prime_factorize(gc) + 1)

Fixed submission:
import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
a, b = map(int, input().split())
gc = math.factorial(a, b)

def prime_factorize(n):
    a = []
    if n % 2 == 0:
        a.append(2)
        while n % 2 == 0:
            n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            while n % f == 0:
                n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(prime_factorize(gc) + 1)

Fixed submission:
import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
longer = max(a,b)
lcm = math.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
print(ans)

Fixed submission:
import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
key_list = []
for i in range(M):
  a,b = map(int,input().split())
  bin_int = 0
  c = list(map(int,input().split()))
  for C in c:
    bin_int += 2 ** (C - 1)
  key_list.append([a, bin_int])

n1 = 2 ** N
dp = [[120001 for i in range(n1)] for j in range(M + 1)]
dp[0][0] = 0

for i in range(M):
  dp_i = dp[i]
  dp_i1 = dp[i + 1]
  key = key_list[i]

  for j in range(n1):
    dp_key = dp_i[j]
    dp_i1[j] = min(dp_key, dp_i1[j])
    dp_i1[j | key[1]] = min(dp_key + key[0], dp_i1[j | key[1]])
  # print(dp)
ans = dp[M - 1][n1 - 1]
if ans == 120001:
  print(-1)
else:
  print(dp[M - 1][n1 - 1])

Fixed submission:
N,M = map(int,input().split())
key_list = []
for i in range(M):
  a,b = map(int,input().split())
  bin_int = 0
  c = list(map(int,input().split()))
  for C in c:
    bin_int += 2 ** (C - 1)
  key_list.append([a, bin_int])

n1 = 2 ** N
dp = [[120001 for i in range(n1)] for j in range(M + 1)]
dp[0][0] = 0

for i in range(M):
  dp_i = dp[i]
  dp_i1 = dp[i + 1]
  key = key_list[i]

  for j in range(n1):
    dp_key = dp_i[j]
    dp_i1[j] = min(dp_key, dp_i1[j])
    dp_i1[j | key[1]] = min(dp_key + key[0], dp_i1[j | key[1]])
  # print(dp)
ans = dp[M - 1][n1 - 1]
if ans == 120001:
  print(-1)
else:
  print(dp[M - 1][n1 - 1])
Buggy python submission (verdict: Runtime Error):
b = list(map(int,input().split()))
ans = b[0]
for i in range(n - 2):
    
    ans += min(b[i],b[i + 1])

ans += b[-1]
print(ans)

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
ans = b[0]
for i in range(n - 2):
    
    ans += min(b[i],b[i + 1])

ans += b[-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
time_ans = 0
A_sort = sorted(A)
before = -1
b = -1
for i in range(N):
        a_sorti = A_sort[i]
        if a_sorti == before:
                time_ans += b
                continue
        b = A_sort.index(a_sorti)
        time_ans += b
        before = a_sorti

for i in range(N):
        for j in range(i + 1,N):
                if A[i] > A[j]:
                        ans += 1
ans1 = int((time_ans * K * (K - 1)) / 2) - K * (time_ans - ans)
print(ans1 % (10 ** 9 + 7))


Fixed submission:
N,M = map(int,input().split())
ans = 0
for n in range(1,N + 1):
        for m in range(1,M + 1):
                m = str(m)
                if len(m) == 1:
                        continue
                if int(m[1]) < 2 or int(m[0]) < 2:
                        continue
                if n == int(m[0]) * int(m[1]):
                        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# n,m = map(int,input().split())
n = int(input())
# n = input()
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
left = 0
for i in range(n):
    a1,b1 = a[i],b[i]
    if a1 <= b1 + left:
        cnt += a1
        left = min(b1 - a1 + left,b1)
    else:
        cnt += b1 + left
        left = 0
if a[n] <= left:
    cnt += a[n]
else:
    cnt += left
print(cnt)


Fixed submission:
n,m = map(int,input().split())
# n = int(input())
# n = input()
if (n + m) % 2 == 0:
    print((n + m) // 2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
n,k = map(int,input().split())
for i in range(1,k + 1):
    print(C(n - k + 1,i) * C(k - 1,i - 1) % 1000000007)

Fixed submission:
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
n,k = map(int,input().split())
for i in range(1,k + 1):
    if n - k + 1 < i:
        print(0)
        continue
    else:
        print(C(n - k + 1,i) * C(k - 1,i - 1) % 1000000007)
Buggy python submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
before = -1
alls = 1
a = -1
if m != 0:
        for i in range(m):
                a = int(input())
                b = (a - before - 2) // 2
                c = a - before - 2
                ptr = 0
                for j in range(b + 1):
                        ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
                alls = alls * ptr
                before = a
ptr = 0
b = (n - a - 1) // 2
c = n - a - 1
for j in range(b + 1):
        ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
alls = alls * ptr
print(int(alls % 1000000007))

Fixed submission:
n,m = map(int,input().split())
stair = [0,1] + [0 for i in range(n)]
ba = 2
for i in range(m):
	a = int(input()) + 1
	for j in range(ba,a):
		stair[j] = stair[j - 1] + stair[j - 2]
	ba = a + 1
for i in range(ba,n + 2):
	stair[i] = stair[i - 1] + stair[i - 2]
print(stair[n + 1] % 1000000007)

Buggy python submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
before = -1
alls = 1
for i in range(m):
        a = int(input())
        b = (a - before - 2) // 2
        c = a - before - 2
        ptr = 0
        for j in range(b + 1):
                ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
        alls = alls * ptr
        before = a
ptr = 0
b = (n - a - 1) // 2
c = n - a - 1
for j in range(b + 1):
        ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
alls = alls * ptr
print(int(alls % 1000000007))

Fixed submission:
n,m = map(int,input().split())
stair = [0,1] + [0 for i in range(n)]
ba = 2
for i in range(m):
	a = int(input()) + 1
	for j in range(ba,a):
		stair[j] = stair[j - 1] + stair[j - 2]
	ba = a + 1
for i in range(ba,n + 2):
	stair[i] = stair[i - 1] + stair[i - 2]
print(stair[n + 1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
asort,bsort,csort = sorted(A,reverse=True),sorted(B,reverse=True),sorted(C,reverse=True)
already = set((0,0,0))
print(asort[0] + bsort[0] + csort[0])
x,y,z = 0,0,0
check = []
for k in range(K - 1):
    if (x + 1,y,z) not in already and x + 1 < X:
        already.add((x + 1,y,z))
        heapq.heappush(check,(-(asort[x + 1] + bsort[y] + csort[z]),x + 1,y,z))
    if (x,y + 1,z) not in already and y + 1 < Y:
        already.add((x,y + 1,z))
        heapq.heappush(check,(-(asort[x] + bsort[y + 1] + csort[z]),x,y + 1,z))
    if (x,y,z + 1) not in already and z + 1 < Z:
        already.add((x,y,z + 1))
        heapq.heappush(check,(-(asort[x] + bsort[y] + csort[z + 1]),x,y,z + 1))
    maxsum = heapq.heappop(check)
    print(-maxsum[0])
    x,y,z = maxsum[1],maxsum[2],maxsum[3]

Fixed submission:
n = int(input())
move = [int(input()) for i in range(5)]
div,mod = divmod(n,min(move))
if mod == 0:
    print(div + 4)
else:print(div + 5)
Buggy python submission (verdict: Runtime Error):
,b,c = map(int,input().split())
print(min(c,b // a))

Fixed submission:
a,b,c = map(int,input().split())
print(min(c,b // a))
Buggy python submission (verdict: Runtime Error):
import fractions
n = int(input())
a = list(map(int,input().split()))
for N in range(n - 1):
    a[N + 1] = math.gcd(a[N],a[N + 1])
print(a[n - 1])

Fixed submission:
import fractions
n = int(input())
a = list(map(int,input().split()))
for N in range(n - 1):
    a[N + 1] = fractions.gcd(a[N],a[N + 1])
print(a[n - 1])
Buggy python submission (verdict: Runtime Error):
x = int(input())
if a == 3 or a == 5 or a == 7:
  print("YES")
else:
  print("NO")

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
alll = ['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']
alfa = {'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'}
count_s = set()
count_t = set()
for s in range(len(S)):
    if count_s == alfa:
        break
    if S[s] in count_s:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(alll[s]))
for t in range(len(T)):
    if count_t == alfa:
        break
    if t in count_t:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(alll[t]))
if S == T:
    print('Yes')
else:print('No')

Fixed submission:
S = input()
T = input()
check = {'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'}
alll = ['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']
alfa = {'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'}
count_s = set()
count_t = set()
nums = 0
numt = 0
for s in range(len(S)):
    if count_s == alfa:
        break
    if S[s] in check:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(alll[nums]))
    nums += 1
for t in range(len(T)):
    if count_t == alfa:
        break
    if T[t] in check:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(alll[numt]))
    numt += 1
if S == T:
    print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1,n + 1):
  if n % 2 == 0:
    continue
  cnt = 0
  for j in range(1,i + 1):
    if i % j = 0:
      cnt += 1
  if cnt == 8:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n + 1):
  if i % 2 == 0:
    continue
  cnt = 0
  for j in range(1,i + 1):
    if i % j == 0:
      cnt += 1
  if cnt == 8:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,Y = map(int,input().split())
cnt10 = 0
cnt5 = 0
cnt1 = 0
def wrong():
	print('-1 -1 -1')
	exit()
all1000 = int(Y / 1000)
if all1000 % 1 != 0:
	wrong()
for x in range(all1000 + 1):
	for y in range(all1000 - x + 1):
		if N - x - y < 0:
			continue
		if x * 10 + y * 5 + (N - x - y) == all1000:
			print('{} {} {}'.format(x,y,N - x - y))
			exit()
print('-1 -1 -1')


Fixed submission:
N,Y = map(int,input().split())
cnt10 = 0
cnt5 = 0
cnt1 = 0
def wrong():
	print('-1 -1 -1')
	exit()
all1000 = int(Y / 1000)
if all1000 % 1 != 0:
	wrong()
for x in range(all1000 + 1):
	for y in range(all1000 - x + 1):
		if N - x - y < 0:
			break
		if x * 10 + y * 5 + (N - x - y) == all1000:
			print('{} {} {}'.format(x,y,N - x - y))
			exit()
print('-1 -1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


if __name__ == '__main__':
    data = set(get_sieve_of_eratosthenes(100000))
    pos = []
    for i in data:
        if (i + 1) % 2 == 0:
            if (i + 1) // 2 in data:
                pos.append(i)
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        ans = 0
        for i in pos:
            if i <= r and l <= i:
                ans += 1
        print(ans)

Fixed submission:
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


if __name__ == '__main__':
    data = set(get_sieve_of_eratosthenes(100000))
    pos = []
    for i in data:
        if (i + 1) % 2 == 0:
            if (i + 1) // 2 in data:
                pos.append(i)
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        ans = 0
        for i in pos:
            if i <= r and l <= i:
                ans += 1
        print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
f = [int(input().replace(' ',''),2) for i in range(n)]
p = [list(map(int,input().split())) for i in range(n)]
prof = - 10 ** 10
for i in range(1,1 <<10):
	prof1 = 0
	for j,time in enumerate(f):
		same = bin(i & time).count(1)
		prof1 += p[j][same]
	prof = max(prof,prof1)
print(prof)


Fixed submission:
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

ans=-10**10
for i in range(1,1<<10):
    prof=0
    for j,f in enumerate(F):
        prof+=P[j][bin(i&f).count("1")]
    ans=max(ans,prof)

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input(),split())) for _ in range(N)]

ans=-10**10
for i in range(1,1<<10):
    prof=0
    for j,f in enumerate(F):
        prof+=P[j][bin(i&f).count("1")]
    ans=max(ans,prof)

print(ans)

Fixed submission:
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

ans=-10**10
for i in range(1,1<<10):
    prof=0
    for j,f in enumerate(F):
        prof+=P[j][bin(i&f).count("1")]
    ans=max(ans,prof)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
cnt = 0
for x in range(s + 1):
	for y in range(s + 1 - x):
		if x <= k and y <= k and s - x - y <= k:
			cnt += 1
print(cnt)


Fixed submission:
k,s = map(int,input().split())
cnt = 0
M = min(s + 1,k + 1)
for x in range(M):
	for y in range(min(s + 1 - x,k + 1)):
		if s - x - y <= k:
			cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = input()
s = s.replace('eraser','z')
s = s.repalace('erase','z')
s = s.repalace('dreamer','z')
s = s.repalace('dream','z')
for  S in s:
    if S != 'z':
        print('NO')
    else:
        print('YES')

Fixed submission:
s = input()
s = s.replace('eraser','z')
s = s.replace('erase','z')
s = s.replace('dreamer','z')
s = s.replace('dream','z')
for  S in s:
    if S != 'z':
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Runtime Error):
s = input()
s = s.replace('eraser','z')
s = s.repalace('erase','z')
s = s.repalace('dreamer','z')
s = s.repalace('dream','z')
for  S in s:
    if S != z:
        print('NO')
    else:
        print('YES')


Fixed submission:
s = input()
s = s.replace('eraser','z')
s = s.replace('erase','z')
s = s.replace('dreamer','z')
s = s.replace('dream','z')
for  S in s:
    if S != 'z':
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

ps = []
for i in range(2, 1000):
    is_p = True
    for j in range(2, i):
        if i % j == 0:
            is_p = False
            break
    if is_p:
        ps.append(i)

def factorization(n):
    arr = defaultdict(int)
    temp = n
    for i in ps:
        if i > int(-(-n**0.5//1))+1:
            break
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr


aa = defaultdict(int)

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

fs = [[]] * 1000001
for i in a:
    if not fs[i]:
        fs[i] = factorization(i)

for i in a:
    for k, v in fs[i].items():
        aa[k] = max(aa[k], v)


mod = 10 ** 9 + 7
ans = 0
for i in a:
    t = 1
    for k, v in aa.items():
        t = (t * k ** (v - fs[i][k])) % mod
    ans = (ans + t) % mod
print(ans)


Fixed submission:
from collections import defaultdict

ps = []
for i in range(2, 1000):
    is_p = True
    for j in range(2, i):
        if i % j == 0:
            is_p = False
            break
    if is_p:
        ps.append(i)

def factorization(n):
    arr = defaultdict(int)
    temp = n
    for i in ps:
        if i > int(-(-n**0.5//1))+1:
            break
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr


aa = defaultdict(int)

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

fs = [[]] * 1000001
for i in a:
    if not fs[i]:
        fs[i] = factorization(i)

for i in a:
    for k, v in fs[i].items():
        aa[k] = max(aa[k], v)


mod = 10 ** 9 + 7
t = 1
for k, v in aa.items():
    t = (t * (k ** v)) % mod
ans = 0
for i in a:
    ans += t * pow(i, mod - 2, mod)
    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
N,Q=map(int,input().split())
*A,=map(int,input().split())
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
for i in range(Q):
  q,a,b = map(int,input().split())
  if q:
    print(bit.query(a,b))
  else:
    bit.add(a+1,b)

Fixed submission:
class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
N,Q=map(int,input().split())
*A,=map(int,input().split())
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
for i in range(Q):
  q,a,b = map(int,input().split())
  if q:
    print(bit.query(a,b))
  else:
    bit.add(a+1,b)