Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)

cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                H[i] -= 1
                atk += 1
                if H[i] == 0:
                    cnt += 1

    if cnt == N:
        break

print(atk)

Fixed submission:
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)

cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                atk += H[i]
                cnt += 1

    if cnt == N:
        break

print(atk)
Buggy python submission (verdict: Runtime Error):
H = int(input())

def Test(m):
    if m == 1:
        return 1
    else:
        return 2 * Test(m/2) + 1

ans = Test(H)

print(ans)

Fixed submission:
H = int(input())

def f(x):
    if x == 1:
        return 1
    else:
        return 2 * f(int(x/2)) + 1

ans = f(H)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

if (N % M == 0):
    print("Yes")
else:
    print("No")

Fixed submission:
N, M = map(int, input().split())

if (M != 0 and N % M == 0):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

if (N % M == 0):
    print("Yes")
else:
    print("No")

Fixed submission:
N, M = map(int, input().split())

if (M != 0 and N % M == 0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
C = input()
print(chr(ord(c)+1))

Fixed submission:
C = input()

a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(a)):
  if a[i] == C:
    print(a[i+1])
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()        
print(6 - A - B)


Fixed submission:
A = int(input())
B = int(input())
print(6 - A - B)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()

ans = ['1', '2', '3']

for i in range(len(ans)):
  if ans[i] == A or ans[i] == B:
    del ans[i]
    
print(ans[0])


Fixed submission:
A = int(input())
B = int(input())
print(6 - A - B)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()

ans = ['1', '2', '3']

for i in range(len(ans)):
  if ans[i] == A or ans[i] == B:
    del ans[i]
    
print(nas[0])


Fixed submission:
A = int(input())
B = int(input())
print(6 - A - B)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()

ans = ['1', '2', '3']

for i in range(len(ans)):
  if ans[i] == A or ans[i] = B:
    del ans[i]
    
print(nas[0])

Fixed submission:
A = int(input())
B = int(input())
print(6 - A - B)
Buggy python submission (verdict: Runtime Error):
S = input()

if S == "Sunny":
	print("Cloudy")
elif S == "Cloudy":
	  print("Rainy")
else S == "Rainy":
	  print("Sunny")

Fixed submission:
S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
	print("Rainy")
else:
	print("Sunny")
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().strip())

print(max(A+B,A-B,A*B))

Fixed submission:
A, B = map(int, input().split())

print(max(A+B,A-B,A*B))
Buggy python submission (verdict: Runtime Error):
A, P = map(int, input().split())

a = A*3 + P

if a > 0:
  print(math.floor(a/2))
else:
  print(0)

Fixed submission:
A, P = map(int, input().split())

a = A*3 + P

if a > 0:
  print(int(a/2))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
A, P = map(int, input().split())

a = A*3 + P

print(math.floor(a/2))

Fixed submission:
A, P = map(int, input().split())

a = A*3 + P

if a > 0:
  print(int(a/2))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
b = input()

a = ['A', 'C', 'G', 'T']
for i in range(len()):
  if a[i] == b:
    print(a[i])
    break

Fixed submission:
b = input()

a = {'A':'T', 'C':'G', 'G':'C', 'T':'A'}

print(a[b])
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

a = int(B/A)

if a >= C:
  print(C)
elif:
  print(a)

Fixed submission:
A, B, C = map(int, input().split())

a = int(B/A)

if a >= C:
  print(C)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N < 1000:
  print("ABC" + N)
else:
  print("ABD" + (N - 999))

Fixed submission:
N = int(input())

if N < 1000:
  print("ABC")
else:
  print("ABD")
Buggy python submission (verdict: Runtime Error):
input = map(int, input().split())

a = input[0] * input[1]

if (a%2 == 0):
	print("Even")
else:
	print("Odd")


Fixed submission:
input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
input = map(int, row_input().split())

a = input[0] * input[1]

if (a%2 == 0):
	print("Even")
else:
	print("Odd")


Fixed submission:
input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
input = input().split()

a = input[0] * input[1]

if (a%2 == 0):
	print("Even")
else:
	print("Odd")


Fixed submission:
input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
input = input().split()

a = input[0] * input[1]

if (a/2 == 0):
	print("Even")
else:
	print("Odd")


Fixed submission:
input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
input = input().split()

a = input[0] * input[1]

if (a/2 == 0):
	print("Even")
else
	print("Odd")

Fixed submission:
input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")
Buggy python submission (verdict: Runtime Error):
a, b = map(float, input().split())
attack_list = list(map(float, input().split()))

if(a <= sum(attack_list)):
    print("Yes")
else:
    print("No")

Fixed submission:
import math
a, b = map(float, input().split())
x = a / b
if (x.is_integer() == False):
    print(math.ceil(x))
else:
    print(int(x))
Buggy python submission (verdict: Time Limit Exceeded):
H ,K = input().split(" ")
H = int(H)
K = int(K)


lst = input().split(" ")
hps = []
for l in lst:
  hps.append(int(l))

hps.sort(reverse=True)

for k in range(K):
  if hps:
  	hps.pop(0)
  else:
    break

if hps:
  sum_hps = sum(hps)
else:
  sum_hps = 0
print(sum_hps)

Fixed submission:
H ,K = input().split(" ")
H = int(H)
K = int(K)


lst = input().split(" ")
hps = []
for l in lst:
  hps.append(int(l))

hps.sort(reverse=True)

if len(hps) < K:
  hps = [0]
else:
  hps = hps[K:]

sum_hps = sum(hps)
print(sum_hps)
Buggy python submission (verdict: Runtime Error):
N, M = input().split(" ")
N = int(N)
M = int(M)

list = [[] for i in range(N)]
# print(list)

for i in range(M):
    p, S = input().split(" ")
    p = int(p)
    if "AC" not in list[p-1]:
        list[p-1].append(S)
    else:
        pass
pe = 0
cl = 0
for l in list:
    if "AC" in l:
        for i in l:
            if i == "AC":
                cl += 1
            else:
                pe += 1
    else:
        pass
print(cl, pe)


Fixed submission:
p = input()
print(chr(ord(p)+1))
Buggy python submission (verdict: Time Limit Exceeded):
#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]
ans = 0

for i in range(m):
    l, r = map(int, input().split())
    for j in range(l, r+1):
        data[j] += 1
        if data[j] == m:
            ans += 1

print(ans)

Fixed submission:
#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]

for i in range(m):
    l, r = map(int, input().split())
    data[l-1] += 1
    data[r] -= 1

for i in range(n):
    data[i+1] += data[i]

print(data.count(m))

Buggy python submission (verdict: Time Limit Exceeded):
#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]
ans = 0

for i in range(m):
    l, r = map(int, input().split())
    for j in range(l, r+1):
        data[j] += 1

for i in range(1, n+1):
    if data[i] == m:
        ans += 1

print(ans)

Fixed submission:
#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]

for i in range(m):
    l, r = map(int, input().split())
    data[l-1] += 1
    data[r] -= 1

for i in range(n):
    data[i+1] += data[i]

print(data.count(m))
Buggy python submission (verdict: Time Limit Exceeded):
# C - Fennec vs Monster

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

for i in range(min({k, n})):
    h.remove(max(h))

a = sum(h)
print(a)


Fixed submission:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())))

if n <= k:
    print(0)
    exit()
else:
    h = h[0:n - k]
    a = sum(h)
    print(a)
Buggy python submission (verdict: Runtime Error):
D = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SUT": 1}
print(D[input()])

Fixed submission:
D = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(D[input()])
Buggy python submission (verdict: Runtime Error):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
L = []
S = set()
count = 0
for i in range(n):
    line = "".join(sorted(list(input())))
    L.append(line)
    S.add(line)


for s in S:
    count += comb(L.count(s), 2)

print(count)

Fixed submission:
n = int(input())
D = {}
count = 0
for i in range(n):
    line = "".join(sorted(list(input())))
    if line not in D:
        D[line] = 0
    else:
        D[line] += 1
        count += D[line]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = []
count = 0
for i in range(n):
    L.append(input())

for j in range(n):
    for k in range(j+1, n):
        st1 = sorted(list(L[j]))
        st2 = sorted(list(L[k]))
        if st1 == st2:
            count += 1

print(count)


Fixed submission:
n = int(input())
D = {}
count = 0
for i in range(n):
    line = "".join(sorted(list(input())))
    if line not in D:
        D[line] = 0
    else:
        D[line] += 1
        count += D[line]

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
stair = list(map(int, input().split()))

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d > 1:
        print("No")
        exit()
    elif d == 1:
        stair -= 1
print("Yes")


Fixed submission:
n = int(input())
stair = list(map(int, input().split()))

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d < -1:
        print("No")
        exit()
    elif d == -1:
        stair[i - 1] -= 1
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 1
for i in range(1, N):
    if min(P[:i]) >= P[i]:
        count += 1
print(count)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

count = 1
minimum = P[0]
for i in range(1, N):
    minimum = min(P[i-1], minimum)
    if P[i] <= minimum:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))

A = [0,0,0,0,0,0]
A[N-1] = B[N-1-1]
for i in range(1,N):
    A[N-1-i] = min(B[N-1-i],B[N-1-i-1])
print(sum(A))

Fixed submission:
N = int(input())
B = list(map(int,input().split()))

A = [0]*N
A[0] = B[0]
A[N-1] = B[N-1-1]
for i in range(1,N-1):
    A[N-1-i] = min(B[N-1-i],B[N-1-i-1])
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
def anagram(s):
    count = 0
    for i in range(n):
        for j in range(i+1,n):
            if s[i] == s[j]:
                count += 1
    return count

n = int(input())
s = []
for i in range(n):
    li = sorted(input())
    li = ''.join(li)
    s.append(li)
print(anagram(s))

Fixed submission:
def anagram(n,s):
    count = 0
    dic = {}
    for s in S:
        if s in dic:
            count += dic[s]
            dic[s] += 1
        else:
            dic[s] = 1
    return count

N = int(input())
S = []
for i in range(N):
    li = sorted(input())
    li = ''.join(li)
    S.append(li)
print(anagram(N,S))

Buggy python submission (verdict: Time Limit Exceeded):
def anagram(s):
    count = 0
    for i in range(n):
        for j in range(i+1,n):
            if s[i] == s[j]:
                count += 1
    return count
  
n = int(input())
s = []
for i in range(n):
    li = sorted(input())
    s.append(li)
print(anagram(s))

Fixed submission:
def anagram(n,s):
    count = 0
    dic = {}
    for s in S:
        if s in dic:
            count += dic[s]
            dic[s] += 1
        else:
            dic[s] = 1
    return count

N = int(input())
S = []
for i in range(N):
    li = sorted(input())
    li = ''.join(li)
    S.append(li)
print(anagram(N,S))
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
print(N//(D*2+1)+1)N, D = map(int, input().split())
print(-(-N//(D*2+1)))

Fixed submission:
N, D = map(int, input().split())
if N%(D*2+1)==0:
    print(N//(D*2+1))
else:
    print(N//(D*2+1)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

maximum = max(A)
for i in range(N):
    if A[i] == maximum:
        new = A[:]
        new.pop(i)
        print(max(new))
    else:
        print(maximum)

Fixed submission:
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

A_sort = sorted(A)
first = A_sort[-1]
second = A_sort[-2]
if first == second:
    for n in range(N):
        print(first)
else:
    for i in range(N):
        if A[i] == first:
            print(second)
        else:
            print(first)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
for i in range(N):
    new = A[:]
    new.pop(i)
    print(max(new))

Fixed submission:
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

A_sort = sorted(A)
first = A_sort[-1]
second = A_sort[-2]
if first == second:
    for n in range(N):
        print(first)
else:
    for i in range(N):
        if A[i] == first:
            print(second)
        else:
            print(first)
Buggy python submission (verdict: Runtime Error):
L,R = int(input().split())
if R-L > 2019:
    print(0)
else:
    ans = (L*(L+1))%2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i%2019)*(j%2019))
    print(ans)

Fixed submission:
L,R = map(int, input().split())
if R-L >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j)%2019)
    print(ans)
Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())
A=list(map(int,input().split())
if H<=sum(A):
       print('Yes')
else:
       print('No')

Fixed submission:
H,A=list(map(int,input().split()))
count=0
while H>0:
    H=H-A
    count +=1
print(count)

Buggy python submission (verdict: Runtime Error):
H,A=list(map(int,input().split()))
count=0
while H>0:
    H=H-A
    count +=1
return count

Fixed submission:
H,A=list(map(int,input().split()))
count=0
while H>0:
    H=H-A
    count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
H, N=map(int,input().split())
A=list(map(int,input().split())
if H<=sum(A):
       print('Yes')
else:
       print('No')

Fixed submission:
H,N=map(int,input().split())
A=list(map(int,input().split()))
if H<=sum(A):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(str(input()))
count=0
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
count=0
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import sys
import math
s=list(map(str,input()))
for i in range(math.ceil(len(s)/2)):
    if s[2*i]!='L' and s[2*i]!='U' and s[2*i]!='D':
        print('No')
        sys.exit()
for j in range(len(s)//2):
    if [2*i+1]!='R' and s[2*i+1]!='U' and s[2*i+1]!='D':
        print('No')
        sys.exit()
print('Yes')   

Fixed submission:
import sys
s=list(map(str,input()))
for i in range(len(s)):
    if i%2==0 and s[i]=='L':
        print('No')
        sys.exit()
    else:
        if i%2==1 and s[i]=='R':
            print('No')
            sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
people=N/(2D+1)
if people%2==O:
    print(int(people))
else:
    print(int(people)+1)


Fixed submission:
N,D=map(int,input().split())
people=N/(2*D+1)
if N % (2*D+1) == 0:
    print(int(people))
else:
    print(int(people)+1)
Buggy python submission (verdict: Runtime Error):
S=str(input())
if S[0]==S[1] or S[1]=S[2] or S[2]=S[3]:
    print('Bad')
else:
    print('Good')

Fixed submission:
S=str(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=int(input())
B=int(input())
if N==1:
    print('Hello World')
else:
    print(A+B)

Fixed submission:
N=int(input())
if N==2:
    A,B=map(int,[input() for i in range(2)])
    print(A+B)
else:
    print('Hello World')
Buggy python submission (verdict: Runtime Error):
1,A2,A3=map(int,input().split())
A=[A1,A2,A3]
A.append(A1)
def A_(i):
    if A[i]-A[i+1]>=0:
        return A[i]-A[i+1]
    else:
        return A[i+1]-A[i]
B=[A_(i) for i in range(3)]
B.append(A_(0))
B.append(A_(1))
def sum(j):
    return B[j]+B[j+1]
C=[sum(j) for j in range(3)]
print(min(C))


Fixed submission:
A1,A2,A3=map(int,input().split())
A=[A1,A2,A3]
A.append(A1)
def A_(i):
    if A[i]-A[i+1]>=0:
        return A[i]-A[i+1]
    else:
        return A[i+1]-A[i]
B=[A_(i) for i in range(3)]
B.append(A_(0))
B.append(A_(1))
def sum(j):
    return B[j]+B[j+1]
C=[sum(j) for j in range(3)]
print(min(C))
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%2=0:
    ans=N
else:
    ans=N*2
print(ans)

Fixed submission:
N=int(input())
if N%2==0:
    ans=N
else:
    ans=N*2
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=a*b
if c%2==0:
    print(Even)
else:
    print(Odd)

Fixed submission:
a,b=map(int,input().split())
c=a*b
if c%2==0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=a*b
if c%2==0:
    print('Even')
else:
    print('Odd')

Fixed submission:
r,g,b=map(int,input().split())
if (100*r+10*g+b)%4==0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
S1 = list(map(int, input().split()))
S2 = list(map(int, input().split()))

H = S1[0]

if H > sum(S2):
    print("no")
else:
    print("yes")

Fixed submission:
H, A = map(int, input().split())
print(-(-H // A))
Buggy python submission (verdict: Runtime Error):
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def Raccon_vs_Monster():
    H, N = wczytaj_liste()
    ruchy = wczytaj_liste()
    suma_obrazen = ruchy.sum()
    if suma_obrazen >= H:
        print('Yes')
    else:
        print('No')

Raccon_vs_Monster()


Fixed submission:
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def Raccon_vs_Monster():
    H, N = wczytaj_liste()
    ruchy = wczytaj_liste()
    suma_obrazen = sum(ruchy)
    if suma_obrazen >= H:
        print('Yes')
    else:
        print('No')

Raccon_vs_Monster()
Buggy python submission (verdict: Time Limit Exceeded):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def mniejsze_elementy(): 
    N = wczytaj_liste()[0]
    P = wczytaj_liste()
    odp = 1
    for i in range(1,N):
        czy_prawda = True
        j = i - 1
        while j >= 0:
            if P[i] > P[j]:
                czy_prawda = False
                j -= 1
                break
            else: 
                j -= 1
        if czy_prawda:
            odp += 1 
    print(odp)
    
mniejsze_elementy()

Fixed submission:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def mniejsze_elementy(): 
    N = wczytaj_liste()[0]
    P = wczytaj_liste()
    odp = 1 
    najmniejszy_dotychczas = P[0]
    for i in range(1,N):
        if P[i]< najmniejszy_dotychczas: 
            odp += 1
            najmniejszy_dotychczas = P[i]
    print(odp)
    
mniejsze_elementy()
Buggy python submission (verdict: Time Limit Exceeded):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def NWD(A, B):
    if A < B:
        A, B = B, A 
    if B == 0: 
        return A
    return NWD(A%B, B)

    
def NWW(A,B):
    return A*B//NWD(A,B)
    
def flatten():
    N = wczytaj_liste()[0]
    A = wczytaj_liste()
    B = []
    najwieksza_wielokrotnosc = A[0]
    for i in range(N): 
        najwieksza_wielokrotnosc = NWW(najwieksza_wielokrotnosc, A[i])
    for i in range(N):
        B.append(najwieksza_wielokrotnosc//A[i])
    print(sum(B)%(10**9+7))

flatten()

Fixed submission:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 


def flatten():
    MOD = 10**9+7
    N = wczytaj_liste()[0]
    A = wczytaj_liste()
    najwieksza = max(A)
    najmniejszy_dzielnik = [None] * (najwieksza + 1)
    for i in reversed(range(2, najwieksza + 1)):
        for j in range(0, najwieksza + 1, i):
            najmniejszy_dzielnik[j] = i
    najwieksze_wykladniki = [0] * (najwieksza + 1)
    for liczba in A:
        dzielnik = 1
        wykladnik = 0
        while liczba != 1:
            d = najmniejszy_dzielnik[liczba]
            if d == dzielnik:
                wykladnik += 1
            else:
                if najwieksze_wykladniki[dzielnik] < wykladnik:
                    najwieksze_wykladniki[dzielnik] = wykladnik
                dzielnik = d
                wykladnik = 1
                
            liczba //= d
            
        if najwieksze_wykladniki[dzielnik] < wykladnik:
            najwieksze_wykladniki[dzielnik] = wykladnik
    
    nww = 1
    for dzielnik, wykladnik in enumerate(najwieksze_wykladniki):
        nww = nww * pow(dzielnik, wykladnik, MOD) % MOD
    
    suma = 0
    for liczba in A:
        suma += nww * pow(liczba, MOD - 2, MOD)
        suma %= MOD
    print(suma)
        

flatten()