Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a>=13:
	print(b)
elif a<=5:
	print(0)
elif a>=6 and a<=12 
	print(b/2)

Fixed submission:
a,b=map(int,input().split())
if a<=5:
   print(0)
elif a<=12:
   print(b//2)
else:
   print(b)

Buggy python submission (verdict: Runtime Error):

a,b = map(int,input().split())
if a>=13:
	print(b)
elif a<=5:
	print(0)
else:
	print(b/2) a,b = map(int,input().split())
if a>=13:
	print(b)
elif a<=5:
	print(b*0)
else:
	print(b/2)

Fixed submission:
a,b=map(int,input().split())
if a<=5:
   print(0)
elif a<=12:
   print(b//2)
else:
   print(b)

Buggy python submission (verdict: Runtime Error):

a,b = map(int,input().split())
if a>=13:
	print(b)
elif a<=5:
	print(0)
else:
	print(b/2) a,b = map(int,input().split())
if a>=13:
	print(b)
elif a<=5:
	print('a')
else:
	print(b/2)

Fixed submission:
a,b=map(int,input().split())
if a<=5:
   print(0)
elif a<=12:
   print(b//2)
else:
   print(b)
Buggy python submission (verdict: Runtime Error):
print(a=list(input())
b=0
for i in range(3):
	if a[i]=='1':
		b=b+1
print(b)

Fixed submission:
a=list(input())
b=0
if a[0]=='1':
	b=b+1
if a[1]=='1':
	b=b+1
if a[2]=='1':
	b=b+1
print(b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(sum(sorted(map(int, input()))[::2]))

Fixed submission:
n = int(input())
print(sum(sorted(list(map(int, input().split())))[::2]))
Buggy python submission (verdict: Runtime Error):

def solve():
    ans = 0
    n=int(input())
    for i in range(1,n+1):
        div_list = []
        for j in range(1,int(i**0.5)+1):
            if i%j!=0:
                continue
            if i//j==j:
                div_list.append(j)
            else:
                div_list.append(i//j)
                div_list.append(j)
        if len(div_list)==8:
            ans=+=1
    print(ans)

if __name__ == '__main__':
    solve()

Fixed submission:
ans = 0
def solve(n):
    global ans
    for i in range(1,n+1,2):
        div_list=[]
        for j in range(1,int((i+1)**0.5)+1):
            if i % j == 0:
                if (i//j)!=j:
                    div_list.append(i//j)
                    div_list.append(j)
                else:
                    div_list.append(j)
        if len(div_list) == 8:
            ans+=1

def main():
    n=int(input())
    solve(n)
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):

def solve():
    ans = 0
    n=int(input())
    for i in range(1,n+1):
        div_list = []
        for j in range(1,int(i**0.5)+1):
            if i%j!=0:
                continue
            if i//j==j:
                div_list.append(j)
            else:
                div_list.append(i//j)
                div_list.append(j)
        if len(div_list)=8:
            ans=+=1
    print(ans)

if __name__ == '__main__':
    solve()

Fixed submission:
ans = 0
def solve(n):
    global ans
    for i in range(1,n+1,2):
        div_list=[]
        for j in range(1,int((i+1)**0.5)+1):
            if i % j == 0:
                if (i//j)!=j:
                    div_list.append(i//j)
                    div_list.append(j)
                else:
                    div_list.append(j)
        if len(div_list) == 8:
            ans+=1

def main():
    n=int(input())
    solve(n)
    print(ans)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
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

h,w,m = map(int,input().split())
grid = [[0] * w for i in range(h)]
# print(*grid,sep= "\n")
for _ in range(m):
  i,j = map(int,input().split())
  i-=1
  j-=1
  grid[i][j] += 1
tate = [0] * w
yoko = [0] * h
for i in range(h):
  yoko[i] = sum(grid[i])
for j in range(w):
  tmp = 0
  for i in range(h):
    tmp += grid[i][j]
  tate[j] = tmp
for i in range(h):
  for j in range(w):
    ans = max(ans,yoko[i] + tate[j]-grid[i][j])
print(ans)
# print(tate)
# print(yoko)

Fixed submission:
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

h,w,m = map(int,input().split())
yoko = [0] * h
tate = [0] * w
S = set()
for _ in range(m):
  i,j = map(int,input().split())
  i-=1
  j-=1
  yoko[i] += 1
  tate[j] += 1
  S.add((i,j))
MY = max(yoko)
MT = max(tate)
max_yokos = []
max_tates = []
for i in range(h):
  if yoko[i] == MY:
    max_yokos.append(i)
for j in range(w):
  if tate[j] == MT:
    max_tates.append(j)
lmy = len(max_yokos)
lmt = len(max_tates)
for i in max_yokos:
  for j in max_tates:
    if not (i,j) in S:
      print(MY + MT)
      exit()
print(MY + MT - 1)


# print(tate)
# print(yoko)
Buggy python submission (verdict: Time Limit Exceeded):
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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n = int(input())
A = list(map(int,input().split()))
data = [0] * (10**6+1)
for i in range(n):
  data[A[i]] += 1
for i in range(n):
  divisors = make_divisors(A[i])
  for divi in divisors:
    if  data[divi] != (1 if A[i] == divi else 0):
      # print(i,divi)
      break
  else:
    count += 1
    # print(i)
print(count)

# print(data[:25])


Fixed submission:
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

def primes(array,n):
    C = collections.Counter(array)
    count = 0
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    for i in array:
      if is_prime[i]:
        if C[i] == 1: count += 1
        for j in range(i, n + 1, i):
            is_prime[j] = False
    return count

n = int(input())
A = list(map(int,input().split()))
A.sort()
data = [0] * (10**6+1)


print(primes(A,10**6))
Buggy python submission (verdict: Time Limit Exceeded):
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,m = map(int,input().split())
G = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)


que = collections.deque()
que.append([0])
visited = [0] * n
visited[0] = []
while que:
  way = que.popleft()
  for gi in G[way[-1]]:
    if visited[gi] == 0:
      visited[gi] = way 
      que.append(way + [gi])
for vi in visited:
  if vi == 0:
    print("No")
else:
  print("Yes")
  for i in range(1,n):
    print(visited[i][-1]+1)

Fixed submission:
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,m = map(int,input().split())
G = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)


que = collections.deque()
que.append(0)
visited = [-1] * n
visited[0] = 0
while que:
  way = que.popleft()
  for gi in G[way]:
    if visited[gi] == -1:
      visited[gi] = way + 1
      que.append(gi)
# print(*visited)
for vi in visited:
  if vi == -1:
    print("No")
    exit()
else:
  print("Yes")
  for i in range(1,n):
    print(visited[i])
Buggy python submission (verdict: Runtime Error):
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 = 1 ;count = 0 ;pro = 1
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

n = int(input())
def make_key0(a,b):
  if (a < 0 and b > 0) or (a > 0 and b < 0):hugou = 1
  else: hugou = -1
  a = abs(a)
  b = abs(b)
  G = gcd(a,b)
  return (hugou*(abs(a)//G),abs(b)//G)

def make_key1(a,b):
  if (a < 0 and b > 0) or (a > 0 and b < 0):hugou = -1
  else: hugou = 1
  a = abs(a)
  b = abs(b)
  G = gcd(a,b)
  return (hugou*(abs(b)//G),abs(a)//G)

C0 = collections.Counter()
C1 = collections.Counter()

for i in range(n):
  a,b = map(int,input().split())
  a0,b0 = make_key0(a,b)
  a1,b1 = make_key1(a,b)
  C0[(a0,b0)] += 1
  # C1[(a1,b1)] += 1
  # print(a0,b0,a1,b1)

S = set()
for key,val in C0.items():
  a0,b0 = key
  S.add((a0,b0))
  a1,b1 = make_key0(b0,a0)
  if (a1,b1) in S:continue
  # print((a0,b0))
  # print((a1,b1))
  # print((pow(2,val,mod) , pow(2,C0[(a1,b1)],mod)))
  # print((-1 if C0[(a1,b1)] else 0),C0[(a1,b1)])
  ans *= pow(2,val,mod) + pow(2,C0[(a1,b1)],mod) -1
  ans %= mod
print((ans-1)%mod)

# for key,val in C0.items():
#   print(key,val)

# for key,val in C1.items():
#   print(key,val)

Fixed submission:
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 = 1 ;count = 0 ;pro = 1
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

n = int(input())
def make_key0(a,b):
  if a == 0 and b != 0:
    return(0,1)
  elif a != 0 and b == 0:
    return(1,0)
  if (a < 0 and b > 0) or (a > 0 and b < 0):hugou = 1
  else: hugou = -1
  a = abs(a)
  b = abs(b)
  G = gcd(a,b)
  return (hugou*(abs(a)//G),abs(b)//G)

C0 = collections.Counter()

for i in range(n):
  a,b = map(int,input().split())
  if (a,b) == (0,0) :count += 1
  else:
    a0,b0 = make_key0(a,b)
    C0[(a0,b0)] += 1

S = set()
for key,val in C0.items():
  a0,b0 = key
  S.add((a0,b0))
  a1,b1 = make_key0(b0,a0)
  if (a1,b1) in S:continue
  ans *= pow(2,val,mod) + pow(2,C0[(a1,b1)],mod) -1
  ans %= mod
ans += count 
print((ans-1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/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
sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
E = [list(map(int,input().split())) for i in range(q)]
def dfs(l,string):
  global ans
  if l == n: ans = max(ans,check(string));return
  for i in range(int(string[-1]),m+1):
    dfs(l+1,string+str(i))

def check(string):
  re = 0
  for a,b,c,d in E:
    if int(string[b])-int(string[a]) == c:
      re += d
  return re
dfs(0,"1")
print(ans)

Fixed submission:
#!/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,m,q = map(int,input().split())
E = [tuple(map(int,input().split())) for i in range(q)]
A = list(itertools.combinations_with_replacement(range(1,m+1),n))
for comb in A:
  tmp = 0
  for a,b,c,d in E:
    a-=1;b-=1
    if comb[b]-comb[a] == c:
      tmp += d
  ans = max(ans,tmp)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/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
sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
E = [list(map(int,input().split())) for i in range(q)]
def dfs(l,string):
  global ans
  if l == n: ans = max(ans,check(string));return
  for i in range(int(string[-1]),m+1):
    dfs(l+1,string+str(i))

def check(string):
  re = 0
  for a,b,c,d in E:
    if int(string[b])-int(string[a]) == c:
      re += d
  return re
dfs(0,"1")
print(ans)

Fixed submission:
#!/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,m,q = map(int,input().split())
E = [tuple(map(int,input().split())) for i in range(q)]
A = list(itertools.combinations_with_replacement(range(1,m+1),n))
for comb in A:
  tmp = 0
  for a,b,c,d in E:
    a-=1;b-=1
    if comb[b]-comb[a] == c:
      tmp += d
  ans = max(ans,tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/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,k = map(int,input().split())
data = [0] * (k+1)
for i in range(k,0,-1):
  tmp =  (k//i) ** n
  for j in range(i+i,k+1,i):
    tmp -= data[j]
  data[i] = tmp % mod
ans = 0
for i,di in enumerate(data):
  ans += i * di
  ans %= mod
print(ans)

Fixed submission:
#!/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,k = map(int,input().split())
data = [0] * (k+1)
for i in range(k,0,-1):
  tmp = pow(k//i,n,mod)
  for j in range(i+i,k+1,i):
    tmp -= data[j]
  data[i] = tmp % mod
ans = 0
for i,di in enumerate(data):
  ans += i * di
  ans %= mod
print(ans)
# print(data)
Buggy python submission (verdict: Runtime Error):
#!/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())
for i in range(2,min(n-1,int(n**.5)+1)):
# for i in range(2,n*+1):
  if n % i == 0:
    tmp = n

    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1
  
    if tmp //i ==
    tmp = n; i = n // i
    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1

  elif (n-1) % i == 0:ans += 2

if n != 1:ans += 2
else: ans += 1
print(ans)


Fixed submission:
#!/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())
for i in range(2,min(n-1,int(n**.5)+1)):
# for i in range(2,n*+1):
  if n % i == 0:
    tmp = n

    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1

    if n //i == i or n //i == n or n // i == n-1:continue

    tmp = n; i = n // i
    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1

  elif (n-1) % i == 0:
    if (n-1)//i != i and  (n-1) //i != n and (n-1) // i != n-1:ans += 2
    else: ans += 1

if n != 2:ans += 2
else: ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/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

a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = min(A); b=min(B)
mans = a+b
for _ in range(m):
  x,y,c = map(int,input().split())
  x-=1;b-=1
  tmp = A[x] + B[x] - c
  mans = min(mans,tmp)
print(mans)

Fixed submission:
#!/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

a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = min(A); b=min(B)
mans = a+b
for _ in range(m):
  x,y,c = map(int,input().split())
  x-=1;y-=1
  tmp = A[x] + B[y] - c
  mans = min(mans,tmp)
print(mans)
Buggy python submission (verdict: Runtime Error):
#!/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())
G = [[] for i in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b-=1
  G[a].append(b)
  G[b].append(a)
ans = [0] * n
color = [[],[]]
def coloring(node,pre,oddeven):
  color[oddeven%2].append(node)
  for vi in G[node]:
    if vi != pre:
      coloring(vi,node,oddeven+1)
  return

coloring(0,-1,0)
A = n//3 + int(bool(n%3))
B = n//3 + int(n%3 == 2)
# この時点ではA>=Bである
if color[0] < color[1]:
  A,B = B,A
a=b=0; c=1
for i,ci in enumerate(color[0]):
  if i < A:
    ans[ci] = 3 * i + 1
  else:
    ans[ci] = 3 * c
    c += 1

for i,ci in enumerate(color[1]):
  if i < B:
    ans[ci] = 3 * i + 2
  else:
    ans[ci] = 3 * c
    c += 1
print(*ans)




Fixed submission:
#!/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
sys.setrecursionlimit(10**7)

n = int(input())
G = [[] for i in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b-=1
  G[a].append(b)
  G[b].append(a)
ans = [0] * n
color = [[],[]]
def coloring(node,pre,oddeven):
  color[oddeven%2].append(node)
  for vi in G[node]:
    if vi != pre:
      coloring(vi,node,oddeven+1)
  return

coloring(0,-1,0)
A = n//3 + int(bool(n%3))
B = n//3 + int(n%3 == 2)
C = n//3
# この時点ではA>=Bである
# if len(color[0]) < len(color[1]):
#   A,B = B,A
a=b=0; c=1
if len(color[0]) > C and len(color[1]) > C:
  for i,ci in enumerate(color[0]):
    if i < A:
      ans[ci] = 3 * i + 1
    else:
      ans[ci] = 3 * c
      c += 1

  for i,ci in enumerate(color[1]):
    if i < B:
      ans[ci] = 3 * i + 2
    else:
      ans[ci] = 3 * c
      c += 1

elif len(color[0]) <= C:
  # elseが読まれるとき必ずlen(color[0]) < A
  # Bは条件を満たすはず
  for i ,ci in enumerate(color[0]):
    ans[ci] = 3 * c
    c += 1
  for i ,ci in enumerate(color[1]):
    if a < A:
      ans[ci] = 3 * a + 1
      a += 1
    elif b < B:
      ans[ci] = 3 * b + 2
      b += 1
    else:
      ans[ci] = 3 * c
      c += 1

else:
  # elseが読まれるとき必ずlen(color[0]) < A
  # そんなことなかったwwww
  for i ,ci in enumerate(color[1]):
    ans[ci] = 3 * c
    c += 1
  for i ,ci in enumerate(color[0]):
    if a < A:
      ans[ci] = 3 * a + 1
      a += 1
    elif b < B:
      ans[ci] = 3 * b + 2
      b += 1
    else:
      ans[ci] = 3 * c
      c += 1

print(*ans)
Buggy python submission (verdict: Runtime Error):
N,D,A=map(int,input().split())
P=sorted([list(map(int,input().split())) for i in range(N)])
l=r=a=d=0
m=[0]*(N+1)
while l<N:
    while r<N and P[r][0]<=P[l][0]+2*D:
        r+=1
    d+=m[l]
    x=-(-max(0,P[l][1]-d)//A)
    a+=x
    d+=x*A
    dm[r]-=x*A
    l+=1
print(a)


Fixed submission:
#!/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

def ceil(x,y):
  return (x-1)//y+1


def solve_binary(mid,k):
    return k < XH[mid][0]

def binary_search(s,n,k):
    ok=n
    ng=s
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve_binary(mid,k):
            ok=mid
        else:
            ng=mid
    return ok

n,D,A=map(int,input().split())
XH=[tuple(map(int,input().split())) for i in range(n)]
XH.sort(key=lambda tup: tup[0])
XH.append((inf,0))
data=[0]*(n+1)
if D==0:
    for xi,hi in XH:
        count += ceil(hi,A)
        # print(count)
    print(count)
    exit()
for i in range(n):
    xi,hi = XH[i]
    hi-=data[i]
    K=max(0,ceil(hi,A)*A); count += max(0,ceil(hi,A))
    data[i]+=K; data[binary_search(i,n,xi+2*D)]-=K
    data[i+1]+=data[i]
print(count)
# print(data)
Buggy python submission (verdict: Time Limit Exceeded):
#!/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
    count%=mod
print(count)


Fixed submission:
#!/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)

P = 10**9 + 7
N = 1000010
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    ans+=inv_t[ai]
    ans%=mod
print((pro*ans)%mod)

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

Buggy python submission (verdict: Time Limit Exceeded):
#!/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
    count%=mod
print(count)

Fixed submission:
#!/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)

P = 10**9 + 7
N = 1000010
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    ans+=inv_t[ai]
    ans%=mod
print((pro*ans)%mod)

# 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)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

n=int(input())
s=list(map(int,input()))
S=set()
checked=[0]*10
# print(s)
# print(checked)
for i in range(n):
    # print(s,3456)
    # print(s[i])
    # print(checked[0])
    if not checked[s[i]]:

        C=[[0]*10 for h in range(10)]
        past=[0]*10
        for j in range(i+1,n):

            for k in range(10):
                if past[k] and C[k][s[j]]==0:
                    C[k][s[j]]+=1
            past[s[j]]=1
        for l in range(10):
            for t in range(10):
                if C[l][t]:
                    S.add(str(s[i])+str(l)+str(t))
        # for r in C:
        #     print(r)
# print(S)
print(len(S))

        
            
        
        
        
        


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

n=int(input())
s=list(map(int,input()))
S=set()
checked=[0]*10
# print(s)
# print(checked)
for i in range(n):
    # print(s,3456)
    # print(s[i])
    # print(checked[0])
    if not checked[s[i]]:

        C=[[0]*10 for h in range(10)]
        past=[0]*10
        for j in range(i+1,n):

            for k in range(10):
                if past[k] and C[k][s[j]]==0:
                    C[k][s[j]]+=1
            past[s[j]]=1
        for l in range(10):
            for t in range(10):
                if C[l][t]:
                    S.add(str(s[i])+str(l)+str(t))
        checked[s[i]]=1
        # for r in C:
        #     print(r)
# print(S)
print(len(S))