Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

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

inip = 1 
for i in range(k):
    inip *= a[i]

# p = [inip]

p = [-1 for _ in range(n-k+1)]
p[0] = inip

tmp = inip
#print('inip =', inip)

for i in range(k, n): 
    s = tmp//a[i-k]*a[i]
    # p.append(s)
    p[i-k+1] = s 
    tmp = s 

# print('p =', p)

for i in range(len(p)-1):
    if p[i+1] > p[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python

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

for i in range(n-k):
    if a[i] < a[i+k]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

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

inip = 1 
for i in range(k):
    inip *= a[i]

p = [inip]
tmp = inip

for i in range(k, n): 
    s = tmp//a[i-k]*a[i]
    p.append(s)
    tmp = s 

for i in range(len(p)-1):
    if p[i+1] > p[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python

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

for i in range(n-k):
    if a[i] < a[i+k]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

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

inip = 1 
for i in range(k):
    inip *= a[i]

p = [inip]
tmp = inip

for i in range(k, n): 
    s = tmp//a[i-k]*a[i]
    p.append(s)
    tmp = s 

for i in range(len(p)-1):
    if p[i+1] > p[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python

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

for i in range(n-k):
    if a[i] < a[i+k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]
visited = []

def dfs(x, y, z): 
    if x+y+z > m or (x, y, z) in visited:
        return
    if p(x, y, z)-1 <= n-1:
        anss[p(x, y, z)-1] += 1
        visited.append((x, y, z)) 
        dfs(x+1, y, z)
        dfs(x, y+1, z)
        dfs(x, y, z+1)

# output
dfs(1,1,1)
for i in range(n):
    print(anss[i])


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]

for x in range(1, m): 
    for y in range(1, m): 
        for z in range(1, m): 
            if p(x, y, z)-1 <= n-1:
                anss[p(x, y, z)-1] += 1

for i in range(n):
    print(anss[i])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]
visited = []

def dfs(x, y, z): 
    if x+y+z > m or (x, y, z) in visited:
        return
    if p(x, y, z)-1 <= n-1:
        anss[p(x, y, z)-1] += 1
        visited.append((x, y, z)) 
        dfs(x+1, y, z)
        dfs(x, y+1, z)
        dfs(x, y, z+1)

# output
dfs(1,1,1)
for i in range(n):
    print(anss[i])


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]

for x in range(1, m): 
    for y in range(1, m): 
        for z in range(1, m): 
            if p(x, y, z)-1 <= n-1:
                anss[p(x, y, z)-1] += 1

for i in range(n):
    print(anss[i])

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]
visited = []

def dfs(x, y, z): 
    if x+y+z > m or (x, y, z) in visited:
        return
    anss[p(x, y, z)-1] += 1
    visited.append((x, y, z)) 
    dfs(x+1, y, z)
    dfs(x, y+1, z)
    dfs(x, y, z+1)

# output
dfs(1,1,1)
for i in range(n):
    print(anss[i])


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
m = int(math.sqrt(n))+1
x = y = z = 0 

def p(x, y, z): 
    return x*x + y*y + z*z + x*y + y*z + z*x 

anss = [0 for _ in range(n)]

for x in range(1, m): 
    for y in range(1, m): 
        for z in range(1, m): 
            if p(x, y, z)-1 <= n-1:
                anss[p(x, y, z)-1] += 1

for i in range(n):
    print(anss[i])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

ans = 0 
time = 0 

while time <= k:
#    print('time =', time)
#    print('a =', a)
#    print('b =', b)

    if len(a) > 0:
        if a[0] <= b[0]:
            if len(a) > 0:
                time += a[0]
                ans += 1
                a.pop(0)
            elif len(b) > 0:
                time += b[0]
                ans += 1
                b.pop(0)
        else:
            if len(b) > 0:
                time += b[0]
                ans += 1
                b.pop(0)
            elif len(a) > 0:
                time += a[0]
                ans += 1
                a.pop(0)

    elif len(b) > 0:
        time += b[0]
        ans += 1
        b.pop(0)

    if len(a) == 0 and len(b) == 0:
        break

if time == k:
    print(ans)
else:
    print(ans-1)

Fixed submission:
#!/usr/bin/env python3
# binary search 1

from bisect import bisect_left, bisect_right

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

cumsum_b = [0 for _ in range(m+1)]
for i in range(1,m+1):
    cumsum_b[i] = cumsum_b[i-1] + b[i-1]
cumsum_a = [0 for _ in range(n+1)]
for i in range(1,n+1):
    cumsum_a[i] = cumsum_a[i-1] + a[i-1]

# print('cumsum_b =', cumsum_b)
ans = -1
for i in range(n+1):
    res = k-cumsum_a[i]
#    print('cumsum_a[{}] ='.format(i), cumsum_a[i])
#    print('res =', res)
    if res < 0:
        break
    bl = bisect_right(cumsum_b, res) - 1 
#    print('i =', i)
#    print('bl =', bl)
    tmp = i + bisect_right(cumsum_b, res) - 1 
    if ans <= tmp:
        ans = tmp 

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# O(NlogN) 

n = int(input())
ans = 0 
for i in range(1, n+1):
    for j in range(i, n+1, i): 
        ans += j
print(ans)


Fixed submission:
#!/usr/bin/env python3
# O(NlogN)

n = int(input())

div = [0 for _ in range(n+1)]
for i in range(1, n+1):
    ti = i 
    while True:
        if ti > n:
            break
        div[ti] += 1 
        ti += i
ans = 0 
for i in range(1, n+1):
    ans += i*div[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# O(NlogN)

n = int(input())

div = [0 for _ in range(n+1)]
for i in range(1, n+1):
    ti = i 
    while True:
        if ti > n:
            break
        div[ti] += 1 
        ti += i
ans = 0 
for i in range(1, n+1):
    ans += i*div[i]
print(ans)


Fixed submission:
#!/usr/bin/env python3
# O(NlogN)

n = int(input())

div = [0 for _ in range(n+1)]
for i in range(1, n+1):
    ti = i 
    while True:
        if ti > n:
            break
        div[ti] += 1 
        ti += i
ans = 0 
for i in range(1, n+1):
    ans += i*div[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

# input
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [-1 for _ in range(q)]
c = [-1 for _ in range(q)]
for i in range(q):
    b[i], c[i] = map(int, input().split())

def innerproduct(d):
    ans = 0
    for key, value in d.items():
        ans += int(key)*int(value)
    return ans

# calc
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

# print(d)
ans = sum(a)
for i in range(q):
    if b[i] in d:
        # ans -= b[i]*d[b[i]]
        if c[i] not in d:
            d[c[i]] = d[b[i]]
        else:
            d[c[i]] += d[b[i]]
        # tmp = d[b[i]]
        d[b[i]] = 0
        # ans += tmp*d[c[i]]

    #print(d)
    print(innerproduct(d))

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

# input
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [-1 for _ in range(q)]
c = [-1 for _ in range(q)]
for i in range(q):
    b[i], c[i] = map(int, input().split())

def innerproduct(d):
    ans = 0
    for key, value in d.items():
        ans += int(key)*int(value)
    return ans

# calc
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

# print(d)
ans = sum(a)
for i in range(q):
    if b[i] in d:
        ans -= b[i]*d[b[i]]
        tmp = d[b[i]]
        if c[i] not in d:
            d[c[i]] = d[b[i]]
        else:
            d[c[i]] += d[b[i]]
        d[b[i]] = 0
        ans += tmp*c[i]

#    print(d)
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

x, n = map(int, input().split())
p = list(map(int, input().split()))

d = [0 for _ in range(100)]
for i in range(100):
    d[i] = i+1 

for i in p:
    d.remove(i)

d2 = [0 for _ in range(len(d))]
for i in range(len(d)):
    d2[i] = abs(d[i]-x)

m = 1000

for i in reversed(range(len(d2))):
    if d2[i] <= m:
        m = d2[i]
        tmpi = i 

print(d[tmpi])


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

x, n = map(int, input().split())
p = list(map(int, input().split()))

d = [0 for _ in range(201)]
for i in range(-100, 101):
    d[i+100] = i+1 

for i in p:
    d.remove(i)

d2 = [0 for _ in range(len(d))]
for i in range(len(d)):
    d2[i] = abs(d[i]-x)

m = 10000
for i in reversed(range(len(d2))):
    if d2[i] <= m:
        m = d2[i]
        tmpi = i 

print(d[tmpi])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# TLE解

import numpy as np

n, k = map(int, input().split())
MOD = int(1e9+7)
rem = (10*100)%MOD 
ans = 0 

# i個取るとき
for i in range(k, n+2):
    #print('i =', i)
    minimum = np.arange(i).sum()
    maximum = np.arange(n, n-i, -1).sum()
    #print('minimum =', minimum)
    #print('maximum =', maximum)
    #print(maximum-minimum+1)
    ans += (maximum-minimum+1)%MOD

print(ans%MOD)


Fixed submission:
#!/usr/bin/env python3
import numpy as np

n, k = map(int, input().split())
MOD = int(1e9+7)
rem = (10*100)%MOD 
ans = 0 

for i in range(k, n+2):
    if i == k:
        minimum = np.arange(i).sum()
        maximum = np.arange(n, n-i, -1).sum()
    else:
        minimum += i-1 
        maximum += n-i+1
    ans += (maximum-minimum+1)%MOD

print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import bisect

n = int(input())
s = list(input())
rind = []
gind = []
bind = []

for index, val in enumerate(s):
    if val == 'R':
        rind.append(index)
    if val == 'G':
        gind.append(index)
    if val == 'B':
        bind.append(index)

# 1つめの条件を満たすものを求めてから
# 2つめの条件を満たすものを引く
ans = len(rind)*len(gind)*len(bind)
sans = 0
# R,G,B
for i in rind:
    for j in gind:
        if i < j and (j-i)+j in bind:
            sans += 1
# R,B,G
for i in rind:
    for j in bind:
        if i < j and (j-i)+j in gind:
            sans += 1
# G,B,R
for i in gind:
    for j in bind:
        if i < j and (j-i)+j in rind:
            sans += 1
# G,R,B
for i in gind:
    for j in rind:
        if i < j and (j-i)+j in bind:
            sans += 1
# B,R,G
for i in bind:
    for j in rind:
        if i < j and (j-i)+j in gind:
            sans += 1
# B,G,R
for i in bind:
    for j in gind:
        if i < j and (j-i)+j in rind:
            sans += 1

print(ans-sans)

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

n = int(input())
s = list(input())

rnum = s.count('R')
gnum = s.count('G')
bnum = s.count('B')
ans = rnum * gnum * bnum
for i in range(n):
    for j in range(n):
        d = i+j 
        f = d+j 
        if f>=n:
            break
        if s[i]!=s[d] and s[d]!=s[f] and s[f]!=s[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import bisect

n = int(input())
s = list(input())
rind = []
gind = []
bind = []

for index, val in enumerate(s):
    if val == 'R':
        rind.append(index)
    if val == 'G':
        gind.append(index)
    if val == 'B':
        bind.append(index)

# 1つめの条件を満たすものを求めてから
# 2つめの条件を満たすものを引く
ans = len(rind)*len(gind)*len(bind)
sans = 0
# R,G,B
for i in rind:
    for j in gind:
        if i < j and (j-i)+j in bind:
            sans += 1
# R,B,G
for i in rind:
    for j in bind:
        if i < j and (j-i)+j in gind:
            sans += 1
# G,B,R
for i in gind:
    for j in bind:
        if i < j and (j-i)+j in rind:
            sans += 1
# G,R,B
for i in gind:
    for j in rind:
        if i < j and (j-i)+j in bind:
            sans += 1
# B,R,G
for i in bind:
    for j in rind:
        if i < j and (j-i)+j in gind:
            sans += 1
# B,G,R
for i in bind:
    for j in gind:
        if i < j and (j-i)+j in rind:
            sans += 1

print(ans-sans)

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

n = int(input())
s = list(input())

rnum = s.count('R')
gnum = s.count('G')
bnum = s.count('B')
ans = rnum * gnum * bnum
for i in range(n):
    for j in range(n):
        d = i+j 
        f = d+j 
        if f>=n:
            break
        if s[i]!=s[d] and s[d]!=s[f] and s[f]!=s[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import pandas as pd

n ,m = map(int, input().split())
a = pd.Series(list(map(int, input().split())))
t = a >= a.sum() * 1/(4*m)
if t.sum() >= m:
    print('Yes')
else:
    print('No')

Fixed submission:
#!/usr/bin/env python3
import numpy as np

n ,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
t = a >= a.sum() * 1/(4*m)
if t.sum() >= m:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

x = int(input())
a = x//500
x -= a*500
b = x//5
print(a*1000+b*5)
~                  

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

x = int(input())
a = x//500
x -= a*500
b = x//5
print(a*1000+b*5)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math

a, b = map(int, input().split())
x = math.floor((a-1)/0.08)
y = math.floor((a+1)/0.08)
z = math.floor((b-1)/0.1)
w = math.floor((b+1)/0.1)

if y<z:
    print(-1)
    exit(0)

ans = []
for i in range(min(x,z), min(y,w)):
    if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
        ans.append(i)

if len(ans) == 0:
    print(-1):
else:
    print(min(ans))


Fixed submission:
#!/usr/bin/env python3
import math

a, b = map(int, input().split())
x = math.floor((a-1)/0.08)
y = math.floor((a+1)/0.08)
z = math.floor((b-1)/0.1)
w = math.floor((b+1)/0.1)

if y<z:
    print(-1)
    exit(0)

ans = []
for i in range(min(x,z), min(y,w)):
    if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math

a, b = map(int, input().split())
x = math.floor((a-1)/0.08)
y = math.floor((a+1)/0.08)
z = math.floor((b-1)/0.1)
w = math.floor((b+1)/0.1)

if y<z:
    print(-1)
    exit(0)

ans = []
for i in range(min(x,z), min(y,w)):
    if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
        ans.append(i)

print(min(ans))


Fixed submission:
#!/usr/bin/env python3
import math

a, b = map(int, input().split())
x = math.floor((a-1)/0.08)
y = math.floor((a+1)/0.08)
z = math.floor((b-1)/0.1)
w = math.floor((b+1)/0.1)

if y<z:
    print(-1)
    exit(0)

ans = []
for i in range(min(x,z), min(y,w)):
    if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import collections

# input
n = int(input())
s = []
for i in range(n):
    s.append(input())

# calc
s2 = sorted(set(s))
times = []

for word in s2: 
    times.append(s.count(word)) 

maxtimes = max(times)
answords = []

for i in range(len(s2)):
    if maxtimes == times[i]:
        answords.append(s2[i])

answords = sorted(answords)
for word in answords:
    print(word)


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

n = int(input())
s = [input() for _ in range(n)]

d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 
ans = []
m = max(d.values())
for k, v in d.items():
    if v == m:
        ans.append(k)

for s in sorted(ans):
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import collections

# input
n = int(input())
s = []
for i in range(n):
    s.append(input())

# calc
s2 = sorted(set(s))
times = []

for word in s2: 
    times.append(s.count(word)) 

maxtimes = max(times)
answords = []

for i in range(len(s2)):
    if maxtimes == times[i]:
        answords.append(s2[i])

answords = sorted(answords)
for word in answords:
    print(word)


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

n = int(input())
s = [input() for _ in range(n)]

d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 
ans = []
m = max(d.values())
for k, v in d.items():
    if v == m:
        ans.append(k)

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

int main(void){

  int n,k;
  vector<int> p(n);
  cin >> n >> k;
  for(int i=0; i<n ; ++i){
    cin >> p.at(i);
  }
  vector<double> exps;
  vector<double> sums;

  for(int i=0; i<n ; ++i){
    double tmp = 0.0;
    for(int j=1 ; j <= p[i] ; ++j){
      tmp += j;
    }   
    tmp /= p[i];
    exps.push_back(tmp);
  }

  for(int i=0; i<n-(k-1) ; ++i){
    double tmp = 0;
    for(int j=0; j<k ; ++j){
      tmp += exps.at(i+j);
    }   
    sums.push_back(tmp);
  }

  sort(sums.begin(), sums.end(), greater<double>());

  // for debug
//  cout << "exps" << endl;
//  for(auto a: exps){
//    cout << a << ", " ;
//  }
//  cout << endl;
//  cout << "sums" << endl;
//  for(auto a: sums){
//    cout << a << ", " ;
//  }
//  cout << endl;

  cout << sums.at(0) << endl;

  return 0;
}

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

import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
exps = []

for i in range(n):
    #exps.append(sum(list(range(1, p[i]+1)))/p[i])
    exps.append((1+p[i])/2)

exps = np.array(exps)
cumexps = exps.cumsum()
cumexps = np.insert(cumexps, 0, 0)

#print(exps)
#print(cumexps)

ans = -1
for i in range(n-k+1):
    tmp = -cumexps[i] + cumexps[i+k]
    if ans <= tmp:
        ans = tmp 

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

n, k = map(int, input().split())
p = list(map(int, input().split()))
exps = []

for i in range(n):
    exps.append(sum(list(range(1, p[i]+1)))/p[i])

sums = []
for i in range(n-(k-1)):
    tmp = 0 
    for j in range(k):
        tmp += exps[i+j]
    sums.append(tmp)

ans = max(sums)
print(ans)


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

import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
exps = []

for i in range(n):
    #exps.append(sum(list(range(1, p[i]+1)))/p[i])
    exps.append((1+p[i])/2)

exps = np.array(exps)
cumexps = exps.cumsum()
cumexps = np.insert(cumexps, 0, 0)

#print(exps)
#print(cumexps)

ans = -1
for i in range(n-k+1):
    tmp = -cumexps[i] + cumexps[i+k]
    if ans <= tmp:
        ans = tmp 

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
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)

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

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

print(ans%mod)


Fixed submission:
#!/usr/bin/env python
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)

l = a[0]
for i in range(n):
    l = lcm(l, a[i])
l %= mod 

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

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

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

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

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

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

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

print(ans%mod)


Fixed submission:
#!/usr/bin/env python
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)

l = a[0]
for i in range(n):
    l = lcm(l, a[i])
l %= mod 

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

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
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)

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

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

print(ans%mod)


Fixed submission:
#!/usr/bin/env python
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)

l = a[0]
for i in range(n):
    l = lcm(l, a[i])
l %= mod 

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

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
from functools import *
import math

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

p = 1 
for i in range(n):
    p *= a[i]

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

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

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

print(ans%mod)


Fixed submission:
#!/usr/bin/env python
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)

l = a[0]
for i in range(n):
    l = lcm(l, a[i])
l %= mod 

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

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a*b/math.gcd(a,b)))


Fixed submission:
#!/usr/bin/env python3
from fractions import gcd 
a, b = map(int, input().split())
print(int(a*b/gcd(a,b)))