qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

from fractions import gcd

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

n = I()
a = LI()
l = 1
for i in a:
    l = lcm(l,i)

ans = 0
for i in a:
    ans += l*pow(i,mod-2,mod)
    ans %= mod
print(ans)


Fixed code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

n = I()
a = LI()
l = 1
for i in range(n):
    l = lcm(l,a[i])

ans = 0
l %= mod
for i in range(n):
    ans += l *pow(a[i],mod-2,mod)
    ans %= mod
print(ans)
Buggy code:
# coding: utf-8
# Your code here!

n=int((input()))
a=list(map(int,input().split()))
mod=10**9+7
b=[]
for i in a:
    b.append(pow(i,mod-2,mod))
    
tmp=sum(b)%mod


def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x
    
def lcm(x,y):
    return (x%mod)*(y%mod)//gcd(x,y)
    
L=a[0]%mod
for i in a:
    L=lcm(L,i%mod)%mod
    


print(L*tmp%mod)

Fixed code:
# coding: utf-8
# Your code here!

n=int((input()))
a=list(map(int,input().split()))
mod=10**9+7
b=0
for i in a:
    b+=(pow(i,mod-2,mod))
    
tmp=b%mod

def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x
    
def lcm(x,y):
    G=gcd(x,y)
    return (x)*(y)//G
    
L=a[0]
for i in a:
    L=lcm(L,i)
    


print(L*tmp%mod)
Buggy code:

MOD = 1000000007

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

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

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)

Fixed code:

MOD = 1000000007

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

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

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)
Buggy code:
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    L = 1
    for a in A:
        L = lcm(L, a)
        L %= mod

    res = 0
    for a in A:
        res += L * pow(a, mod - 2, mod)
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Fixed code:
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    L = 1
    for a in A:
        L = lcm(L, a)

    res = 0
    for a in A:
        res += L * pow(a, mod - 2, mod)
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()
Buggy code:
n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a
def lcm(a,b):
    return a // gcd(a,b)

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i]
print(ans%mod)


Fixed code:
n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a
def lcm(a,b):
    return a // gcd(a,b) * b

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i]
print(ans%mod)
Buggy code:
from functools import reduce

def gcd(x, y):
    y, x = sorted([x, y])
    while True:
        r = x % y
        if r == 0:
            print(x, y, r)
            return r
        else:
            print(x, y, r)
            x, y = y, r

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

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

N = int(input())
l = list(map(int, input().split(" ")))

p = lcm_list(l)
c = 0
z = 10 ** 9 + 7
for i in l:
  c += p // i
print(c % z)

Fixed code:
from functools import reduce

def gcd(x, y):
    y, x = sorted([x, y])
    while True:
        r = x % y
        if r == 0:
            # print(x, y, r)
            return y
        else:
            # print(x, y, r)
            x, y = y, r

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

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

N = int(input())
l = list(map(int, input().split(" ")))

p = lcm_list(l)
c = 0
z = 10 ** 9 + 7
for i in l:
  c += p // i
print(c % z)
Buggy code:
def main():
  def sieve(n):
    prime=[]
    limit=n*0.5
    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]
        
  prime=sieve(1000)
  import sys
  import numpy as np
  input=sys.stdin.readline
  mod=10**9+7
  
  n=int(input())
  num=np.array(list(map(int,input().split())))
  
  lcm=1
  num_copy=num.copy()
  for p in prime:
    while np.any(num%p==0):
      num[num%p==0]//=p
      lcm *= p
      lcm %= mod
      
  #print(lcm,num_copy)
  ans=0
  for i in range(n):
    ans += lcm * pow(num_copy[i] ,mod-2 ,mod)
    ans %= mod 
    #print(ans)
  print(ans)
  
if  __name__=='__main__':
  main()

Fixed code:
def main():
  def sieve(n):
    prime=[]
    limit=n*0.5
    data=[i+1 for i in range(1,n)]
    p_append=prime.append
    while True:
        p=data[0]
        if limit<=p:
            return prime+data
        p_append(p)
        data=[e for e in data if e%p!=0]
        
  prime=sieve(1000)
  import sys
  import numpy as np
  input=sys.stdin.readline
  mod=10**9+7
  
  n=int(input())
  num=list(map(int,input().split()))
  num_copy=np.array(num)
  
  lcm=1
  for p in prime:
    while np.any(num_copy%p==0):
      num_copy[num_copy%p==0]//=p
      lcm *= p
      lcm %= mod
  
  for i in set(num_copy.tolist()):
    lcm *= i
    lcm %= mod
    
  #print(lcm,num)
  ans=0
  for i in range(n):
    ans += lcm * pow(num[i] ,mod-2 ,mod)
    ans %= mod 
    #print(ans)
  print(ans)
  
if  __name__=='__main__':
  main()
Buggy code:
def GCD(x,y):
    if y==0:
        return x
    return GCD(y,x%y)

def func(x):
    if x <= 1:
        return []
    for i in range(2,int(x**0.5)+1):
        if x%i == 0:
            count = 0
            while x%i==0:
                x //= i
                count += 1
            return [[i,count]]+func(x)
    return [[x,1]]
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = [0]*(10**6)
for i in A:
    for a,b in func(i):
        lcm[a] = max(lcm[a],b)
L = 1
for i in range(2,10**6):
    L *= pow(i,lcm[i],MOD)
    L %= MOD
ans = 1
for i in A:
    ans += L*pow(i,MOD-2,MOD)
    ans %= MOD
print(ans)



Fixed code:
def GCD(x,y):
    if y==0:
        return x
    return GCD(y,x%y)

def func(x):
    if x <= 1:
        return []
    for i in range(2,int(x**0.5)+1):
        if x%i == 0:
            count = 0
            while x%i==0:
                x //= i
                count += 1
            return [[i,count]]+func(x)
    return [[x,1]]
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = [0]*(10**6)
for i in A:
    for a,b in func(i):
        lcm[a] = max(lcm[a],b)
L = 1
for i in range(2,10**6):
    L *= pow(i,lcm[i],MOD)
    L %= MOD
ans = 0
for i in A:
    ans += L*pow(i,MOD-2,MOD)
    ans %= MOD
print(ans)
Buggy code:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
        
def lcm(a,b):
    return a*b//gcd(a,b)
    
N = int(input())
A = list(map(int, input().split()))

lcm_A = 1
for i in range(N):
    lcm_A = lcm(lcm_A, A[i])
    
ans = 0
for i in range(N):
    ans += lcm_A // A[i]

mod = 10**9+7
print(ans & mod)

Fixed code:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
        
def lcm(a,b):
    return a*b//gcd(a,b)
    
N = int(input())
A = list(map(int, input().split()))

lcm_A = 1
for i in range(N):
    lcm_A = lcm(lcm_A, A[i])
    
ans = 0
for i in range(N):
    ans += lcm_A // A[i]

mod = 10**9+7
print(ans % mod)
Buggy code:
import fractions
import functools

MOD = int(1e9) + 7

def lcm(a, b):
    return a // fractions.gcd(a, b) * b


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x, MOD - 2)


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

v = functools.reduce(lcm, A)
ans = 0
for a in A:
    ans = (ans + v // a) % MOD
print(ans)

Fixed code:
import fractions
import functools

MOD = int(1e9) + 7


def lcm(a, b):
    c, d = a, b
    while d != 0:
        c, d = d, c % d
    return a // c * b


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x, MOD - 2)


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

v = functools.reduce(lcm, A)
v %= MOD
ans = 0
for a in A:
    ans = (ans + v * Inv.inv(a)) % MOD
print(ans)
Buggy code:
    import math
    from functools import reduce
     
    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)
     
    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)
      
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
     
    lcm = lcm_list(A)
     
    for i in range(N):
      ans += lcm//A[i]
     
    print(ans%1000000007)

Fixed code:
import math
from functools import reduce
     
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
     
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
      
N = int(input())
A = list(map(int,input().split()))
ans = 0
     
lcm = lcm_list(A)
     
for i in range(N):
    ans += lcm//A[i]
     
print(ans%1000000007)
Buggy code:
def gcd(x, y):
    x = x % y
    if x == 0:
        return y
    return gcd(y, x)

def lcm(x, y):
    return x // gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
print(l)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)


Fixed code:
def gcd(x, y):
    x = x % y
    if x == 0:
        return y
    return gcd(y, x)

def lcm(x, y):
    return x // gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(n, m):
    return n * m // gcd(n, m)

L = A[0]
A = set(A)
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans += L // a
    ans %= MOD

print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(n, m):
    return n * m // gcd(n, m)

L = A[0]
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans += L // a

print(ans % MOD)
Buggy code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

for ai in A:
    pro=lcm(pro,ai)

# pro2=1
# for ai in A:
#     pro2=(pro2*ai)%mod
#     pro=gcd(pro,ai)
# for ai in A:
#     count+=pro//ai
#     count%=mod
# print(count)

Fixed code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)
for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    count+=pro//ai
print(count%mod)
Buggy code:
def lcm(a, b):
    while b:
        a %= b
        a, b = b, a
    gcd = a
    return a * b // gcd


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)


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


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


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)
Buggy code:
def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]*pow(gcd(kbs,A[i]),mod-2,mod)
  kbs %= mod
  
ans = 0
for i in range(N):
  ans += kbs*pow(A[i],mod-2,mod)
  ans %= mod
print(ans)    

Fixed code:
def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]//gcd(kbs,A[i])
kbs %= mod

ans = 0
for i in range(N):
  ans += pow(A[i],mod-2,mod)
  ans %= mod
print(kbs*ans%mod)
Buggy code:
import sys
sys.setrecursionlimit(100000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))




Fixed code:
import sys
sys.setrecursionlimit(10000000)


def gcd(aa, b):
    if b == 0:
        return aa
    return gcd(b, aa % b)


mod = int(1e9 + 7)
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek // a[i]
print(int(s % mod))
Buggy code:
import functools

MOD = 10**9 + 7


def lcm(a, b):
    c, d = a, b
    while d != 0:
        c, d = d, c % d
    return a / c * b


def inv_mod(x):
    return pow(x, MOD - 2)


def pow(x: int, n: int) -> int:
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1

    return res


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

    lcm_an = functools.reduce(lcm, an)
    lcm_an %= MOD

    ans = 0
    for a in an:
        ans = (ans + lcm_an * inv_mod(a)) % MOD

    print(ans)


if __name__ == '__main__':
    main()


Fixed code:
import functools

MOD = 10**9 + 7


def lcm(a, b) -> int:
    c, d = a, b
    while d != 0:
        c, d = d, c % d
    return a // c * b


def inv_mod(x):
    return pow(x, MOD - 2)


def pow(x: int, n: int) -> int:
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1

    return res


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

    lcm_an = functools.reduce(lcm, an)
    lcm_an %= MOD

    ans = 0
    for a in an:
        ans = (ans + lcm_an * inv_mod(a)) % MOD

    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
import math
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

a_gcd = 1
a_seki = 1
for i in range(n):
    a_gcd = math.gcd(a_gcd, a[i])
    a_seki = a_seki * a[i]
a_lcm = a_seki//a_gcd

b_sum = 0
for i in range(n):
    b_sum = (b_sum + (a_lcm // a[i])) % mod

print(b_sum)


Fixed code:
import math
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

a_lcm = 1
for i in range(n):
    a_lcm = lcm(a_lcm, a[i])

b_sum = 0
for ai in a:
    b_sum += a_lcm // ai

print(b_sum%mod)
Buggy code:
N = int(input())
*A, = map(int, input().split())

mod = 10**9 + 7
MAX = 1_000_000


def gen_primes(n):
    n = int(n**0.5) + 2
    is_prime = [True]*n
    is_prime[0] = is_prime[1] = False
    for i in range(2, n):
        if is_prime[i]:
            for j in range(2*i, n, i):
                is_prime[j] = False
    return [i for i, flag in enumerate(is_prime) if flag]


C = [0]*(MAX+1)
primes = gen_primes(MAX)


def prime_fact(n):
    cnt = 0
    for p in primes:
        if n % p:
            continue
        while n % p == 0:
            cnt += 1
            n //= p
        C[p] = max(C[p], cnt)
        cnt = 0
    if n != 1:
        C[n] = 1


for a in A:
    prime_fact(a)

lcm = 1
for i, c in enumerate(C):
    if c:
        lcm = lcm * pow(i, c, mod) % mod

print(lcm)

ans = 0
for a in A:
    ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod
print(ans)


Fixed code:
N = int(input())
*A, = map(int, input().split())

mod = 10**9 + 7
MAX = 1_000_000


def gen_primes(n):
    n = int(n**0.5) + 2
    is_prime = [True]*n
    is_prime[0] = is_prime[1] = False
    for i in range(2, n):
        if is_prime[i]:
            for j in range(2*i, n, i):
                is_prime[j] = False
    return [i for i, flag in enumerate(is_prime) if flag]


C = [0]*(MAX+1)
primes = gen_primes(MAX)


def prime_fact(n):
    cnt = 0
    for p in primes:
        if n % p:
            continue
        while n % p == 0:
            cnt += 1
            n //= p
        C[p] = max(C[p], cnt)
        cnt = 0
    if n != 1:
        C[n] = 1


for a in A:
    prime_fact(a)

lcm = 1
for i, c in enumerate(C):
    if c:
        lcm = lcm * pow(i, c, mod) % mod

ans = 0
for a in A:
    ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod
print(ans)
Buggy code:
def gcd(a,b):
    while b:a,b=a,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l//A[i]
    ans %= mod

print(ans)

Fixed code:
def gcd(a,b):
    while b:a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l*pow(i,mod-2,mod)
    ans %= mod

print(ans)
Buggy code:
def s():
  from sys import stdin
  read=stdin.buffer.readline
  n=int(read())
  l=list(map(int,read().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    s,d=max(s,d),min(s,d)
    while  d:
      s,d=d,s%d
    return s
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    b,u,v=mod,1,0
    while b:
      t=x//b;x,b=b,x%b;u-=t*v;u,v=v,u
    ans+=(f*u%mod)%mod
    ans%=mod
  print(ans)
  
if __name__=="__main__":s()


Fixed code:
def s():
  from sys import stdin
  read=stdin.buffer.readline
  n=int(read())
  l=list(map(int,read().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    s,d=max(s,d),min(s,d)
    while  d:
      s,d=d,s%d
    return s
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    b,u,v=mod,1,0
    while b:
      t=iu//b;iu,b=b,iu%b;u-=t*v;u,v=v,u
    ans+=(f*u%mod)%mod
    ans%=mod
  print(ans)
  
if __name__=="__main__":s()
Buggy code:
n = int(input())
nums = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y): #LCM
    # lowest_common_multiple
    return x * y // gcd(x, y)

LCM = 1
for num in nums:
    LCM = lcm(num, LCM)
LCM %= mod
ans = 0
for num in nums:
    ans += (LCM // num) % mod
print(ans % mod)

Fixed code:
n = int(input())
nums = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y): #LCM
    # lowest_common_multiple
    return x * y // gcd(x, y)

LCM = 1
for num in nums:
    LCM = lcm(num, LCM)
LCM %= mod
# ans = 0
# for num in nums:
#     ans += (LCM // num) % mod
# print(ans % mod)
ans = 0
for num in nums:
    ans += LCM * pow(num, mod - 2, mod)
    ans %= mod

print(ans % mod)
Buggy code:
import fractions

mod=10**9+7

n=int(input())

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

def lcm(a,b):
    return a//fractions.gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])%mod

print(ans)


Fixed code:
mod=10**9+7

n=int(input())

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])

print(ans%mod)
Buggy code:
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
mod=10**9+7

n=int(input())
a=list(map(int,input().split()))
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
  l%=mod

ans=0
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)

Fixed code:
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
ans=0
l%=mod
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)
Buggy code:
import sys

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b 

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9
    gcdA = A[0]
    lcmA = A[0]
    for i in range(1, N):
        gcdA = gcd(lcmA, A[i])
        lcmA *=  (A[i] * pow(gcdA, mod - 2, mod)) % mod
        lcmA %= mod
    Ans = 0
    for a in A:
        Ans += (lcmA * pow(a, mod - 2, mod)) % mod
        Ans %= mod
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Fixed code:
import sys

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b 

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9
    gcdA = A[0]
    lcmA = A[0]
    for i in range(1, N):
        gcdA = gcd(lcmA, A[i])
        lcmA = (lcmA * A[i]) // gcdA
    lcmA %= mod
    Ans = 0
    for a in A:
        Ans += (lcmA * pow(a, mod - 2, mod)) % mod
        Ans %= mod
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()