Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = [list(map(int, input().split())) for _ in range(2)]

print(n)

Fixed submission:
n = input()
if '7' in n:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
          elif c == "G":
              ans += (ruisekiG[n] - ruisekiG[j])
            else:
                ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)

Fixed submission:
n = input()
if '7' in n:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
        if c == "G":
            ans += (ruisekiG[n] - ruisekiG[j])
        if c == "B":
            ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)

Fixed submission:
n = input()
if '7' in n:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map (int, input().split()))
if 0 in A:
  print(0)
  return
 
re = 1
for i in range(N):
    re *= A[i]
    if re >= pow(10,18):
        print(-1)
        return
else:
    print(re)
    return
    

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

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = int(input())

# 出力
print(a*b)

Fixed submission:
a,b = map(int,input(). split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)


Fixed submission:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

Buggy python submission (verdict: Runtime Error):
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    return
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)


Fixed submission:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

Buggy python submission (verdict: Runtime Error):
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    return

b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)


Fixed submission:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input(). split ()))
if 0 in A:
	print(0)
	return
prod = 1
for a in A:
	prod *= a
	if prod > 1000000000000000000:
		print(-1)
		return

print(prod)

Fixed submission:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map (int, input().split()))
if 0 in A:
  print(0)
  return
 
re = 1
for i in range(N):
    re *= A[i]
    if re >= pow(10,18):
        print(-1)
        return
else:
    print(re)
    return

Fixed submission:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)

Fixed submission:
from sys import stdin

# 標準入力から読み込み
inputs = [int(x) for x in stdin.readline().rstrip().split()]

# output = input[0] * input[1]
print(inputs[0] * inputs[1])

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)

Fixed submission:
from sys import stdin

# 標準入力から読み込み
inputs = [int(x) for x in stdin.readline().rstrip().split()]

# output = input[0] * input[1]
print(inputs[0] * inputs[1])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) <= 1e18 or x < 0 or y < 0  else (X * y)), inputs)

print(output)

Fixed submission:
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

output = 0 if (0 in inputs) else reduce((lambda x, y: x * y), inputs)
if output > 1e18:
  output = -1

print(output)

Fixed submission:
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
 print(s[:k] + (len(s)>k)*'...')

Fixed submission:
k=int(input())
s=input()
print(s[:k] + (len(s)>k)*'...')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
thres = pow(10, 18)
for i in A:
  ans = i * ans

if ans > thres:
  print(-1)
else:
  print(ans)


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

ans = 1
thres = 10**18

if 0 in A:
  print(0)
  sys.exit()

for i in A:
  ans = i * ans
  if ans > thres:
    print(-1)
    sys.exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input('a='))
b=int(input('b='))
total=a*b
if total%2==0:
    print('Even')
else:
    print('Odd')

Fixed submission:
a,b=map(int,input().split())
total=a*b
if total%2==0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
while True:
    a=int(input('a='))
    b=int(input('b='))
    total=a*b
    if total%2==0:
        print('Even')
    else:
        print('Odd')

Fixed submission:
a,b=map(int,input().split())
total=a*b
if total%2==0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
while True:
    a=int(input('a='))
    b=int(input('b='))
    total=a*b
    if total%2==0:
        print('even')
    else:
        print('odd')

Fixed submission:
a,b=map(int,input().split())
total=a*b
if total%2==0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
"""
4
1 2 2 1

2


5
3 1 2 3 1

5
"""

_ = int(input())
first = list(map(int, input().split()))
count = 0


def water(base_list):
    global count
    count += 1
    separated = []
    each = []
    for i in base_list:
        if i - 1 == 0:
            separated.append(each)
            each = []
        else:
            each.append(i-1)
    if each:
        separated.append(each)

    new_separated = []
    for i in separated:
        if i:
            new_separated.append(i)

    if new_separated:
        for i in new_separated:
            water(i)
    else:
        return


water(first)

print(count)


Fixed submission:
"""
4
1 2 2 1

2


5
3 1 2 3 1

5


8
4 23 75 0 23 96 50 100

221
"""

_ = int(input())
first = list(map(int, input().split()))
count = 0


def water(base_list):
    global count
    count += 1
    separated = []
    each = []
    for i in base_list:
        hoge = i - 1
        if hoge == 0:
            separated.append(each)
            each = []
        else:
            each.append(hoge)
    if each:
        separated.append(each)

    new_separated = []
    for i in separated:
        if i:
            new_separated.append(i)

    if new_separated:
        for i in new_separated:
            water(i)
    else:
        return


def plus_one(i):
    return i + 1


first = list(map(plus_one, first))


water(first)

print(count - 1)
Buggy python submission (verdict: Runtime Error):
arr = [input() for i in range(4)]

count = 0
for fi in range(0, arr[0]):
    for hun in range(0, arr[1]):
        for fifty in range(0, arr[2]):
            sum = int(fi) * 500 + int(hun) * 100 + int(fifty) * 50
            if sum == arr[3]:
                count += 1
print(count)

Fixed submission:
arr = [input() for i in range(4)]

count = 0
for fi in range(0, int(arr[0])+1):
    for hun in range(0, int(arr[1])+1):
        for fifty in range(0, int(arr[2])+1):
            sum = fi * 500 + hun * 100 + fifty * 50
            if sum == int(arr[3]):
                count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
arr = [input() for i in range(4)]

count = 0
for fi in range(0, arr[0]):
    for hun in range(0, arr[1]):
        for fifty in range(0, arr[2]):
            sum = int(fi) * 500 + int(hun) * 100 + int(fifty) * 50
            if sum == arr[3]:
                count += 1
print(count)

Fixed submission:
arr = [input() for i in range(4)]

count = 0
for fi in range(0, int(arr[0])+1):
    for hun in range(0, int(arr[1])+1):
        for fifty in range(0, int(arr[2])+1):
            sum = fi * 500 + hun * 100 + fifty * 50
            if sum == int(arr[3]):
                count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
list = input().split()
a = int(list[0])
b = int(list[1])

if a * b % 2 == 0:
  print(Even)
else:
  print(Odd)

Fixed submission:
list = input().split()
a = int(list[0])
b = int(list[1])

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")

Buggy python submission (verdict: Runtime Error):
list = input().split()
a = list[0]
b = list[1]

if a * b % 2 == 0:
  print(Even)
else:
  print(Odd)

Fixed submission:
list = input().split()
a = int(list[0])
b = int(list[1])

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")

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

if a * b % 2 == 0:
  print(Even)
else:
  print(Odd)

Fixed submission:
list = input().split()
a = int(list[0])
b = int(list[1])

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
if flag == True:
  print(result)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
  if flag == True:
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

n = input()
li = list(map(int, input().split()))
result = functools.reduce(operator.mul, li)

if result > 10 ** 18:
  print(-1)
else:
  print(result)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
  if flag == True:
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

multi = 1
for i in range(n):
  multi *= num[i]

if multi > 10 ** 18:
  print(-1)
else:
  print(multi)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
  if flag == True:
    print(result)
Buggy python submission (verdict: Runtime Error):
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radian(hour * 360 / 12))
y_ji = jishin * math.sin(math.radian(hour * 360 / 12))
x_hun = hunshin  * math.cos(math.radian(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radian(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)


Fixed submission:
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radians((hour + minute / 60) * 360 / 12))
y_ji = jishin * math.sin(math.radians((hour + minute / 60) * 360 / 12))
x_hun = hunshin  * math.cos(math.radians(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radians(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)

Buggy python submission (verdict: Runtime Error):
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radian(hour * 360 / 12))
y_ji = jishin * math.sin(math.radian(hour * 360 / 12))
x_hun = hunshin  * math.cos(math.radian(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radian(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 - (y_ji - y_hun) ** 2)
print(kyori)

Fixed submission:
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radians((hour + minute / 60) * 360 / 12))
y_ji = jishin * math.sin(math.radians((hour + minute / 60) * 360 / 12))
x_hun = hunshin  * math.cos(math.radians(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radians(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for r in range(N):
  ans *= A[r]
if ans > 1e18:
    ans = -1
print(ans)

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for r in range(N):
  ans *= A[r]
if ans > 1e18:
    ans = -1
print(ans)

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)

Buggy python submission (verdict: Runtime Error):
a = [int(map(int, input.split())) for i in range(n)]
a1 = a[0]
a2 = a[1]
ans = 1
for r in range(a[0]):
  ans *= a2[r]
print(ans)

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input(),split()))
ans = 1

for r in range(0,len(a)):
  ans *= a[r]
  
print(ans)

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(-1)
  exit(0)
ans = 1
for i in A:
  ans *= i
  if ans >= 10 ** 18:
    print(-1)
	exit(0)
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  exit(0)
ans = 1
for i in A:
  ans *= i
  if ans > 10 ** 18:
    print(-1)
    exit(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(-1)
  exit()
ans = 1
for i in A:
  ans *= i
  if ans >= 10 ** 18:
    print(-1)
	exit()
print(ans)

         

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  exit(0)
ans = 1
for i in A:
  ans *= i
  if ans > 10 ** 18:
    print(-1)
    exit(0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
factors = []
i = 2
while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
  i += 1

ans = 0
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
factors = []
i = 2
while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1

ans = 0
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
factors = []
i = 2
while N > 1:
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1

ans = 0
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
factors = []
i = 2
while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1

ans = 0
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


class UnionFind:
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rk = [0] * size

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rk[x] < self.rk[y]:
            self.par[x] = y
        elif self.rk[x] > self.rk[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            self.rk[y] += 1


N, M, K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.unite(a, b)
    friend[a].add(b)
    friend[b].add(a)

block = defaultdict(set)
for _ in range(K):
    c, d = map(lambda x: int(x) - 1, input().split())
    block[c].add(d)
    block[d].add(c)

group = defaultdict(set)
for i in range(N):
    group[uf.find(i)].add(i)

ans = [0] * N
for people in group.values():
    for p in people:
        ans[p] = len(people) - 1 - sum(1 if i in people else 0 for i in friend[p]) - sum(1 if i in people else 0 for i in block[p])

print(' '.join(ans))




Fixed submission:
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


class UnionFind:
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rk = [0] * size

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rk[x] < self.rk[y]:
            self.par[x] = y
        elif self.rk[x] > self.rk[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            self.rk[y] += 1


N, M, K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.unite(a, b)
    friend[a].add(b)
    friend[b].add(a)

block = defaultdict(set)
for _ in range(K):
    c, d = map(lambda x: int(x) - 1, input().split())
    block[c].add(d)
    block[d].add(c)

group = defaultdict(set)
for i in range(N):
    group[uf.find(i)].add(i)

ans = [0] * N
for people in group.values():
    for p in people:
        ans[p] = len(people) - 1 - sum(1 if i in people else 0 for i in friend[p]) - sum(1 if i in people else 0 for i in block[p])

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

def factorize(x):
    count = {}
    i = 2
    while i * i <= x:
        while x % i == 0:
            x //= i
            count[i] = count.get(i, 0) + 1
        i += 1
    if x > 1:
        count[x] = count.get(x, 0) + 1
    return count


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

A = list(map(factorize, A))

lcm = {}
for i in A:
    for factor, count in i.items():
        lcm[factor] = max(lcm.get(factor, 0), count)

MOD = 1000000007
ans = 0
for i in A:
    B = 1
    for factor, count in lcm.items():
        B *= pow(factor, count - i.get(factor, 0), MOD)
        B % MOD
    ans = (ans + B) % MOD
print(ans)

Fixed submission:
import sys
import math

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


def inverse(x, mod):
    return pow(x, mod - 2, mod)


def factorize(x):
    count = {}
    i = 2
    while i * i <= x:
        while x % i == 0:
            x //= i
            count[i] = count.get(i, 0) + 1
        i += 1
    if x > 1:
        count[x] = count.get(x, 0) + 1
    return count


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

A = list(map(factorize, A))

lcm = {}
for i in A:
    for factor, count in i.items():
        lcm[factor] = max(lcm.get(factor, 0), count)

MOD = 1000000007

lcm_int = 1
for factor, count in lcm.items():
    lcm_int *= pow(factor, count, MOD)
    lcm_int %= MOD

ans = 0
for i in A:
    B = lcm_int
    for factor, count in i.items():
        B *= inverse(pow(factor, count, MOD), MOD)
        B % MOD
    ans = (ans + B) % MOD
print(ans)