qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a = list(map(int,input().split()))
b = a[0] - a[1]
if b == 0 :
	print(str(a[0]) * a[0])
else : print(str(max(a[0], a[1])) * min(a[0], a[1]))

Fixed code:
a = list(map(int,input().split()))
b = a[0] - a[1]
if b == 0 :
	print(str(a[0]) * a[0])
else : print(str(min(a[0], a[1])) * max(a[0], a[1]))
Buggy code:
a, b = input().split()

bigA = a*int(b)
bigB = b*int(a)

if bigA < bigB:
    print(bigA)
elif bigA = bigB:
    print(bigA)
else:
    print(bigB)

Fixed code:
a, b = input().split()

bigA = a*int(b)
bigB = b*int(a)

if bigA < bigB:
    print(bigA)
elif bigA == bigB:
    print(bigA)
else:
    print(bigB)
Buggy code:
a,b = map(int, input().split())
print(min(a * int(b), b * int(a)))

Fixed code:
a,b = input().split()
print(min(a * int(b), b * int(a)))
Buggy code:
a, b = map(int, input().split())

x = a if a<=b else b

for _ in range(x):
    print(x, end='')

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

(x, y) = (a, b) if a<=b else (b, a)

for _ in range(y):
    print(x, end='')
Buggy code:
a, b = map(int, input().split())
 
if a > b:
  print(str(b) * a)
else
  print(str(a) * b)

Fixed code:
a, b = map(int, input().split())
 
if a > b:
  print(str(b) * a)
else:
  print(str(a) * b)
Buggy code:
a_str, b_str = input.split()
a, b = int(a_str), int(b_str)

A = a_str*b
B = b_str*a

print(min(A, B))

Fixed code:
a_str, b_str = input().split()
a = int(a_str)
b = int(b_str)

A = a_str*b
B = b_str*a
 
print(min(A, B))
Buggy code:
a, b = input().split()

x = int(a * int(b))
y = int(b * int(a))

print(min(x, y))


Fixed code:
a, b = input().split()

x = a * int(b)
y = b * int(a)

print(min(x, y))
Buggy code:
# -*- coding: utf-8 -*-
a,b = list(map(int, input().split()))
print(max(str(a)*b, str(b)*a))

Fixed code:
# -*- coding: utf-8 -*-
a,b = list(map(int, input().split()))
print(min(str(a)*b, str(b)*a))
Buggy code:
a,b=map(int,input().split())

if a<b:
  print(str(a)*b)
else
  print(str(b)*a)

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

if a<b:
  print(str(a)*b)
else:
  print(str(b)*a)
Buggy code:
a, b=list(map(int, input().split()))
big = 0
small =0
if a > b:
  big = a
  small = b
else:
  big = b
  small = a
  
s = ""
for i in range(b):
  s += str(small)

print(s)

Fixed code:
a, b=list(map(int, input().split()))
big = 0
small =0
if a > b:
  big = a
  small = b
else:
  big = b
  small = a
  
s = ""
for i in range(big):
  s += str(small)
  
print(s)
Buggy code:
a,b = map(int,input().split())


A = str(a)
B = str(b)

c =A
d=B

for i in range(b):
    c = c+A;

for i in range(a):
    d = d+B
    
if int(c) > int(d):
    print(d)
else:
    print(c)

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


A = str(a)
B = str(b)

c =""
d=""

for i in range(b):
    c = c+A;

for i in range(a):
    d = d+B
    
if c > d:
    print(d)
else:
    print(c)
Buggy code:
hoge = input().split(" ")
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort
print(a[0])

Fixed code:
hoge = input().split(" ")
a=""
b=""
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort()
print(txt[0])
Buggy code:
N = int(input())
A = list(map(int,input().split()))

mod = 10**9 + 7

from fractions import gcd

def p_prime(n): 
    prime = [2]
    for i in range(3,n+1):
        flag = 0
        for j in prime:
            if i%j == 0:
                flag = 1
                break
            if i**0.5 < j:
                break
        if flag == 0:
            prime.append(i)
    return prime

def soinsuu(M):
    a = {}
    prime = p_prime(int(M**0.5+1))
    for p in prime:
        count = 0
        while M%p ==0:
            count += 1
            M //= p
        if count > 0:
            a[p] = count
    if M != 1:
        a[M] = 1
    return a

from collections import defaultdict
AA = defaultdict(int)

for i in range(N):
    tmp = soinsuu(A[i])
    for j in tmp:
        AA[j] = max(AA[j],tmp[j])

BB = 1
for k in AA:
    BB *= pow(k,AA[k],mod)
    BB %= mod
    
ans = 0
for i in range(N):
    ans += BB*pow(A[i],mod-2,mod)
    ans %= mod

    
print(ans%mod)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
 
def p_prime(n): 
    prime = [2]
    for i in range(3,n+1):
        flag = 0
        for j in prime:
            if i%j == 0:
                flag = 1
                break
            if i**0.5 < j:
                break
        if flag == 0:
            prime.append(i)
    return prime

prime = p_prime(int(mod**0.5+1))
def soinsuu(M):
    a = {}
    for p in prime:
        count = 0
        while M%p ==0:
            count += 1
            M //= p
        if count > 0:
            a[p] = count
    if M != 1:
        a[M] = 1
    return a

from collections import defaultdict
AA = defaultdict(int)

for i in range(N):
    tmp = soinsuu(A[i])
    for j in tmp:
        AA[j] = max(AA[j], tmp[j])
        
L = 1
for i in AA:
    L *= pow(i,AA[i],mod)

ans = 0
for i in range(N):
    ans += L*pow(A[i],mod-2,mod)
    
print(ans%mod)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    
l = 1
B = 0

for i in range(N):
  l = lcm(l,A[i])
for i in range(N):
  B += l//A[i]%mod
B %= mod

print(B)

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

import fractions
from functools import reduce

def gcd(x,y):
  if x == 0:
    return y
  else:
    return gcd(y-x*(y//x),x)
 

def lcm(x, y):
    return (x*y)//gcd(x,y)
    
l = 1
B = 0

for i in range(N):
  l = lcm(l,A[i])
for i in range(N):
  B += l//A[i]
B %= mod

print(B)
Buggy code:
import collections
import sys

readline = sys.stdin.buffer.readline


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    C = 10**9 + 7

    d = collections.defaultdict(list)

    for a in A:
        B = factorization(a)
        for b in B:
            d[b[0]].append(b[1])
    e = 1
    for k, v in d.items():
        e += k**max(v)

    ans = 0
    for a in A:
        ans += (e // a)
        ans %= C
    print(ans)


main()


Fixed code:
import collections
import sys

readline = sys.stdin.buffer.readline


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    C = 10**9 + 7

    d = collections.defaultdict(list)

    for a in A:
        B = factorization(a)
        for b in B:
            d[b[0]].append(b[1])
    e = 1
    for k, v in d.items():
        e *= k**max(v)

    ans = 0
    for a in A:
        ans += (e // a)
    print(ans % C)


main()
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()))

tg = 1
for a in A:
    tg = lcm(tg, a)
ans = 0
for a in A:
    ans += tg // a
print(ans)

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()))

tg = 1
for a in A:
    tg = lcm(tg, a)
ans = 0
for a in A:
    ans += tg // a
print(ans%(10**9+7))
Buggy code:
def read_values():
    return map(int, input().split())
 
 
def read_list():
    return list(read_values())

def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
  
    u = {}
    for a in A:
      m = 2
      while m * m <= a:
        c = 0
        while a % m == 0:
          c += 1
          a //= m
        if c > 0:
          u[m] = max(u.get(m, 0), c)
        m += 1
      if a > 1:
        u[a] = max(u.get(a, 0), 1)

    lcm = 1
    for k, v in u.items():
      lcm *= pow(k, v, mod)
      lcm %= mod

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

    print(ans)

if __name__ == "__main__":
  main()

Fixed code:
def read_values():
    return map(int, input().split())
 
 
def read_list():
    return list(read_values())

def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
  
    u = {}
    for a in A:
      m = 2
      while m * m <= a:
        c = 0
        while a % m == 0:
          c += 1
          a //= m
        if c > 0:
          u[m] = max(u.get(m, 0), c)
        m += 1
      if a > 1:
        u[a] = max(u.get(a, 0), 1)

    lcm = 1
    for k, v in u.items():
      lcm *= pow(k, v, mod)
      lcm %= mod

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

    print(ans)

if __name__ == "__main__":
  main()
Buggy code:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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


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

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

lcm_ = lcm_ % mod
ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)


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

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


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

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)
Buggy code:
import math
from collections import defaultdict, Counter

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

N = int(input())
A = [int(i) for i in input().split()]
v_list = []
mod = 10 ** 9 + 7
LCM_dict = defaultdict(int)
for i in range(N):
    prime_cnt = Counter(prime_factorize(A[i]))
    for k, v in prime_cnt.items():
        LCM_dict[k] = max(LCM_dict[k], v)
        v_list.append(prime_cnt)
ans = 0
for i in range(N):
    prime_cnt = v_list[i]
    tmp_value = 1
    for k, v in LCM_dict.items():
        cnt = 0 if k not in prime_cnt.keys() else prime_cnt[k]
        tmp_value = pow(k, v - cnt) * tmp_value
    ans += tmp_value
    ans = ans % mod
print(ans)

Fixed code:
import math
from collections import defaultdict, Counter

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

N = int(input())
A = [int(i) for i in input().split()]
v_list = []
mod = 10 ** 9 + 7
LCM_dict = defaultdict(int)
for i in range(N):
    prime_cnt = Counter(prime_factorize(A[i]))
    for k, v in prime_cnt.items():
        LCM_dict[k] = max(LCM_dict[k], v)
    v_list.append(prime_cnt)
ans = 0
for i in range(N):
    prime_cnt = v_list[i]
    tmp_value = 1
    for k, v in LCM_dict.items():
        cnt = 0 if k not in prime_cnt.keys() else prime_cnt[k]
        tmp_value = pow(k, v - cnt) * tmp_value
        tmp_value = tmp_value % mod
    ans += tmp_value
    ans = ans % mod
print(ans)
Buggy code:
m functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
n = int(input())
A = list(map(int, input().split()))
k = lcm_list(A)
r = 0
ln = list(range(n))
for i in ln:
    r += k//A[i]
print(r%(10**9+7))

Fixed code:
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

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

n = int(input())
A = list(map(int, input().split()))
k = lcm_list(A)
r = 0
ln = list(range(n))
for i in ln:
    r += k//A[i]
print(r%(10**9+7))
Buggy code:
from fractions import gcd


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


MOD = 1000000007

N = int(input())

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

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

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

ans %= MOD
print(int(ans))

Fixed code:
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


MOD = 1000000007

N = int(input())

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

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

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

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 = a[0]

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

ans = 0

for i in a:
    ans += lcm_a // i

print(ans)


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 = a[0]

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

ans = 0

for i in a:
    ans += lcm_a // i

print(ans%1000000007)
Buggy code:
def gcd(a, b):
  while(b > 0):
    a %= b
    swap(a, b)
  return a
def lcm(a, b):
  return a * b // gcd(a,b)
n = int(input())
md = int(1e9 + 7)
a = [int(e) for e in input().split()]
x = 1
for j in range(n):
  x = lcm(x, a[j])
ans = 0
for i in range(n):
  ans += lcm // a[i]
ans %= md
print(ans)

Fixed code:
def gcd(a, b):
  while(b > 0):
    a %= b
    a, b = b, a
  return a
def lcm(a, b):
  return a * b // gcd(a,b)
n = int(input())
md = int(1e9 + 7)
a = [int(e) for e in input().split()]
x = 1
for j in range(n):
  x = lcm(x, a[j])
ans = 0
for i in range(n):
  ans += x // a[i]
ans %= md
print(ans)
Buggy code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

import collections

lcm_pf = collections.defaultdict(int)
for i, v in enumerate(a):
    j = 2
    pf = {}
    while j ** 2 <= v:
        ext = 0
        while v % j == 0:
            ext += 1
            v //= j
        if ext:
            pf[j] = ext
            lcm_pf[j] = max(lcm_pf[j], ext)
        j += 1
    if v != 1:
        pf[v] = 1
        lcm_pf[v] = max(lcm_pf[v], 1)

lcm = 1
for p in lcm_pf:
    lcm = lcm * (p ** lcm_pf[p])

ans = 0
for v in a:
    #ans = ans + (lcm // v)) % MOD
    ans = ans + (lcm // v)) % MOD
print(ans % MOD)


Fixed code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

import collections

lcm_pf = collections.defaultdict(int)
for i, v in enumerate(a):
    j = 2
    pf = {}
    while j ** 2 <= v:
        ext = 0
        while v % j == 0:
            ext += 1
            v //= j
        if ext:
            pf[j] = ext
            lcm_pf[j] = max(lcm_pf[j], ext)
        j += 1
    if v != 1:
        pf[v] = 1
        lcm_pf[v] = max(lcm_pf[v], 1)

lcm = 1
for p in lcm_pf:
    lcm = lcm * (p ** lcm_pf[p])

ans = 0
for v in a:
    ans = ans + (lcm // v)
print(ans % MOD)
Buggy code:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(input().split()))
s=1
for a in A:
    s=lcm(s,i)
ans=0
for a in A:
    ans+=s//i
print(ans%(10**9+7))

Fixed code:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))
Buggy code:
def gcd(a,b):
    if not b: 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()))
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l/x)
    if ans > mod: ans %= MOD
print(ans)


Fixed code:
def gcd(a,b):
    if not b: 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()))
l = 1
ans, mod = 0, 1000000007

for x in A:
    l = lcm(l, x)

for x in A:
    ans = ans + l//x
print(ans % mod)
Buggy code:
from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

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

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

def addmod(a, b):
    return (a+b) % MOD
  
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

l = reduce(lcm, a_list) % MOD
ans = reduce(addmod, (l//a for a in a_list))

print(ans)

Fixed code:
from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

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

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

def lcm_list(l:list):
    return reduce(lcm, l, 1)
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

num = lcm_list(a_list) % MOD
ans = 0
for a in a_list:
    ans += (num * pow(a, MOD-2, MOD)) % MOD

print(ans%MOD)
Buggy code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd % MOD

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)

Fixed code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

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

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)
Buggy code:
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))

MOD=10**9+7

primes=[]
is_prime=[True]*(10**3)
for i in range(2,10**3):
    if not is_prime[i]: continue
    primes.append(i)
    for j in range(2*i,10**3,i):
        is_prime[j]=False

LCM=defaultdict(int)
for i in range(N):
    n=A[i]
    for j,p in enumerate(primes):
        tmp=0
        while n%p==0:
            tmp+=1
            n//=p
        LCM[j]=max(LCM[j],tmp)
    if n!=1:
        LCM[n]=max(LCM[j],1)
l=1
for p,n in LCM.items():
    l=l*pow(p,n,MOD)%MOD

ans=0
for a in A:
    ans+=l*pow(a,MOD-2,MOD)
    ans%=MOD

print(ans)

Fixed code:
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))

MOD=10**9+7

primes=[]
is_prime=[True]*(10**3)
for i in range(2,10**3):
    if not is_prime[i]: continue
    primes.append(i)
    for j in range(2*i,10**3,i):
        is_prime[j]=False

LCM=defaultdict(int)
for n in A:
    for p in primes:
        tmp=0
        while n%p==0:
            tmp+=1
            n//=p
        LCM[p]=max(LCM[p],tmp)
    if n!=1:
        LCM[n]=max(LCM[n],1)
l=1
for p,n in LCM.items():
    l=l*pow(p,n,MOD)%MOD

ans=0
for a in A:
    ans+=l*pow(a,MOD-2,MOD)
    ans%=MOD

print(ans)
Buggy code:
import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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

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

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]%mod

print(ans%mod)


Fixed code:
import sys

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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

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

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]

print(ans%mod)
Buggy code:
from fractions import gcd

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

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)


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

print(ans % MOD)

Fixed code:
from math import gcd

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

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)


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


print(ans % MOD)
Buggy code:
import sys

n = int(input())
a = [int(x) for x in input().split()]
am = max(a)
mod = 10**9+7
if n==1:
    print(1)
    sys.exit()
li = [0]*(am+1)
lcm = 1
for k in range(n):
    z = a[k]
    for i in range(2,int(z**0.5)+1):
        x = 0
        while z%i==0:
            x += 1
            z//=i
        li[i] = max(li[i],x)
    if z!=1 :
        li[z] = 1

for i in range(2,am+1):
    if li[i]>0:
        lcm = (lcm*i*li[i])%mod

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

Fixed code:
import sys

n = int(input())
a = [int(x) for x in input().split()]
am = max(a)
mod = 10**9+7
if n==1:
    print(1)
    sys.exit()
li = [0]*(am+1)
lcm = 1
for k in range(n):
    z = a[k]
    for i in range(2,int(z**0.5)+1):
        x = 0
        while z%i==0:
            x += 1
            z//=i
        li[i] = max(li[i],x)
    if z!=1 and li[z]==0:
        li[z] = 1

for i in range(2,am+1):
    if li[i]>0:
        lcm = lcm * i**li[i] % mod

ans = 0
for i in range(n):
    m = pow(a[i],mod-2,mod)
    ans = (ans+(lcm*m)%mod)%mod
print(ans%mod)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        primes[a] = 1

lcm = 1
for p in primes.value():
    lcm *= pow(p, primes[p], MOD) % MOD

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

print(ans)

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

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        if a not in primes:
            primes[a] = 1

lcm = 1
for p in primes:
    lcm = lcm * pow(p, primes[p], MOD) % MOD

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

print(ans)
Buggy code:
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 = int(input())
mod = 1e9 + 7
a = [int(i) for i in input().split()]
ans = 1    
for i in a:
    ans = lcm(ans,i)

print(sum(ans//i for i in a)%mod)


Fixed code:
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 = int(input())
mod = int(1e9 + 7)
a = [int(i) for i in input().split()]
ans = int(1)
for i in a:
    ans = lcm(ans,i)

print(sum(ans//i for i in a)%mod)