problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02793
u131638468
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import numpy as np\nimport fractions\nn=int(input())\na=list(map(int,input().split()))\na2=np.array(a.copy())\nmod=10**9+7\ndef f(n,i):\n for j in range(i+1,n):\n c=fractions.gcd(a[i],a[j])\n a[j]//=c\n\nfor i in range(n):\n f(n,i)\nm = 1\nfor i in a:\n m = m * i\nb=(m//a2)%mod\nans=np.sum(b)%mod\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\n\ndef eucrid(a,b):\n a,b=max(a,b),min(a,b)\n while True:\n if a%b==0:\n return b\n else:\n a,b=b,a%b\nm=a[0]\nfor i in range(n):\n m=m//eucrid(m,a[i])*a[i]\nb=0\nm=m%mod\nfor i in a:\n b+=m*pow(i,mod-2,mod)%mod\nprint(b%mod)']
['Time Limit Exceeded', 'Accepted']
['s939716498', 's030036678']
[16436.0, 4084.0]
[2109.0, 1412.0]
[300, 289]
p02793
u155687575
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nfrom functools import reduce\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\nmod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\n\nkoubai = lcm_list(lst)\ntotal = 0\nfor l in lst:\n b = koubai//l\n total += b\n total %= mod\nprint(total)', 'mod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\nkoubai = lst[0]\ndef gcd(a, b):\n if a > b:\n a, b = b, a\n while b > 0:\n a, b = b, a % b\n return a\nfor i in range(1, n):\n koubai = koubai*lst[i]//gcd(koubai, lst[i])\n \ntotal = 0\nfor i in lst:\n total += koubai//l\n\nprint(total%mod)', 'import fractions\nmod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\nkoubai = lst[0]\ndef gcd(a, b):\n if a > b:\n a, b = b, a\n while b > 0:\n a, b = b, a % b\n return a\nfor i in range(1, n):\n koubai = koubai*lst[i]//gcd(koubai, lst[i])\n \ntotal = 0\nfor l in lst:\n b = koubai//l\nprint(total%mod)', 'mod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\nkoubai = lst[0]\ndef gcd(a, b):\n if a > b:\n a, b = b, a\n while b > 0:\n a, b = b, a % b\n return a\nfor i in range(1, n):\n koubai = koubai*lst[i]//gcd(koubai, lst[i])\n \ntotal = 0\nfor l in lst:\n b += koubai//l\n\nprint(total%mod)\n', 'import fractions\nfrom functools import reduce\nimport numpy as np\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\nmod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\n\nkoubai = lcm_list(lst)\ntmp = np.array([koubai for _ in range(n)])\ntmp2 = tmp//lst\nprint(tmp2.sum() % mod)', 'import fractions\nmod = 10**9 + 7\nn = int(input())\nlst = list(map(int, input().split()))\nkoubai = lst[0]\nfor i in range(1, n):\n koubai = koubai*lst[i]//fractions.gcd(koubai, lst[i])\n \ntotal = 0\nfor l in lst:\n b = koubai//l\n total += b\n total %= mod\nprint(total)', 'n = int(input())\na = list(map(int, input().split()))\nlcm = a[0]\n\ndef gcd(a, b):\n if a > b:\n a, b = b, a\n while b > 0:\n a, b = b, a % b\n return a\n\nfor i in range(1, n):\n lcm = lcm * a[i] // gcd(lcm, a[i])\nmod = 10**9 + 7\nans = 0\nfor i in range(n):\n ans += lcm // a[i]\nprint(ans % mod)']
['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s069183971', 's178906526', 's195126919', 's681686169', 's861516078', 's996981864', 's776029378']
[6136.0, 4084.0, 6116.0, 4084.0, 272368.0, 6116.0, 4084.0]
[2104.0, 914.0, 1822.0, 913.0, 2125.0, 2104.0, 1884.0]
[352, 326, 337, 323, 367, 272, 312]
p02793
u163783894
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["import sys\nimport fractions\ninput = lambda: sys.stdin.readline().rstrip()\n\nmod = 10**9 + 7\n\n\ndef solve():\n N = int(input())\n A = list(map(int, input().split()))\n\n lcm = A[0]\n for i in range(1, N):\n lcm = lcm * A[i] // fractions.gcd(lcm, A[i])\n\n B = [lcm // a for a in A]\n\n ans = 0\n for i in range(N):\n ans += B[i]\n ans %= mod\n\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "import sys\nfrom collections import defaultdict\ninput = lambda: sys.stdin.readline().rstrip()\n\nmod = 10**9 + 7\n\n\nclass Factorize(object):\n\n def __init__(self, maxnum):\n self.primes = self.__smallest_prime_factors(maxnum)\n\n \n def factorize_list(self, n):\n\n fct = []\n while n != 1:\n fct.append(self.primes[n])\n n //= self.primes[n]\n return fct\n\n \n def factorize_dict(self, n):\n fct = defaultdict(lambda: 0)\n while n != 1:\n fct[self.primes[n]] += 1\n n //= self.primes[n]\n return fct\n\n \n def __smallest_prime_factors(self, n):\n\n prime = list(range(n + 1))\n\n for i in range(2, int(n**0.5) + 1):\n if prime[i] != i:\n continue\n for j in range(i * 2, n + 1, i):\n prime[j] = min(prime[j], i)\n return prime\n\n\ndef divmod(x, mod=10**9 + 7):\n return pow(x, mod - 2, mod)\n\n\ndef solve():\n\n N = int(input())\n A = list(map(int, input().split()))\n fct = Factorize(max(A))\n\n lcm_dict = defaultdict(lambda: 0)\n for i in range(N):\n d = fct.factorize_dict(A[i])\n for k, v in d.items():\n lcm_dict[k] = max(lcm_dict[k], v)\n\n lcm = 1\n for k, v in lcm_dict.items():\n lcm *= (k**v)\n lcm %= mod\n\n ans = 0\n for i in range(N):\n ans += divmod(A[i])\n ans %= mod\n\n ans *= lcm\n ans %= mod\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n"]
['Time Limit Exceeded', 'Accepted']
['s823530828', 's034761423']
[264668.0, 44396.0]
[2120.0, 643.0]
[425, 1595]
p02793
u168026006
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\nsys.setrecursionlimit(100000000)\n\n\ndef gcd(aa, b):\n if b == 0:\n return a\n return gcd(b, aa % b)\n\n\nmod = 1e9 + 7\nn = int(input())\na = [int(i) for i in input().split()]\nkek = 1\nfor i in range(n):\n kek = (kek * a[i]) / gcd(kek, a[i])\ns = 0\nfor i in range(n):\n s += kek / a[i]\nprint(int(s % mod))\n\n\n', 'import sys\nsys.setrecursionlimit(10000000)\n\n\ndef gcd(aa, b):\n if b == 0:\n return aa\n return gcd(b, aa % b)\n\n\nmod = int(1e9 + 7)\nn = int(input())\na = [int(i) for i in input().split()]\nkek = 1\nfor i in range(n):\n kek = (kek * a[i]) // gcd(kek, a[i])\ns = 0\nfor i in range(n):\n s += kek // a[i]\nprint(int(s % mod))\n\n\n']
['Runtime Error', 'Accepted']
['s642276225', 's007466065']
[4084.0, 4084.0]
[20.0, 1890.0]
[325, 332]
p02793
u169138653
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nlcm=1\nd=dict()\nfor i in range(n):\n k=a[i]\n for j in range(1,int(a[i]**0.5)+1):\n cnt=0\n while k%(j+1)==0:\n k//=j+1\n cnt+=1\n if j+1 in d:\n if d[j+1]<cnt:\n lcm*=(j+1)**(cnt-d[j+1])\n d[j+1]=cnt\n else:\n lcm*=(j+1)**cnt\n d[j+1]=cnt\n if k in d:\n if d[j+1]<1:\n lcm*=k\n d[k]=1\nans=0\nfor i in range(n):\n ans+=(lcm//a[i])%mod\nprint(ans%mod)', 'from fractions import gcd\nn=int(input())\na=list(map(int,input().split()))\nlcm=a[0]\nmod=10**9+7\nfor i in range(1,n):\n lcm=(lcm//gcd(lcm,a[i]))*(a[i]//gcd(lcm,a[i]))*gcd(lcm,a[i])\nans=0\nfor i in range(n):\n ans+=(lcm//a[i])%mod\nprint(ans%mod)', 'from fractions import gcd\nP = 10**9 + 7\nN = 1000001 \ninv = [0] + [1] # 1/x\nfinv = [1] + [1] # 1/x!\nfac = [1] + [1] # x!\nfor i in range(2,N):\n inv += [inv[P % i] * (P - int(P / i)) % P]\n fac += [(fac[i-1] * i) % P]\n finv += [(finv[i-1] * inv[i]) % P]\nn=int(input())\na=list(map(int,input().split()))\nlcm=a[0]\nmod=10**9+7\nfor i in range(1,n):\n lcm=(lcm//gcd(lcm,a[i]))*(a[i]//gcd(lcm,a[i]))*gcd(lcm,a[i])\nans=0\nfor i in range(n):\n ans+=lcm*inv[a[i]]%mod\nprint(ans%mod)', 'n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nlcm=1\nd=dict()\nfor i in range(n):\n k=a[i]\n for j in range(1,int(a[i]**0.5)+1):\n cnt=0\n while k%(j+1)==0:\n k//=j+1\n cnt+=1\n if j+1 in d:\n if d[j+1]<cnt:\n lcm*=(j+1)**(cnt-d[j+1])\n d[j+1]=cnt\n else:\n lcm*=(j+1)**cnt\n d[j+1]=cnt\n if k in d:\n if d[k]<1:\n lcm*=k\n d[k]=1\n else:\n lcm*=k\n d[k]=1\nans=0\nprint(d)\nfor i in range(n):\n ans+=(lcm//a[i])%mod\nprint(ans%mod)', 'from collections import defaultdict\nfrom collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\n\ndef prime_factorization(n):\n table = []\n for x in range(2, int(n ** 0.5) + 1):\n while n % x == 0:\n table.append(x)\n n //= x\n if n > 1:\n table.append(n)\n return table\n\n\nprime_max_factors = defaultdict(int)\nfor a in A:\n prime_factors = Counter(prime_factorization(a))\n for k, v in prime_factors.items():\n prime_max_factors[k] = max(prime_max_factors[k], v)\n\n\nLCM = 1\nfor k, v in prime_max_factors.items():\n LCM *= pow(k, v, MOD)\nLCM %= MOD\n\nans = 0\nfor a in A:\n ans += LCM * pow(a, MOD - 2, MOD)\n ans %= MOD\n\nprint(ans % MOD)\n\n']
['Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s433256545', 's579555995', 's622014722', 's906673583', 's925427424']
[4084.0, 6108.0, 127192.0, 4468.0, 4852.0]
[2104.0, 2104.0, 2117.0, 2104.0, 1098.0]
[457, 241, 551, 494, 736]
p02793
u211160392
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nlcm %= MOD\nans = 0\nfor i in A:\n ans += lcm//i\n ans %= MOD\nprint(ans)\n', 'from fractions import gcd\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nlcm %= MOD\nfor i in A:\n ans += lcm//i\n ans %= MOD\nprint(ans)\n', 'from fractions import gcd\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nans = 0\nfor i in A:\n ans += lcm//i\n ans %= MOD\nprint(ans)\n', 'def gcd(x,y):\n if y==0:\n return x\n return gcd(y,x%y)\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nlcm %= MOD\nans = 0\nfor i in A:\n ans += lcm*pow(i,MOD-2,MOD)\n ans %= MOD\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s024402825', 's219089015', 's734567591', 's285363377']
[6112.0, 6112.0, 6112.0, 4084.0]
[930.0, 928.0, 2104.0, 959.0]
[218, 210, 207, 272]
p02793
u223663729
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['N = int(input())\n*A, = map(int, input().split())\n\nmod = 10**9 + 7\nMAX = 1_000_000\n\n\ndef gen_primes(n):\n n = int(n**0.5) + 2\n is_prime = [True]*n\n is_prime[0] = is_prime[1] = False\n for i in range(2, n):\n if is_prime[i]:\n for j in range(2*i, n, i):\n is_prime[j] = False\n return [i for i, flag in enumerate(is_prime) if flag]\n\n\nC = [0]*(MAX+1)\nprimes = gen_primes(MAX)\n\n\ndef prime_fact(n):\n cnt = 0\n for p in primes:\n if n % p:\n continue\n while n % p == 0:\n cnt += 1\n n //= p\n C[p] = max(C[p], cnt)\n cnt = 0\n if n != 1:\n C[n] = 1\n\n\nfor a in A:\n prime_fact(a)\n\nlcm = 1\nfor i, c in enumerate(C):\n if c:\n lcm = lcm * pow(i, c, mod) % mod\n\nprint(lcm)\n\nans = 0\nfor a in A:\n ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod\nprint(ans)\n', 'N = int(input())\n*A, = map(int, input().split())\n\nmod = 10**9 + 7\nMAX = 1_000_000\n\n\ndef gen_primes(n):\n n = int(n**0.5) + 2\n is_prime = [True]*n\n is_prime[0] = is_prime[1] = False\n for i in range(2, n):\n if is_prime[i]:\n for j in range(2*i, n, i):\n is_prime[j] = False\n return [i for i, flag in enumerate(is_prime) if flag]\n\n\nC = [0]*(MAX+1)\nprimes = gen_primes(MAX)\n\n\ndef prime_fact(n):\n cnt = 0\n for p in primes:\n if n % p:\n continue\n while n % p == 0:\n cnt += 1\n n //= p\n C[p] = max(C[p], cnt)\n cnt = 0\n if n != 1:\n C[n] = 1\n\n\nfor a in A:\n prime_fact(a)\n\nlcm = 1\nfor i, c in enumerate(C):\n if c:\n lcm = lcm * pow(i, c, mod) % mod\n\nans = 0\nfor a in A:\n ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s464411576', 's150718341']
[17796.0, 17740.0]
[215.0, 219.0]
[870, 858]
p02793
u228223940
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\n\nn = int(input())\nai = [int(i) for i in input().split()]\n\n\nmod = 10**9+7\n\nif n == 1:\n print(1)\n exit()\n\nb_li = []\n\nseki = 1\n\nfor i in range(n):\n seki *= ai[i]\n\nfor i in range(n):\n b_li.append(seki/ai[i])\n\nt_gcd = fractions.gcd(b_li[0],b_li[1])\n\nfor i in range(n-2):\n t_gcd = int(fractions.gcd(t_gcd,b_li[i+2]))\n \nans = 0\n\nfor i in range(n):\n ans += int(seki/t_gcd/ai[i])\n \nprint(ans%mod)', 'import fractions\n\nn = int(input())\nai = [int(i) for i in input().split()]\n\n\nmod = 10**9+7\n\nif n == 1:\n print(1)\n exit()\n\nb_li = []\n\nseki = 1\n\nfor i in range(n):\n seki *= ai[i]\n seki %= mod\n\nfor i in range(n):\n b_li.append(seki/ai[i])\n\nt_gcd = fractions.gcd(b_li[0],b_li[1])\n\nfor i in range(n-2):\n t_gcd = int(fractions.gcd(t_gcd,b_li[i+2]))\n \nans = 0\n\nfor i in range(n):\n ans += int(seki/t_gcd/ai[i])\n \nprint(ans%mod)', 'import math\nmod = 10**9+7\n\n\n\ndef prime(n):\n factor = {}\n tmp = int(math.sqrt(n)) + 1\n for num in range(2, tmp):\n while n % num == 0:\n n //= num\n if not num in factor.keys():\n factor[num] = 1\n else:\n factor[num] += 1\n if num > n:\n break\n if n != 1:\n if not n in factor.keys():\n factor[n] = 1\n else:\n factor[n] += 1\n return factor\n\n\ndef extgcd(a,b):\n r = [1,0,a]\n w = [0,1,b]\n while w[2]!=1:\n q = r[2]//w[2]\n r2 = w\n w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]\n r = r2\n w = w2\n #[x,y]\n return [w[0],w[1]]\n\n\ndef mod_inv(a,m=mod):\n x = extgcd(a,m)[0]\n return (m+x%m)%m\n\nimport sys\ninput = sys.stdin.readline\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nfor a in A:\n pr = prime(a)\n print(pr)\n exit()\n for num, count in pr.items():\n if not num in dic.keys():\n dic[num] = count\n else:\n if dic[num] < count:\n dic[num] = count\n\nlcm = 1\nfor num, count in dic.items():\n lcm *= pow(num, count, mod)\n lcm %= mod\n\nans = 0\nfor a in A:\n ans += mod_inv(a)*lcm\n ans %= mod\n\nprint(ans)\n', 'def gcd(n,m):\n if n>m:\n return gcd(m,n);\n if n==0:\n return m;\n return gcd(m-n*(m//n),n)\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n \nn=int(input())\na=list(map(int,input().split()))\ns=1\nfor i in a:\n s=lcm(s,i)\nans=0\nfor i in a:\n ans+=s//i\nprint(ans % 1000000007)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s180473060', 's443978580', 's926574474', 's840648933']
[6204.0, 6204.0, 4212.0, 4084.0]
[90.0, 61.0, 20.0, 1969.0]
[428, 444, 1456, 278]
p02793
u246124919
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
[' import math\n from functools import reduce\n \n def lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n \n def lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \n N = int(input())\n A = list(map(int,input().split()))\n ans = 0\n \n lcm = lcm_list(A)\n \n for i in range(N):\n ans += lcm//A[i]\n \n print(ans%1000000007)', " def gcd(a,b): \n if a == 0: \n return b \n return gcd(b % a, a) \n \n def lcm(a,b): \n return (a*b) // gcd(a,b) \n \n n = int(input())\n arr = input() # takes the whole line of n numbers\n a = list(map(int,arr.split(' ')))\n l = a[0]\n ans = 0\n for i in range(n):\n l = lcm(l, a[i])\n for i in range(n):\n ans = ans + l//a[i]\n print(ans%1000000007)", 'import math\nfrom functools import reduce\n \ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n \ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \nN = int(input())\nA = list(map(int,input().split()))\nans = 0\n \nlcm = lcm_list(A)\n \nfor i in range(N):\n ans += lcm//A[i]\n \nprint(ans%1000000007)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s203982524', 's771484199', 's083080937']
[9004.0, 8932.0, 10544.0]
[27.0, 23.0, 1617.0]
[387, 422, 337]
p02793
u257162238
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\n\ndef gcd_array(x):\n value = x[0]\n for i in range(1, len(x)):\n value = fractions.gcd(value, x[i])\n return value\n\ndef lcm(a, b):\n return a * b // fractions.gcd(a, b)\n\ndef lcm_array(x):\n value = x[0]\n for i in range(1, len(x)):\n value = lcm(value, x[i])\n return value \n\ndef read():\n N = int(input().strip())\n A = list(map(int, input().strip().split()))\n return N, A\n\ndef solve(N, A, MOD=1000000007):\n lcmv = lcm_array(A)\n bsum = 0\n for i in range(N):\n bsum += (lcmv // A[i])\n bsum %= MOD\n return bsum\n\n\nif __name__ == \'__main__\':\n inputs = read()\n print("%s" % solve(*inputs))\n', 'import collections\n\n\ndef modinv(n, p):\n \n if n >= p:\n raise ValueError(\'p must be larger than n\')\n return pow(n, p-2, p)\n\n\ndef prime_sieve(n):\n \n is_prime = [True for i in range(n+1)]\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, n+1):\n if is_prime[i]:\n for j in range(i+i, n+1, i):\n is_prime[j] = False\n return [i for i in range(2, n+1) if is_prime[i]]\n\n\ndef prime_factorization(it):\n \n n = max(it)\n factor = [1 for i in range(n+1)]\n factor[0] = 0\n factor[1] = 1\n for i in range(2, n+1):\n if factor[i] == 1:\n for j in range(i, n+1, i):\n factor[j] = i\n for a in it:\n if a < 2:\n yield list()\n else:\n prime_factors = list()\n while a != factor[a]:\n prime_factors.append(factor[a])\n a //= factor[a]\n prime_factors.append(factor[a])\n yield list(sorted(prime_factors))\n\n\ndef lcm(x, p=-1):\n \n max_prime_counts = dict()\n for prime in prime_sieve(max(x)):\n max_prime_counts[prime] = 0\n pfs = prime_factorization(x)\n for pf in pfs:\n prime_count = collections.Counter(pf)\n for prime in prime_count.keys():\n max_prime_counts[prime] = max(max_prime_counts[prime], prime_count[prime])\n lcm_value = 1\n for prime, factor in max_prime_counts.items():\n if p > 0:\n lcm_value *= pow(prime, factor, p)\n lcm_value %= p\n else:\n lcm_value *= pow(prime, factor)\n return lcm_value\n\n\ndef read():\n N = int(input().strip())\n A = list(map(int, input().strip().split()))\n return N, A\n\n\ndef solve(N, A, MOD=1000000007):\n bsum = 0\n for i in range(N):\n bsum += modinv(A[i], MOD)\n bsum %= MOD\n bsum *= lcm(A, p=MOD)\n bsum %= MOD\n return bsum\n\n\nif __name__ == \'__main__\':\n inputs = read()\n print("%d" % solve(*inputs))']
['Time Limit Exceeded', 'Accepted']
['s311176962', 's880874644']
[6100.0, 24768.0]
[2104.0, 719.0]
[667, 2396]
p02793
u277440940
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\n \ndef compute_gcd(x, y):\n while(y):\n x, y = y, x % y\n return x\n \ndef compute_lcm(x, y):\n lcm = (x*y)//compute_gcd(x,y)\n return lcm\n \nn = int(input())\n\na = list(map(int, input().split()))\n\nMOD = 10 ** 9 + 7\n\nans = 1\nd = 1\ncur = 0\n\nfor i in a:\n\tans = compute_lcm(ans, i)\n\nfor i in a:\n\tcur += ans / i\n\nprint(cur % MOD)\n', 'import sys\n\ndef compute_gcd(x, y):\n while(y):\n x, y = y, x % y\n return x\n \ndef compute_lcm(x, y):\n lcm = (x*y)//compute_gcd(x,y)\n return lcm\n\ndef lcm(a):\n\tx = a[0]\n\tfor i in range(1, len(a)):\n\t\tx = compute_lcm(x, a[i])\n\treturn x\n\nn = int(input())\n\na = list(map(int, input().split()))\n\nMOD = 10 ** 9 + 7\n\nans = lcm(a)\ncur = 0\n\nfor i in a:\n\tcur += ans // i\n\nprint(cur % MOD)\n']
['Runtime Error', 'Accepted']
['s984567843', 's706994681']
[4084.0, 4084.0]
[911.0, 1877.0]
[343, 387]
p02793
u281610856
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["import sys\ninput = sys.stdin.readline\nMOD = 10 ** 9 + 7\n\n\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b != 0:\n a, b = b, a % b\n return b\n\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n l = 1\n for a in A:\n l = lcm(l, a)\n c = 0\n for a in A:\n c += l * pow(a, MOD - 2, MOD)\n ans = l * c % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", 'import sys\ninput = sys.stdin.readline\n\nMOD = 10 ** 9 + 7\n# INF = float("inf")\n\n\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b != 0:\n a, b = b, a % b\n return b\n\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n l = 1\n for a in A:\n l = lcm(l, a)\n c = 0\n for a in A:\n c += pow(a, MOD - 2, MOD)\n ans = l * c % MOD\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Accepted']
['s625736564', 's443337336']
[4084.0, 4084.0]
[1574.0, 1405.0]
[513, 563]
p02793
u314050667
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import numpy as np\n\nN = int(input())\nA = np.array(list(map(int, input().split())), np.uint64)\nmod = 10**9+7\ndef gcd(a,b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a%b)\nLCM = A[0]\nfor i in range(1, N):\n\tGCD = gcd(LCM, A[i])\n\tLCM *= A[i]\n\tLCM //= GCD\n\n\nB = np.array([LCM] * N, np.uint64)\nB = B//A\n\nans = 0\nfor i in range(N):\n\tt = B[i] % mod\n\tans += t\n\tans %= mod\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\ndef gcd(a,b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a%b)\nLCM = A[0]\nfor i in range(1, N):\n\tGCD = gcd(LCM, A[i])\n\tLCM *= A[i]\n\tLCM //= GCD\nLCM %= mod\nans = 0\nfor i in range(N):\n\tt = LCM * pow(A[i], mod-2, mod)\n\tans += t\n\tans %= mod\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s410962282', 's399787371']
[14556.0, 4084.0]
[1002.0, 962.0]
[369, 309]
p02793
u317423698
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["import sys\nimport itertools\nimport functools\nfrom math import gcd\n\n\ndef lcm2(x, y):\n return (x * // gcd(x, y)) * y\n\n\ndef lcm(x):\n return functools.reduce(lcm2, x)\n\n\ndef resolve(in_):\n N = int(next(in_))\n A = tuple(map(int, next(in_).split()))\n a_lcm = lcm(A)\n\n mod = 10 ** 9 + 7\n\n ans = 0\n for a in A:\n ans += a_lcm // a\n if ans > mod:\n ans %= mod\n \n return ans\n\n\ndef main():\n answer = resolve(sys.stdin.buffer)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom collections import Counter\nfrom functools import reduce\nfrom operator import mul, ior\n\nfrom typing import Callable, ClassVar, Sequence, Type, TypeVar\n\n\nT = TypeVar('T', bound='ModIntBase')\n\n\nclass ModIntBase:\n value: int\n mod: ClassVar[int]\n fac: ClassVar[Sequence[int]] = ()\n inv: ClassVar[Sequence[int]] = ()\n finv: ClassVar[Sequence[int]] = ()\n\n def __init__(self, value: int) -> None:\n self.value = value % self.mod\n\n def __hash__(self) -> int:\n return hash((self.value, self.mod))\n\n def __eq__(self, other) -> bool:\n if isinstance(other, self.__class__):\n return self.value == other.value\n else:\n return NotImplemented\n\n def __ne__(self, other) -> bool:\n if isinstance(other, self.__class__):\n return self.value != other.value\n else:\n return NotImplemented\n\n \n def __add__(self, other):\n if isinstance(other, self.__class__):\n return self.__class__((self.value + other.value) % self.mod)\n else:\n return NotImplemented\n\n def __sub__(self, other):\n if isinstance(other, self.__class__):\n return self.__class__((self.value - other.value) % self.mod)\n else:\n return NotImplemented\n\n def __mul__(self, other):\n if isinstance(other, self.__class__):\n return self.__class__(self.value * other.value % self.mod)\n else:\n return NotImplemented\n\n def __truediv__(self, other):\n if isinstance(other, self.__class__):\n a = other.value\n b = self.mod\n u = 1\n v = 0\n while b:\n t = a // b\n a, b = b, a - t * b\n u, v = v, u - t * v\n return self.__class__(self.value * u % self.mod)\n else:\n return NotImplemented\n\n def __pow__(self, other):\n if isinstance(other, self.__class__):\n v = 1\n a = self.value\n b = other.value\n mod = self.mod\n while b > 0:\n if b & 1:\n v = v * a % mod\n a = a * a % mod\n b >>= 1\n return self.__class__(v)\n else:\n return NotImplemented\n\n @classmethod\n def comb(cls, n: int, k: int):\n if n < k:\n return cls(0)\n if n < 0 or k < 0:\n return cls(0)\n\n if n < len(cls.fac):\n return cls(cls.fac[n] * (cls.finv[k] * cls.finv[n - k] % cls.mod) % cls.mod)\n else:\n k = min(k, n - k)\n a = reduce(mul, map(cls, range(n - k + 1, n + 1)), cls(1))\n b = reduce(mul, map(cls, range(1, k + 1)), cls(1))\n return a / b\n\n def __repr__(self) -> str:\n return f'{self.__class__.__name__}({self.value!r})'\n\n def __str__(self) -> str:\n return str(self.value)\n\n\nclass ModInt(ModIntBase):\n mod = 1000000007 # 10 ** 9 + 7\n\n\ndef prime_factor(a, temp):\n while a > 1:\n yield temp[a]\n a //= temp[a]\n\n\ndef resolve(in_):\n N = int(next(in_))\n A = tuple(map(int, next(in_).split()))\n\n max_a = max(A)\n temp = [0] * (max_a + 1)\n temp[1] = 1\n\n for i in range(2, max_a + 1):\n if temp[i]:\n continue\n\n for j in range(i, max_a + 1, i):\n temp[j] = i\n \n ap_list = (Counter(prime_factor(a, temp)) for a in A)\n lcm = reduce(ior, ap_list, Counter())\n lcm_i = ModInt(1)\n for v in lcm.elements():\n lcm_i *= ModInt(v)\n\n\n ans = ModInt(0)\n for a in A:\n ans += lcm_i / ModInt(a)\n\n return ans\n\n\ndef main():\n answer = resolve(sys.stdin.buffer)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s380072696', 's705922768']
[8888.0, 21456.0]
[22.0, 1725.0]
[536, 3768]
p02793
u318127926
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nfrom functools import reduce\nn = int(input())\na = list(map(int, input().split()))\ndef lcm_base(x, y):\n return (x*y) // fractions.gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nl = lcm(a)\nmod = 10**9+7\ntotal = 0\nfor i in a:\n total += l//i\n total %= mod\nprint(total)', 'import fractions\nn = int(input())\na = list(map(int, input().split()))\nb = list(set(a))\nl = b[0]\nfor i in b[1:]:\n l = l * i // fractions.gcd(l,i)\nmod = 10**9+7\ntotal = 0\nfor i in a:\n total += l//i\n if total > mod:\n total %= mod\nprint(total)', 'import fractions\nfrom functools import reduce\nn = int(input())\na = list(map(int, input().split()))\ndef lcm_base(x, y):\n return (x*y) // fractions.gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nl = lcm(list(set(a)))\nmod = 10**9+7\ntotal = 0\nfor i in a:\n total += l//i\n if total > mod:\n total %= mod\nprint(total)', 'import fractions\nfrom functools import reduce\nn = int(input())\na = list(map(int, input().split()))\ndef lcm_base(x, y):\n return (x*y) // fractions.gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nl = lcm(a)\nmod = 10**9+7\ntotal = 0\nfor i in a:\n total += l//i\n if total > mod:\n total %= mod\nprint(total)', '#GCD, LCM\ndef gcd_base(a, b):\n while b!=0:\n a, b = b, a%b\n return a\n\ndef lcm(num_list):\n ans = 1\n for i in num_list:\n ans = ans * i // gcd_base(ans, i)\n return ans\n\nn = int(input())\na = list(map(int, input().split()))\nl = lcm(a)\nmod = 10**9+7\ntotal = 0\nfor i in a:\n total += l//i\nprint(total%mod)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s197311899', 's216829316', 's524223623', 's942788242', 's713336013']
[6108.0, 6584.0, 6492.0, 6108.0, 4084.0]
[2104.0, 2104.0, 2104.0, 2104.0, 1876.0]
[313, 255, 348, 337, 329]
p02793
u343523553
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\n\nnum = int(input())\nA = [int(s) for s in input().split()]\nans = A[0]\nfor i in range(1,num):\n ans = ans * A[i]//fractions.gcd(ans,A[i])\nB = [ans//A[s] for s in range(num)]\nprint(B)\nprint(sum(B)%(10**(9)+7))', 'import fractions\n\nnum = int(input())\nA = [int(s) for s in input().split()]\nans = A[0]\nfor i in range(1,num):\n ans = ans * A[i]//fractions.gcd(ans,A[i])\nB = [ans//A[s] for s in range(num)]\nprint(sum(B)%(10**(9)+7))', 'def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\ndef lcm(x, y):\n\treturn x * y // gcd (x, y)\n\nnum = int(input())\nA = [int(s) for s in input().split()]\nans = A[0]\nfor i in range(1,num):\n ans = lcm(ans,A[i])\nB = [ans//A[s] for s in range(num)]\nprint(sum(B)%(10**(9)+7))']
['Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s188991263', 's743774423', 's014314692']
[265016.0, 264632.0, 262644.0]
[2121.0, 2016.0, 1984.0]
[225, 216, 274]
p02793
u374051158
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nn = int(input())\na = list(map(int, input().split()))\n\ndef lcm(n, m):\n return n // fractions.gcd(n, m) * m\n\nLCM = a[0]\nfor i in range(1, n):\n LCM = lcm(a[i], LCM)\n\nres = 0\nMOD = 1000000007\nfor i in range(n):\n res = (res + LCM//a[i]) % MOD\nprint(res)', 'n = int(input())\na = list(map(int, input().split()))\n \ndef gcd(n, m):\n if(m): return gcd(m, n%m)\n else: return n\n \ndef lcm(n, m):\n return n // gcd(n, m) * m\n \nLCM = a[0]\nfor i in range(1, n):\n LCM = lcm(a[i], LCM)\n \nres = 0\nMOD = 1000000007\nfor i in range(n):\n res += LCM//a[i]\n \nprint(res % MOD)']
['Time Limit Exceeded', 'Accepted']
['s035911903', 's108258533']
[6112.0, 4084.0]
[2104.0, 1506.0]
[274, 314]
p02793
u374531474
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\nMOD = 10 ** 9 + 7\nN = int(input())\nA = list(map(int, input().split()))\n\nL = A[0]\nfor i in range(1, N):\n L = L * A[i] // gcd(L, A[i])\n\nans = 0\nfor i in range(N):\n ans += L // A[i]\n ans %= MOD\nprint(ans)\n', 'from fractions import gcd\nfrom functools import reduce\n\nMOD = 10 ** 9 + 7\nN = int(input())\nA = list(map(int, input().split()))\n\nL = reduce(lambda x, y: x * y // gcd(x, y), set(A))\n\nans = 0\nfor i in range(N):\n ans += L // A[i]\n ans %= MOD\nprint(ans)\n', 'from collections import Counter, defaultdict\n\nMOD = 10 ** 9 + 7\nN = int(input())\nA = list(map(int, input().split()))\n\nmax_A = max(A)\nf = list(range(max_A + 1))\nfor i in range(2, int(max_A ** 0.5) + 1):\n if f[i] == i:\n f[i::i] = [i] * (max_A // i)\n\n\ndef factors(x):\n factor = defaultdict(int)\n while x != 1:\n factor[f[x]] += 1\n x //= f[x]\n return factor\n\n\nL = defaultdict(int)\nfor i in range(N):\n Ai = factors(A[i])\n for p, index in Ai.items():\n L[p] = max(L[p], index)\nlcm = 1\nfor p, index in L.items():\n if index == 0:\n continue\n lcm *= pow(p, index, MOD)\n lcm %= MOD\n\nans = 0\nfor Ai in A:\n ans += lcm * pow(Ai, MOD - 2, MOD)\n ans %= MOD\nprint(ans % MOD)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s650698371', 's670517884', 's605239953']
[6112.0, 6484.0, 51828.0]
[2104.0, 2104.0, 199.0]
[238, 255, 724]
p02793
u378991640
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def lcm(a, b):\n while b:\n a %= b\n a, b = b, a\n gcd = a\n return a * b // gcd\n\n\nn = int(input())\na = list(map(int, input().split(" ")))\nalcm = a[0]\nfor i in a:\n alcm = lcm(alcm, i)\n\ntot = 0\nfor num in a:\n tot += alcm // num\n\nprint(tot % 1000000007)\n', 'def lcm(a, b):\n ca = a\n ca = b\n while b:\n a %= b\n a, b = b, a\n gcd = a\n return ca * cb // gcd\n\n\nn = int(input())\na = list(map(int, input().split(" ")))\nalcm = a[0]\nfor i in a:\n alcm = lcm(alcm, i)\n\ntot = 0\nfor num in a:\n tot += alcm // num\n\nprint(tot % 1000000007)\n', 'from collections import deque, Counter, defaultdict\nfrom functools import lru_cache\nfrom itertools import permutations\nfrom heapq import (\n heappush,\n heappop,\n heapreplace,\n heappushpop,\n heapify,\n merge,\n nlargest,\n nsmallest,\n)\nfrom statistics import mean, median, mode\n\n\ndef lcm(a, b):\n p = a * b\n while b:\n a %= b\n a, b = b, a\n return p // a\n\n\nn = int(input())\na = list(map(int, input().split(" ")))\nalcm = a[0]\nfor i in a:\n alcm = lcm(alcm, i)\n\ntot = 0\nfor num in a:\n tot += alcm // num\n\nprint(tot % 1000000007)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s818850429', 's911570544', 's806015955']
[4084.0, 4084.0, 6084.0]
[23.0, 20.0, 1902.0]
[276, 300, 571]
p02793
u392319141
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\nMOD = 10**9 + 7\n\ndef primeCount(N):\n R = int(N**(0.5)) + 1 \n primes = defaultdict(int) \n n = N\n for num in range(2, R):\n primes[num] = 0\n while n % num == 0:\n n //= num\n primes[num] += 1\n if n > 1 :\n primes[n] = 1\n return primes\n\nPC = [primeCount(a) for a in set(A)]\n\nprimes = defaultdict(int)\nfor pc in PC:\n for p, c in pc.items():\n if c > primes[p]:\n primes[p] = c\n\nprint(0)\n', 'N = int(input())\nA = list(map(int, input().split()))\nMOD = 10**9 + 7\n\ndef gcd(n, m):\n if m == 0:\n return n\n return gcd(m, n % m)\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nL = 1\nfor a in A:\n L = lcm(L, a)\n\nL %= MOD\ncoef = 0\nfor a in A:\n coef += pow(a, MOD - 2, MOD)\nprint((L * coef) % MOD)\n']
['Wrong Answer', 'Accepted']
['s433940683', 's129873900']
[721348.0, 4084.0]
[2149.0, 955.0]
[588, 313]
p02793
u392712707
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\n\nN = int(input())\nlist = list(map(int, input().split()))\n\nlcm = list[0]\nfor i in range(1, N):\n lcm = lcm * list[i] // fractions.gcd(lcm, list[i])\n\n\n\nans = 0\n\nfor i in range(N):\n ans += int(lcm / list[i])\n\nprint(ans % (10**9 + 7))\n', 'N = int(input())\nlist = list(map(int, input().split()))\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd (a, b)\n\nalllcm = 1\n\nfor i in range(N):\n alllcm = lcm(alllcm, list[i])\n\nans = 0\n\nfor i in range(N):\n ans += alllcm // list[i]\n\nprint(ans % (10**9 + 7))\n']
['Runtime Error', 'Accepted']
['s158662880', 's393334243']
[6200.0, 4084.0]
[931.0, 1877.0]
[251, 305]
p02793
u413165887
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nmod = 10**9 +7\nn = int(input())\na = list(map(int, input().split()))\nr = a[0]\nfor i in range(1, n):\n r = r*a[i]//gcd(r, a[i])\nresult = 0\nfor i in a:\n result = (result+r//i)%mod\nprint(result)', 'from collections import defaultdict\nn = int(input())\na = list(map(int, input().split()))\n\nmod = 10**9 + 7\nmemo = defaultdict(int)\nbase = 0\nfor i in a:\n base = (base+pow(i, mod-2, mod))%mod\n num = i\n c = 0\n while num%2==0:\n c += 1\n num //= 2\n memo[2] = max(memo[2], c)\n for j in range(3, int(i**.5)+1, 2):\n if num%j==0:\n c = 0\n while num%j==0:\n num //= j\n c += 1\n memo[j] = max(memo[j], c)\n if num != 1:\n memo[num] = max(memo[num], 1)\nk = 1\nfor s, t in memo.items():\n k = (k*pow(s, t, mod))%mod\n\nprint((k*base)%mod)']
['Time Limit Exceeded', 'Accepted']
['s890961258', 's829725943']
[6112.0, 4852.0]
[2104.0, 665.0]
[221, 629]
p02793
u414699019
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\nN=int(input())\nA=list(map(int,input().split()))\na_lcm=A[0]\n\nfor i in range(1,N):\n a_lcm=lcm(a_lcm,A[i])\n\nresult=0\nfor i in range(N):\n result+=a_lcm//A[i]\n result%=1000000007\nprint(result%1000000007)', 'import fractions\n\ndef lcm(x, y):\n return (x * y) // fractions.gcd(x, y)\n\nN=int(input())\nA=list(map(int,input().split()))\na_lcm=A[0]\n\nfor i in range(1,N):\n a_lcm=lcm(a_lcm,A[i])\n\nresult=0\nfor i in range(N):\n result+=a_lcm//A[i]\n result%=1000000007\nprint(result%1000000007)', 'import fractions\n\nN=int(input())\nA=list(map(int,input().split()))\n\nfor i in range(N-1):\n if i==0:\n a_lcm=(A[i]*A[i+1])//fractions.gcd(A[i],A[i+1])\n else:\n a_lcm=(a_lcm*A[i+1])//fractions.gcd(a_lcm,A[i+1])\n\nresult=0\nfor i in range(N):\n result+=a_lcm//A[i]\n result%=1000000007\nprint(result)', 'def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\n \ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN=int(input())\nA=list(map(int,input().split()))\na_lcm=A[0]\nMod=10**9+7\n\nfor i in range(1,N):\n a_lcm=lcm(a_lcm,A[i])\n\na_lcm%=Mod\n\nresult=0\nfor i in range(N):\n result+=a_lcm*pow(A[i],Mod-2,Mod)\nprint(result%1000000007)']
['Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s073651615', 's371738168', 's754821160', 's133291876']
[6112.0, 6112.0, 6200.0, 4084.0]
[38.0, 2104.0, 2104.0, 950.0]
[278, 283, 314, 342]
p02793
u424241608
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def gcd(a,b):\n if a==0:return b\n return gcd(b%a,a)\nn = int(input())\na = list(map(int, input().split()))\n#print(a)\nb=[]\nfor i in range(n):\n #print(i)\n b.append(a[i])\nfor i in range(n):\n if i != 0:\n b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]\nlcm=b[n-1]\nans=0\nfor i in range(n):\n #print(a[i])\n ans=(ans+lcm/a[i])\nprint(int(ans%(10**9+7))\n', 'import java.io.*;\nimport java.util.*;\nimport java.math.BigInteger;\n\npublic class Main {\n static int N = (int)1e9 + 7;\n public static void main(String[] args){\n MyReader mr = new MyReader();\n PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\n int n = mr.nextInt();\n int[] arr = mr.nextIntArray(n);\n\n BigInteger l = BigInteger.valueOf(arr[0]);\n\n for(int i = 1;i<n;i++){\n l = lcm(l,BigInteger.valueOf(arr[i]));\n }\n\n BigInteger sum = BigInteger.valueOf(0);\n for(int num : arr){\n BigInteger tmp = l.divide(BigInteger.valueOf(num));\n sum = sum.add(tmp);\n\n }\n\n\n\n System.out.println(sum.mod(BigInteger.valueOf(N)).toString());\n\n\n\n\n\n\n\n }\n\n static BigInteger lcm(BigInteger a, BigInteger b){\n BigInteger gcd = a.gcd(b);\n BigInteger mul = a.multiply(b);\n BigInteger res = mul.divide(gcd);\n return res;\n }\n\n\n\n static class MyReader {\n BufferedReader br;\n StringTokenizer st;\n\n MyReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String res = "";\n try {\n res = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n return res;\n }\n\n int[] nextIntArray(int n){\n try{\n st = new StringTokenizer(br.readLine());\n }\n catch (Exception e){\n e.printStackTrace();\n }\n int[] arr = new int[n];\n for(int i=0;i<n;i++){\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n return arr;\n }\n\n long[] nextLongArray(int n){\n try{\n st = new StringTokenizer(br.readLine());\n }\n catch (Exception e){\n e.printStackTrace();\n }\n long[] arr = new long[n];\n for(int i=0;i<n;i++){\n arr[i] = Integer.parseInt(st.nextToken());\n }\n\n return arr;\n }\n\n String[] nextStringArray(int n){\n String res = "";\n try{\n res = br.readLine();\n }\n catch (Exception e){\n e.printStackTrace();\n }\n\n String[] arr = res.split(" ");\n return arr;\n }\n }\n\n static class Pair {\n int x, y;\n\n public Pair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n }\n\n static void swap(int[] arr, int i, int j) {\n int tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n\n}\n\n\n', 'n = int(input())\narr = list(map(int,input().split()))\n\nN = pow(10,9)+7\ndef gcd(a,b):\n if a==0:return b\n return gcd(b%a,a)\n\ndef lcm(a,b):\n tmp = (a*b)//gcd(a,b)\n return tmp\n\nhcm = arr[0]\nfor i in range(1,n):\n hcm = lcm(hcm,arr[i])\n\nres = 0\nfor num in arr:\n res += (hcm//num)\n \n\nprint(res%N)\n \n\n \n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s049667560', 's621251287', 's013083902']
[3064.0, 2940.0, 4084.0]
[17.0, 17.0, 1886.0]
[360, 3347, 323]
p02793
u442877951
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['N = int(input())\nA = list(map(int,input().split()))\nmod = 10**9+7\n\nimport fractions\nfrom functools import reduce\n\ndef gcd(x,y):\n if x == 0:\n return y\n else:\n return gcd(x%y,x)\n \n\ndef lcm(x, y):\n return (x*y)//gcd(x,y)\n \nl = 1\nB = 0\n\nfor i in range(N):\n l = lcm(l,A[i])\nfor i in range(N):\n B += l//A[i]\nB %= mod\n\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\nA = sorted(A)\nmod = 10**9+7\nsetA = []\nfor i in range(N):\n if A[-1]%A[i] != 0 or i == N-1:\n setA.append(A[i])\n\nimport fractions\nfrom functools import reduce\n \ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n \ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n \ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \n \nl = lcm(*setA)\nB = 0\nfor i in range(N):\n B += l//A[i]%mod\nB %= mod\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 10**9+7\n\nimport fractions\nfrom functools import reduce\n\ndef lcm(x, y):\n return (x * y) // fractions.gcd(x, y)\n \nl = 1\nB = 0\n\nfor i in range(N):\n l = lcm(l,A[i])\nfor i in range(N):\n B += l//A[i]%mod\nB %= mod\n\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\n\nmod = 10**9+7\n\nimport fractions\nfrom functools import reduce\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\n\nl = lcm(*A)\nB = 0\nfor i in range(N):\n B += l//A[i]%mod\nB %= mod\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\n\nA = sorted(A)\nmod = 10**9+7\nsetA = [0]*N\nsetA[-1] = A[-1]\n\nfor i in range(N):\n if A[-1]%A[i] != 0:\n setA[i] = A[i]\nsetA = [s for s in setA if s != 0]\n\n\nimport fractions\nfrom functools import reduce\n\n \ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n \ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n \ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \n \nl = lcm(*setA)\nB = 0\n\nfor i in range(N):\n B += l//A[i]%mod\nB %= mod\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\nsetA = list(set(A))\nmod = 10**9+7\n \nimport fractions\nfrom functools import reduce\n \ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n \ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n \ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \n \nl = lcm(*setA)\nB = 0\nfor i in range(N):\n B += l//A[i]%mod\nB %= mod\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\n\nmod = 10**9+7\n\nimport fractions\nfrom functools import reduce\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\n\nl = lcm(*A)\nB = 0\nfor i in range(N):\n B += l//A[i]\n B %= mod\nprint(B)', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 10**9+7\n\nimport fractions\nfrom functools import reduce\n\ndef gcd(x,y):\n if x == 0:\n return y\n else:\n return gcd(y-x*(y//x),x)\n \n\ndef lcm(x, y):\n return (x*y)//gcd(x,y)\n \nl = 1\nB = 0\n\nfor i in range(N):\n l = lcm(l,A[i])\nfor i in range(N):\n B += l//A[i]\nB %= mod\n\nprint(B)']
['Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s064343229', 's151132218', 's152968371', 's330229405', 's417435422', 's740561176', 's936592305', 's467665579']
[5496.0, 5972.0, 5616.0, 5844.0, 5944.0, 5924.0, 5844.0, 5612.0]
[190.0, 2104.0, 2104.0, 2104.0, 2104.0, 2104.0, 2104.0, 1986.0]
[336, 482, 282, 376, 527, 404, 374, 343]
p02793
u457901067
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from itertools import groupby\nfrom collections import Counter\n\n\ndef fast_prime_factorization_many(lst):\n \n from subprocess import Popen, PIPE\n res = Popen(["factor"] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b"\\n")[:-1]\n return [Counter(list(map(int, r.split()[1:]))) for r in res]\n\ndef main():\n import sys\n input = sys.stdin.readline\n N = int(input())\n A = list(map(int, input().split()))\n if N == 1:\n print(1)\n exit(0)\n \n mod = int(1e9+7)\n Factors = fast_prime_factorization_many(A)\n #print(Factors)\n \n lcm = 1\n max_factor = [0] * (1000010)\n for f in Factors:\n for k,v in f.items():\n v_prev = max_factor[k]\n if v_prev < v:\n for i in range(v-v_prev):\n lcm = lcm * k % mod\n max_factor[k] = v\n \n print(lcm)\n ans = 0\n for a in A:\n wk = lcm * pow(a,mod-2,mod)\n print(wk)\n ans += wk\n ans %= mod\n print(ans)\n exit(0)\n \nmain()\n', 'from math import sqrt\nfrom fractions import gcd\nN = int(input())\nA = list(map(int, input().split()))\n\ndef insuu(N):\n ret = {}\n for i in range(2,int(sqrt(N)+10)):\n if i > 3 and (i%2 == 0 or i%3 == 0):\n continue\n if N%i == 0:\n ret[i] = 1\n N /= i\n while N%i == 0:\n ret[i] += 1\n N /= i\n if N>1:\n ret[N] = 1\n return ret\n \n#for a in A:\n\n \n\nwork = insuu(A[0])\nfor i in range(1,N):\n now = insuu(A[i])\n for k,v in work.items():\n if k in now and now[k] > v:\n work[k] = now[k]\n for k,v in now.items():\n if not k in work:\n work[k] = v\n \n#print(work)\n\n\nans = 0\nmod = int(1e9+7)\n\nfor a in A:\n B = 1\n now = insuu(a)\n for k,v in work.items():\n if k in now:\n B = B * k ** (v - now[k]) % mod\n else:\n B = B * k ** v % mod\n ans = (ans + B) % mod\n \nprint(ans)', "N = int(input())\nA = list(map(int, input().split()))\nif N == 1:\n print(1)\n exit(0)\n \nmod = int(1e9+7)\n\n######\n# https://qiita.com/fantm21/items/5e270dce9f4f1d963c1e\nimport math\n\ndef get_sieve_of_eratosthenes(n):\n if not isinstance(n, int):\n raise TypeError('n is int type.')\n if n < 2:\n raise ValueError('n is more than 2')\n prime = []\n limit = math.sqrt(n)\n data = [i + 1 for i in range(1, n)]\n while True:\n p = data[0]\n if limit <= p:\n return prime + data\n prime.append(p)\n data = [e for e in data if e % p != 0]\n##########\n\nB = get_sieve_of_eratosthenes(10**3+10)\nprint(len(B))\nfrom collections import defaultdict\nD = defaultdict(int)\n \ndef insu_bunkai(a):\n ret = defaultdict(int)\n for b in B:\n while a%b == 0:\n a = a // b\n ret[b] += 1\n if a > 1000:\n ret[a] += 1\n break\n return ret\nDA = []\nfor a in A:\n w = insu_bunkai(a)\n for k,v in w.items():\n D[k] = max(D[k], v)\n DA.append(w)\n \nans = 0\nfor i in range(N):\n wk = 1\n for k,v in D.items():\n if k in DA[i]:\n wk *= pow(k,v-DA[i][k],mod)\n else:\n wk *= pow(k,v,mod) \n wk %= mod\n ans += wk\n ans %= mod\n \nprint(ans)", 'from itertools import groupby\nfrom collections import Counter\n\n\ndef fast_prime_factorization_many(lst):\n \n from subprocess import Popen, PIPE\n res = Popen(["factor"] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b"\\n")[:-1]\n return [Counter(list(map(int, r.split()[1:]))) for r in res]\n\ndef main():\n import sys\n input = sys.stdin.readline\n N = int(input())\n A = list(map(int, input().split()))\n if N == 1:\n print(1)\n exit(0)\n \n mod = int(1e9+7)\n Factors = fast_prime_factorization_many(A)\n #print(Factors)\n \n lcm = 1\n max_factor = [0] * (1000010)\n for f in Factors:\n for k,v in f.items():\n v_prev = max_factor[k]\n if v_prev < v:\n for i in range(v-v_prev):\n lcm = lcm * k % mod\n max_factor[k] = v\n \n #print(lcm)\n ans = 0\n for a in A:\n wk = lcm * pow(a,mod-2,mod)\n #print(wk)\n ans += wk\n ans %= mod\n print(ans)\n exit(0)\n \nmain()\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s350167854', 's625769828', 's634784380', 's029398733']
[21760.0, 6240.0, 12804.0, 21784.0]
[122.0, 2104.0, 2206.0, 124.0]
[1042, 882, 1199, 1044]
p02793
u474514603
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['#-*- coding: utf-8 -*-\n"""\noj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d\noj test -d test-d -c "python abc116d.py"\noj test -d test-d -c "python abc116d.py" test-d/sample-3.in\n"""\nfrom collections import defaultdict\nimport sys\nimport math\nfrom datetime import datetime\nimport re\nimport math\n\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\ndef lcm_list(nums):\n if len(nums) == 0:\n return None\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n lcm(nums[0], nums[1])\n else: # > 2\n a = lcm(nums[0], nums[1])\n for i in range(2, len(nums)):\n A = lcm(a, nums[i])\n a = A\n return a\n\n\n\n\ndef sol(S):\n mod = 10**9 + 7\n x = lcm_list(S)\n print(x)\n T = [ x//s for s in S]\n return sum(T) % mod\n\n\n\n\n\n\n\ndo_submit = True\n\n\ndef input_parse(input_str):\n lines = [x.strip() for x in input_str.split("\\n") if x.strip()]\n parsed_lines = [list(map(str, line.split())) for line in lines]\n print(parsed_lines)\n # n = int(parsed_lines[0][0])\n \n S = parsed_lines[0][0]\n return S\n\n\nif not do_submit:\n S = input_parse("""\n 1905\n """)\n print(sol(S))\n\n S = input_parse("""\n 0112\n """)\n print(sol(S))\n\n S = input_parse("""\n 1700\n """)\n print(sol(S))\n\n S = input_parse("""\n 0000\n """)\n print(sol(S))\n\n S = input_parse("""\n 1001\n """)\n print(sol(S))\n\n\n\nelse:\n n = int(input())\n S = list(map(int, input().split()))\n #S = input()\n print(sol(S))\n\n # S = input().strip()\n # print(sol(S))\n # print(lcm(2, 3))\n # print(lcm_list([2, 3, 4]))\n # print(lcm_list([27, 9, 3]))\n\n\n\n\n', '#-*- coding: utf-8 -*-\n"""\noj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d\noj test -d test-d -c "python abc116d.py"\noj test -d test-d -c "python abc116d.py" test-d/sample-3.in\n"""\nfrom collections import defaultdict\nimport sys\nimport math\nfrom datetime import datetime\nimport re\nimport math\n\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\ndef lcm_list(nums):\n if len(nums) == 0:\n return None\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n lcm(nums[0], nums[1])\n else: # > 2\n a = lcm(nums[0], nums[1])\n for i in range(2, len(nums)):\n A = lcm(a, nums[i])\n a = A\n return a\n\n\n\n\ndef sol(S):\n mod = 10**9 + 7\n x = lcm_list(S)\n #print(x)\n T = [ x//s for s in S]\n return sum(T) % mod\n\n\n\n\n\n\n\ndo_submit = True\n\n\ndef input_parse(input_str):\n lines = [x.strip() for x in input_str.split("\\n") if x.strip()]\n parsed_lines = [list(map(str, line.split())) for line in lines]\n print(parsed_lines)\n # n = int(parsed_lines[0][0])\n \n S = parsed_lines[0][0]\n return S\n\n\nif not do_submit:\n S = input_parse("""\n 1905\n """)\n print(sol(S))\n\n S = input_parse("""\n 0112\n """)\n print(sol(S))\n\n S = input_parse("""\n 1700\n """)\n print(sol(S))\n\n S = input_parse("""\n 0000\n """)\n print(sol(S))\n\n S = input_parse("""\n 1001\n """)\n print(sol(S))\n\n\n\nelse:\n n = int(input())\n S = list(map(int, input().split()))\n #S = input()\n print(sol(S))\n\n # S = input().strip()\n # print(sol(S))\n # print(lcm(2, 3))\n # print(lcm_list([2, 3, 4]))\n # print(lcm_list([27, 9, 3]))\n\n\n\n\n']
['Wrong Answer', 'Accepted']
['s703798541', 's610221880']
[263408.0, 263280.0]
[2049.0, 1991.0]
[1794, 1795]
p02793
u477977638
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\n\nread = sys.stdin.buffer.read\ninput = sys.stdin.buffer.readline\ninputs = sys.stdin.buffer.readlines\n\n\nmod=10**9+7\n# rstrip().decode(\'utf-8\')\n# map(int,input().split())\n#import numpy as np\n\n#from math import gcd\nfrom fractions import gcd\n\ndef main():\n\tn=int(input())\n\tA=list(map(int,input().split()))\n\t\n\ta=1\n\tfor i in A:\n\t\ta=a*i//gcd(a, i)\n\tans=0\n\tfor i in A:\n\t\tans+=(a//i)\n\t\tans%=mod\n\tprint(ans)\n\t\n\t\n\t\n\t\n\t\n\t\n\n\nif __name__ == "__main__":\n\tmain()\n', 'import sys\n\nread = sys.stdin.buffer.read\ninput = sys.stdin.buffer.readline\ninputs = sys.stdin.buffer.readlines\n\n\nmod=10**9+7\n# rstrip().decode(\'utf-8\')\n# map(int,input().split())\n#import numpy as np\n\n#from math import gcd\nfrom fractions import gcd\n\ndef main():\n\tn=int(input())\n\tA=list(map(int,input().split()))\n\tB=set(A)\n\tA=list(A)\n\tA.sort(reverse=True)\n\ta=1\n\tans=0\n\tfor i in A:\n\t\tg=gcd(a, i)\n\t\tans *=i//g\n\t\ta=a*i//gcd(a, i)\n\t\tans+=a//i\n\t\tans%=mod\n\t\n\t\n\t\n\t\n\tprint(ans)\n\t\n\t\n\t\n\t\n\t\n\t\n\n\nif __name__ == "__main__":\n\tmain()\n', 'def gcd(x,y):\n if y==0:\n return x\n return gcd(y,x%y)\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\n\tlcm %= MOD\nans = 0\nfor i in A:\n ans += lcm*pow(i,MOD-2,MOD)\n\nprint(ans%MOD)\n', 'def gcd(x,y):\n if y==0:\n return x\n return gcd(y,x%y)\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nlcm = MOD\nans = 0\nfor i in A:\n ans += lcm//i\n ans %= MOD\nprint(ans)\n', 'def gcd(x,y):\n if y==0:\n return x\n return gcd(y,x%y)\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int,input().split()))\nlcm = 1\nfor i in A:\n lcm = (lcm*i)//gcd(lcm,i)\nlcm %= MOD\nans = 0\nfor i in A:\n ans += lcm*pow(i,MOD-2,MOD)\n\nprint(ans%MOD)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s367000208', 's669288445', 's720141395', 's761812673', 's896746241']
[5944.0, 6456.0, 3064.0, 4084.0, 4084.0]
[2104.0, 2104.0, 18.0, 921.0, 957.0]
[456, 517, 263, 257, 262]
p02793
u497952650
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\ndef lcm(a, b):\n return (a * b)//gcd(a,b)\n\nN = int(input())\nA = list(map(int,input().split()))\n\nlcm_a = 1\n\nfor i in range(N):\n lcm_a = lcm(lcm_a,A[i])\n\nB = np.array([])\nfor i in range(N):\n B = np.append(B,lcm_a//A[i])\n\nmod = int(1e9+7)\nprint(int((np.sum(B)%mod)))\n\nfrom fractions import gcd', 'import numpy as np \n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\ndef lcm(a, b):\n return (a * b)//gcd(a,b)\n\nN = int(input())\nA = list(map(int,input().split()))\n\nlcm_a = 1\n\nfor i in range(N):\n lcm_a = lcm(lcm_a,A[i])\n\nB = np.array([])\nfor i in range(N):\n B = np.append(B,lcm_a//A[i])\n\nmod = int(1e9+7)\nprint((np.sum(B)%mod)//1)', 'import numpy as np \n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\ndef lcm(a, b):\n return (a * b)//gcd(a,b)\n\nN = int(input())\nA = list(map(int,input().split()))\n\nlcm_a = 1\n\nfor i in range(N):\n lcm_a = lcm(lcm_a,A[i])\n\nB = np.array([])\nfor i in range(N):\n B = np.append(B,lcm_a//A[i])\n\nmod = int(1e9+7)\nprint(np.sum(B)%mod//1)\n', 'def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\ndef lcm(a, b):\n return (a * b)//gcd(a,b)\n\nN = int(input())\nA = list(map(int,input().split()))\n\nlcm_a = 1\n\nfor i in A:\n lcm_a = lcm(lcm_a,i)\n\nans = 0\nfor i in A:\n ans +=lcm_a//i \n \nprint(ans%int(1e9+7))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s142578393', 's233022206', 's452073629', 's528114389']
[6140.0, 185776.0, 184368.0, 4084.0]
[931.0, 2119.0, 2119.0, 1874.0]
[325, 352, 351, 275]
p02793
u499381410
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nfrom bisect import bisect_right, bisect_left\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom copy import deepcopy\nfrom math import factorial, ceil, floor, gamma, log, gcd\nfrom operator import mul\nfrom functools import reduce\n\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 20\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 10 ** 9 + 7\n\n\ndef prime_decomposition(n):\n table = []\n for i in range(2, int(n ** 0.5) + 1):\n while n % i == 0:\n table += [i]\n n //= i\n if n == 1:\n break\n if n != 1:\n table += [a]\n return table\n\n\nn = I()\nA = LI()\nprime_d = defaultdict(int)\nfor a in A:\n for p, cnt in Counter(prime_decomposition(a)).items():\n if prime_d[p] < cnt:\n prime_d[p] = cnt\n\n\nlcm = 1\nfor p, cnt in prime_d.items():\n lcm = lcm * pow(p, cnt, mod) % mod\n\n\ninv = list(range(10 ** 6 + 1))\nfor i in range(1, 10 ** 6 + 1):\n inv[i] = pow(inv[i], mod-2, mod)\n\n\nans = 0\nfor a in A:\n ans = ans + lcm * inv[a]\n\n\nprint(ans % mod)", "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nfrom bisect import bisect_right, bisect_left\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom copy import deepcopy\nfrom math import factorial, ceil, floor, gamma, log\nfrom operator import mul\nfrom functools import reduce\n\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 20\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 10 ** 9 + 7\n\n\ndef prime_decomposition(n):\n table = []\n for i in range(2, int(n ** 0.5) + 1):\n while n % i == 0:\n table += [i]\n n //= i\n if n == 1:\n break\n if n != 1:\n table += [a]\n return table\n\n\nn = I()\nA = LI()\nprime_d = defaultdict(int)\nfor a in A:\n for p, cnt in Counter(prime_decomposition(a)).items():\n if prime_d[p] < cnt:\n prime_d[p] = cnt\n\n\nlcm = 1\nfor p, cnt in prime_d.items():\n lcm = lcm * pow(p, cnt, mod) % mod\n\n\ninv = list(range(10 ** 6 + 1))\nfor i in range(1, 10 ** 6 + 1):\n inv[i] = pow(inv[i], mod-2, mod)\n\n\nans = 0\nfor a in A:\n ans = ans + lcm * inv[a]\n\n\nprint(ans % mod)", "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nfrom bisect import bisect_right, bisect_left\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom copy import deepcopy\nfrom math import factorial, ceil, floor, gamma, log\nfrom operator import mul\nfrom functools import reduce\n\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 20\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 10 ** 9 + 7\n\ndef primes(n):\n ass = []\n is_prime = [True] * (n + 1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5) + 1):\n if not is_prime[i]:\n continue\n for j in range(i * 2, n + 1, i):\n is_prime[j] = False\n for i in range(len(is_prime)):\n if is_prime[i]:\n ass.append(i)\n return ass\n\ndef prime_decomposition(n):\n table = []\n for i in range(2, int(n ** 0.5) + 1):\n while n % i == 0:\n table += [i]\n n //= i\n if n == 1:\n break\n if n != 1:\n table += [a]\n return table\n\npr = primes(10 ** 3 + 1)\nn = I()\nA = LI()\nD = defaultdict(int)\nfor a in A:\n for p in pr:\n if a < p:\n break\n cnt = 0\n while a % p == 0:\n cnt += 1\n a //= p\n if cnt > D[p]:\n D[p] = cnt\n if a > 1 and D[a] == 0:\n D[a] = 1\n\nlcm = 1\nfor v in D:\n lcm = lcm * pow(v, D[v], mod) % mod\n\nans = 0\nfor a in A:\n ans = (ans + pow(a, mod-2, mod) * lcm % mod) % mod\n\n\n\nprint(ans)"]
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s922875094', 's932450251', 's409181683']
[5148.0, 46676.0, 5708.0]
[44.0, 2108.0, 582.0]
[1733, 1728, 2123]
p02793
u500496457
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["def gcd(x, y):\n x = x % y\n if x == 0:\n return y\n return gcd(y, x)\n\ndef lcm(x, y):\n return x // gcd(x, y) * y\nn = int(input())\na = list(map(int, input().split(' ')))\nl = 1\nfor ai in a:\n l = lcm(l, ai)\nprint(l)\nmod = 1000000007\nans = 0\nfor ai in a:\n ans += l // ai\nans %= mod\nprint(ans)\n", "def gcd(x, y):\n x = x % y\n if x == 0:\n return y\n return gcd(y, x)\n\ndef lcm(x, y):\n return x // gcd(x, y) * y\nn = int(input())\na = list(map(int, input().split(' ')))\nl = 1\nfor ai in a:\n l = lcm(l, ai)\nmod = 1000000007\nans = 0\nfor ai in a:\n ans += l // ai\nans %= mod\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s581879897', 's119917151']
[4084.0, 4084.0]
[1943.0, 1887.0]
[310, 301]
p02793
u501265339
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nN = int(input())\na = list(map(int, input().split()))\nans = a[0]\nfor i in range(1, N):\n ans = ans * a[i] // fractions.gcd(ans, a[i])\n\nB = []\nfor i in range(N):\n B.append(ans//a[i])\n\nprint(sum(B) % (10**9 + 7))', 'def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN = int(input())\na = list(map(int, input().split()))\nans = a[0]\nfor i in range(1, N):\n ans = ans * a[i] // gcd(ans, a[i])\n\nB = []\nfor i in range(N):\n B.append(ans//a[i])\n\nprint(sum(B) % (10**9 + 7))']
['Time Limit Exceeded', 'Accepted']
['s196168736', 's400671140']
[264632.0, 262644.0]
[2003.0, 1992.0]
[231, 306]
p02793
u521602455
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def gcd(a,b):\n if a>b:\n return gcd(b,a)\n if a==0:\n return b\n return gcd(b-a*(b//a),a)\ndef lcm(x,y):\n return (x*y)//gcd(x,y)\nN=int(input())\nA=list(map(input().split()))\ns=1\nfor a in A:\n s=lcm(s,a)\nans=0\nfor a in A:\n ans+=s//a\nprint(ans%(10**9+7))', 'def gcd(a,b):\n if a>b:\n return gcd(b,a)\n if a==0:\n return b\n return gcd(b-a*(b//a),a)\ndef lcm(x,y):\n return (x*y)//gcd(x,y)\nN=int(input())\nA=list(map(input().split()))\ns=1\nfor a in A:\n s=lcm(s,i)\nans=0\nfor a in A:\n ans+=s//i\nprint(ans%(10**9+7))', 'def gcd(a,b):\n if a>b:\n return gcd(b,a)\n if a==0:\n return b\n return gcd(b-a*(b//a),a)\ndef lcm(x,y):\n return (x*y)//gcd(x,y)\nN=int(input())\nA=list(map(int,input().split()))\ns=1\nfor a in A:\n s=lcm(s,a)\nans=0\nfor a in A:\n ans+=s//a\nprint(ans%(10**9+7))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s126225842', 's987507641', 's980022022']
[3828.0, 3700.0, 4084.0]
[18.0, 19.0, 1970.0]
[277, 277, 281]
p02793
u532573979
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['mod=10**9+7\nn=int(input())\na=list(map(int,input().split()))\n\ndef gcd(m, n):\n while n:\n m, n = n, m % n\n return m\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nL=1\nfor i in range(n):\n L = lcm(l, a[i])\nans = 0\nL %= mod\nfor i in range(n):\n ans += l * pow(a[i], mod - 2, mod)\n ans %= mod\nprint(ans)\n', 'mod=10**9+7\nn=int(input())\na=list(map(int,input().split()))\n\ndef gcd(m, n):\n while n:\n m, n = n, m % n\n return m\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nL = 1\nfor i in range(n):\n L = lcm(L, a[i])\nans = 0\nL %= mod\nfor i in range(n):\n ans += L * pow(a[i], mod - 2, mod)\n ans %= mod\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s913781172', 's374456252']
[4084.0, 4084.0]
[19.0, 950.0]
[304, 306]
p02793
u540761833
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nN = int(input())\nA = list(map(int,input().split()))\nmod = 10**9 + 7\nLCM = 1\nfor i in A:\n GCD = gcd(LCM,i)\n LCM = LCM*i//GCD\nans = 0\nfor i in A:\n ans += (LCM//i)%mod\nprint(ans)', 'from fractions import gcd\nN = int(input())\nA = list(map(int,input().split()))\nmod = 10**9 + 7\nLCM = A[0]\nGCD = A[0]\nfor i in A:\n GCD = gcd(LCM,i)\n LCM = LCM*i//GCD\nans = 0\nfor i in A:\n ans += (LCM//i)%mod\nprint(ans)', 'from fractions import gcd\nN = int(input())\nA = list(map(int,input().split()))\nmod = 10**9 + 7\nLCM = 1\nfor i in A:\n GCD = gcd(LCM,i)\n LCM = LCM*i//GCD\nans = 0\nfor i in A:\n ans = (ans+LCM//i)%mod\nprint(ans)', 'from fractions import gcd\nN = int(input())\nA = list(map(int,input().split()))\nmod = 10**9 + 7\nLCM = 1\nfor i in A:\n GCD = gcd(LCM,i)\n LCM = LCM*i//GCD\nans = 0\nfor i in A:\n ans = (ans+LCM//i)%mod\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 10**9 + 7\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n\ndef lcm(a,b):\n gcda = gcd(a,b)\n return a*b//gcda\n\n\ndef lcmlist(lista):\n if len(lista) == 1:\n return lista[0]\n else:\n from functools import reduce\n return reduce(lcm,lista)\nLCM = lcmlist(A)\nans = 0\nfor i in A:\n ans += LCM//i\nprint(ans%mod)']
['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s189874572', 's287327151', 's506314290', 's804638909', 's645710154']
[6112.0, 6112.0, 6112.0, 6112.0, 4208.0]
[2108.0, 2104.0, 2104.0, 2104.0, 1892.0]
[210, 224, 213, 213, 453]
p02793
u548163222
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['N = int(input())\nA = list(map(int, input().split()))\n\nimport numpy as np\n\ndef gcd(x: int, y: int):\n if (y == 0):\n return x\n else:\n return gcd(y, x%y)\n\ng = 1\nfor i in range(N):\n g = g * A[i] // gcd(g, A[i])\nan = 0\nMOD = 10**9+7\n\nfor x in A:\n //print(g,g//x)\n an += g//x\n an %= MOD\n\nprint(an)', "N = int(input())\nA = list(map(int, input().split()))\n\n#N = 10000\n\n\nMOD = 10**9+7\n\nsm = 0\nfor x in A:\n sm += pow(x,MOD-2,MOD)\n sm %= MOD\n\ndef gcd(x: int, y: int):\n while(y!=0):\n tmp = x%y\n x = y\n y = tmp\n return x\n\ng = 1\nfor i in range(N):\n g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)\n #print(g)\n\nan = g * sm % MOD\n\n'''\nfor x in A:\n #print(g,g//x)\n an += g*pow(x,MOD-2,MOD)\n an %= MOD\n print(g,g//x,an)\n'''\n\nprint(an)"]
['Runtime Error', 'Accepted']
['s799942237', 's150205926']
[3064.0, 4084.0]
[17.0, 953.0]
[302, 485]
p02793
u561231954
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["def main():\n def sieve(n):\n prime=[]\n limit=n*0.5\n data=[i+1 for i in range(1,n)]\n while True:\n p=data[0]\n if limit<=p:\n return prime+data\n prime.append(p)\n data=[e for e in data if e%p!=0]\n \n prime=sieve(1000)\n import sys\n import numpy as np\n input=sys.stdin.readline\n mod=10**9+7\n \n n=int(input())\n num=np.array(list(map(int,input().split())))\n \n lcm=1\n num_copy=num.copy()\n for p in prime:\n while np.any(num%p==0):\n num[num%p==0]//=p\n lcm *= p\n lcm %= mod\n \n #print(lcm,num_copy)\n ans=0\n for i in range(n):\n ans += lcm * pow(num_copy[i] ,mod-2 ,mod)\n ans %= mod \n #print(ans)\n print(ans)\n \nif __name__=='__main__':\n main()", "def main():\n def sieve(n):\n prime=[]\n limit=n*0.5\n data=[i+1 for i in range(1,n)]\n p_append=prime.append\n while True:\n p=data[0]\n if limit<=p:\n return prime+data\n p_append(p)\n data=[e for e in data if e%p!=0]\n \n prime=sieve(1000)\n import sys\n import numpy as np\n input=sys.stdin.readline\n mod=10**9+7\n \n n=int(input())\n num=list(map(int,input().split()))\n num_copy=np.array(num)\n \n lcm=1\n for p in prime:\n while np.any(num_copy%p==0):\n num_copy[num_copy%p==0]//=p\n lcm *= p\n lcm %= mod\n \n for i in set(num_copy.tolist()):\n lcm *= i\n lcm %= mod\n \n #print(lcm,num)\n ans=0\n for i in range(n):\n ans += lcm * pow(num[i] ,mod-2 ,mod)\n ans %= mod \n #print(ans)\n print(ans)\n \nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s261059422', 's480992601']
[14204.0, 13604.0]
[343.0, 295.0]
[735, 819]
p02793
u570770016
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\ndef lcm(a, b):\n return (a*b)//gcd(a, b)\nN = int(input())\nA = list(map(int,input().split()))\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x)\nfor x in A:\n ans = (ans + l/x)\n if ans > mod: ans %= MOD\nprint(ans)\n', '\ndef gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\ndef lcm(a, b):\n return (a*b) //gcd(a, b)\nN = int(input())\nA = list(map(int,input().split()))\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x) % mod\nfor x in A:\n ans = (ans + l/x) % mod\nprint(ans)', '\ndef gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\ndef lcm(a, b):\n return (a*b) //gcd(a, b)\nN = int(input())\nA = list(map(int,input().split()))\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x)\nfor x in A:\n ans = (ans + l/x) % mod\nprint(ans)', '\nimport math\ndef lcm(a, b):\n return (a*b) //math.gcd(a, b)\nN = int(input())\nA = map(int, input().split())\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x) % mod\nfor x in A:\n ans = (ans + l/x) % mod\nprint(ans)', 'def gcd(a, b):\n\tif b == 0: return a\n\treturn gcd(b, a%b)\n\ndef lcm(a, b):\n\treturn (a*b)/gcd(a,b);\n\nA = []\n\nN = int(raw_input())\nA = map(int, raw_input().split())\nl = 1\nfor x in A:\n l = lcm(l, x)\nans, mod = 0, 1000000007\nfor x in A:\n ans = (ans + l/x)\n if ans > mod: ans = ans % mod\nprint(ans)\n', '\ndef gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\ndef lcm(a, b):\n return (a*b)//gcd(a, b)\nN = int(input())\nA = map(int, input().split())\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x)\nfor x in A:\n ans = (ans + l//x) % mod\nprint(ans)\n', '\ndef gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\ndef lcm(a, b):\n return (a*b)//gcd(a, b)\nN = int(input())\nA = map(int, input().split())\nl = 1\nans, mod = 0, 1000000007\nfor x in A:\n l = lcm(l, x) % mod\nfor x in A:\n ans = (ans + l//x) % mod\nprint(ans)', 'def gcd(a,b):\n if not b: return a\n return gcd(b,a%b)\n\ndef lcm(a, b):\n return (a*b)//gcd(a, b)\n\nN = int(input())\nA = list(map(int,input().split()))\nl = 1\nans, mod = 0, 1000000007\n\nfor x in A:\n l = lcm(l, x)\n\nfor x in A:\n ans = ans + l//x\nprint(ans % mod)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s024315238', 's029296625', 's032946493', 's058270125', 's245409704', 's391655166', 's417363093', 's320344837']
[4084.0, 4084.0, 4084.0, 3828.0, 3064.0, 3828.0, 3700.0, 4084.0]
[918.0, 43.0, 920.0, 19.0, 18.0, 921.0, 41.0, 1890.0]
[289, 304, 298, 257, 300, 294, 299, 269]
p02793
u572193732
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n \ndef lcm(a,b):\n return a*b//gcd(a,b)\n \nN = int(input())\nA = list(map(int, input().split()))\n\nlcm_A = 1\nfor i in range(N):\n lcm_A = lcm(lcm_A, A[i])\n \nans = 0\nfor i in range(N):\n ans += lcm_A // A[i]\n\nmod = 10**9+7\nprint(ans & mod)', 'def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n \ndef lcm(a,b):\n return a*b//gcd(a,b)\n \nN = int(input())\nA = list(map(int, input().split()))\n\nlcm_A = 1\nfor i in range(N):\n lcm_A = lcm(lcm_A, A[i])\n \nans = 0\nfor i in range(N):\n ans += lcm_A // A[i]\n\nmod = 10**9+7\nprint(ans % mod)\n']
['Wrong Answer', 'Accepted']
['s174039094', 's277404571']
[4084.0, 4084.0]
[1880.0, 1880.0]
[314, 315]
p02793
u583354994
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\ndef lcm(a, b):\n return a // gcd(a, b) * b\n\ndef main():\n num = int(input())\n d = list(map(int, input().split()))\n k = 1\n MOD = 1000000007\n ans = 0\n for a in d:\n k = lcm(k, a)\n for a in d:\n ans += k // a % MOD\n print(ans % MOD)\n\nif __name__ == "__main__":\n main()\n', 'from fractions import gcd\nfrom sys import stdin\n\ndef lcm(a, b):\n return a // gcd(a, b) * b\n\ndef main():\n readline = stdin.readline\n num = int(readline())\n d = list(map(int, readline().split()))\n k = 1\n MOD = 1000000007\n ans = 0\n for a in d:\n k = lcm(k, a)\n for a in d:\n ans += k // a % MOD\n print(ans % MOD)\n\nif __name__ == "__main__":\n main()', 'from sys import stdin\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a%b\n return a\n\ndef lcm(a, b):\n return (a * b) // gcd(a, b)\n\nreadline = stdin.readline\nnum = int(readline())\nd = list(map(int, readline().split()))\nk = 1\nMOD = 1000000007\nans = 0\nfor a in d:\n k = lcm(k, a)\nfor a in d:\n ans += k // a\nprint(ans % MOD)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s723522642', 's769770969', 's205765895']
[6112.0, 6136.0, 4084.0]
[2104.0, 2104.0, 1877.0]
[332, 390, 334]
p02793
u588341295
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["# -*- coding: utf-8 -*-\n\nimport sys\nfrom fractions import gcd\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\ndef lcm(x, y): return (x * y) // gcd(x, y)\n\nN = INT()\nA = LIST()\n\nl = 1\nfor a in A:\n l = lcm(l, a)\n\nB = [0] * N\nfor i, a in enumerate(A):\n B[i] = l // a\n\nans = 0\nfor b in B:\n ans += b\n ans %= MOD\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\nimport sys\nfrom fractions import gcd\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\ndef lcm(x, y): return (x * y) // gcd(x, y)\n\nN = INT()\nA = LIST()\n\nl = 1\nfor a in A:\n l = lcm(l, a)\n\nB = [0] * N\nfor i, a in enumerate(A):\n B[i] = l // a\n\nans = 0\nfor b in B:\n ans += b\nprint(ans%MOD)\n", "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\ndef fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD\n\ndef factorize(num: int) -> dict:\n \n from math import sqrt\n from collections import Counter\n\n d = Counter()\n \n for i in range(2, int(sqrt(num))+1):\n \n while num % i == 0:\n num //= i\n d[i] += 1\n \n if num == 1:\n break\n \n if num != 1:\n d[num] += 1\n return d\n\ndef mul(C1, C2):\n return C1 + C2\n\ndef div(C1, C2):\n return C1 - C2\n\ndef gcd(C1, C2):\n return C1 & C2\n\ndef lcm(C1, C2):\n return C1 | C2\n\nN = INT()\nA = LIST()\n\n\nA2 = [factorize(a) for a in A]\nl2 = Counter()\nfor a in A2:\n l2 = lcm(l2, a)\n\nraise Exception\n\n\nl = 1\nfor k, v in l2.items():\n l *= pow(k, v, MOD)\n l %= MOD\n\nans = 0\nfor a in A:\n ans += fermat(l, a, MOD)\n ans %= MOD\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\ndef fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD\n\ndef factorize(num: int) -> dict:\n \n from math import sqrt\n from collections import Counter\n\n d = Counter()\n \n for i in range(2, int(sqrt(num))+1):\n \n while num % i == 0:\n num //= i\n d[i] += 1\n \n if num == 1:\n break\n \n if num != 1:\n d[num] += 1\n return d\n\ndef mul(C1, C2):\n return C1 + C2\n\ndef div(C1, C2):\n return C1 - C2\n\ndef gcd(C1, C2):\n for k, v in C2.items():\n C1[k] = min(C1[k], v)\n return C1\n # return C1 & C2\n\ndef lcm(C1, C2):\n for k, v in C2.items():\n C1[k] = max(C1[k], v)\n return C1\n \n # return C1 | C2\n\nN = INT()\nA = LIST()\n\n\nA2 = [factorize(a) for a in A]\nl2 = Counter()\nfor a in A2:\n l2 = lcm(l2, a)\n\n\nl = 1\nfor k, v in l2.items():\n l *= pow(k, v, MOD)\n l %= MOD\n\nans = 0\nfor a in A:\n ans += fermat(l, a, MOD)\n ans %= MOD\nprint(ans)\n"]
['Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s152046930', 's319069633', 's597533170', 's857753988']
[264500.0, 264500.0, 7648.0, 7972.0]
[2120.0, 2004.0, 2104.0, 1219.0]
[922, 911, 1847, 2018]
p02793
u597455618
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\ndef gcd(m, n):\n r = m % n\n return gcd(n, r) if r else n\n\ndef lcm(m, n):\n return m//gcd(m, n)*n\n\nMOD = 10**9+7\nn = int(input())\nn, *a = map(int, sys.stdin.buffer.read().split())\nl = a[0]\nfor x in a[1:]:\n l = lcm(x, l)\n\nl %= MOD\n\nans = 0\nfor x in a:\n ans += l*pow(x, MOD-2, MOD)%MOD\nprint(ans%MOD)\n', 'def gcd(m, n):\n r = m % n\n return gcd(n, r) if r else n\n\ndef lcm(m, n):\n return m//gcd(m, n)*n\n\nMOD = 10**9+7\nn, *a = map(int, sys.stdin.buffer.read().split())\nl = a[0]\nfor x in a[1:]:\n l = lcm(x, l)\nl %= MOD\n\nans = 0\nfor x in a:\n ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD\nprint(ans)\n', 'def gcd(m, n):\n r = m % n\n return gcd(n, r) if r else n\n\ndef lcm(m, n):\n return m//gcd(m, n)*n\n\nMOD = 10**9+7\nn = int(input())\na = list(map(int, input().split()))\nl = a[0]\nfor x in a[1:]:\n l = lcm(x, l)\nl %= MOD\n\nans = 0\nfor x in a:\n ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s600755771', 's623465221', 's230643980']
[3828.0, 3064.0, 4084.0]
[460.0, 17.0, 576.0]
[322, 302, 305]
p02793
u599114793
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['n = int(input())\ns = list(map(int,input().split()))\nans = 0\nmod = int(1e9+7)\nimport fractions\n\n# while b != 0:\n# a, b = b, a % b\n# return a\n\ndef lcm(a,b):\n return (a*b) // fractions.gcd(a,b)\n\ng = 1\nfor i in range(n):\n g = lcm(g, s[i])\nfor i in range(n):\n ans += g // s[i] % mod\nprint(ans%mod)\n\n', 'n = int(input())\ns = list(map(int,input().split()))\nans = 0\nmod = int(1e9+7)\ndef gcd(a,b):\n while b != 0:\n a, b = b, a % b\n return a\ndef lcm(a,b):\n return a // gcd(a,b)\n\ng = 1\nfor i in range(n):\n g = lcm(g, s[i])\nfor i in range(n):\n ans += g // s[i]\nprint(ans%mod)\n', 'n = int(input())\ns = list(map(int,input().split()))\nans = 0\nmod = int(1e9+7)\ndef gcd(a,b):\n while b != 0:\n a, b = b, a % b\n return a\ndef lcm(a,b):\n return a // gcd(a,b) * b\n\ng = 1\nfor i in range(n):\n g = lcm(g, s[i])\nfor i in range(n):\n ans += g // s[i]\nprint(ans%mod)\n']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s773028795', 's877236063', 's268143429']
[5612.0, 4084.0, 4084.0]
[2104.0, 26.0, 1879.0]
[343, 279, 283]
p02793
u620084012
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['#pragma GCC optimize("Ofast")\n#include <bits/stdc++.h>\nusing namespace std;\n\n#define ALL(a) (a).begin(),(a).end()\ntypedef long long ll;\n\ninline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }\ninline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }\n\nint main(){\n ll MOD = 1000000007;\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n int N;\n cin >> N;\n vector<ll> A(N,0);\n REP(i,N){\n cin >> A[i];}\n ll c = A[0];\n for (auto e: A){\n c = lcm(e,c);\n }\n ll ans = 0;\n for (auto e: A){\n ans += c/e;\n ans %= MOD;\n }\n cout << ans << endl;\n return 0;\n}\n', 'N = int(input())\nA = list(map(int,input().split()))\nMOD = 10**9 + 7\nt = A[0]\n\ndef gcd(a,b):\n if b == 0:\n return a\n return gcd(b,a%b)\ndef lcm(a,b):\n return a*b//gcd(a,b)\nfor e in A:\n t = lcm(e,t)\n\nans = 0\nfor e in A:\n ans += t//e\n\nprint(ans%MOD)\n']
['Runtime Error', 'Accepted']
['s999691403', 's114095979']
[2940.0, 4084.0]
[17.0, 1889.0]
[671, 267]
p02793
u638902622
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(fractions.gcd, numbers)\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = int(input())\nA = list(map(int, input().split()))\n\nMOD = 10**9+7\nlcm_val = lcm_list(A)\ndiff = [lcm_val // a for a in A]\nprint(sum(diff)%MOD)\n', 'class PrimeOptimizer:\n def __init__(self, MAX_NUM=10**3):\n is_prime = [True] * MAX_NUM\n is_prime[0] = False\n is_prime[1] = False\n primes = []\n for i in range(MAX_NUM):\n if is_prime[i]:\n primes.append(i)\n for j in range(2*i, MAX_NUM, i):\n is_prime[j] = False\n self.primes = primes\n\n def prime_factorization(self, x):\n res = {}\n for prime in self.primes:\n while x % prime == 0:\n if not prime in res:\n res[prime] = 0\n res[prime] += 1\n x //= prime\n if x > 1:\n res[x] = 1\n return res\n\nMOD = 10**9+7\n\ndef mod_pow(p, q):\n res = 1\n while q:\n if q & 1:\n res = (res * p) % MOD\n p = (p * p) % MOD\n q //= 2\n return res\n\ndef mod_inv(p):\n return mod_pow(p, MOD - 2)\n\ndef solve(n, a):\n primeOpt = PrimeOptimizer()\n D = {}\n for i in range(n):\n prime_num_mapping = primeOpt.prime_factorization(a[i])\n for prime, num in prime_num_mapping.items():\n if not prime in D:\n D[prime] = 0\n D[prime] = max(D[prime], num)\n L = 1\n for prime, num in D.items():\n L = (L * mod_pow(prime, num)) % MOD\n res = sum([L * mod_inv(x) % MOD for x in a])\n return res % MOD\n\nN = int(input())\nA = list(map(int, input().split()))\nprint(solve(N, A))']
['Time Limit Exceeded', 'Accepted']
['s738644650', 's263379631']
[264660.0, 4596.0]
[2022.0, 278.0]
[506, 1449]
p02793
u648212584
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\ninput = sys.stdin.buffer.readline\nimport fractions\n\ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n MOD = 10**9+7\n \n def lcm(x,y):\n return((x*y)//fractions.gcd(x,y))\n \n ans = 0\n l0 = 1\n for num in a:\n l1 = lcm(l0,num)\n ans = (ans*(l1//l0)+l1//num)%MOD\n l0 = l1\n \n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\nimport fractions\nfrom functools import reduce\n\ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n MOD = 10**9+7\n \n def lcm(x,y):\n return((x*y)//fractions.gcd(x,y))\n \n l = reduce(lcm,a)\n ans = 0\n for num in a:\n ans += l//num\n ans %= MOD\n \n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\nimport fractions\nfrom functools import reduce\n\ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n MOD = 10**9+7\n \n def lcm(x,y):\n return((x*y)//fractions.gcd(x,y))\n \n l = reduce(lcm,a)\n ans = 0\n for num in a:\n ans += l//num\n \n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\nimport fractions\n\ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n MOD = 10**9+7\n \n def lcm(x,y):\n return((x*y)//fractions.gcd(x,y))\n \n ans = 0\n l = [1]\n for num in a:\n l.append(lcm(l[-1],num))\n ans = (ans*(l[-1]//l[-2])+l[-1]//num)%MOD\n \n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\nfrom collections import defaultdict\n\ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n MOD = 10**9+7\n \n d = defaultdict(int)\n \n for x in a:\n num = x\n count = 0\n while num%2 == 0:\n num //= 2\n count += 1\n d[2] = max(d[2],count)\n for i in range(3,int(x**(1/2))+1,2):\n if num%i == 0:\n count = 0\n while num%i == 0:\n num //= i\n count += 1\n d[i] = max(d[i],count)\n if num != 1:\n d[num] = max(d[num],1)\n\n base = 1\n for x,y in d.items():\n base *= pow(x,y,MOD)\n base %= MOD\n \n s = 0\n for num in a:\n inv_a = pow(num,MOD-2,MOD)\n s += inv_a\n s %= MOD\n \n print((base*s)%MOD)\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s231997681', 's235915077', 's556998130', 's793091857', 's925871447']
[5980.0, 5852.0, 6108.0, 144604.0, 4792.0]
[2055.0, 2104.0, 1943.0, 2113.0, 472.0]
[420, 415, 396, 422, 916]
p02793
u648881683
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import fractions\nfrom functools import reduce\n\nN = int(input())\nA = list(map(int, input().split()))\n\np = 10**9+7\nans = 0\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nlcm = lcm_list(A)\n\nfor i in A:\n ans += lcm // i % p\n\nprint(ans%p)', 'import fractions\nimport numpy as np\nfrom functools import reduce\nfrom operator import mul\n\nN = int(input())\nA = list(map(int, input().split()))\n\nmod = 10**9+7\n\ndef sieve(n):\n is_prime = [True for _ in range(n+1)]\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n for j in range(i*2, n+1):\n if j%i == 0:\n is_prime[j] = False\n return [i for i in range(n+1) if is_prime[i]]\n\nprimes = sieve(A)\n\n\ndef primeFactorization(n):\n temp = n\n ans = [0 for _ in range(len(primes))]\n for i in range(len(primes)):\n while temp%primes[i] == 0:\n temp /= primes[i]\n ans[i] += 1\n return ans\n\nAFactorized = list(map(primeFactorization, A))\n\nlcm = [0 for _ in range(len(primes))]\nfor i in AFactorized:\n lcm = np.maximum(lcm, i)\n\nB = [lcm-a for a in AFactorized]\n\nans = 0\nfor b in B:\n ans += reduce(mul, primes**b%mod)\n ans %= mod\n\nprint(ans)', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nmod = 10**9+7\n\ndef sieve(n):\n is_prime = [True for _ in range(n+1)]\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n if is_prime[i]:\n for j in range(i*2, n+1, i):\n is_prime[j] = False\n return [i for i in range(n+1) if is_prime[i]]\n\nprimes = sieve(10**3)\n\ndef primeFactorization(n):\n ans = []\n temp = n\n for p in primes:\n while temp%p == 0:\n ans.append(p)\n temp //= p\n if temp > 1:\n ans.append(temp)\n return collections.Counter(ans)\n\nAFactorized = list(map(primeFactorization, A))\n\nlcm = collections.Counter()\nfor a in AFactorized:\n for p, n in a.items():\n lcm[p] = max(lcm[p], n)\n\nlcm_val = 1\nfor p, n in lcm.items():\n lcm_val *= pow(p, n, mod)\n\nans = 0\nfor a in A:\n ans += lcm_val * pow(a, mod-2, mod)\n ans %= mod\n\nprint(ans)']
['Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s150331487', 's804233590', 's816644112']
[6112.0, 13984.0, 7860.0]
[2104.0, 158.0, 1384.0]
[317, 980, 947]
p02793
u665224938
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from functools import reduce\n\ndef gcd(x, y):\n y, x = sorted([x, y])\n while True:\n r = x % y\n if r == 0:\n print(x, y, r)\n return r\n else:\n print(x, y, r)\n x, y = y, r\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = int(input())\nl = list(map(int, input().split(" ")))\n\np = lcm_list(l)\nc = 0\nz = 10 ** 9 + 7\nfor i in l:\n c += p // i\nprint(c % z)', 'import fractions\nfrom functools import reduce\n \ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n \nN = int(input())\nl = list(map(int, input().split(" ")))\n \np = gcd(l)\n \nn = reduce(lambda a, b: a * b, l) / (p ** N) / (10 ** 9 + 7)\nprint(n)', 'import fractions\nfrom functools import reduce\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = int(input())\nl = list(map(int, input().split(" ")))\n\np = lcm_list(l)\nc = 0\nz = 10 ** 9 + 7\nfor i in l:\n c += p // i % z\nprint(c % z)', 'import fractions\nfrom functools import reduce\n \ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n \nN = int(input())\nl = list(map(int, input().split(" ")))\n \np = gcd(l)\n\nc = 0\nfor i in l:\n c += i // p\nprint(c // (10 ** 9 + 7))', 'import math\nfrom fractions import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nN = int(input())\nl = list(map(int, input().split(" ")))\n\np = gcd(l)\n\nn = reduce(lambda a, b: a * b, l) / (p ** N) / (10 ** 9 + 7)\nprint(n)', 'from functools import reduce\n\ndef gcd(x, y):\n y, x = sorted([x, y])\n while True:\n r = x % y\n if r == 0:\n # print(x, y, r)\n return y\n else:\n # print(x, y, r)\n x, y = y, r\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = int(input())\nl = list(map(int, input().split(" ")))\n\np = lcm_list(l)\nc = 0\nz = 10 ** 9 + 7\nfor i in l:\n c += p // i\nprint(c % z)']
['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Accepted']
['s142998001', 's476422583', 's489897026', 's553658342', 's623992458', 's643868930']
[4708.0, 6108.0, 6112.0, 6200.0, 5048.0, 4708.0]
[26.0, 86.0, 2104.0, 37.0, 37.0, 1884.0]
[488, 251, 311, 238, 237, 492]
p02793
u687053495
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nfrom fractions import gcd\nfrom functools import reduce\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n\nL = reduce(lcm, A)\n\nB = [None] * N\n\nfor i in range(N):\n B[i] = (L // A[i]) % mod\n\nprint(sum(B) % mod)', '\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nfrom fractions import gcd\nfrom functools import reduce\n\nL = A[0]\nfor i in range(1,N):\n L=(L*A[i])//gcd(L,A[i])\n\nans = 0\n\nfor i in range(N):\n ans += (L // A[i]) % mod\n\nprint(ans % mod)\n', "\ndef main():\n import sys\n input = sys.stdin.readline\n\n N = int(input())\n A = list(map(int, input().split()))\n mod = 10 ** 9 + 7\n\n from fractions import gcd\n from functools import reduce\n\n def lcm(x, y):\n return x * y // gcd(x, y)\n\n L = reduce(lcm, A)\n\n B = [None] * N\n\n for i in range(N):\n B[i] = (L // A[i]) % mod\n\n print(sum(B) % mod)\n\nif __name__ == '__main__':\n main()", "\ndef main():\n import sys\n input = sys.stdin.readline\n\n N = int(input())\n A = list(map(int, input().split()))\n T = set(A)\n mod = 10 ** 9 + 7\n\n from fractions import gcd\n from functools import reduce\n\n def lcm(x, y):\n return x * y // gcd(x, y)\n\n L = reduce(lcm, T)\n\n ans = 0\n\n for i in range(N):\n ans += (L // A[i]) % mod\n\n print(ans % mod)\n\nif __name__ == '__main__':\n main()", "\ndef main():\n import sys\n input = sys.stdin.readline\n\n N = int(input())\n A = list(map(int, input().split()))\n mod = 10 ** 9 + 7\n\n from fractions import gcd\n from functools import reduce\n\n def lcm(x, y):\n return x * y // gcd(x, y)\n\n L = reduce(lcm, A)\n\n ans = 0\n\n for i in range(N):\n ans += (L // A[i]) % mod\n\n print(ans % mod)\n\nif __name__ == '__main__':\n main()", "\ndef main():\n import sys\n input = sys.stdin.readline\n\n N = int(input())\n A = list(map(int, input().split()))\n T = set(A)\n mod = 10 ** 9 + 7\n\n from fractions import gcd\n from functools import reduce\n\n def lcm(x, y):\n return x * y // gcd(x, y)\n\n L = reduce(lcm, T)\n\n B = [None] * N\n\n for i in range(N):\n B[i] = (L // A[i]) % mod\n\n print(sum(B) % mod)\n\nif __name__ == '__main__':\n main()", '\n\n\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\ndef inverse(a): \n return pow(a, mod-2, mod)\n\ndef eratosthenes(n): \n A = [0] * n\n A[0], A[1] = -1, -1\n for i in range(2, n):\n if A[i] == 0:\n j = i\n while j < n:\n A[j] = i\n j += i\n return A\n\nE = eratosthenes(10**6+5)\nl = {}\n\nfor a in A:\n now = a\n f = [] \n\n while now > 1:\n f.append(E[now])\n now //= E[now]\n\n chk = 0 \n\n for p in f:\n if chk == p: \n continue\n chk = p\n if p in l.keys(): \n l[p] = max(l[p], f.count(p))\n else: \n l[p] = f.count(p)\n \nlcm = 1\nfor k in l:\n for i in range(l[k]):\n lcm= lcm * k % mod\n\ns = 0\nfor i in range(N):\n s += lcm * inverse(A[i])\n s %= mod\nprint(s)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s365478126', 's573871033', 's634823162', 's817082000', 's895329940', 's923669272', 's597927077']
[5836.0, 5596.0, 5840.0, 6076.0, 5580.0, 6352.0, 15664.0]
[2104.0, 2104.0, 2104.0, 2103.0, 2104.0, 2104.0, 418.0]
[275, 298, 393, 396, 383, 406, 1080]
p02793
u702142173
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['#include <bits/stdc++.h>\n\n#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define pb push_back\n#define rep(i,l,r) for(int i=l;i<r;i++)\n#define bep(i,l,r) for(int i=l;i>=r;i--)\n#define ld long double\n\n#define ss second\n\n\n\n\n\n#define all(v) v.begin(),v.end()\n\n\nusing namespace std;\n\nint inf = 1e18;\nconst int N = 5e5+5;\nint mod = 1e9+7;\nint powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}\n\nsigned main()\n{\n io\n int tt = 1;\n //cin>>tt;\n while(tt--)\n {\n int n;\n cin>>n;\n unordered_map<int,int> mp;\n int arr[n];\n rep(i,0,n)\n cin>>arr[i];\n rep(i,0,n)\n {\n int ct = 0;\n int x = arr[i];\n for(int i=2;i*i<=x;++i)\n {\n\n if(x%i==0)\n {\n ct = 0;\n while(x%i==0)\n {\n ct++;\n x/=i;\n }\n mp[i]= max(mp[i],ct);mp[i]= max(mp[i],ct);\n }\n\n }\n if(x!=1)\n mp[x] = max(mp[x],1LL);\n }\n int lcm = 1;\n for(auto x:mp)\n lcm = (lcm*powmod(x.ff,x.ss))%mod;\n int ans = 0;\n rep(i,0,n)\n {\n ans = (ans + (lcm*powmod(arr[i],mod-2))%mod)%mod;\n }\n cout<<ans<<el;\n }\n\n\n return 0;\n }\n', 'def gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\ndef lcm(arr):\n ans = 1\n for i in arr:\n ans = (ans*i)//gcd(ans,i)\n return ans\nn = int(input())\narr = list(map(int,input().split())) #list(map(int, input().split()))\nl = lcm(arr)\nans = 0;\nfor i in arr:\n ans+= l//i\nprint(ans%(10**9+7))\n']
['Runtime Error', 'Accepted']
['s868185934', 's533565385']
[2940.0, 4084.0]
[17.0, 1887.0]
[1620, 298]
p02793
u704284486
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\ndef lcm(a):\n ans = a[0]\n \n for i in range(1,len(a)):\n ans = (ans//gcd(ans,a[i]))*a[i]\n \n return ans\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\ng = lcm(A)\nans = 0\nmod = 10**9+7\n\nfor i in A:\n ans += (g//i)%(mod)\n\nprint(ans%mod)', 'from fractions import gcd\nN = int(input())\nA = [0 for _ in range(N)]\ng = 0\nfor i,a in enumerate(map(int,input().split(" "))):\n A[i] = a\n if i == 0:\n g = a\n g = g*a//gcd(a,g)\nans = 0\nA = tuple(A)\nfor a in A:\n ans += g//a\n ans %= (10**9+7)\nprint(ans)', 'from fractions import gcd\n\ndef lcm(a):\n ans = a[0]\n \n for i in range(1,len(a)):\n ans = (ans//gcd(ans,a[i]))*a[i]\n \n return ans\n\nN = int(input())\nA = list(map(int,input().split(" ")))\ng = lcm(A)\nans = 0\nmod = 10**9+7\n\nfor i in A:\n ans += (g//i)%(mod)\n\nprint(ans%mod)', 'from fractions import gcd\n\ndef lcm(a):\n ans = a[0]\n for i in range(1,len(a)):\n ans = (ans//gcd(ans,a[i]))*a[i]\n return ans\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\ng = lcm(A)\nans = 0\nfor i in A:\n ans += g//i\n ans %= (10**9+7)\n\nprint(ans)', 'from fractions import gcd\n\ndef lcm(a):\n ans = a[0]\n \n for i in range(1,len(a)):\n ans = (ans//gcd(ans,a[i]))*a[i]\n \n return ans\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\ng = lcm(A)\nans = 0\nmod = 10**9+7\n\nfor i in A:\n ans += (g//i)%(mod)\n\nprint(ans)', 'from fractions import gcd\nN = int(input())\nA = tuple(map(int,input().split(" ")))\ng = A[0]\nl = 1\nfor i in range(N):\n g = g*A[i]//gcd(A[i],g)\nans = 0\nfor i in range(N):\n ans += g//A[i]\n ans %= (10**9+7)\nprint(ans)', 'def gcd(a,b):\n while b:a,b=a,a%b\n return a\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\nans = 0\nmod = 10**9+7\nl = 1\nfor i in range(N):\n l = lcm(l,A[i])\nl %= mod\n\nfor i in A:\n ans += l//A[i]\n ans %= mod\n\nprint(ans)', 'def gcd(a,b):\n while b:a,b=a,a%b\n return a\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\nans = 0\nmod = 10**9+7\nl = 1\nfor i in range(N):\n l = lcm(l,A[i])\nl %= mod\n\nfor i in A:\n ans += l//i\n ans %= mod\n\nprint(ans)', 'def gcd(a,b):\n while b:a,b=b,a%b\n return a\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN = int(input())\nA = tuple(map(int,input().split(" ")))\nans = 0\nmod = 10**9+7\nl = 1\nfor i in range(N):\n l = lcm(l,A[i])\nl %= mod\n\nfor i in A:\n ans += l*pow(i,mod-2,mod)\n ans %= mod\n\nprint(ans)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s079659516', 's381648107', 's402181814', 's447471818', 's537192468', 's703039162', 's758179487', 's860287041', 's649035898']
[6200.0, 6200.0, 6200.0, 6076.0, 6076.0, 6072.0, 4084.0, 4084.0, 4084.0]
[2104.0, 2104.0, 2104.0, 2104.0, 2104.0, 2104.0, 28.0, 30.0, 950.0]
[291, 270, 290, 275, 287, 221, 279, 277, 290]
p02793
u707124227
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['n=int(input())\na=list(map(int,input().split()))\n#n=10000\n#a=list(range(10**6,10**6-n,-1))\nimport fractions \nmod=pow(10,9)+7\n\nb=[a,[]]\npre=0\nnow=1\nwhile len(b[pre])>1:\n for i in range(0,len(b[pre])-1,2):\n b[now].append((b[pre][i]*b[pre][i+1])//fractions.gcd(b[pre][i],b[pre][i+1]))\n if len(b[pre])%2==1:\n b[now].append(b[pre][-1])\n b[pre]=[]\n now,pre=pre,now\n\nlcma=b[pre][0]\nans=0\nfor ai in a:\n ans+=((lcma//ai))%mod\n ans%=mod\nprint(ans)\n', 'n=int(input())\na=list(map(int,input().split()))\nimport functools\nimport fractions \n\ndef lcm(x, y):\n return (x * y) // fractions.gcd(x, y)\ndef lcmn(nums):\n return functools.reduce(lcm, nums)\nlcma=lcmn(a)\nans=0\nmod=pow(10,9)+7\nfor ai in a:\n ans+=lcma//ai\n ans%=mod\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nimport fractions \nmod=pow(10,9)+7\nlcma=1\nfor ai in a:\n lcma*=ai//fractions.gcd(lcma,ai)\nans=0\nfor ai in a:\n ans+=((lcma//ai))%mod\n ans%=mod\nprint(ans)\n', 'n=int(input())\na=list(map(int,input().split()))\nmod=pow(10,9)+7\n\n#n=10000\n#a=list(range(10**6,10**6-n,-1))\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n if temp!=1:\n arr.append([temp, 1])\n if arr==[]:\n arr.append([n, 1])\n return arr\nlcma={}\nfor ai in a:\n f=factorization(ai)\n for fi in f:\n if fi[0] in lcma:\n lcma[fi[0]]=max(lcma[fi[0]],fi[1])\n else:\n lcma[fi[0]]=fi[1]\nl=1\nfor k,v in lcma.items():\n l*=pow(k,v,mod)\n l%=mod\nans=0\nfor ai in a:\n ans+=l*pow(ai,mod-2,mod)\n ans%=mod\nprint(ans)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s227731301', 's420756377', 's824701013', 's883077549']
[5732.0, 5572.0, 5688.0, 4596.0]
[2104.0, 2104.0, 2103.0, 881.0]
[449, 294, 202, 736]
p02793
u708255304
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\n\ndef lcm(x, y):\n return (x*y) // gcd(x, y)\n\n\nlcm_value = A[0]\nfor i in range(1, N):\n lcm_value = lcm(lcm_value, A[i])\n\n# print(lcm_value)\nmod = 10**9+7\nans = 0\nfor i in range(N):\n ans += (lcm_value // A[i]) % mod\n\nprint(ans%mod)\n', 'def gcd(m, n):\n while n:\n m, n = n, m % n\n return m\n\n\ndef lcm(x, y):\n return (x*y) // gcd(x, y)\n\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort()\nlcm_value = A[0]\nfor i in range(1, N):\n lcm_value = lcm(lcm_value, A[i])\n\n# print(lcm_value)\nmod = 10**9+7\nans = 0\nfor i in range(N):\n ans += (lcm_value // A[i])\n\nprint(ans % mod)\n']
['Time Limit Exceeded', 'Accepted']
['s983206765', 's135822416']
[6072.0, 4084.0]
[2104.0, 1876.0]
[324, 366]
p02793
u714378447
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nfrom functools import reduce\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = int(input())\nA = [int(x) for x in input().split()]\nt = lcm(A)\n\nmod = 10**9+7\nans = 0\nfor i in range(N):\n ans = (ans + t//A[i])%mod\n\nprint(ans)\n', '\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\n \ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nN=int(input())\nA=list(map(int,input().split()))\na_lcm=A[0]\n\nfor i in range(1,N):\n a_lcm=lcm(a_lcm,A[i])\n\na_lcm%=1000000007\n\nresult=0\nfor i in range(N):\n result+=(a_lcm*pow(A[i],1000000007-2, 1000000007))%1000000007\nprint(result%1000000007)\n']
['Time Limit Exceeded', 'Accepted']
['s331378333', 's893374437']
[6136.0, 4084.0]
[2104.0, 950.0]
[318, 442]
p02793
u721316601
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['N = int(input())\nA = list(map(int, input().split()))\n\nMOD = 10**9+7\n\nfrom collections import Counter\n\ndef prime(n):\n p = Counter()\n\n while not n % 2:\n p[2] += 1\n n //= 2\n \n i = 3\n \n while i <= n**0.5:\n while not n % i:\n p[i] += 1\n n //= i\n i += 2\n \n if n > 1: p[n] += 1\n \n return p\n\nc = Counter()\nfor a in A:\n p = prime(a)\n\n for key, value in p.items():\n c[key] = max(c[key], value)\n\nn = 1\nfor key, value in c.items():\n n *= key**value\n\nans = 0\nfor a in A:\n ans += pow(a, MOD-2, MOD) \n ans %= MOD\n\nprint(ans)\n', "import sys\ninput = sys.stdin.readline\n\nMOD = 10**9+7\ndef pow(a, b):\n res = 1\n while b:\n if b & 1: res = res * a % MOD\n a = a**2 % MOD\n b >>= 1\n return res\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n B = set(A)\n \n m = max(B)+1 \n prime = {i:i for i in range(m)}\n is_prime = [False] * m\n \n for i in range(2, int(m**0.5)+1):\n if is_prime[i]: continue\n is_prime[i] = True\n \n for j in range(2*i, m, i):\n if not is_prime[j]: prime[j] = i\n is_prime[j] = True\n \n from collections import Counter\n \n count = Counter()\n \n for a in A:\n c = Counter()\n while a > 1:\n n = prime[a]\n c[n] += 1\n a //= n\n for k, v in c.items(): count[k] = max(count[k], v)\n \n x = 1\n for k, v in count.items(): x = x * k**v % MOD\n \n ans = 0\n for a in A: ans += x * pow(a, MOD-2) % MOD\n \n print(ans%MOD)\n\nif __name__ == '__main__':\n main() \n"]
['Wrong Answer', 'Accepted']
['s413808697', 's939431569']
[4580.0, 99992.0]
[2001.0, 615.0]
[619, 1068]
p02793
u736788838
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\nMOD = 1000000007\n\nN = int(input())\n\nA = list(map(int, input().split()))\n\nlcm_ = 1\nfor a in A:\n lcm_ = lcm(lcm_, a)\n\nans = 0\nfor a in A:\n ans += lcm_ / a\n\nans %= MOD\nprint(int(ans))', 'import math\n\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\n\nMOD = 1000000007\n\nN = int(input())\n\nA = list(map(int, input().split()))\n\nlcm_ = 1\nfor a in A:\n lcm_ = lcm(lcm_, a)\n\nans = 0\nfor a in A:\n ans += lcm_ // a\n\nans %= MOD\nprint(ans)']
['Runtime Error', 'Accepted']
['s578007568', 's647004972']
[11360.0, 10184.0]
[873.0, 1603.0]
[263, 250]
p02793
u744920373
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef ti(): return tuple(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\n#from itertools import accumulate #list(accumulate(A))\n\nfrom functools import reduce\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n r = a % b\n if r == 0:\n return b\n return gcd(b, r)\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef table(n:int, p=10**9+7):\n global fact, factinv, inv\n fact = [1, 1]\n factinv = [1, 1]\n inv = [0, 1]\n for i in range(2, n+1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef main():\n N = ii()\n A = ti()\n P = 10**9 + 7\n lcm_a = lcm(A) % P\n\n \n N = 10**6+1\n inv_t = [0]+[1]\n for i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\n ans = 0\n for num in A:\n ans = (ans + inv_t[num] * lcm_a) % P\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef ti(): return tuple(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\n#from itertools import accumulate #list(accumulate(A))\n\nfrom functools import reduce\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n r = a % b\n if r == 0:\n return b\n return gcd(b, r)\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef table(n:int, p=10**9+7):\n global fact, factinv, inv\n fact = [1, 1]\n factinv = [1, 1]\n inv = [0, 1]\n for i in range(2, n+1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef main():\n N = ii()\n A = ti()\n P = 10**9 + 7\n lcm_a = lcm_list(A) % P\n\n \n N = 10**6+1\n inv_t = [0]+[1]\n for i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\n ans = 0\n for num in A:\n ans = (ans + inv_t[num] * lcm_a) % P\n print(ans)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s163500977', 's399295424']
[4700.0, 43740.0]
[25.0, 1510.0]
[1565, 1570]
p02793
u747703115
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from functools import reduce\nfrom fractions import gcd\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\nn = int(input())\nA = [int(i) for i in input().split()]\nk = lcm_list(A)\nr = 0\nfor i in range(n):\n r += k//A[i]\n if r > 10**9+7:\n r %= 10**9+7\nprint(r)', 'm functools import reduce\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n \ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n \ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n \nn = int(input())\nA = list(map(int, input().split()))\nk = lcm_list(A)\nr = 0\nln = list(range(n))\nfor i in ln:\n r += k//A[i]\nprint(r%(10**9+7))', 'from functools import reduce\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\nn = int(input())\nA = list(map(int, input().split()))\nk = lcm_list(A)\nr = 0\nln = list(range(n))\nfor i in ln:\n r += k//A[i]\nprint(r%(10**9+7))\n']
['Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s844837757', 's975115315', 's018496233']
[6080.0, 3064.0, 4828.0]
[2104.0, 17.0, 1882.0]
[334, 355, 356]
p02793
u762540523
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nfrom functools import reduce\nn=int(input())\na=list(map(int,input().split()))\nx=reduce(lambda x,y: y//gcd(x,y)*x, set(a))\nans=0\nfor i in a:\n ans+=x//i\n ans%=1000000007\nprint(ans)', 'from fractions import gcd\nfrom functools import reduce\nn=int(input())\na=list(map(int,input().split()))\nx=reduce(lambda x,y: y//gcd(x,y)*x, a)\nans=0\nfor i in a:\n ans+=x//i\n ans%=1000000007\nprint(ans)', 'from functools import reduce\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\ndef lcm(a, b):\n return b // gcd(a, b) * a\nn=int(input())\na=list(map(int,input().split()))\nx=reduce(lambda x,y: lcm(x,y), set(a))\nans=0\nfor i in a:\n ans+=x//i\nans%=1000000007\nprint(ans)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s415273783', 's550614876', 's395318943']
[6496.0, 6112.0, 5216.0]
[2104.0, 2104.0, 1501.0]
[205, 200, 282]
p02793
u774539708
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['n=int(input())\nA=list(map(int,input().split()))\nmod=10**9+7\n\nimport fractions\ndef lcm(a,b):\n return a*b//fractions.gcd(a,b)\n\ndef power(a,p):\n T=[a]\n while 2**(len(T))<p:\n T.append(T[-1]**2%p)\n b=bin(p-2)\n ans=1\n for i in range(len(b)-2):\n if int(b[-i-1])==1:\n ans=ans*T[i]%p\n return ans \n\nl=A[0]\nfor i in range(n-1):\n l=lcm(l,A[i+1])\ns=0\nfor i in range(n):\n s+=l*power(A[i],mod)%mod\n s%=mod\nprint(s)', 'n=int(input())\nA=list(map(int,input().split()))\nmod=10**9+7\n\nimport fractions\nprint(fractions.gcd(6,10))\ndef lcm(a,b):\n return a*b//fractions.gcd(a,b)\n\ndef power(a,p):\n T=[a]\n while 2**(len(T))<p:\n T.append(T[-1]**2%p)\n b=bin(p-2)\n ans=1\n for i in range(len(b)-2):\n if int(b[-i-1])==1:\n ans=ans*T[i]%p\n return ans \n\nl=A[0]\nfor i in range(n-1):\n l=lcm(l,A[i+1])\ns=0\nfor i in range(n):\n s+=l*power(A[i],mod)%mod\n s%=mod\nprint(s)', 'n=int(input())\nA=list(map(int,input().split()))\nmod=10**9+7\n\ndef inverse(a): \n T=[a]\n while 2**(len(T))<mod: \n T.append(T[-1]**2%mod)\n b=bin(mod-2) \n ans=1\n for i in range(len(b)-2):\n if int(b[-i-1])==1:\n ans=ans*T[i]%mod\n return ans\n\ndef make_eratosthenes(n): \n A=[0]*n\n A[0],A[1]=-1,-1\n for i in range(2,n):\n if A[i]==0:\n j=i\n while j<n:\n A[j]=i\n j+=i\n return A\n\nE=make_eratosthenes(10**6+5)\n\nl={}\nfor a in A:\n now=a\n f=[] \n while now>1:\n f.append(E[now])\n now//=E[now]\n chk=0 \n for p in f:\n if chk==p: \n continue\n chk=p\n if p in l.keys(): \n l[p]=max(l[p],f.count(p))\n else: \n l[p]=f.count(p)\n\nlcm=1\nfor k in l:\n for i in range(l[k]):\n lcm=lcm*k%mod\ns=0\nfor i in range(n):\n s+=lcm*inverse(A[i])%mod\n s%=mod\nprint(s)']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s049028455', 's649178250', 's946772161']
[5612.0, 5612.0, 14476.0]
[2104.0, 2104.0, 690.0]
[456, 483, 1296]
p02793
u780475861
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import sys\nread = sys.stdin.read\nfrom fractions import gcd\nfrom functools import reduce\n \nn,*alst = list(map(int, read().split()))\n\ndef lcm(x, y):\n g = gcd(x, y)\n g = x * y // g\n return g\n\ng = reduce(lcm, alst)\nmod=10**9+7\nres=0\nfor a in alst:\n res+=pow(a,mod-2,mod)*g\n res%=mod\nprint(res)', 'import sys\nread = sys.stdin.read\nfrom fractions import gcd\nfrom functools import reduce\n \nn,*alst = list(map(int, read().split()))\n\ndef lcm(x, y):\n g = gcd(x, y)\n g = x * y // g\n return g\n\ng = reduce(lcm, alst)\nmod=10**9+7\nres=0\nfor a in alst:\n res+=(pow(a,mod-2,mod)*g)%mod\nprint(res)', '\n\nimport sys\nread = sys.stdin.read\n\nN, *A = map(int, read().split())\nmod = 10 ** 9 + 7\n\n\ndef min_factor(n):\n sieve = list(range(n + 1))\n sieve[2::2] = [2] * (n // 2)\n for i in range(3, int(n ** 0.5) + 2, 2):\n if sieve[i] == i:\n sieve[i * i::2 * i] = [i] * ((n - i * i) // (2 * i) + 1)\n return sieve\n\n\ndef prime_factorize(n):\n a = {}\n while n != 1:\n b = table[n]\n if b in a:\n a[b] += 1\n else:\n a[b] = 1\n n //= b\n return a\n\n\ntable = min_factor(max(A))\n\ndic = {}\nfor i in A:\n for key, value in prime_factorize(i).items():\n if key in dic:\n dic[key] = max(dic[key], value)\n else:\n dic[key] = value\n\nlcm = 1\nfor i, j in dic.items():\n lcm *= pow(i, j, mod)\n lcm %= mod\n\nanswer = sum(lcm * pow(i, mod - 2, mod) for i in A) % mod\nprint(answer)\n']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s310091089', 's942754817', 's408318070']
[6108.0, 6108.0, 51572.0]
[2022.0, 1953.0, 181.0]
[300, 295, 925]
p02793
u785578220
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def main():\n import sys\n input = sys.stdin.readline\n from fractions import gcd\n a = int(input())\n l = list(map(int,input().split()))\n\n\n\n def lcm(a,b):\n return a*b//gcd(a,b)\n\n MOD = 10**9+7\n ans = 0\n t = 1\n for i in l:\n t = lcm(t,i)\n\n for i in l:\n ans +=t//i\n ans %=MOD\n print(ans)\nmain()', 'a = int(input())\nl = list(map(int,input().split()))\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nMOD = 10**9+7\nans = 0\nt = 1\nfor i in l:\n t = lcm(t,i)\n\nfor i in l:\n ans +=t//i\nprint(ans%MOD)\n']
['Time Limit Exceeded', 'Accepted']
['s843131361', 's078544987']
[6100.0, 4084.0]
[2104.0, 1874.0]
[351, 256]
p02793
u793868662
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def resolve():\n from fractions import gcd\n n = int(input())\n a = list(map(int, input().split()))\n mod = 10**9 + 7\n lsd = a[0]\n for i in range(1, n):\n lsd = (lsd * a[i]) // gcd(lsd, a[i])\n\n ans = 0\n for i in range(n):\n ans += (lsd/a[i]) % mod\n\n print(int(ans % mod))\n\nresolve()', "def resolve():\n from fractions import gcd\n n = int(input())\n a = list(map(int, input().split()))\n mod = 10**9 + 7\n lsd = a[0]\n for i in range(1, n):\n lsd = (lsd * a[i]) // gcd(lsd, a[i])\n \n ans = 0\n for i in range(n):\n ans += (lsd//a[i]) % mod\n \n print(int(ans % mod))\n \n \nif __name__ == '__main__':\n resolve()", 'def resolve():\n from fractions import gcd\n n = int(input())\n a = list(map(int, input().split()))\n mod = 10**9 + 7\n lsd = a[0]\n for i in range(1, n):\n lsd = (lsd * a[i]) // gcd(lsd, a[i])\n \n ans = 0\n for i in range(n):\n ans += (lsd//a[i]) % mod\n \n print(int(ans % mod))\nresolve()', 'def resolve():\n def lcm(X, Y):\n x = X\n y = Y\n if y > x:\n x, y = y, x\n while x % y != 0:\n x, y = y, x % y\n return X * Y // y\n n = int(input())\n a = list(map(int, input().split()))\n mod = 10**9 + 7\n lsd = a[0]\n for i in range(1, n):\n lsd = lcm(lsd, a[i])\n lsd = lsd % mod\n\n ans = 0\n for i in range(n):\n ans += (lsd * pow(a[i], mod-2, mod)) % mod\n\n print(int(ans % mod))\n\nresolve()']
['Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s199378311', 's281222374', 's913552496', 's290616802']
[6076.0, 6076.0, 6076.0, 4084.0]
[930.0, 2104.0, 2107.0, 1403.0]
[317, 354, 319, 479]
p02793
u798818115
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['# coding: utf-8\n# Your code here!\nfrom fractions import gcd\n\nN=int(input())\nA=list(map(int,input().split()))\n\ntemp=A[0]\nfor item in A:\n temp=temp*item//gcd(temp,item)\n\nans=0\nfor item in A:\n ans+=temp//item\n ans%=10**9+7\n#print(temp)\nprint(ans)', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\ndef lcm(a):\n from fractions import gcd\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nN=int(input())\na=list(map(int,input().split()))\ncalc=(lcm(a)) \n\nans=0\nfor item in a:\n ans+=(calc)//item\n ans%=(10**9+7)\n\nprint(int((ans)%(10**9+7)))\n \n\n', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\nimport sys\ninput = sys.stdin.readline\n\n\ndef lcm(a):\n from fractions import gcd\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nN=int(input())\na=list(map(int,input().split()))\ncalc=(lcm(a)) \n\nans=0\nfor item in a:\n ans+=(calc)//item\n ans%=(10**9+7)\n\nprint(int((ans)%(10**9+7)))\n \n\n', '# coding: utf-8\n# Your code here!\ndef lcm(a):\n from fractions import gcd\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nN=int(input())\na=list(map(int,input().split()))\ncalc=(lcm(a)) \n\nans=0\nfor item in a:\n ans+=(calc)/item\n ans%=(10**9+7)\n\nprint(int((ans)%(10**9+7)))\n ', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\nimport sys\ninput = sys.stdin.readline\n\nimport functools\n\ndef euclid(a, b):\n if b == 0:\n return a\n else:\n return euclid(b, a%b)\ndef multiple(a, b):\n return a*b // euclid(a, b)\ndef lcm(nums):\n return functools.reduce(multiple, nums)\n\n\nN=int(input())\na=list(map(int,input().split()))\ncalc=(lcm(a)) \n\n\nans=0\nfor index,item in enumerate(a):\n ans+=(calc)//item\n\nprint(int((ans)%(10**9+7)))\n \n\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s285433408', 's647172350', 's794050116', 's991385844', 's629958330']
[6112.0, 5616.0, 5596.0, 5616.0, 4708.0]
[2108.0, 2104.0, 2104.0, 928.0, 1891.0]
[252, 387, 427, 350, 510]
p02793
u808092084
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['def gcd(a, b):\n if b==0:\n return a\n return gcd(b, a%b)\n\ndef lcm(a, b):\n return a*(b/gcd(a, b))\n\nmod = int(1e9+7)\n\nn = int(input())\nvs = map(int, input().split())\nl = 1\nfor x in vs:\n l = lcm(l, x)\n\nans = 0\nfor x in vs:\n ans = (ans + ((l/x)%mod))%mod\nprint(ans)\n', 'def gcd(a, b):\n if b==0:\n return a\n return gcd(b, a%b)\n\ndef lcm(a, b):\n return a*(b//gcd(a, b))\n\nmod = int(1e9+7)\ndef ext_gcd(a, b, x, y):\n if b==0:\n x[0] = 1\n y[0] = 0\n return a\n g = ext_gcd(b, a%b, y, x)\n y[0]-=a//b*x[0]\n return g\n\ndef mod_inv(a):\n x = [0]\n y = [0]\n ext_gcd(a, mod, x, y)\n return (x[0]%mod + mod)%mod;\n\nn = int(input())\nvs = list(map(int, input().split()))\nl = 1\nfor x in vs:\n l = lcm(l, x)\nl = l%mod;\nans = 0\nfor x in vs:\n ans = (ans + ((l*mod_inv(x))%mod))%mod\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s692701733', 's131955271']
[4692.0, 4084.0]
[74.0, 592.0]
[282, 560]
p02793
u824144553
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import numpy as np\nfrom collections import Counter\n\ndef resolve():\n \n \n \n \n \n \n\n \n \n \n \n \n \n # \n \n \n \n \n # \n MOD = 10**9 + 7\n N = int(input())\n A = list(map(int, input().split()))\n\n \n MX = int(10**6)\n L = np.zeros(MX+1)\n L[0] = -1\n L[1] = -1\n primes = []\n\n for i in range(2, MX+1):\n if L[i]:\n continue\n primes.append(i)\n L[i] = i\n for j in range(i*i, MX+1, i):\n if L[j] == 0:\n L[j] = i\n\n def factor(x: int):\n res = []\n while x != 1:\n prime = L[x] if L[x] != 0 else x\n res.append(prime)\n x /= prime\n return res\n\n max_e = {}\n for a in A:\n a = Counter(factor(a))\n for key, v in a.items():\n if not key in max_e:\n max_e[key] = v\n else:\n if v > max_e[key]:\n max_e[key] = v\n # print(max_e)\n\n def modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\n lcm = 1\n for key, v in max_e.items():\n lcm *= key ** v\n\n # print(max_e)\n # print(lcm)\n lcm %= MOD\n # print(lcm)\n\n ans = 0\n for i in range(N):\n b = lcm * modinv(A[i]) \n ans += b\n\n print(int(ans % MOD))\n\n\ndef resolve_ref():\n from fractions import gcd\n \n mod = 10 ** 9 + 7\n \n N = int(input())\n A = list(map(int, input().split()))\n \n L = 1\n for a in A:\n L *= a // gcd(L, a)\n \n print(L)\n L %= mod\n print(L)\n \n print(sum(L * pow(a, mod - 2, mod) for a in A) % mod)\n\nif __name__ == "__main__":\n resolve()', 'import numpy as np\nfrom collections import Counter\n\ndef resolve():\n \n \n \n \n \n \n\n \n \n \n \n \n \n # \n \n \n \n \n # \n MOD = 10**9 + 7\n N = int(input())\n A = list(map(int, input().split()))\n\n \n MX = int(10**6 + 5)\n L = np.zeros(MX+1)\n L[0] = -1\n L[1] = -1\n primes = []\n\n for i in range(2, MX+1):\n if L[i]:\n continue\n primes.append(i)\n for j in range(i+i, MX, i):\n if L[j] == 0:\n L[j] = i\n\n def factor(x: int):\n res = []\n while x != 1:\n prime = L[x] if L[x] != 0 else x\n res.append(prime)\n x /= prime\n return res\n\n max_e = {}\n for a in A:\n a = Counter(factor(a))\n for key, v in a.items():\n if not key in max_e:\n max_e[key] = v\n else:\n if v > max_e[key]:\n max_e[key] = v\n # print(max_e)\n\n def modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\n lcm = 1\n for key, v in max_e.items():\n lcm *= key ** v\n\n # print(max_e)\n # print(lcm)\n lcm %= MOD\n # print(lcm)\n\n ans = 0\n for i in range(N):\n b = lcm * modinv(A[i]) \n ans += b\n\n print(int(ans % MOD))\n\n\ndef resolve_ref():\n from fractions import gcd\n \n mod = 10 ** 9 + 7\n \n N = int(input())\n A = list(map(int, input().split()))\n \n L = 1\n for a in A:\n L *= a // gcd(L, a)\n \n print(L)\n L %= mod\n print(L)\n \n print(sum(L * pow(a, mod - 2, mod) for a in A) % mod)\n\nif __name__ == "__main__":\n resolve()', 'from collections import Counter\n\ndef resolve():\n \n \n \n \n \n \n\n \n \n \n \n \n \n # \n \n \n \n \n # \n MOD = 10**9 + 7\n N = int(input())\n A = list(map(int, input().split()))\n\n \n MX = int(10**6)\n L = [0] * (MX + 1)\n L[0] = -1\n L[1] = -1\n primes = []\n\n for i in range(2, MX+1):\n if L[i]:\n continue\n primes.append(i)\n L[i] = i\n for j in range(i*i, MX+1, i):\n if L[j] == 0:\n L[j] = i\n\n def factor(x: int):\n res = []\n while x != 1:\n prime = L[x] if L[x] != 0 else x\n res.append(prime)\n x /= prime\n x = int(x)\n return res\n\n max_e = {}\n for a in A:\n a = Counter(factor(a))\n for key, v in a.items():\n if not key in max_e:\n max_e[key] = v\n else:\n if v > max_e[key]:\n max_e[key] = v\n # print(max_e)\n\n def modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\n lcm = 1\n for key, v in max_e.items():\n lcm *= key ** v\n\n # print(max_e)\n # print(lcm)\n lcm %= MOD\n # print(lcm)\n\n ans = 0\n for i in range(N):\n b = lcm * modinv(A[i]) \n ans += b\n\n print(int(ans % MOD))\n\n\ndef resolve_ref():\n from fractions import gcd\n \n mod = 10 ** 9 + 7\n \n N = int(input())\n A = list(map(int, input().split()))\n \n L = 1\n for a in A:\n L *= a // gcd(L, a)\n \n print(L)\n L %= mod\n print(L)\n \n print(sum(L * pow(a, mod - 2, mod) for a in A) % mod)\n\nif __name__ == "__main__":\n resolve()']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s445129350', 's566793688', 's790363043']
[22784.0, 22492.0, 15440.0]
[2109.0, 2109.0, 386.0]
[2568, 2553, 2572]
p02793
u824237520
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['# = int(input())\n# = map(int, input().split())\n# = list(map(int, input().split()))\n# = list(input())\n# = [tuple(map(int, input().split())) for _ in range(n)]\n\nfrom fractions import gcd\n\nn = int(input())\np = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nc = p[0]\nfor x in p[1:]:\n c = lcm(c, x)\n\nans = 0\nfor x in p:\n ans = (ans + c // x) % MOD\n\nprint(ans)\n', '# = int(input())\n# = map(int, input().split())\n# = list(map(int, input().split()))\n# = list(input())\n# = [tuple(map(int, input().split())) for _ in range(n)]\n\nfrom fractions import gcd\n\nn = int(input())\np = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\nc = p[0]\nfor x in p[1:]:\n c = c * x // gcd(c, x)\n\nans = 0\nfor x in p:\n ans = (ans + c // x) % MOD\n\nprint(ans)\n', '# = int(input())\n# = map(int, input().split())\n# = list(map(int, input().split()))\n# = list(input())\n# = [tuple(map(int, input().split())) for _ in range(n)]\n\nfrom fractions import gcd\n\nn = int(input())\np = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\n#def gcd(a, b):\n# while b:\n# a, b = b, a%b\n# return a\n\nc = p[0]\nfor x in p[1:]:\n c = c * x // gcd(c, x)\n\nans = 0\nfor x in p:\n ans += c // x\n\nprint(ans)\n', '# = int(input())\n# = map(int, input().split())\n# = list(map(int, input().split()))\n# = list(input())\n# = [tuple(map(int, input().split())) for _ in range(n)]\n\nn = int(input())\np = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\nc = p[0]\nfor x in p[1:]:\n c = c * x // gcd(c, x)\n\nans = 0\nfor x in p:\n ans += c // x\n\nprint(ans % MOD)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s223923900', 's374831144', 's828932995', 's055137905']
[6072.0, 6200.0, 6200.0, 4084.0]
[2104.0, 2104.0, 1951.0, 1879.0]
[448, 411, 466, 441]
p02793
u888337853
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
["import sys\n# import re\nimport math\nimport collections\n\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\n# import heapq\nimport decimal\n# import statistics\nimport queue\n\n# import numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n from functools import reduce\n\n tmp = [2, 4, 6, 8]\n gcdans = reduce(fractions.gcd, tmp)\n\n \n def lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n def lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n\n def lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\n n = ni()\n a = na()\n\n lcm = lcm_list(a)\n\n ans = 0\n for ai in a:\n ans += lcm // ai\n ans %= MOD\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\n# import re\nimport math\nimport collections\n\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\n# import heapq\nimport decimal\n# import statistics\nimport queue\n\n# import numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n from functools import reduce\n\n n = ni()\n a = na()\n\n lcm = a[0]\n for i in a:\n lcm = lcm // math.gcd(lcm, i) * i\n lcm %= MOD\n\n ans = 0\n for ai in a:\n ans += lcm * pow(ai, MOD - 2, MOD) % MOD\n ans %= MOD\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Time Limit Exceeded', 'Accepted']
['s066553536', 's728670560']
[11908.0, 11712.0]
[2206.0, 854.0]
[1002, 800]
p02793
u901582103
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nm=10**9+7\nn=int(input())\nL=list(map(int,input().split()))\ng=L[0]\nfor i in range(n-1):\n g=(g*L[i+1])//gcd(g,L[i+1])\nr=0\nfor i in range(n):\n r+=g//L[i]%m\nprint(r%m)', 'from collections import defaultdict\n\nn=int(input())\nA=list(map(int,input().split()))\nMOD=10**9+7\nL=defaultdict(int)\n\ndef soinsu(n):\n\tl=defaultdict(int)\n\tfor j in range(2,int(n**0.5)+1):\n\t\twhile n%j==0:\n\t\t\tl[j]+=1\n\t\t\tn//=j\n\tif l=={}:\n\t\t\tl[n]+=1\n\telse:\n\t\tif n!=1:\n\t\t\tl[n]+=1\n\tfor k,v in l.items():\n\t\tL[k]=max(L[k],v)\n\nfor i in range(n):\n\tsoinsu(A[i])\n\nLM=1\nfor k,v in L.items():\n\tLM*=k**v\n\tLM%=MOD\n\nr=0\nfor i in range(n):\n\tr+=LM*pow(A[i],MOD-2,MOD)\n\tr%=MOD\nprint(r)']
['Time Limit Exceeded', 'Accepted']
['s197212125', 's591878714']
[6200.0, 4852.0]
[2104.0, 996.0]
[194, 463]
p02793
u905711033
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\n\ndef lcm(a):\n x = a[0]\n for i in range(1, len(a)):\n if x % a[i] != 0:\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nn = int(input())\na = list(map(int, input().split()))\n\ndiv = 10**9 + 7\nlcm_num = lcm(a)\nans = [lcm_num//ai for ai in a]\n\nprint(sum(ans)%div)\n', 'from fractions import gcd\n\nN = int(input())\nA = list(map(int, input().split()))\n\nif N == 1:\n print(1)\n exit()\n\ndef saisho_ko_baisu(A,B):\n return A*B // gcd(A,B)\n# # A < B\n# x = A*B\n# r = B%A\n# while r!=0:\n# B = A\n# A = r\n# r = B%A\n# return x//A\n\nA.sort(reverse = True)\ntmp = saisho_ko_baisu(A[0], A[1])\nres = tmp//A[0] + tmp//A[1]\nfor i in range(2,N):\n if tmp % A[i] != 0:\n new = saisho_ko_baisu(A[i], tmp)\n res *= new//tmp\n tmp = new\n res += tmp // A[i]\n\nprint(res % (10**9 + 7))\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nif N == 1:\n print(1)\n exit()\n\ndef saisho_ko_baisu(A,B):\n # A < B\n if B < A:\n A,B = B,A\n x = A*B\n r = B%A\n while r!=0:\n B = A\n A = r\n r = B%A\n return x//A\n\nA.sort()\ntmp = saisho_ko_baisu(A[0], A[1])\nfor i in range(2,N):\n tmp = saisho_ko_baisu(tmp, A[i])\nres = 0\nfor a in A:\n res += tmp//a\n\nprint(res % (10**9 + 7))\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s141495960', 's247735134', 's808470758']
[197688.0, 6108.0, 4084.0]
[2116.0, 2104.0, 1881.0]
[306, 561, 426]
p02793
u922952729
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['N=int(input())\nA=[int(i) for i in input().split(" ")]\nmod=10**9+7\n\ndef GCD(a,b):\n if min(a,b)==0:\n return max(a,b)\n else:\n return GCD(min(a,b),max(a,b)%min(a,b))\n\ndef LCM(a,b):\n return int(a*b//GCD(a,b))\n\n\n\ndef egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return (lastx, lasty, a)\n\n\ndef modinv(a, m):\n (inv, q, gcd_val) = egcd(a, m)\n return inv % m\n\n\nlcm=1\nfor a in A:\n lcm=LCM(lcm,a)\n\n\nretval=0\nfor a in A:\n retval+=a*lcm\n retval=retval%mod\n\nprint(int(retval%mod))\n', 'N=int(input())\nA=[int(i) for i in input().split(" ")]\nmod=10**9+7\n\ndef GCD(a,b):\n if min(a,b)==0:\n return max(a,b)\n else:\n return GCD(min(a,b),max(a,b)%min(a,b))\n\ndef LCM(a,b):\n return int(a*b//GCD(a,b))\n\n\n\n\n\nlcm=1\nfor a in A:\n lcm=LCM(lcm,a)\n\n\nretval=0\nfor a in A:\n retval+=lcm//a\n\nprint(int(retval%mod))\n']
['Wrong Answer', 'Accepted']
['s473884055', 's216495857']
[4084.0, 4084.0]
[2062.0, 1975.0]
[668, 335]
p02793
u924691798
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from fractions import gcd\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\nnow = A[0]\nans = 0\nfor i in range(1,N):\n now = now//gcd(now, A[i])*A[i]\nfor i in range(N):\n ans += now//A[i]\n ans %= MOD\nprint(ans)\n', 'from fractions import gcd\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\nnow = A[0]\nans = 0\nfor i in range(1,N):\n now = now//gcd(now, A[i])*A[i]\nfor i in range(N):\n ans += now//A[i]\nprint(ans)', 'from collections import defaultdict\n\ndef prime_factors(n):\n d = defaultdict(int)\n while n%2 == 0:\n d[2] += 1\n n //= 2\n i = 3\n while i*i <= n:\n while n%i == 0:\n d[i] += 1\n n //= i\n i += 2\n if n > 2:\n d[n] += 1\n return d\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\nG = defaultdict(int)\nfor a in A:\n pf = prime_factors(a)\n for k,v in pf.items():\n G[k] = max(G[k], v)\nlcm = 1\nfor k,v in G.items():\n lcm *= pow(k, v, MOD)\n lcm %= MOD\nans = 0\nfor a in A:\n ans += lcm * pow(a, MOD-2, MOD) % MOD\n ans %= MOD\nprint(ans)']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s556312019', 's816990664', 's223205999']
[6112.0, 6112.0, 4852.0]
[2104.0, 1946.0, 861.0]
[234, 218, 634]
p02793
u927078824
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import functools\nimport fractions\nMOD = 10**9+7\n\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\n\ndef lcm(numbers):\n return functools.reduce(lcm_base, numbers, 1)\n\n\ndef main():\n n = int(input())\n x = list(map(int, input().split()))\n\n l = lcm(x)\n ans = 0\n for i in range(n):\n ans += l // x[i]\n ans %= MOD\n\n print(ans)\n\n\nmain()\n', 'import functools\nimport fractions\nMOD = 10**9+7\n\n\ndef sieve(n):\n result = [0] * (n+1)\n result[0] = result[1] = -1\n \n for i in range(2, n+1):\n if(result[i]):\n continue\n \n result[i] = i\n for j in range(i*i, n+1, i):\n if not result[j]:\n result[j] = i\n return result\n\n\ndef is_prime(table, x):\n return table[x] == x\n\n\ndef factor(table, x):\n result = {}\n while(x != 1):\n p = str(table[x])\n if p not in result:\n result[p] = 1\n else:\n result[p] += 1\n x //= int(p)\n return result\n\n\ndef main():\n n = int(input())\n x = list(map(int, input().split()))\n\n table = sieve(10**6)\n max_table = {}\n for i in range(n):\n f = factor(table, x[i])\n for j in f:\n if j not in max_table:\n max_table[j] = f[j]\n else:\n max_table[j] = max(max_table[j], f[j])\n\n lcm = 1\n for p in max_table:\n lcm *= int(p)**max_table[p] % MOD\n\n ans = 0\n for i in range(n):\n ans += lcm//x[i]\n print(ans % MOD)\n\n\nmain()\n']
['Time Limit Exceeded', 'Accepted']
['s518774111', 's391688577']
[6084.0, 16868.0]
[2104.0, 1253.0]
[377, 1152]
p02793
u930705402
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['import math\nimport fractions\nN=int(input())\nA=list(map(int,input().split()))\ntmp=A[0]\nans=0\n\nfor i in range(N):\n tmp=math.floor((tmp*A[i])/(fractions.gcd(tmp,A[i])))\n\nfor i in range(N):\n ans+=(tmp/A[i])\n ans%=1000000007\n \nprint(int(ans))', "MOD=10**9+7\nimport sys\nread=sys.stdin.readline\nfrom fractions import gcd\nfrom collections import deque\ndef lcm(a,b):\n return(a//gcd(a,b)*b)\ndef main():\n N=int(input())\n A=list(map(int,read().split()))\n d=deque(A)\n while(len(d)>1):\n a,b=d.popleft(),d.popleft()\n d.append(lcm(a,b))\n g=d[0]\n res=0\n for i in range(N):\n res=(res+g//A[i])%MOD\n print(res)\n \nif __name__=='__main__':\n main()", 'MOD=10**9+7\ndef factorization(n):\n arr=[]\n tmp=n\n for i in range(2,int(n**0.5)+1):\n if(tmp%i==0):\n cnt=0\n while tmp%i==0:\n cnt+=1\n tmp//=i\n arr.append([i,cnt])\n if(not arr):\n arr.append([1,1])\n if(tmp!=1):\n arr.append([tmp,1])\n return arr\ndef moddiv(a,m):\n return pow(a,m-2,m)\nN=int(input())\nA=list(map(int,input().split()))\ncnt={}\nfor i in range(N):\n arr=factorization(A[i])\n for a,b in arr:\n cnt[a]=max(cnt.get(a,0),b)\ng=1;res=0\nfor k,v in cnt.items():\n g=g*(pow(k,v,MOD))%MOD\nfor i in range(N):\n res=(res+(g*moddiv(A[i],MOD))%MOD)%MOD\nprint(res)']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s514950378', 's850210366', 's462976843']
[6200.0, 6136.0, 4700.0]
[45.0, 2104.0, 866.0]
[249, 438, 672]
p02793
u994988729
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nd = [0] * (max(A) + 1)\nd = {i: 0 for i in range(1, max(A)+1)}\nd = defaultdict(int)\n\n\ndef prime_factorization(n): \n res = []\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n cnt = 0\n while n % i == 0:\n cnt += 1\n n //= i\n res.append((i, cnt))\n if n > 1:\n res.append((n, 1))\n return res\n\n\npf = []\nfor a in A:\n res = []\n for i in range(2, int(a ** 0.5) + 1):\n if a % i == 0:\n cnt = 0\n while a % i == 0:\n cnt += 1\n a //= i\n d[i] = max(d[i], cnt)\n res.append((i, cnt))\n if a != 1:\n d[a] = max(d[a], 1)\n res.append((i, cnt))\n pf.append(res)\n\nans = 0\nfor i, a in enumerate(A):\n tmpD = d.copy()\n for k, v in pf[i]:\n tmpD[k] -= v\n b = 1\n for k, v in tmpD.items():\n if v == 0:\n continue\n b *= pow(k, v, mod)\n v %= mod\n ans += b\n ans %= mod\n\nprint(ans % mod)\n', 'from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nd = defaultdict(int)\n\npf = []\nfor a in A:\n res = []\n for i in range(2, int(a ** 0.5) + 1):\n if a % i == 0:\n cnt = 0\n while a % i == 0:\n cnt += 1\n a //= i\n d[i] = max(d[i], cnt)\n res.append((i, cnt))\n if a != 1:\n d[a] = max(d[a], 1)\n res.append((i, cnt))\n pf.append(res)\n\nans = 0\nfor i, a in enumerate(A):\n tmpD = d.copy()\n for k, v in pf[i]:\n tmpD[k] -= v\n b = 1\n for k, v in tmpD.items():\n if v <= 0:\n continue\n b *= pow(k, v, mod)\n v %= mod\n ans += b\n ans %= mod\n\nprint(ans % mod)\n', 'from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nd = defaultdict(int)\n\n\ndef prime_factorization(n): \n res = []\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n cnt = 0\n while n % i == 0:\n cnt += 1\n n //= i\n res.append((i, cnt))\n if n > 1:\n res.append((n, 1))\n return res\n\n\nfor a in A:\n for i in range(2, int(a ** 0.5) + 1):\n if a % i == 0:\n cnt = 0\n while a % i == 0:\n cnt += 1\n a //= i\n d[i] = max(d[i], cnt)\n if a != 1:\n d[a] = max(d[a], 1)\n\nans = 0\nlcm = 1\nfor k, v in d.items():\n lcm *= pow(k, v, mod)\n lcm %= mod\n\nfor a in A:\n if a == 1:\n ans += lcm\n continue\n l = lcm*pow(a, mod-2, mod)\n ans += l\n ans %= mod\n\nprint(ans % mod)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s423367217', 's758400137', 's252750305']
[107672.0, 8744.0, 4844.0]
[1666.0, 2104.0, 1141.0]
[1133, 755, 921]
p02793
u998741086
2,000
1,048,576
Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N. Since the answer can be enormous, print the sum modulo (10^9 +7).
['#!/usr/bin/env python\nimport math\n\nn = int(input())\na = list(map(int, input().split()))\nmod = 10**9+7\n\ndef gcd(x, y): \n if x == 0: return y\n else: return gcd(x%y, x)\n\ndef lcm(a, b): \n return a*b//gcd(a, b)\n\nl = a[0]\nfor i in range(n):\n l = lcm(l, a[i])\n\nans = 0 \nfor i in range(n):\n ans += (l//a[i])%mod\n\nprint(ans%mod)\n', '#!/usr/bin/env python\nimport math\nn = int(input()) \na = list(map(int, input().split()))\n\nmod = 10**9+7\n\ndef lcm(a, b): \n return a*b//math.gcd(a, b)\n\nl = a[0]\nfor i in range(n):\n l = lcm(l, a[i])\nl %= mod \n\nans = 0 \nfor i in range(n):\n inv = pow(a[i], mod-2, mod)\n ans += (l*inv)%mod\n\nprint(ans%mod)\n']
['Wrong Answer', 'Accepted']
['s551604075', 's286111874']
[10100.0, 10184.0]
[205.0, 839.0]
[335, 311]
p02794
u018990794
4,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i. Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions? * The i-th (1 \leq i \leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.
["N = int(input())\nadj = [[] for _ in range(n)] \nadj_dict = dict()\n\nfor i in range(N - 1):\n a, b = [int(x) - 1 for x in input().split()]\n adj[a].append(b)\n adj[b].append(a)\n if a > b:\n adj_dict[(b, a)] = i\n else:\n adj_dict[(a, b)] = i\n\nm = int(input())\nuv = []\nfor _ in range(m):\n uv.append([int(x) - 1 for x in input().split()])\n\n\ndef dfs(p, v, dest):\n if v == dest:\n return [v]\n if p != -1 and len(adj[v]) == 1:\n return False\n for nv in adj[v]:\n if nv == p:\n continue\n ret = dfs(v, nv, dest)\n if ret:\n return ret + [v]\n return False\n\nedgest = [0] * (2 ** m)\nfor i, (u, v) in enumerate(uv):\n ret = dfs(-1, u, v)\n for uu, vv in zip(ret, ret[1:]):\n if uu > vv:\n uu, vv = vv, uu\n if (uu, vv) in adj_dict:\n edgest[1 << i] |= (1 << adj_dict[(uu, vv)])\n\nfor i in range(1, 2 ** m):\n lsb = i & (-i)\n edgest[i] = edgest[i ^ lsb] | edgest[lsb]\n\ndp = [0] * (2 ** m)\ndp[0] = 1 << (N - 1)\nans = dp[0]\nfor i in range(1, 2 ** m):\n lsb = i & (-i)\n lim = bin(edgest[i] ^ edgest[i ^ lsb]).count('1')\n dp[i] = dp[i ^ lsb] >> lim\n if bin(i).count('1') % 2 == 0:\n ans += dp[i]\n else:\n ans -= dp[i]\nprint(ans)\n", "n = int(input())\nadj = [[] for _ in range(n)]\nadj_dict = dict()\n\nfor i in range(n - 1):\n a, b = [int(x) - 1 for x in input().split()]\n adj[a].append(b)\n adj[b].append(a)\n if a > b:\n adj_dict[(b, a)] = i\n else:\n adj_dict[(a, b)] = i\n\nm = int(input())\nuv = []\nfor _ in range(m):\n uv.append([int(x) - 1 for x in input().split()])\n\ndef dfs(p, v, dest):\n if v == dest:\n return [v]\n if p != -1 and len(adj[v]) == 1:\n return False\n for nv in adj[v]:\n if nv == p:\n continue\n ret = dfs(v, nv, dest)\n if ret:\n return ret + [v]\n return False\n\nedgest = [0] * (2 ** m)\nfor i, (u, v) in enumerate(uv):\n ret = dfs(-1, u, v)\n for uu, vv in zip(ret, ret[1:]):\n if uu > vv:\n uu, vv = vv, uu\n if (uu, vv) in adj_dict:\n edgest[1 << i] |= (1 << adj_dict[(uu, vv)])\n\nfor i in range(1, 2 ** m):\n lsb = i & (-i)\n edgest[i] = edgest[i ^ lsb] | edgest[lsb]\n\ndp = [0] * (2 ** m)\ndp[0] = 1 << (n - 1)\nans = dp[0]\nfor i in range(1, 2 ** m):\n lsb = i & (-i)\n lim = bin(edgest[i] ^ edgest[i ^ lsb]).count('1')\n dp[i] = dp[i ^ lsb] >> lim\n if bin(i).count('1') % 2 == 0:\n ans += dp[i]\n else:\n ans -= dp[i]\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s737065072', 's212252138']
[3188.0, 86088.0]
[18.0, 2065.0]
[1308, 1263]
p02794
u096616343
4,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i. Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions? * The i-th (1 \leq i \leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.
['N = int(input())\nab = [tuple(map(int,input().split())) for _ in range(N - 1)]\nM = int(input())\nuv = [tuple(map(int,input().split())) for _ in range(M)]\nroute = [[] for _ in range(N)]\n\nfor i, (a, b) in enumerate(ab):\n a -= 1\n b -= 1\n route[a].append((b, i))\n route[b].append((a, i))\n\npath = [0] * M\nfor i, (u, v) in enumerate(uv):\n u -= 1\n v -= 1\n stack = [u]\n visited = [0] * N\n visited[u] = 1\n dire = [[] for _ in range(N)]\n while True:\n s = stack.pop()\n for g, j in route[s]:\n if visited[g]:\n continue \n stack.append(g)\n dire[g].append((s, j))\n visited[g] = 1\n if visited[v]:\n break\n s = v\n while True:\n g, num = dire[s]\n path[i] |= (1 << num)\n if g == u:\n break\n\ndata = [0] * (1 << M)\nans = 2 ** (N - 1)\nfor i in range(1, a << M):\n k = bin(i) - 3\n data[i] = data[i - (2 ** k)] | path[k]\n power = bin(data[i]).count("1")\n judge = bin(i).count("1")\n ans += (-2 ** (N - 1 - power) if judge % 2 else 2 ** (N - 1 - power))\nprint(ans)', 'N = int(input())\nab = [tuple(map(int,input().split())) for _ in range(N - 1)]\nM = int(input())\nuv = [tuple(map(int,input().split())) for _ in range(M)]\nroute = [[] for _ in range(N)]\n\nfor i, (a, b) in enumerate(ab):\n a -= 1\n b -= 1\n route[a].append((b, i))\n route[b].append((a, i))\n\npath = [0] * M\nfor i, (u, v) in enumerate(uv):\n u -= 1\n v -= 1\n stack = [u]\n visited = [0] * N\n visited[u] = 1\n dire = [[] for _ in range(N)]\n while True:\n s = stack.pop()\n for g, j in route[s]:\n if visited[g]:\n continue \n stack.append(g)\n dire[g].append((s, j))\n visited[g] = 1\n if visited[v]:\n break\n s = v\n while True:\n g, num = dire[s][0]\n path[i] |= (1 << num)\n if g == u:\n break\n\ndata = [0] * (1 << M)\nans = 2 ** (N - 1)\nfor i in range(1, a << M):\n k = bin(i) - 3\n data[i] = data[i - (2 ** k)] | path[k]\n power = bin(data[i]).count("1")\n judge = bin(i).count("1")\n ans += (-2 ** (N - 1 - power) if judge % 2 else 2 ** (N - 1 - power))\nprint(ans)', 'N = int(input())\nab = [tuple(map(int,input().split())) for _ in range(N - 1)]\nM = int(input())\nuv = [tuple(map(int,input().split())) for _ in range(M)]\nroute = [[] for _ in range(N)]\n\nfor i, (a, b) in enumerate(ab):\n a -= 1\n b -= 1\n route[a].append(b, i)\n route[b].append(a, i)\n\npath = [0] * M\nfor i, (u, v) in enumerate(uv):\n u -= 1\n v -= 1\n stack = [u]\n visited = [0] * N\n visited[u] = 1\n dire = [[] for _ in range(N)]\n while True:\n s = stack.pop()\n for g, j in route[s]:\n if visited[g]:\n continue \n stack.append(g)\n dire[g].append((s, j))\n visited[g] = 1\n if visited[v]:\n break\n s = v\n while True:\n g, num = dire[s]\n path[i] |= (1 << num)\n if g == u:\n break\n\ndata = [0] * (1 << M)\nans = 2 ** (N - 1)\nfor i in range(1, a << M):\n k = bin(i) - 3\n data[i] = data[i - (2 ** k)] | path[k]\n power = bin(data[i]).count("1")\n judge = bin(i).count("1")\n ans += (-2 ** (N - 1 - power) if judge % 2 else 2 ** (N - 1 - power))\nprint(ans)', 'N = int(input())\nab = [tuple(map(int,input().split())) for _ in range(N - 1)]\nM = int(input())\nuv = [tuple(map(int,input().split())) for _ in range(M)]\nroute = [[] for _ in range(N)]\n\nfor i, (a, b) in enumerate(ab):\n a -= 1\n b -= 1\n route[a].append((b, i))\n route[b].append((a, i))\n\npath = [0] * M\nfor i, (u, v) in enumerate(uv):\n u -= 1\n v -= 1\n stack = [u]\n visited = [0] * N\n visited[u] = 1\n dire = [[] for _ in range(N)]\n while True:\n s = stack.pop()\n for g, j in route[s]:\n if visited[g]:\n continue \n stack.append(g)\n dire[g].append((s, j))\n visited[g] = 1\n if visited[v]:\n break\n s = v\n while True:\n g, num = dire[s][0]\n path[i] |= (1 << num)\n if g == u:\n break\n s = g\n\ndata = [0] * (1 << M)\nans = 2 ** (N - 1)\nfor i in range(1, 1 << M):\n k = len(bin(i)) - 3\n data[i] = data[i - (2 ** k)] | path[k]\n power = bin(data[i]).count("1")\n judge = bin(i).count("1")\n ans += (-2 ** (N - 1 - power) if judge % 2 else 2 ** (N - 1 - power))\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s079485102', 's315744560', 's723811698', 's021897847']
[3188.0, 3188.0, 3188.0, 44548.0]
[18.0, 4204.0, 18.0, 2434.0]
[1110, 1113, 1106, 1133]
p02794
u885494445
4,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i. Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions? * The i-th (1 \leq i \leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport numpy as np\n\nMOD = 10 ** 9 +7\n\nn = int(readline)\nab = list(list(map(int,readline().split()))for _ in range(n-1))\nm=int(readline())\nuv=list(list(map(int,readline().split()))for _ in range(m))\n\ngraph = [[]for _ in range(n+1)]\nfor i ,(a,b) in enumerate(ab):\n graph[a].append((b,i))\n graph[b].append((a,i))\n\ndef get_path(u,v):\n INF = 100\n visited =[False]*(n+1)\n pred =[None]*(n+1)\n stack =[u]\n visited[u]=True\n while stack:\n v = stack.pop()\n for w,i in graph[v]:\n if visited[w]:\n continue\n visited[w] = True\n pred[w] = (v,i)\n stack.append(w)\n path = 0\n w = v\n while w!= u:\n v,i = pred[w]\n w =v\n path+=1<<i\n return path\n\ncondition_path = [get_path(u,v)for u,v in uv]\n\ns=np.zeros(1<<m,np.int64)\nsgn = np.ones(1<<m,np.int64)\nfor i in range(m):\n s[1<<i:1<<(i+1)] = s[:1<<i] | condition_path[i]\n sgn[1<<i:1<<(i+1)]=-sgn[:1<<i]\n\ndef popcnt(n):\n c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)\n c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)\n c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)\n c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)\n c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)\n c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)\n return c\n\nn_edges = popcnt(s)\n\nx= 1<<(n-1-n_edges)\nanswer =(x*sgn).sum()\nprint(answer)\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport numpy as np\n\nMOD = 10 ** 9 +7\n\nn = int(readline())\nab = list(list(map(int,readline().split()))for _ in range(n-1))\nm=int(readline())\nuv=list(list(map(int,readline().split()))for _ in range(m))\n\ngraph = [[]for _ in range(n+1)]\nfor i ,(a,b) in enumerate(ab):\n graph[a].append((b,i))\n graph[b].append((a,i))\n\ndef get_path(U,V):\n INF = 100\n visited =[False]*(n+1)\n pred =[None]*(n+1)\n stack =[U]\n visited[U]=True\n while stack:\n v = stack.pop()\n for w,i in graph[v]:\n if visited[w]:\n continue\n visited[w] = True\n pred[w] = (v,i)\n stack.append(w)\n path = 0\n w = V\n while w!= U:\n v,i = pred[w]\n w =v\n path+=1<<i\n return path\n\ncondition_path = [get_path(u,v)for u,v in uv]\n\ns=np.zeros(1<<m,np.int64)\nsgn = np.ones(1<<m,np.int64)\nfor i in range(m):\n s[1<<i:1<<(i+1)] = s[:1<<i] | condition_path[i]\n sgn[1<<i:1<<(i+1)]=-sgn[:1<<i]\n\ndef popcnt(n):\n c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)\n c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)\n c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)\n c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)\n c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)\n c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)\n return c\n\nn_edges = popcnt(s)\n\nx= 1<<(n-1-n_edges)\nanswer =(x*sgn).sum()\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s389557282', 's284224794']
[12512.0, 61680.0]
[153.0, 234.0]
[1655, 1657]
p02801
u003019316
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
["N, M = map(int, input().split())\nAC = set()\nwa = [0] * (N+1)\n\nfor _ in range(M):\n p, s = input().split()\n p = int(p)\n if not p in AC:\n if s == 'AC':\n AC.add(p)\n if s == 'WA':\n wa[p] += 1\n\nwa_ans = 0\nfor i in range(1,N+1):\n if i in AC:\n wa_ans += wa[i]\n\nprint(len(AC), wa_ans)", 'import sys\nalp = "abcdefghijklmnopqrstuvwxyza"\nC = input()\nfor i in range(26):\n if alp[i] == C:\n print(alp[i+1])\n sys.exit()']
['Runtime Error', 'Accepted']
['s135553961', 's797988513']
[3064.0, 2940.0]
[17.0, 17.0]
[330, 141]
p02801
u006883624
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['s = input()\n\nprint(s[0] + 1)', 's = input()\n\nprint(chr(ord(s[0]) + 1))']
['Runtime Error', 'Accepted']
['s954096247', 's769654543']
[2940.0, 2940.0]
[17.0, 17.0]
[28, 38]
p02801
u007738720
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['print(chr(ord(input())+1)', 'print(chr(ord(input())+1))']
['Runtime Error', 'Accepted']
['s317961786', 's872840848']
[2940.0, 2940.0]
[17.0, 17.0]
[25, 26]
p02801
u007808656
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['chrs=string.ascii_lowercase\nnx={c:d for c,d in zip(chrs,chrs[1:])}\nprint(nx(input())', 'import string\nchrs=string.ascii_lowercase\nnx={c:d for c,d in zip(chrs,chrs[1:])}\nprint(nx[input()])\n\n']
['Runtime Error', 'Accepted']
['s555603118', 's590263776']
[2940.0, 3768.0]
[17.0, 25.0]
[84, 101]
p02801
u013513417
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
["print chr(ord('a') + 1)", 'print(chr(ord(input()) + 1))']
['Runtime Error', 'Accepted']
['s177651261', 's066823844']
[2940.0, 2940.0]
[18.0, 17.0]
[23, 28]
p02801
u015564739
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['list = [a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z]\n\nC = str(input())\n\nprint(list[(list.index(C)+1)%len(list)])', "list = ['a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\n\nC = str(input())\n\nprint(list[(list.index(C)+1)%len(list)])\n"]
['Runtime Error', 'Accepted']
['s258327858', 's766832990']
[3060.0, 2940.0]
[17.0, 17.0]
[118, 169]
p02801
u018679195
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['n=(input())\nprint(chr(ord(n)+1))\nprint(n,"is followed by",(chr(ord(n)+1)))\n', 'x = input("Enter a letter: ").lower()\nprint(chr(ord(x) + 1))', 'InputStr = input()\nA = InputStr[0]\nB = ord(A)+1\nC = chr(B)\nprint("%s" % C)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s012060658', 's745717544', 's737876947']
[2940.0, 2940.0, 8988.0]
[17.0, 17.0, 26.0]
[75, 60, 74]
p02801
u019674621
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['a=input()\nprint(str(ord(a)+1)', 'a=input()\nb = chr(ord(a)+1)\nprint(b)']
['Runtime Error', 'Accepted']
['s519541242', 's151149372']
[2940.0, 2940.0]
[17.0, 17.0]
[29, 36]
p02801
u021019433
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['print(chr(ord(input()) + 1)', 'print(chr(ord(input()) + 1))']
['Runtime Error', 'Accepted']
['s172202898', 's198564953']
[2940.0, 2940.0]
[17.0, 17.0]
[27, 28]
p02801
u021763820
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['# -*- coding: utf-8 -*-\nn, k, m = map(int, input().split())\na = list(map(int, input().split()))\nan = m*n-sum(a)\nif (0 <= an <= k):\n print(an)\nif 0 > an:\n print(0)\nif k < an:\n print(-1)', 'a = input()\nnxt = chr(ord(a)+1)\nprint(nxt)']
['Runtime Error', 'Accepted']
['s142944491', 's611121517']
[3060.0, 2940.0]
[17.0, 17.0]
[193, 42]
p02801
u024340351
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['# simply use double ifs\ns = input()\nprint(chr(ord(s))+1)\n', '# simply use double ifs\ns = input()\nprint(chr(ord(s)+1))']
['Runtime Error', 'Accepted']
['s335351286', 's936362572']
[2940.0, 2940.0]
[17.0, 17.0]
[57, 56]
p02801
u024568043
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"\nC = input()\nprint(a[a.index(C)+1])', 'a = "abcdefghijklmnopqrstuvwxyz"\nC = input()\nprint(a[a.index(C)+1])']
['Runtime Error', 'Accepted']
['s634284511', 's161323595']
[2940.0, 2940.0]
[17.0, 17.0]
[67, 67]
p02801
u024965372
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
["c = input()\ns = 'abcdefghijklmnopqrstuvwxyz'\n\nfor i in s:\n if c == s[i]:\n print(s[i+1])\n exit()", "c = input()\ns = list('abcdefghijklmnopqrstuvwxyz')\n\nfor i in s:\n if c == s[i]:\n print(s[i+1])\n exit()", "c = input()\ns = list('abcdefghijklmnopqrstuvwxyz')\n\nfor i in range(len(s)):\n if c == s[i]:\n print(s[i+1])\n exit()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s402293045', 's692944228', 's788454251']
[8864.0, 8908.0, 9036.0]
[23.0, 20.0, 27.0]
[112, 118, 130]
p02801
u026155812
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['a = input()\nprint(char(ord(a)+1))', 'a = input()\nprint(chr(ord(a)+1))\n']
['Runtime Error', 'Accepted']
['s774393048', 's449732886']
[2940.0, 2940.0]
[16.0, 17.0]
[33, 33]
p02801
u026731851
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['c=input()\nprint(c+1)', 'print(chr(ord(input())+1))\n']
['Runtime Error', 'Accepted']
['s965767618', 's556104166']
[2940.0, 2940.0]
[17.0, 19.0]
[20, 27]
p02801
u026862065
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['s = input()\nprint(chr(ord(s + 1)))', 's = input()\nprint(chr(ord(s) + 1))']
['Runtime Error', 'Accepted']
['s140324786', 's842683788']
[2940.0, 2940.0]
[17.0, 17.0]
[34, 34]
p02801
u027685417
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['import sys\ninput = sys.stdin.readline\n\n\nalphabets = "abcdefghijklmnopqrstuvwxyz"\n\nc = input()\ni = alphabets.index(c)\n\nanswer = alphabets[i + 1]\nprint(answer)\n', 'import sys\ninput = sys.stdin.readline\n\n\nalphabets = "abcdefghijklmnopqrstuvwxyz"\n\nc = input().strip()\ni = alphabets.index(c)\n\nanswer = alphabets[i + 1]\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s836022854', 's546083660']
[2940.0, 2940.0]
[17.0, 17.0]
[158, 166]
p02801
u032222383
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
["a=input()\nb=('abcdefghijklmnopqrstuvwxyz')\nfor i in range(int(len(b)):\n\tif b[i]==a:\n \tprint(b[i+1])\n ", 'print(chr(ord(input())+1))\n']
['Runtime Error', 'Accepted']
['s211859143', 's359276504']
[2940.0, 2940.0]
[17.0, 17.0]
[117, 27]
p02801
u033524082
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
["alphabet = ['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']\nprint(alphabet[alphabet.index(input())])", "alphabet = ['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']\nprint(alphabet[alphabet.index(input())+1])"]
['Wrong Answer', 'Accepted']
['s539064390', 's005704494']
[2940.0, 2940.0]
[20.0, 18.0]
[157, 159]
p02801
u039189422
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['n,m=map(int,input().split())\na=[]\nfor i in range(m):\n\tp,s=input().split()\n\tif p in a:\n\t\tcontinue\n\tif s=="AC":\n\t\ta.append(p)\nprint(len(a))', 'c=input()\nprint(chr(ord(c)+1))']
['Runtime Error', 'Accepted']
['s619965492', 's360548812']
[3060.0, 2940.0]
[17.0, 17.0]
[137, 30]
p02801
u039355749
2,000
1,048,576
Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.
['import string\n\nprint(type(string.ascii_lowercase))\ninput = input()\nalphabets = string.ascii_lowercase\n\nprint(alphabets.index(input))\ni = alphabets.index(input)\nans = alphabets[i + 1]\n \nprint(ans)', "import string\n\nprint(type(string.ascii_lowercase))\ninput = input()\nalphabets = string.ascii_lowercase\n\n\ni = alphabets.index(input)\noutput = alphabets[i+1]\n \nprint('{} の次は {} です。'.format(input, output))", 'from string import ascii_lowercase as alphabets\n\ninput = input()\nprint(alphabets[alphabets.index(input) + 1])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s406464097', 's728198279', 's290549726']
[3960.0, 3892.0, 3768.0]
[36.0, 28.0, 24.0]
[196, 245, 109]