Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':

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

    cnt = 0
    ans = 0

    while cnt < n:
        tmp1 = min(a,n-cnt)
        ans += tmp1
        cnt += tmp1 + b
    print(ans)

Fixed submission:
if __name__ == '__main__':

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

    tmp1 = (n // (a + b)) * a
    if tmp1 == 0:
        tmp2 = min(n,a)
    else:
        tmp2 = n % (a + b)
        tmp2 = min(a,tmp2)
    print(tmp1+tmp2)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':

	n,m = map(int,input().split())
	
	A = [0 for _ in range(m)]

	for i in range(m):
		s,c = map(int,input().split())
		if A[s-1] != 0:
			A[s-1] = min(A[s-1],c)
		else:
			A[s-1] = c
	
	ans = ""
	if A[0] == 0:
		print(-1)
	else:
		for j in range(m):
			ans += str(A[j])
		print(int(ans))

Fixed submission:
if __name__ == '__main__':

	n,m = map(int,input().split())

	A = [-1 for _ in range(n)]
	B = []
	for i in range(m):
		x,y = map(int,input().split())
		B.append([x,y])

	flg = True
	
	for a in B:
		x = a[0]
		y = a[1]

		if A[x-1] == -1:
			A[x-1] = y
		else:
			if A[x-1] != y:
				flg = False
				break

	ans = 0
	if flg:
		#穴埋め
		for i,j in enumerate(A):
			if j == -1:
				if i == 0 and len(A) != 1:
					A[i] = 1
				else:
					A[i] = 0

		tmp = ""
		for k in range(n):
			tmp += str(A[k])
		tmp = str(int(tmp))
		if len(tmp) == n :
			ans = int(tmp)
		else:
			ans = -1
	else:
		ans = -1

	print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':

	n = int(input())
	
	d = {}
	for i in range(n):
		cmd = input()
		if cmd in d:
			d[cmd] += 1
		else:
			d[cmd] = 1

	A = []
	for kv in d.items():
		if kv[1] == max(d.values()):
			A.append(kv[0])

	B = sorted(A)
	for b in B:
		print(b)


Fixed submission:
if __name__ == '__main__':

	n = int(input())
	
	d = {}
	for i in range(n):
		cmd = input()
		if cmd in d:
			d[cmd] += 1
		else:
			d[cmd] = 1

	mval = max(d.values())
	A = [kv[0] for kv in d.items() if kv[1] == mval]

	B = sorted(A)
	for b in B:
		print(b)
Buggy python submission (verdict: Runtime Error):
import itertools

if __name__ == '__main__':

	n = int(input())

	A = tuple(map(int,input().split()))
	B = tuple(map(int,input().split()))

    C  = [i for i in range(1,n+1)]
	D = [v for v in itertools.permutations(C, n)]

	a = D.index(A)
	b = D.index(B)

	print(abs(a-b))


Fixed submission:
import itertools

if __name__ == '__main__':

	n = int(input())

	A = tuple(map(int,input().split()))
	B = tuple(map(int,input().split()))

	C  = [i for i in range(1,n+1)]
	D = [v for v in itertools.permutations(C, n)]

	a = D.index(A)
	b = D.index(B)

	print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
import math

if __name__ == '__main__':

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

	print((a * b) // math.gcd(a,b))


Fixed submission:
import fractions

if __name__ == '__main__':

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

	print((a * b) // fractions.gcd(a,b))
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)
	end = n - 1

    for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)


Fixed submission:

if __name__ == '__main__':

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

	if (1 <= A[0] <= 9) and (1 <= A[1] <= 9):
		print(A[0] * A[1])
	else:
		print(-1)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

   	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)


Fixed submission:
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)
Buggy python submission (verdict: Runtime Error):

if __name__ == '__main__':

	S = input()
	K = int(input())

	leng = len(S)
	cnt = 0

	i = 0
	while i < leng - 1:
		if S[i] == S[i+1]:
			cnt += 1
			i += 2
		else:
			i += 1

	ans = K*cnt

	j = 0
	if (S[j] == S[leng-1]) and (S[j] != S[j+1]) and (S[leng-1] != S[leng-2]):
		ans += 1

	if S.count(S[0]) == leng and leng % 2 == 1:
		ans += 1

	print(ans)


Fixed submission:

if __name__ == '__main__':

	S = input()
	K = int(input())

	leng = len(S)
	ans = 0

	#１文字である場合
	if K == 1:
		ans = 0
	#全部同じ文字である場合
	elif S.count(S[0]) == leng:
		ans = int(leng*K/2)
	else:
		#隣り合った文字はＮ文字で置き換える文字はＭ文字か計算する
		start = ""
		cnt = 0
		rep = 0
		for x,y in enumerate(S):
			if x == 0:
				start = y
			else:
				if start == y:
					cnt += 1
				else:
					#同じ文字あり
					if cnt > 0:
						cnt += 1	#最初を追加
						rep += int(cnt/2)
						cnt = 0	#初期化

					start = y
		#後処理
		if cnt > 0:
			cnt += 1	#最初を追加
			rep += int(cnt/2)

		#先頭と末尾が同じ文字である場合
		if S[0] == S[leng-1]:

			#先頭文字での置き換え文字数
			cnt1 = 1
			smoji = S[0]
			for x in range(1,leng):
				if S[0] == S[x]:
					cnt1 += 1
					smoji += S[0]
				else:
					break
			moto1 = int(cnt1/2)


			#末尾文字での置き換え文字数
			cnt2 = 1
			#文字列反転
			S = S[::-1]
			smoji += S[0]
			for x in range(1,leng):
				if S[0] == S[x]:
					cnt2 += 1
					smoji += S[0]
				else:
					break
			moto2 = int(cnt2/2)

			#先頭と末尾を合わせたものを置き換えた文字数
			slen = len(smoji)
			moto3 = int(slen/2)

			kekka = (moto1 + moto2) - moto3
			kekka = kekka * (K -1)

			ans = rep * K - kekka
		else:
			ans = rep * K

	print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':

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

    INF = 10**9
    dp = [INF] * (n+1)
    dp[0] = 0
    k = min(k,n)
    for i in range(1,n):
        for j in range(1,k+1):
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])



Fixed submission:
if __name__ == '__main__':

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

    #TLE pypy
    INF = 10**9
    dp = [INF] * (n+1)
    dp[0] = 0
    k = min(k,n)
    for i in range(1,n):
        for j in range(1,k+1):
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
	n,m,x,y = map(int,input().split())
	X = list(map(int,input().split()))
	Y = list(map(int,input().split()))
 
	x_max = max(X)
	y_min = min(Y)
 
 	flg = False
	for Z in range(x+1,y+1):
		if x_max < Z and Z <= y_min:
			flg = True
			break

	if flg :
		print("No war")
	else:
		print("War")
 

Fixed submission:
if __name__ == '__main__':
	n,m,X,Y = map(int,input().split())
	x = list(map(int,input().split()))
	y = list(map(int,input().split()))
 
	x_max = max(x)
	y_min = min(y)

	flg = False
	for Z in range(X+1,Y+1):
		if x_max < Z <= y_min:
			flg = True
			break

	if flg:
		print("No War")
	else:
		print("War")

Buggy python submission (verdict: Runtime Error):

if __name__ == '__main__':
	n,m,x,y = map(int,input().split())
	X = list(map(int,input().split()))
	Y = list(map(int,input().split()))

	x_max = max(X)
	y_min = min(Y)

	for Z in range(x,y):
		if y_max < Z <= y_min:
			print("No war")
			break
	else:
		print("War")


Fixed submission:
if __name__ == '__main__':
	n,m,X,Y = map(int,input().split())
	x = list(map(int,input().split()))
	y = list(map(int,input().split()))
 
	x_max = max(x)
	y_min = min(y)

	flg = False
	for Z in range(X+1,Y+1):
		if x_max < Z <= y_min:
			flg = True
			break

	if flg:
		print("No War")
	else:
		print("War")
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
	input()
	A = list(map(int,input().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]
	EVE.sort()

	while True:
		if len(EVE) == 0:
			print(cnt)
			break
		else:
			EVE[-1] = EVE[-1] // 2
			if EVE[-1] % 2 == 1:
				EVE.pop(-1)
			else:
				EVE.sort()
			cnt += 1


Fixed submission:
import sys

if __name__ == '__main__':
	input()
	A = list(map(int,sys.stdin.readline().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]

	for j in EVE:
		while True:
			j = j // 2
			if j % 2 == 1:
				cnt += 1
				break
			cnt += 1

	print(cnt)

Buggy python submission (verdict: Runtime Error):

if __name__ == '__main__':

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

	cnt = 0
	ODD = []
	EVE = []

	#奇数と偶数に分類
	for i in A:
		if i % 2 == 1:
			ODD.append(i)
		else:
			EVE.append(i)

	while True:

		#全部奇数なら終了
		if len(ODD) == n:
			print(cnt)
			break
		else:
			#奇数は全部３倍する
			for i in range(len(ODD)):
				ODD[i] = ODD[i] * 3

			#偶数はMAX値を２で割る
			#それ以外は３倍する
			chg = False
			mval = max(EVE)
			ind = EVE.index(mval)
			for j in range(len(EVE)):
				if j == ind:
					EVE[j] = int(EVE[j] / 2)
					if ( mval / 2 ) % 2 == 1:
						chg = True
				else:
					EVE[j] = EVE[j] * 3

			#２で割った値が奇数になったらODDに移動
			if chg == True:
				ODD.append(EVE.pop(ind))

			cnt += 1


Fixed submission:
import sys

if __name__ == '__main__':
	input()
	A = list(map(int,sys.stdin.readline().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]

	for j in EVE:
		while True:
			j = j // 2
			if j % 2 == 1:
				cnt += 1
				break
			cnt += 1

	print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

if __name__ == '__main__':

	n,m = map(int,input().split())

	A =[]
	for i in range(n):
		A.append(list(map(int,input().split())))

	maxval = 0
	for v in itertools.combinations(A,m):
		a = abs(sum(list(map(lambda x: x[0], v))))
		b = abs(sum(list(map(lambda x: x[1], v))))
		c = abs(sum(list(map(lambda x: x[2], v))))

		maxval = max(maxval,a+b+c)

	print(maxval)


Fixed submission:
import itertools

if __name__ == '__main__':

	n,m = map(int,input().split())

	A =[]
	for i in range(n):
		A.append(list(map(int,input().split())))

	P = list(itertools.product([1,-1],repeat=3))

	maxval = 0

	for p in P:
		B=[]
		for a in A:
			val = (a[0] * p[0]) + (a[1] * p[1]) + (a[2] * p[2])
			B.append(val)

		#結果をソートして上位ｍ番目までの合計を計算する	
		C = sorted(B,reverse=True)
		maxval = max(maxval,sum(C[:m]))

	print(maxval)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

ll n,k,mod=1e9+7,ans=0;

ll fastMod(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=(res*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return res;
}

void solve(){    
    cin>>n>>k;
    vector<ll> v(k+1);
    for(int i=k;i>0;i--){
        v[i]=fastMod(k/i,n);
        for(int j=2*i;j<=k;j+=i){
            v[i]=(v[i]-v[j]+mod)%mod;
        }
    }
    for(int i=1;i<=k;i++){
        ll val=(v[i]*i)%mod;
        ans=(ans+val)%mod;
    }
    cout<<ans%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Fixed submission:
n,k=[int(x) for x in input().split()]
ans=0
l=[0]*(k+1)
i=k
mod=1000000007
while i>0:
    l[i]=pow(k//i,n,mod)
    j=2*i
    while j<=k:
        l[i]=(l[i]-l[j]+mod)%mod
        j+=i
    i-=1
for i in range(1,k+1):
    ans+=(l[i]*i)%mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def dp():
    n,=list(map(int,input().split()))
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()

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

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

n=int(input())
l=list(map(int,input().split()))
lcm=1
for i in l:
    lcm=(lcm*i)//gcd(lcm,i)
ans=0
mod=1000000007
for i in l:
    ans=(ans+(lcm//i))%mod
print(ans)

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a.insert(0, 0)
    b.insert(0, 0)

    a_sum = [0]*(n+1)
    a_sum[0] = a[0]
    for i in range(1, n+1):
        a_sum[i] = a_sum[i-1] + a[i]

    b_sum = [0]*(m+1)
    b_sum[0] = b[0]
    for i in range(1, m+1):
        b_sum[i] = b_sum[i-1] + b[i]

    ans = 0
    for i_a in range(n+1):
        for j_b in range(m+1):
            if a_sum[i_a]+b_sum[j_b] <= k:
                ans = max(ans, i_a + j_b)
            else:
                break

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a.insert(0, 0)
    b.insert(0, 0)

    a_sum = [0]*(n+1)
    a_sum[0] = a[0]
    for i in range(1, n+1):
        a_sum[i] = a_sum[i-1] + a[i]

    b_sum = [0]*(m+1)
    b_sum[0] = b[0]
    for i in range(1, m+1):
        b_sum[i] = b_sum[i-1] + b[i]

    b_sum = b_sum[::-1]

    i_b = 0
    ans = 0
    for i_a in range(n+1):
        while i_b <= m:
            if k < a_sum[i_a] + b_sum[i_b]:
                i_b += 1
                continue
            else:
                ans = max(ans, i_a+(m-i_b))
                break

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    total_pass = 0
    for i, i_A in enumerate(A_list):
        for j in range(i+i_A, N):
            if (j - i) == i_A + A_list[j]:
                total_pass += 1

    print(total_pass)

    return

if __name__ == '__main__':
    main()
    sys.exit(0)

Fixed submission:
import sys

def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    h_list = [0] * N

    for i, i_A in enumerate(A_list):
        if i - i_A >= 0:
            h_list[i-i_A] += 1

    total_pair = 0
    for i, i_A in enumerate(A_list):
        if i+i_A <= N-1:
            total_pair += h_list[i+i_A]

    print(total_pair)
    return
    
if __name__ == '__main__':
    main()
    sys.exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S_list = [[_ for _ in input()] for i in range(N)]

gift = []
for i_s in S_list:
    if not i_s in gift:
        gift.append(i_s)

print(len(gift))

Fixed submission:
N = int(input())
S_list = [input() for i in range(N)]

S_set = set(S_list)
print(len(S_set))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S_list = [[_ for _ in input()] for i in range(N)]

gift = []
for i_s in S_list:
    if not i_s in gift:
        gift.append(i_s)

print(len(gift))

Fixed submission:
N = int(input())
S_list = [input() for i in range(N)]

S_set = set(S_list)
print(len(S_set))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

dp = [0] * 2019

for i in range(len(S)-1, -1, -1):
    dp[int(S[i:]) % 2019] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

print(ans)

Fixed submission:
S = input()
S_reverse = S[::-1]

dp = [0] * 2019
now_mod = 0
digit = 1

for i_s in S_reverse:
    now_mod = (now_mod + int(i_s)*digit) % 2019
    digit = (digit*10) % 2019
    dp[now_mod] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = input()

if len(S) < 5:
    print(0)
    exit()

check_str = deque()
first = 0
end = 4

for i_range in range(5, len(S)):
    start = 0
    while start+i_range <= len(S):
        check_str.append(int(S[start:start+i_range]))
        start += 1

ans = 0
while len(check_str) > 0:
    now_num = check_str.popleft()
    if now_num % 2019 == 0:
        ans += 1

print(ans)

Fixed submission:
S = input()
S_reverse = S[::-1]

dp = [0] * 2019
now_mod = 0
digit = 1

for i_s in S_reverse:
    now_mod = (now_mod + int(i_s)*digit) % 2019
    digit = (digit*10) % 2019
    dp[now_mod] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = input()

if len(S) < 5:
    print(0)
    exit()

check_str = deque()
first = 0
end = 4
check_str.append([first, end])

ans = deque()
while len(check_str) > 0:
    now_first, now_end = check_str.popleft()
    now_str = S[now_first:now_end+1]
    if int(now_str) % 2019 == 0 and [now_first, now_end] not in ans:
        ans.append([now_first, now_end])
    
    if len(now_str) > 5:
        check_str.append([now_first+1, now_end])

    if now_end < len(S)-1:
        check_str.append([now_first, now_end+1])

print(len(ans))

Fixed submission:
S = input()
S_reverse = S[::-1]

dp = [0] * 2019
now_mod = 0
digit = 1

for i_s in S_reverse:
    now_mod = (now_mod + int(i_s)*digit) % 2019
    digit = (digit*10) % 2019
    dp[now_mod] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)

def is_circular(string):
    reverse = string[::-1]
    if string == reverse:
        return True
    else:
        return False

if is_circular(S) and is_circular(S[:(N)//2]) and is_circular(S[(N+3)//2]):
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
N = len(S)

if N == 3:
    if S[0] == S[2]:
        print('Yes')
    else:
        print('No')
    exit()

def is_circular(string):
    reverse = string[::-1]
    if string == reverse:
        return True
    else:
        return False

if is_circular(S) and is_circular(S[:(N)//2]) and is_circular(S[(N+3)//2]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

n, *a = map(int, open(0).read().split())

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)

ans = 0
for a_i in a:
  ans += lcm // a_i

ans = ans % (10**9 + 7)
print(ans)

Fixed submission:
import fractions
from functools import reduce

n, *a = map(int, open(0).read().split())

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)

ans = 0
for a_i in a:
  ans += lcm // a_i

ans = ans % (10**9 + 7)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k, *h = map(int,open(0).read().split());
print(sum(h>=k for h_i in h))

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
list = list(map(int, input().split()))
ans = 0
for n_i in range(0, n):
    if list[n_i] >= k:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k, *h = map(int,open(0).read().split())
print(sum(h>=k for h_i in h))

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
list = list(map(int, input().split()))
ans = 0
for n_i in range(0, n):
    if list[n_i] >= k:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for pos_i in pos:
            print(s[pre_i:pos_i], pre_i, pos_i)
            ans += int(s[pre_i:pos_i])
            pre_i = pos_i
        
        if pre_i == 0:
            ans = int(s)
        else:
            ans += int(s[pre_i:len(s)] if pre_i != len(s) else '0')
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos)
    
    pos.append(i)
    s_ans = add_or_do_nothing(s, i+1, pos)
    
    return f_ans + s_ans

s = input()

pos = []
ans = add_or_do_nothing(s, 1, pos)

print(ans)

Fixed submission:
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for i, pos_i in enumerate(pos, 1):
            if pos_i == '1':
                ans += int(s[pre_i:i])
                pre_i = i

        ans += int(s[pre_i:len(s)])
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos+'0')
    s_ans = add_or_do_nothing(s, i+1, pos+'1')
    return f_ans + s_ans

s = input()

pos = ''
ans = add_or_do_nothing(s, 1, pos)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

uf = UnionFind(n)

for i in range(m):
    a,b = map(int, input().split())
    a -=1
    b -=1
    uf.union(a,b)
    
res = 0
for j in  uf.roots():
    res = max(res,len(uf.members(j)))
print(res)

Fixed submission:
n,m = map(int, input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

uf = UnionFind(n)

for i in range(m):
    a,b = map(int, input().split())
    a -=1
    b -=1
    uf.union(a,b)
    
res = [0]
for j in  uf.roots():
    res.append(uf.size(j))
print(max(res))