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
|
---|---|---|---|---|---|---|---|---|---|---|
p03253 | u375616706 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n, m = (list)(map(int, input().split()))\n\nl_prime = [0]*(n+1)\nN = n\nran = range(3, N+1)\n\nwhile n % 2 == 0:\n l_prime[2] += 1\n n /= 2\n\nfor i in ran:\n while n != 1:\n if n % i == 0:\n n /= i\n l_prime[i] += 1\n else:\n i += 2\n\n\ndef fact(n):\n tmp = 1\n while n != 0:\n tmp *= n\n n -= 1\n\n return tmp\n\n\ndef comb(a, b):\n if a < b:\n print("err")\n\n return (int)(fact(a)/(fact(a-b)*fact(b)))\n\n\nres = 1\nfor i in range(1, N+1):\n ele = l_prime[i]\n if ele != 0:\n ret = comb(ele+m-1, ele)\n print(ret)\n res *= ret\n\nprint(res)\n', 'mod = 10 ** 9 + 7\nn, m = map(int, input().split())\n\nf = []\np = 2\nwhile p * p <= m:\n if m % p != 0:\n p += 1\n continue\n c = 0\n while m % p == 0:\n c += 1\n m //= p\n f.append(c)\n p += 1\nif m != 1:\n f.append(1)\n\n\ndef comb(a, b):\n ret = 1\n r = min(b, a-b)\n for i in range(a-r+1, a+1):\n ret *= i\n for j in range(1, r+1):\n ret /= j\n return ret\n\n\nres = 1\nfor ele in f:\n ret = comb(ele+n-1, n-1)\n res *= ret\n\nprint(res % mod)\n\n#print(comb(5, 2))\n', 'import math\nmod = 10 ** 9 + 7\nn, m = map(int, input().split())\n\nf = []\np = 2\nwhile p * p <= m:\n if m % p != 0:\n p += 1\n continue\n c = 0\n while m % p == 0:\n c += 1\n m //= p\n f.append(c)\n p += 1\nif m != 1:\n f.append(1)\n\n\ndef comb(a, b):\n ret = 1\n r = min(b, a-b)\n for i in range(a-r+1, a+1):\n ret *= i\n for j in range(1, r+1):\n ret //= j\n\n return (int)(ret)\n\n\nans = 1\nfor i in f:\n ans *= comb(i+n-1, i)\nprint(ans % mod)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s251754760', 's560881781', 's881231969'] | [4492.0, 3064.0, 3064.0] | [2104.0, 19.0, 19.0] | [622, 516, 496] |
p03253 | u382423941 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\nfrom collections import Counter\n\nn, m = map(int, input().split())\nmod = 10**9 + 7\n\nfact = [0] * (n+21)\nifact = [0] * (n+21)\nfact[0] = 1\nfor i in range(1,n+21):\n fact[i] = fact[i-1] * i % mod\nifact[n+20] = pow(fact[n+20], mod-2, mod)\nfor i in reversed(range(1,n+21)):\n ifact[i-1] = ifact[i] * i % mod\n\ndef comb(n, k):\n return fact[n] * ifact[n-k] % mod * ifact[k] % mod\n\ndef getprime(n):\n primes = []\n i = 2\n while n > i * i:\n while n % i == 0:\n n //= i\n primes.append(i)\n i += 1\n if n != 1:\n primes.append(n)\n return primes\n\nans = 1\ncounter = Counter(getprime(m))\nprint(counter)\nfor k in counter.values():\n print(n+k-1, k, comb(n+k-1, k))\n ans *= comb(n+k-1, k)\n ans %= mod\nprint(ans)', 'import math\nfrom collections import Counter\n\nn, m = map(int, input().split())\nmod = 10**9 + 7\n\nK = 50\nfact = [0] * (n+1+K)\nifact = [0] * (n+1+K)\nfact[0] = 1\nfor i in range(1,n+1+K):\n fact[i] = fact[i-1] * i % mod\nifact[n+K] = pow(fact[n+K], mod-2, mod)\nfor i in reversed(range(1,n+1+K)):\n ifact[i-1] = ifact[i] * i % mod\n\ndef comb(n, k):\n return fact[n] * ifact[n-k] % mod * ifact[k] % mod\n\ndef getprime(n):\n primes = []\n i = 2\n while n >= i * i:\n while n % i == 0:\n n //= i\n primes.append(i)\n i += 1\n if n != 1:\n primes.append(n)\n return primes\n\nans = 1\ncounter = Counter(getprime(m))\nprint(counter)\nfor k in counter.values():\n ans *= comb(n+k-1, k)\n ans %= mod\nprint(ans)', 'import math\nfrom collections import Counter\n\nn, m = map(int, input().split())\nmod = 10**9 + 7\n\nK = 50\nfact = [0] * (n+1+K)\nifact = [0] * (n+1+K)\nfact[0] = 1\nfor i in range(1,n+1+K):\n fact[i] = fact[i-1] * i % mod\nifact[n+K] = pow(fact[n+K], mod-2, mod)\nfor i in reversed(range(1,n+1+K)):\n ifact[i-1] = ifact[i] * i % mod\n\ndef comb(n, k):\n return fact[n] * ifact[n-k] % mod * ifact[k] % mod\n\ndef getprime(n):\n primes = []\n i = 2\n while n >= i * i:\n while n % i == 0:\n n //= i\n primes.append(i)\n i += 1\n if n != 1:\n primes.append(n)\n return primes\n\nans = 1\ncounter = Counter(getprime(m))\nfor k in counter.values():\n ans *= comb(n+k-1, k)\n ans %= mod\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s840900290', 's854113855', 's489734062'] | [11244.0, 11252.0, 11376.0] | [91.0, 96.0, 86.0] | [772, 746, 731] |
p03253 | u384124931 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\ndef cmb(n, r):\n if n < 0 or r < 0:\n return 0\n if r > n:\n return 0\n \n r = min(n-r, r)\n res = 1\n for i in range(r):\n res *= n - i\nn, m = map(int, input().split())\nb = [x[1] for x in factorization(m)]\nans = 1\nfor i in b:\n c = cmb(n+i-1, i)\n ans = ans * c\nprint(ans%(10**9+7))\n', 'def factrize(x):\n f = {}\n if x == 1:\n return f\n tmp = x\n i = 2\n while i**2 <= tmp:\n cnt = 0\n while tmp % i == 0:\n cnt += 1\n tmp = tmp//i\n if cnt > 0:\n f[i] = cnt\n i += 1\n if tmp != 1 or f == {}:\n f[tmp] = 1\n return f\n\n\ndef comb(n, r, p):\n x = 1\n for i in range(1, r + 1):\n x *= (n - i + 1) * pow(i, p - 2, p) % p\n return x % p\n\n\np = 10**9+7\nn, m = map(int, input().split())\nA = list(factrize(m).values())\nans = 1\nfor a in A:\n ans = (ans*comb(a+n-1, a, p)) % p\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s661211051', 's080825908'] | [3188.0, 3064.0] | [20.0, 20.0] | [675, 586] |
p03253 | u389910364 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\nfrom collections import Counter\n\nfrom scipy.misc import comb\n\n\ndef get_divisors(n):\n \n ret = []\n for i in range(1, int(math.sqrt(n)) + 1):\n if n % i == 0:\n ret.append(i)\n if n // i != i:\n ret.append(n // i)\n return ret\n\n\ndef get_factors(n):\n \n ret = []\n i = 2\n while 2 <= i <= n:\n if n % i == 0:\n ret.append(i)\n n //= i\n else:\n i += 1\n return ret\n\n\nn, m = map(int, input().split())\nMOD = 10 ** 9 + 7\n\n\n\n\n# for _ in range(n - 1):\n\n# div = divs[i]\n\n# print(dp)\n# print(dp)\n\n\n\nfactors = get_factors(m)\ncounts = Counter(factors)\n\n\n\n\n\nans = 1\nfor k, v in counts.items():\n ans *= comb(v + (n - 1), v, exact=True)\n ans %= MOD\nprint(ans)\n', 'import math\nimport os\nimport sys\nfrom collections import Counter\nfrom functools import reduce\nfrom operator import mul\n\nif os.getenv("LOCAL"):\n sys.stdin = open("_in.txt", "r")\n\nsys.setrecursionlimit(10 ** 9)\nINF = float("inf")\nIINF = 10 ** 18\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nN, M = list(map(int, sys.stdin.buffer.readline().split()))\n\n\ndef get_factors(n):\n \n if n <= 1:\n return []\n\n ret = []\n while n > 2 and n % 2 == 0:\n ret.append(2)\n n //= 2\n i = 3\n while i <= math.sqrt(n):\n if n % i == 0:\n ret.append(i)\n n //= i\n else:\n i += 2\n ret.append(n)\n return ret\n\n\ndef mod_inv(a, mod):\n \n return pow(a, mod - 2, mod)\n\n\ndef ncr(n, r, mod=None):\n \n if n < r:\n return 0\n\n \n r = min(n - r, r)\n if r == 0:\n return 1\n if mod:\n return reduce(mul, range(n, n - r, -1)) * mod_inv(reduce(mul, range(r, 0, -1)), mod) % mod\n else:\n \n \n return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))\n\n\ndef nhr(n, r, mod=None):\n \n return ncr(n + r - 1, r, mod)\n\n\ncounts = Counter(get_factors(M))\nans = 1\nfor c in counts.values():\n \n ans = ans * nhr(N, c, MOD) % MOD\nprint(ans)\n'] | ['Time Limit Exceeded', 'Accepted'] | ['s439427488', 's864482379'] | [15240.0, 3684.0] | [2109.0, 24.0] | [1436, 1958] |
p03253 | u403301154 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n, m = list(map(int, input().split()))\n\nMAX = 2*10**5+1\nMOD = 10**9+7\nfact = [0 for i in range(MAX)]\ninv = [0 for i in range(MAX)]\ninvfact = [0 for i in range(MAX)]\n\ndef comb_build(n):\n fact[0] = inv[0] = invfact[0] = 1\n fact[1] = inv[1] = invfact[1] = 1\n for i in range(2, n):\n fact[i] = fact[i-1]*i%MOD\n inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD\n invfact[i] = invfact[i-1]*inv[i]%MOD\n\ndef nCk(n, k):\n if n<k or n<0 or k<0:\n return 0\n return (((fact[n]*invfact[k])%MOD)*invfact[n-k])%MOD\n\ndef prime_factor(n):\n from collections import defaultdict\n ret = defaultdict(int)\n for i in range(2, int(n**(1/2))+1):\n while n%i==0:\n ret[i] += 1\n n //= i\n return ret\n\ncomb_build(MAX)\nans = 1\nfor e in prime_factor(m).values():\n ans *= nCk(e+n-1, e)%MOD\nprint(ans%MOD)', 'n, m = list(map(int, input().split()))\n\nMAX = 2*10**5+1\nMOD = 10**9+7\nfact = [0 for i in range(MAX)]\ninv = [0 for i in range(MAX)]\ninvfact = [0 for i in range(MAX)]\n\ndef comb_build(n):\n fact[0] = inv[0] = invfact[0] = 1\n fact[1] = inv[1] = invfact[1] = 1\n for i in range(2, n):\n fact[i] = fact[i-1]*i%MOD\n inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD\n invfact[i] = invfact[i-1]*inv[i]%MOD\n\ndef nCk(n, k):\n if n<k or n<0 or k<0:\n return 0\n return (((fact[n]*invfact[k])%MOD)*invfact[n-k])%MOD\n\ndef prime_factor(n):\n from collections import defaultdict\n ret = defaultdict(int)\n for i in range(2, int(n**(1/2))+10):\n while n%i==0:\n ret[i] += 1\n n //= i\n if n!=1:\n ret[n] = 1\n return ret\n\ncomb_build(MAX)\nans = 1\nfor e in prime_factor(m).values():\n ans *= nCk(e+n-1, e)%MOD\nprint(ans%MOD)'] | ['Wrong Answer', 'Accepted'] | ['s168815391', 's473678465'] | [27160.0, 27160.0] | [272.0, 290.0] | [788, 815] |
p03253 | u404676457 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\n(n, m) =map(int, input().split())\nsqm = math.sqrt(m)\nmap = {}\ni = 2\ny = m\nwhile m != 1 and sqm > i:\n if m % i == 0 :\n m = m / i\n if i in map:\n map[i] += 1\n else:\n map[i] = 1\n else:\n i += 1\nsum = 1\nfor i in map:\n tmpn = n + map[i] - 1\n c = 1\n d = 1\n e = 1\n for j in range(map[i]):\n c = c * (tmpn - j)\n d = d * (map[i] - j)\n e = e * c // d\n \n sum = sum * e % 1000000007\nprint(sum )', 'import math\n(n, m) =map(int, input().split())\nfactor = []\nfor i in range(2 , int(math.sqrt(m)) + 1):\n count = 0\n while m % i == 0:\n m = m / i\n count += 1\n if count != 0:\n factor.append(count)\nif m > 1:\n factor.append(1)\nsum = 1\nfor i in range(len(factor)):\n tmpn = n + factor[i] - 1\n d = 1\n for j in range(factor[i]):\n sum = sum * (tmpn - j)\n d = d * (factor[i] - j)\n sum = sum // d % 1000000007\nprint(sum)'] | ['Wrong Answer', 'Accepted'] | ['s411393111', 's779843085'] | [3188.0, 3064.0] | [28.0, 25.0] | [486, 466] |
p03253 | u419686324 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['N,M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nimport math\nclass PrimeUtils:\n @staticmethod\n def primes_sieve(n):\n sieve = [True] * (n + 1)\n for i in range(2, n + 1):\n if sieve[i]:\n for j in range(i + i, n + 1, i):\n sieve[j] = False\n return [i for i, x in enumerate(sieve[2:], 2) if x]\n @staticmethod\n \n def pfd(n):\n rn = math.ceil(math.sqrt(n))\n primes = PrimeUtils.primes_sieve(rn)\n\n factors = []\n cur = n\n for p in primes:\n cnt = 0\n while True:\n div, rem = divmod(cur, p)\n if rem == 0:\n cnt += 1\n cur = div\n else:\n break\n if cnt != 0:\n factors.append((p, cnt))\n if cur != 1 or n == 1:\n factors.append((cur, 1))\n return factors\n\nps = PrimeUtils.pfd(M)\nprint(ps)\n\nimport itertools, operator, math\nclass Combination:\n def __init__(self, fact=math.factorial, div=operator.itruediv):\n self.fact = fact\n self.div = div\n def comb(self, n, m):\n if n < m: return 0\n if m == 0 or n == m: return 1\n return self.div(\n self.fact(n),\n self.fact(n - m) * self.fact(m)\n )\n\nclass GFp:\n def __init__(self, p):\n self.p = p\n def inv(self, v):\n return pow(v, self.p - 2, self.p)\n\nclass CachedFactorial:\n def __init__(self, n, mod):\n self.mod = mod\n self.fact_cache = list(\n itertools.accumulate(\n itertools.chain(\n [1],\n range(1, n+1)\n ),\n lambda a,x: (a * x) % mod\n )\n )\n def factorial(self, n):\n return self.fact_cache[n]\n\nclass CachedComb(Combination):\n def __init__(self, n, mod):\n self.mod = mod\n self.gfp = GFp(mod)\n\n self.n = n\n self.fact = CachedFactorial(n, mod)\n super().__init__(\n self.fact.factorial,\n lambda x, y: (x * self.gfp.inv(y)) % self.mod\n )\n\ncc = CachedComb(N + max(x[1] for x in ps), mod)\nans = 1\nfor p, c in ps:\n cmb = cc.comb(N - 1 + c, c)\n ans = ans * cmb % mod\nprint(ans)', 'N,M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nimport math\nclass PrimeUtils:\n @staticmethod\n def primes_sieve(n):\n sieve = [True] * (n + 1)\n for i in range(2, n + 1):\n if sieve[i]:\n for j in range(i + i, n + 1, i):\n sieve[j] = False\n return [i for i, x in enumerate(sieve[2:], 2) if x]\n @staticmethod\n \n def pfd(n):\n rn = math.ceil(math.sqrt(n))\n primes = PrimeUtils.primes_sieve(rn)\n\n factors = []\n cur = n\n for p in primes:\n cnt = 0\n while True:\n div, rem = divmod(cur, p)\n if rem == 0:\n cnt += 1\n cur = div\n else:\n break\n if cnt != 0:\n factors.append((p, cnt))\n if cur != 1 or n == 1:\n factors.append((cur, 1))\n return factors\n\nimport itertools, operator, math\nclass Combination:\n def __init__(self, fact=math.factorial, div=operator.itruediv):\n self.fact = fact\n self.div = div\n def C(self, n, m):\n if n < m: return 0\n if m == 0 or n == m: return 1\n return self.div(\n self.fact(n),\n self.fact(n - m) * self.fact(m)\n )\n def H(self, n, r):\n return self.C(n - 1 + r, r)\n\nclass GFp:\n def __init__(self, p):\n self.p = p\n def inv(self, v):\n return pow(v, self.p - 2, self.p)\n\nclass CachedFactorial:\n def __init__(self, n, mod):\n self.mod = mod\n self.fact_cache = list(\n itertools.accumulate(\n itertools.chain(\n [1],\n range(1, n+1)\n ),\n lambda a,x: (a * x) % mod\n )\n )\n def factorial(self, n):\n return self.fact_cache[n]\n\nclass CachedComb(Combination):\n def __init__(self, n, mod):\n self.mod = mod\n self.gfp = GFp(mod)\n\n self.n = n\n self.fact = CachedFactorial(n, mod)\n super().__init__(\n self.fact.factorial,\n lambda x, y: (x * self.gfp.inv(y)) % self.mod\n )\n\nps = PrimeUtils.pfd(M)\ncc = CachedComb(N + max(x[1] for x in ps), mod)\nans = 1\nfor p, c in ps:\n if p == 1: continue\n cmb = cc.H(N, c)\n ans = ans * cmb % mod\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s668235238', 's205261646'] | [7572.0, 7556.0] | [51.0, 51.0] | [2375, 2433] |
p03253 | u419877586 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from collections import defaultdict\n\nn, m = map(int, input().split())\n\nprime_list = defaultdict(int)\np = 2\nwhile p <= 10**4.5+5:\n if m%p == 0:\n prime_list[p] += 1\n m //= p\n else:\n p += 1\n\nif m > 1:\n prime_list[m] += 1\n\nMOD=10**9+7\n\ndef comb(n, r): \n if r<0 or r>n: \n return 0\n r=min(r, n-r)\n res=1\n for i in range(r): \n res=res*(n-i)%MOD*pow(i+1, MOD-2, MOD)%MOD\n return res\n\nprint(prime_list)\n\nans = 1\nfor k in prime_list.keys():\n ans *= comb(prime_list[k]+n-1, prime_list[k])\n ans %= MOD\n\nprint(ans)', 'from collections import defaultdict\n\nn, m = map(int, input().split())\n\nprime_list = defaultdict(int)\np = 2\nwhile p <= 10**4.5+5:\n if m%p == 0:\n prime_list[p] += 1\n m //= p\n else:\n p += 1\n\nif m > 1:\n prime_list[m] += 1\n\nMOD=10**9+7\n\ndef comb(n, r): \n if r<0 or r>n: \n return 0\n r=min(r, n-r)\n res=1\n for i in range(r): \n res=res*(n-i)%MOD*pow(i+1, MOD-2, MOD)%MOD\n return res\n\nans = 1\nfor k in prime_list.keys():\n ans *= comb(prime_list[k]+n-1, prime_list[k])\n ans %= MOD\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s747825553', 's747670250'] | [3316.0, 3316.0] | [31.0, 30.0] | [566, 547] |
p03253 | u427344224 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['def prime_factorize(num):\n """\n This function performs prime factorization on the input natural number.\n The result is returned in the form of a dictionary with the prime number as the key\n and its number as the value.\n :param num:\n :return prime_factor: Dictionary with the prime number as the key and its number as the value.\n """\n prime_factor = {}\n i = 2\n while i ** 2 <= num:\n while num % i == 0:\n num //= i\n if i in prime_factor.keys():\n prime_factor[i] += 1\n else:\n prime_factor[i] = 1\n i += 1\n if num > 1:\n prime_factor[num] = 1\n return prime_factor\n\n\nfrom math import factorial\n\n\ndef comb(n, r):\n return factorial(n) // (factorial(n-r) * factorial(r))\n\n\nn, m = map(int, input().split())\nr = 1\nprime_fac = prime_factorize(m)\nprint(prime_fac)\nfor v in prime_fac.values():\n r *= comb(v+n-1, v)\nmod = 1000000000 + 7\nprint(r % mod)\n', 'def prime_factorize(num):\n """\n This function performs prime factorization on the input natural number.\n The result is returned in the form of a dictionary with the prime number as the key\n and its number as the value.\n :param num:\n :return prime_factor: Dictionary with the prime number as the key and its number as the value.\n """\n prime_factor = {}\n i = 2\n while i ** 2 <= num:\n while num % i == 0:\n num //= i\n if i in prime_factor.keys():\n prime_factor[i] += 1\n else:\n prime_factor[i] = 1\n i += 1\n if num > 1:\n prime_factor[num] = 1\n return prime_factor\n\n\nfrom math import factorial\n\n\ndef comb(n, r):\n return factorial(n) // (factorial(n-r) * factorial(r))\n\n\nn, m = map(int, input().split())\nr = 1\nprime_fac = prime_factorize(m)\nprint(prime_fac)\nfor v in prime_fac.values():\n r *= comb(v+n-1, v)\nmod = 1000000000 + 7\nprint(r % mod)\n', 'def prime_factorize(num):\n """\n This function performs prime factorization on the input natural number.\n The result is returned in the form of a dictionary with the prime number as the key\n and its number as the value.\n :param num:\n :return prime_factor: Dictionary with the prime number as the key and its number as the value.\n """\n prime_factor = {}\n i = 2\n while i ** 2 <= num:\n while num % i == 0:\n num //= i\n if i in prime_factor.keys():\n prime_factor[i] += 1\n else:\n prime_factor[i] = 1\n i += 1\n if num > 1:\n prime_factor[num] = 1\n return prime_factor\n\n\n\ndef combination(n, r):\n r = min(n-r, r)\n result = 1\n for i in range(n, n-r, -1):\n result *= i\n for i in range(1, r+1):\n result //= i\n return result\n\n\nn, m = map(int, input().split())\nr = 1\n\nprime_fac = prime_factorize(m)\nfor v in prime_fac.values():\n r *= combination(v + n - 1, v)\nmod = 1000000000 + 7\nprint(r % mod)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s142843187', 's877034273', 's952701444'] | [4400.0, 4404.0, 3064.0] | [2104.0, 2104.0, 20.0] | [962, 962, 1031] |
p03253 | u442581202 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\ndef comb(x,y):\n f = 1\n for i in range(y):\n f *= (x-i)\n f //= (i+1)\n\n return f\n\nn,m = map(int,input().split())\n\ncnt = [0]\nfor i in range(2,int(math.sqrt(m))+1):\n while m!=i:\n if m%i==0:\n m //=i\n cnt[-1]+=1\n else:\n cnt.append(0)\n break\n if m==i:\n cnt[-1]+=1\n break\ncnt = [item for item in cnt if cnt != 0]\n\n\nres = 1\nr = 10**9 +7\nfor item in cnt:\n res = (res* comb(item+n-1,item))%r\n\nprint(res%r)\n', 'import math\ndef comb(x,y):\n f = 1\n for i in range(y):\n f *= (x-i)\n f //= (i+1)\n\n return f\n\nn,m = map(int,input().split())\n\ni = 2\ncnt = []\nwhile i*i<=m:\n c = 0\n while m%i == 0:\n m //= i\n c += 1\n if c>0:\n cnt.append(c)\n i+=1\nif m>1:\n cnt.append(1)\n \n\nres = 1\nr = 10**9 +7\nfor item in cnt:\n res = (res* comb(item+n-1,item))%r\n\nprint(res%r)\n'] | ['Wrong Answer', 'Accepted'] | ['s576451570', 's869943309'] | [3628.0, 3064.0] | [39.0, 19.0] | [510, 406] |
p03253 | u466331465 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from operator import mul\nfrom functools import reduce\n\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\nimport itertools\nN,M = [int(x) for x in input().split()]\ne = [0]*(int(M**0.5)+1)\nfor j in range(2,int(M**0.5)+1):\n while M%j==0:\n e[j] += 1\n M = M//j\nans = 1\nfor i in e:\n ans *=cmb(i+N-1,i)\n ans %=10**9+7\nprint(ans)', 'from operator import mul\nfrom functools import reduce\nimport math\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\nimport itertools\nN,M = [int(x) for x in input().split()]\ne = [0]*(int(math.sqrt(M)) + 1)\nfor j in range(2,int(math.sqrt(M)) + 1):\n while M%j==0:\n e[j] += 1\n M = M//j\nans = 1\nfor i in e:\n ans *=cmb(i+N-1,i)\n ans %=10**9+7\nprint(ans)', 'from operator import mul\nfrom functools import reduce\nimport math\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\nimport itertools\nN,M = [int(x) for x in input().split()]\ne = {}\nfor j in range(2,int(math.sqrt(M)) +2):\n cnt=0\n while M%j==0:\n cnt+= 1\n M = M//j\n if cnt!=0:\n e[j]=cnt\nif M!=1:\n e[M]=1\n\n\nans = 1\nfor i in e.values():\n ans *=cmb(i+N-1,i)\n ans %=10**9+7\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s543959750', 's613260894', 's699271956'] | [3944.0, 3816.0, 3700.0] | [43.0, 44.0, 29.0] | [445, 472, 508] |
p03253 | u476435125 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\n\n\n\n# yield i\n#n以下の素数のリスト\n\n\n\n\n# l[(i+2)*j-2]=0\n\n\ndef prime_l(n):\n l=[1 for i in range(2,n+1)]\n #sq_n=n**(1/2)\n for i in range(n-1):\n if l[i]==1:\n for j in range(2*(i+2),n+1,i+2):\n l[j-2]=0\n l1=[]\n for i in range(n-1):\n if l[i]==1:\n l1.append(i+2)\n return l1\n\n\ndef modpow(a,n,p):#a^n mod p\n res=1\n while n>0:\n if n&1:\n res=res*a%p\n a=a*a%p\n n>>=1\n \n return res\n\nif m==1:\n print(1)\nelse:\n \n \n l=prime_l(int(m**(1/2)))\n #ll=next(l)\n i=0\n d={}\n while m!=1 and i!=len(l)-1:\n if m%(l[i])==0:\n d[l[i]]=1\n m/=l[i]\n while m%(l[i])==0:\n d[l[i]]+=1\n m/=l[i]\n #ll=next(l)\n i+=1\n #while l[i]==0:\n # i+=1\n if m!=1:\n d[m]=1\n #s_k=0\n \n # s_k+=i\n #print(d.values())\n mod=int(1e9+7)\n n_fac=1\n fac_l=[1]#0!\n d_max=max(d.values())\n \n # n_fac*=i+1\n for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!\n n_fac*=i+1\n n_fac=n_fac%mod\n fac_l.append(n_fac)\n\n fac_1_l=[]\n for i in range(n+d_max-1):\n fac_1_l.append(modpow(fac_l[i],mod-2,mod))\n w=1\n for dv in d.values():\n w*=fac_l[n+dv-1]\n w=w%mod\n #n_n_fac=fac_l[n-dv]\n #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n \n # w+=1e9+7\n #w=int(w/div)\n w=w*fac_1_l[n-1]%mod\n w=w*fac_1_l[dv]%mod\n print(w)\n', 'n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\n\n\n\n# yield i\n#n以下の素数のリスト\n\n\n\n\n# l[(i+2)*j-2]=0\n\n\ndef prime_l(n):\n l=[1 for i in range(2,n+1)]\n #sq_n=n**(1/2)\n for i in range(n-1):\n if l[i]==1:\n for j in range(2*(i+2),n+1,i+2):\n l[j-2]=0\n l1=[]\n for i in range(n-1):\n if l[i]==1:\n l1.append(i+2)\n return l1\n\n\ndef modpow(a,n,p):#a^n mod p\n res=1\n while n>0:\n if n&1:\n res=res*a%p\n a=a*a%p\n n>>=1\n \n return res\n\nif m==1:\n print(1)\nelse:\n \n l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)\n #ll=next(l)\n i=0\n d={}\n while m!=1:\n if m%(l[i])==0:\n d[l[i]]=1\n m/=l[i]\n while m%(l[i])==0:\n d[l[i]]+=1\n m/=l[i]\n #ll=next(l)\n i+=1\n #while l[i]==0:\n # i+=1\n #s_k=0\n \n # s_k+=i\n #print(d.values())\n mod=int(1e9+7)\n n_fac=1\n fac_l=[1]#0!\n d_max=max(d.values())\n \n # n_fac*=i+1\n for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!\n n_fac*=i+1\n n_fac=n_fac%mod\n fac_l.append(n_fac)\n\n fac_1_l=[]\n for i in range(n+d_max-1):\n fac_1_l.append(modpow(fac_l[i],mod-2,mod))\n w=1\n for dv in d.values():\n w*=fac_l[n+dv-1]\n w=w%mod\n #n_n_fac=fac_l[n-dv]\n #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n \n # w+=1e9+7\n #w=int(w/div)\n w=w*fac_1_l[n-1]%mod\n w=w*fac_1_l[dv]%mod\n print(w)\n', 'n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\n\n\n\n# yield i\n#n以下の素数のリスト\n\n\n\n\n# l[(i+2)*j-2]=0\n\n\ndef prime_l(n):\n l=[1 for i in range(2,n+1)]\n #sq_n=n**(1/2)\n for i in range(n-1):\n if l[i]==1:\n for j in range(2*(i+2),n+1,i+2):\n l[j-2]=0\n l1=[]\n for i in range(n-1):\n if l[i]==1:\n l1.append(i+2)\n return l1\n\n\ndef modpow(a,n,p):#a^n mod p\n res=1\n while n>0:\n if n&1:\n res=res*a%p\n a=a*a%p\n n>>=1\n \n return res\n\nif m==1:\n print(1)\nelse:\n \n \n l=prime_l(int(m**(1/2)))\n #ll=next(l)\n i=0\n d={}\n while m!=1 and i!=len(l)-1:\n if m%(l[i])==0:\n d[l[i]]=1\n m/=l[i]\n while m%(l[i])==0:\n d[l[i]]+=1\n m/=l[i]\n #ll=next(l)\n i+=1\n #while l[i]==0:\n # i+=1\n if m!=1:\n d[m]=1\n #s_k=0\n \n # s_k+=i\n #print(d.values())\n mod=int(1e9+7)\n n_fac=1\n fac_l=[1]#0!\n d_max=max(d.values())\n \n # n_fac*=i+1\n for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!\n n_fac*=i+1\n n_fac=n_fac%mod\n fac_l.append(n_fac)\n\n fac_1_l=[]\n for i in range(n+d_max):\n fac_1_l.append(modpow(fac_l[i],mod-2,mod))\n w=1\n for dv in d.values():\n w*=fac_l[n+dv-1]\n w=w%mod\n #n_n_fac=fac_l[n-dv]\n #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n \n # w+=1e9+7\n #w=int(w/div)\n w=w*fac_1_l[n-1]%mod\n w=w*fac_1_l[dv]%mod\n print(w)\n', 'n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\n\n\n\n# yield i\n#n以下の素数のリスト\n\n\n\n\n# l[(i+2)*j-2]=0\n\n\ndef prime_l(n):\n l=[1 for i in range(2,n+1)]\n #sq_n=n**(1/2)\n for i in range(n-1):\n if l[i]==1:\n for j in range(2*(i+2),n+1,i+2):\n l[j-2]=0\n l1=[]\n for i in range(n-1):\n if l[i]==1:\n l1.append(i+2)\n return l1\n\n\ndef modpow(a,n,p):#a^n mod p\n res=1\n while n>0:\n if n&1:\n res=res*a%p\n a=a*a%p\n n>>=1\n \n return res\n\nif m==1:\n print(1)\nelse:\n \n l=prime_l(int(m**(1/2)))\n #ll=next(l)\n i=0\n d={}\n while m!=1:\n if m%(l[i])==0:\n d[l[i]]=1\n m/=l[i]\n while m%(l[i])==0:\n d[l[i]]+=1\n m/=l[i]\n #ll=next(l)\n i+=1\n #while l[i]==0:\n # i+=1\n #s_k=0\n \n # s_k+=i\n #print(d.values())\n mod=int(1e9+7)\n n_fac=1\n fac_l=[1]#0!\n d_max=max(d.values())\n \n # n_fac*=i+1\n for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!\n n_fac*=i+1\n n_fac=n_fac%mod\n fac_l.append(n_fac)\n\n fac_1_l=[]\n for i in range(n+d_max-1):\n fac_1_l.append(modpow(fac_l[i],mod-2,mod))\n w=1\n for dv in d.values():\n w*=fac_l[n+dv-1]\n w=w%mod\n #n_n_fac=fac_l[n-dv]\n #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n \n # w+=1e9+7\n #w=int(w/div)\n w=w*fac_1_l[n-1]%mod\n w=w*fac_1_l[dv]%mod\n print(w)\n', 'n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\ndef prime_l(n):\n for i in range(2,n+1):\n if prime(i)==1:\n yield i\n\nl=prime_l(int(1e9))\nll=next(l)\nd={}\nwhile m!=1:\n if m%ll==0:\n d[ll]=1\n m/=ll\n while m%ll==0:\n d[ll]+=1\n m/=ll\n ll=next(l)\n#s_k=0\n\n# s_k+=i\nfor dk in d.keys():\n #print(dk)\n #print(d[dk])\n pass\nn_fac=1\nfac_l=[]\nd_max=max(d.values())\nfor i in range(n+d_max):# 1!,2!,,,,\n n_fac*=i+1\n n_fac=int(n_fac%(1e9+7))\n fac_l.append(n_fac)\n\n print(fac_l[i])\nw=1\nfor dv in d.values():\n w*=fac_l[n+dv-1-1]\n w=int(w%(1e9+7))\n #n_n_fac=fac_l[n-dv]\n div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n if div>w:\n w+=1e9+7\n w=int(w/div)\nprint(w)\n', 'n,m=map(int,input().split())\n\ndef prime(n):\n for i in range(2,n):\n if n%i==0:\n return 0\n return 1\n\n\n\n\n# yield i\n#n以下の素数のリスト\n\n\n\n\n# l[(i+2)*j-2]=0\n\n\ndef prime_l(n):\n l=[1 for i in range(2,n+1)]\n #sq_n=n**(1/2)\n for i in range(n-1):\n if l[i]==1:\n for j in range(2*(i+2),n+1,i+2):\n l[j-2]=0\n l1=[]\n for i in range(n-1):\n if l[i]==1:\n l1.append(i+2)\n return l1\n\n\ndef modpow(a,n,p):#a^n mod p\n res=1\n while n>0:\n if n&1:\n res=res*a%p\n a=a*a%p\n n>>=1\n \n return res\n\nif m==1:\n print(1)\nelse:\n \n \n l=prime_l(int(m**(1/2)))\n #ll=next(l)\n i=0\n d={}\n while m!=1 and i!=len(l):\n if m%(l[i])==0:\n d[l[i]]=1\n m/=l[i]\n while m%(l[i])==0:\n d[l[i]]+=1\n m/=l[i]\n #ll=next(l)\n i+=1\n #while l[i]==0:\n # i+=1\n if m!=1:\n d[m]=1\n #s_k=0\n \n # s_k+=i\n #print(d.values())\n mod=int(1e9+7)\n n_fac=1\n fac_l=[1]#0!\n d_max=max(d.values())\n \n # n_fac*=i+1\n for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!\n n_fac*=i+1\n n_fac=n_fac%mod\n fac_l.append(n_fac)\n\n fac_1_l=[]\n for i in range(n+d_max):\n fac_1_l.append(modpow(fac_l[i],mod-2,mod))\n w=1\n for dv in d.values():\n w*=fac_l[n+dv-1]\n w=w%mod\n #n_n_fac=fac_l[n-dv]\n #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))\n #print(div)\n \n # w+=1e9+7\n #w=int(w/div)\n w=w*fac_1_l[n-1]%mod\n w=w*fac_1_l[dv]%mod\n print(w)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s087850213', 's105517462', 's144901746', 's185333709', 's825445422', 's472257806'] | [11484.0, 11388.0, 11388.0, 11388.0, 8140.0, 11388.0] | [931.0, 956.0, 949.0, 946.0, 2104.0, 954.0] | [2506, 2361, 2504, 2337, 985, 2502] |
p03253 | u492026192 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m=map(int,input().split())\nMOD=10**9+7\ndef factorization(n):\n arr = []\n temp = n\n if n==1:\n return arr\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\n if temp!=1:\n arr.append((temp, 1))\n\n if arr==[]:\n arr.append((n, 1))\n\n return arr\narr=factorization(m)\nprint(arr)\nl=len(arr)\nN=30\ncomb=[1]*31\ninv_t = [0]+[1]\nfor i in range(2,N+1):\n inv_t += [inv_t[MOD % i] * (MOD - int(MOD / i)) % MOD]\nfor i in range(1,31):\n comb[i]=comb[i-1]*(n-1+i)*inv_t[i]\n comb[i]%=MOD\ncount=1\nfor fact,num in arr:\n #print(fact,num,comb[num])\n count*=comb[num]\n count%=MOD\nprint(count)', 'n,m=map(int,input().split())\nMOD=10**9+7\ndef factorization(n):\n arr = []\n temp = n\n if n==1:\n return arr\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\n if temp!=1:\n arr.append((temp, 1))\n\n if arr==[]:\n arr.append((n, 1))\n\n return arr\narr=factorization(m)\n#print(arr)\nl=len(arr)\nN=30\ncomb=[1]*31\ninv_t = [0]+[1]\nfor i in range(2,N+1):\n inv_t += [inv_t[MOD % i] * (MOD - int(MOD / i)) % MOD]\nfor i in range(1,31):\n comb[i]=comb[i-1]*(n-1+i)*inv_t[i]\n comb[i]%=MOD\ncount=1\nfor fact,num in arr:\n #print(fact,num,comb[num])\n count*=comb[num]\n count%=MOD\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s080021139', 's546302217'] | [3064.0, 3064.0] | [20.0, 20.0] | [767, 768] |
p03253 | u532966492 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['N,M=map(int,input().split())\n\nfrom collections import Counter\n \ndef soinsuu(n):\n list_=[]\n while(n!=1):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n list_.append(i)\n n=n//i\n break\n else:\n list_.append(n)\n n=1\n return sorted(list_)\n \ndef product(a):\n pro=1\n for b in a:\n pro=pro*b%mod\n return pro\n \n\ndef n_func(n,mod=10**9+7):\n ans=1\n for i in range(1,n+1):\n ans=(ans*i)%mod\n return ans\ndef inv_n(n,mod=10**9+7):\n return pow(n,mod-2,mod)\ndef nPr(n,r,mod=10**9+7):\n ans=n_func(n-r,mod)\n ans=inv_n(ans,mod)\n return ans*n_func(n,mod)%mod\ndef nCr(n,r,mod=10**9+7):\n ans=n_func(n-r,mod)*n_func(r,mod)%mod\n ans=inv_n(ans,mod)\n return ans*n_func(n,mod)%mod\n \np=list(Counter(soinsuu(M)).values())\nprint(product([nCr(N+p[i]-1,p[i]) for i in range(len(p))]))', "def soinsuu(a):\n yy,j=[],2\n y=yy.append\n while(a>1):\n for i in range(j,int(a**0.5)+1):\n if a%i==0:\n y(i)\n a,j=a//i,i\n break\n else:\n y(a)\n break\n yy.sort()\n return yy\n\ndef n_func(n,mod=10**9+7):\n ans=1\n for i in range(1,n+1):ans=(ans*i)%mod\n return ans\ndef inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)\ndef nCr(n,r,mod=10**9+7):return inv_n(n_func(n-r,mod)*n_func(r,mod)%mod,mod)*n_func(n,mod)%mod\n\n\ndef main():\n mod=10**9+7\n from collections import Counter\n n,m=map(int,input().split())\n s=Counter(soinsuu(m))\n ans=1\n for i in s.values():\n ans=(ans*nCr(n+i-1,i))%mod\n print(ans)\n \nif __name__ == '__main__':\n\tmain()"] | ['Runtime Error', 'Accepted'] | ['s108481716', 's493017374'] | [3316.0, 3316.0] | [230.0, 229.0] | [932, 761] |
p03253 | u537905693 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ["#!/usr/bin/env python\n# coding: utf-8\n\nimport math\nfrom operator import mul\nfrom functools import reduce\n\n\ninf = 10**9+7\n\n\n# nCr\ndef combination(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\n\nclass PrimeUtil:\n def __init__(self, n):\n self.l_is_prime = [True for _ in range(n+1)]\n self.l_is_prime[0] = False\n self.l_is_prime[1] = False\n self.n = n\n self.primes = []\n for k in range(2, n+1):\n if self.l_is_prime[k]:\n self.primes.append(k)\n self._set_false(k)\n\n \n def _set_false(self, p):\n k = p\n for _ in range(1, self.n//p):\n k += p\n self.l_is_prime[k] = False\n\n \n def factor(self, k):\n ret = {}\n tmp = k\n for p in self.primes:\n if p > tmp:\n break\n while True:\n if tmp % p != 0:\n break\n ret.setdefault(p, 0)\n ret[p] += 1\n tmp /= p\n if tmp == 1:\n break\n if tmp > 0:\n ret[tmp] = 1\n return ret\n\n\ndef main():\n N, M = list(map(int, input().split()))\n pu = PrimeUtil(100000)\n ans = 1\n f = pu.factor(M)\n for v in f.values():\n ans *= combination(v+N-1, v)\n ans %= inf\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python\n# coding: utf-8\n\nimport math\nfrom operator import mul\nfrom functools import reduce\n\n\ninf = 10**9+7\n\n\n# nCr\ndef combination(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\n\nclass PrimeUtil:\n def __init__(self, n):\n self.l_is_prime = [True for _ in range(n+1)]\n self.l_is_prime[0] = False\n self.l_is_prime[1] = False\n self.n = n\n self.primes = []\n for k in range(2, n+1):\n if self.l_is_prime[k]:\n self.primes.append(k)\n self._set_false(k)\n\n \n def _set_false(self, p):\n k = p\n for _ in range(1, self.n//p):\n k += p\n self.l_is_prime[k] = False\n\n \n def factor(self, k):\n ret = {}\n tmp = k\n for p in self.primes:\n if p > tmp:\n break\n while True:\n if tmp % p != 0:\n break\n ret.setdefault(p, 0)\n ret[p] += 1\n tmp /= p\n if tmp == 1:\n break\n if tmp > 1:\n ret[tmp] = 1\n return ret\n\n\ndef main():\n N, M = list(map(int, input().split()))\n pu = PrimeUtil(100000)\n ans = 1\n f = pu.factor(M)\n for v in f.values():\n ans *= combination(v+N-1, v)\n ans %= inf\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s678026781', 's647250690'] | [4724.0, 4724.0] | [65.0, 65.0] | [1618, 1618] |
p03253 | u545368057 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from collections import deque\n\nN, M = map(int,input().split())\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n return sorted(divisors,reverse=True)\n\n\ndef count(nlist):\n nset = list(set(nlist))\n denom = 1\n for n in nset:\n cnt = nlist.count(n)\n prod = 1\n for i in range(1,cnt+1):\n prod *= i\n denom *= prod\n anom = 1\n for i in range(1,len(nlist)+1):\n anom *= i\n return(anom//denom)\n\n\n\n\ndivs = make_divisors(M)\ndivdict = {str(div):i for i, div in enumerate(divs)} \ndivlist = [] \nstack = deque([])\nリスト0のところを追加しておこう\nfor div in divs:\n stack.append([div,M//div])\n\nans = 0\nif N == 2:\n for div in divs:\n if div < M//div:\n ans += 2\n elif div == M//div:\n ans += 1\nelse:\n \n while len(stack) > 0:\n nlist = stack.pop()\n div = nlist[-2]\n divided = nlist[-1]\n \n ind = divdict[str(div)]\n for div in divs[ind:]:\n if len(nlist) < N and divided%div == 0:\n new = nlist[:-1]+[div, divided//div]\n stack.append(new)\n \n if len(new) == N:\n prod = nlist[0]\n for i in range(1,N):\n prod *= new[i]\n if new[-1] <= new[-2] and prod==M: \n ans += count(new)\n\n\nprint(ans%(10**9+7))\n', '"""\n8:30:00\n"""\n\nfrom collections import defaultdict\ndef getprime(n):\n if not isinstance(n, int):\n raise TypeError("Input int")\n if n < 2:\n raise ValueError("N >= 2")\n prime = []\n \n data = [i+1 for i in range(1,n)]\n while True:\n p = data[0]\n if p >= int(n**0.5):\n return prime+data\n prime.append(p)\n \n data = [d for d in data if d%p != 0]\n\ndef factorization(n):\n factors = defaultdict(int)\n primes = getprime(int(n**0.5))\n for prime in primes:\n while n % prime == 0:\n factors[prime] += 1\n n //= prime\n # print(factors,n)\n if n != 1:\n factors[n] += 1\n return factors\n\n\ndef modconb(n,k,mod):\n \n fac = [0]*(n+1)\n finv = [0]*(n+1)\n inv = [0]*(n+1) \n\n fac[0] = fac[1] = 1\n finv[0] = finv[1] = 1\n inv[1] = 1\n\n for i in range(2,n+1):\n fac[i] = fac[i-1]*i % mod\n inv[i] = mod - inv[mod%i] * (mod//i) % mod\n finv[i] = finv[i-1] * inv[i] % mod\n\n if n<k: return 0\n if n<0 or k<0: return 0\n return(fac[n]*(finv[k]*finv[n-k]%mod)%mod)\n\n\n\nmod = 10**9 + 7\nn, m = map(int, input().split())\nif m == 1:\n print(1)\n exit()\nfactors = factorization(m)\nans = 1\nfor k in factors.keys():\n x = factors[k]\n ans *= modconb(x+n-1,x,mod)\n ans %= mod\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s905543090', 's551593325'] | [4296.0, 16808.0] | [2108.0, 725.0] | [1832, 1667] |
p03253 | u547167033 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,p):\n from math import factorial\n if n<0 or k<0 or n<k:return 0\n if n==0 and k==0:return 1\n a=factorial(n)%p\n b=factorial(k)%p\n c=factorial(n-k)%p\n return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p\ndef power_func(a,b,p):\n if b==0:\n return 1\n if b%2==0:\n d=power_func(a,b//2,p)\n return (d*d)%p\n else:\n return (a*power_func(a,b-1,p))%p\ndef factorization(x):\n ans=[]\n for i in range(2,int(x**0.5)+2):\n if x%i==0:\n cnt=0\n while x%i==0:\n x//=i\n cnt+=1\n ans.append([i,cnt])\n return ans\ng=factorization(m)\nans=1\nprint(g)\nfor i in g:\n ans*=comb(i[1]+n-1,i[1],mod)\n ans%=mod\nprint(ans)', 'from math import sqrt,floor\ndef comb(n,m):\n if m == 0:\n return 1\n return comb(n-1,m-1)*n // m\nn,m=map(int,input().split())\nmod=10**9+7\ndef factorization(x):\n ans=[]\n for i in range(2,floor(sqrt(x))+1):\n if x%i==0:\n cnt=0\n while x%i==0:\n x//=i\n cnt+=1\n ans.append([i,cnt])\n if x==1:\n break\n if x!=1:\n ans.append([x,1])\n return ans\ng=factorization(m)\nans=1\nfor i in g:\n ans=(ans*(comb(i[1]+n-1,i[1])%mod))%mod\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s979508591', 's121455338'] | [4244.0, 3064.0] | [2104.0, 20.0] | [691, 475] |
p03253 | u562935282 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['def comb(a, b):\n if b > a - b:\n return comb(a, a - b)\n # res = 1\n mul = 1\n div = 1\n for i in range(b):\n # res *= (a - i)\n # res /= (i + 1)\n mul *= (a - i)\n div *= (i + 1)\n res = mul / div\n return res\n\n\nn, m = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\nans = 1\ni = 2\nleft = m + 0\nwhile True:\n if (i * i > m) and (left == 1):\n break\n power = 0\n while left % i == 0:\n left /= i\n power += 1\n if power > 0:\n ans *= comb(n - 1 + power, power)\n i += 1\n\nans %= MOD\n\nprint(ans)', 'def comb(a, b):\n if b > a - b:\n return comb(a, a - b)\n # res = 1\n mul = 1\n div = 1\n for i in range(b):\n # res *= (a - i)\n # res /= (i + 1)\n mul *= (a - i)\n mul %= MOD\n\n div *= (i + 1)\n div %= MOD\n res = mul / div\n return res\n\n\nn, m = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\nans = 1\ni = 2\nleft = m + 0\nwhile True:\n if (i * i > m) and (left == 1):\n break\n power = 0\n while left % i == 0:\n left /= i\n power += 1\n if power > 0:\n ans *= comb(n - 1 + power, power)\n i += 1\n\nans %= MOD\n\nprint(ans)', "def gen(n):\n x = n\n d = 2\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n\n d = 3\n while d * d <= n:\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n d += 2\n\n if x > 1:\n yield 1\n\n\ndef main():\n MOD = 10 ** 9 + 7\n\n N, M = map(int, input().split())\n\n ans = 1\n for cnt in gen(M):\n for d in range(cnt):\n ans = (ans * (N - 1 + cnt - d) % MOD) * pow(d + 1, MOD - 2, MOD) % MOD\n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s158328867', 's940570075', 's569938093'] | [3064.0, 3064.0, 3064.0] | [2103.0, 2104.0, 23.0] | [570, 609, 583] |
p03253 | u577170763 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ["class Solution:\n\n def solve(self, N: int, M: int) -> int:\n\n mod = 10**9+7\n INT_MAX = 10**7\n\n # calculate {m+n}C{n}\n\n def egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n\n def modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n def combination(n: int, r: int, mod: int = 10**9+7) -> int:\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n-i) * modinv(i+1, mod) % mod\n return res\n\n \n\n isPrime = [True] * (INT_MAX + 1)\n isPrime[0], isPrime[1] = False, False\n primes = []\n\n for i in range(2, len(isPrime)):\n if isPrime[i] == True:\n primes.append(i)\n for j in range(2 * i, len(isPrime), i):\n isPrime[j] = False\n\n # solve\n\n m = M\n answer = 1\n factors = {}\n while m > 1:\n for p in primes:\n factors[p] = 0\n\n while m % p == 0:\n m //= p\n factors[p] += 1\n\n if factors[p] > 0:\n answer *= combination(N + factors[p] - 1, N - 1, mod=mod)\n answer %= mod\n\n return answer\n\n\nif __name__ == '__main__':\n\n # standard input\n N, M = map(int, input().split())\n\n # solve\n solution = Solution()\n print(solution.solve(N, M))\n", "class Solution:\n\n def solve(self, N: int, M: int) -> int:\n\n mod = 10**9+7\n INT_MAX = 10**9\n\n # calculate {m+n}C{n}\n\n def egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n\n def modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n def combination(n: int, r: int, mod: int = 10**9+7) -> int:\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n-i) * modinv(i+1, mod) % mod\n return res\n\n \n\n isPrime = [True] * (INT_MAX + 1)\n isPrime[0], isPrime[1] = False, False\n primes = []\n\n for i in range(2, len(isPrime)):\n if isPrime[i] == True:\n primes.append(i)\n for j in range(2 * i, len(isPrime), i):\n isPrime[j] = False\n\n # solve\n\n m = M\n answer = 1\n factors = {}\n while m > 1:\n for p in primes:\n factors[p] = 0\n\n while m % p == 0:\n m //= p\n factors[p] += 1\n\n if factors[p] > 0:\n answer *= combination(N + factors[p] - 1, N - 1, mod=mod)\n answer %= mod\n\n return answer\n\n\nif __name__ == '__main__':\n\n # standard input\n N, M = map(int, input().split())\n\n # solve\n solution = Solution()\n print(solution.solve(N, M))\n", "import math\n\n\nclass Solution:\n\n def solve(self, N: int, M: int) -> int:\n\n mod = 10**9+7\n INT_MAX = 10**9\n\n # calculate {m+n}C{n}\n\n def egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n\n def modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n def combination(n: int, r: int, mod: int = 10**9+7) -> int:\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n-i) * modinv(i+1, mod) % mod\n return res\n\n # solve\n\n m = M\n answer = 1\n factors = {}\n for i in range(2, int(math.sqrt(M))+1):\n factor = 0\n while m % i == 0:\n m //= i\n factor += 1\n\n if factor > 0:\n answer *= combination(N + factor - 1, N - 1, mod=mod)\n answer %= mod\n\n if m > 1:\n answer *= N\n answer %= mod\n\n return answer\n\n\nif __name__ == '__main__':\n\n # standard input\n N, M = map(int, input().split())\n\n # solve\n solution = Solution()\n print(solution.solve(N, M))\n"] | ['Time Limit Exceeded', 'Runtime Error', 'Accepted'] | ['s422907752', 's815937021', 's083616200'] | [81268.0, 3188.0, 3064.0] | [2104.0, 18.0, 21.0] | [1666, 1666, 1367] |
p03253 | u593005350 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['#How many ways M=a1*a2*...*aN ex)N=2,M=6 a={1,6},{2,3},{3,2},{6,1}\nimport math\nn,m=map(int,input().split())\nfactor=[]\nc=0\nmod=10**9+7\n\n\nwhile m%2 == 0:\n m//=2\n c+=1\nif c != 0:\n factor.append([2,c])\n#Alternate\nfor i in range(3,int(math.sqrt(m+1)),2):\n c=0\n while m%i == 0:\n m//=i\n c+=1\n if c != 0:\n #print(i,c)\n factor.append([i,c])\n if m == 1:\n break\n if i*i>=m: # m is prime\n factor.append([m,1])\n break\n \n#print(factor)\n\ndef C(n,k):\n ans=1\n for s in range(1,k+1):\n ans*=n\n ans//=s\n n-=1\n return ans\n\ndef funcount(length,rest):\n a=0\n if length==1:\n #print(rest)\n return 1\n elif rest <= 1:\n #print("not",rest)\n return 0\n else:\n for i in range(1,rest):\n #print(i,end=" ")\n a+=funcount(length-1,rest-i)\n return a\n\n\nway=1\nfor f in factor:\n sum=0\n for k in range(1,f[1]+1):\n sum+=funcount(k,f[1])*C(n,k)\n way=(way*sum)%mod\n \nprint(way%mod)', '#How many ways M=a1*a2*...*aN ex)N=2,M=6 a={1,6},{2,3},{3,2},{6,1}\nimport math\nn,m=map(int,input().split())\nfactor=[]\nc=0\nmod=10**9+7\n\n\nwhile m%2 == 0:\n m//=2\n c+=1\n \'\'\'\n if c>=20:\n c=0\n break\n \'\'\'\nif c != 0:\n factor.append([2,c])\n#Alternate\nfor i in range(3,m+1,2):\n c=0\n while m%i == 0:\n m//=i\n c+=1\n if c != 0:\n #print(i,c)\n factor.append([i,c])\n if m == 1:\n break\n if i*i>=m: # m is prime\n factor.append([m,1])\n break\n \n#print(factor)\n\ndef C(n,k):\n ans=1\n for s in range(1,k+1):\n ans*=n\n ans//=s\n n-=1\n return ans\n\ndef funcount(length,rest,memo):\n a=0\n if length==1:\n #print(length,rest)\n memo[length][rest]=1\n return 1,memo\n elif rest <= 1:\n #print(length,rest)\n memo[length][rest]=0\n return 0,memo\n if memo[length][rest] != -1:\n return memo[length][rest],memo\n else:\n for i in range(1,rest):\n #print(i,end=" ")\n a+=funcount(length-1,rest-i,memo)[0]\n memo=funcount(length-1,rest-i,memo)[1]\n #print(memo)\n memo[length][rest]=a\n return a,memo\n \n\nway=1\nfor f in factor:\n sum=0\n for k in range(1,f[1]+1):\n memo=[[-1 for r in range(f[1]+1)] for l in range(k+1)] \n #print(memo)\n sum+=funcount(k,f[1],memo)[0]*C(n,k)\n way=(way*sum)%mod\n \nprint(way%mod)'] | ['Wrong Answer', 'Accepted'] | ['s349494587', 's001489121'] | [3064.0, 3188.0] | [2103.0, 72.0] | [1076, 1488] |
p03253 | u606045429 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['N, M = [int(i) for i in input().split()]\n\ndef prime_decomposition(n):\n table = []\n i = 2\n while i * i <= n:\n count = 0\n while n % i == 0:\n n //= i\n count += 1\n if count != 0:\n table.append((i, count))\n i += 1\n if n > 1:\n table.append((n, 1))\n return table\n\ndef cmb(n,r):\n from operator import mul\n from functools import reduce\n r = min(n - r, r)\n if r == 0:\n return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\nmod = 10 ** 9 + 7\nA = prime_decomposition(M)\nprint(A)\nresult = 1\nfor _, a in A:\n result = result * cmb(a + N - 1, a) % mod\n\nprint(result)', 'N, M = [int(i) for i in input().split()]\n\ndef prime_decomposition(n):\n table = []\n i = 2\n while i * i <= n:\n count = 0\n while n % i == 0:\n n //= i\n count += 1\n if count != 0:\n table.append((i, count))\n i += 1\n if n > 1:\n table.append((n, 1))\n return table\n\ndef cmb(n,r):\n from operator import mul\n from functools import reduce\n r = min(n - r, r)\n if r == 0:\n return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\nmod = 10 ** 9 + 7\nA = prime_decomposition(M)\nresult = 1\nfor _, a in A:\n result = result * cmb(a + N - 1, a) % mod\n\nprint(result)'] | ['Wrong Answer', 'Accepted'] | ['s705007616', 's421448646'] | [3572.0, 3572.0] | [24.0, 24.0] | [674, 665] |
p03253 | u622523700 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\nimport collections\nn, m = map(int, input().split())\n\nfactor = []\ntmp = int(m ** (1/2)) + 1\nfor i in range(2, tmp):\n while m % i == 0:\n m //= i\n factor.append(i)\nif m > 1:\n factor.append(m)\nnum = list(collections.Counter(factor).most_common())\n\nans = 1\nfor i in range(len(num)):\n ans *= (math.factorial(num[i] + n - 1) // (math.factorial(n - 1) * math.factorial(num[i])) % 1000000007)\n ans %= 1000000007\nprint(ans)', 'import collections\nn, m = map(int, input().split())\n\nfactor = []\ntmp = int(m ** (1/2)) + 1\nfor i in range(2, tmp):\n while m % i == 0:\n m //= i\n factor.append(i)\nif m > 1:\n factor.append(m)\nnum = list(collections.Counter(factor).most_common())\n\ndef comb(n, r):\n tmp = 1\n for i in range(r):\n tmp *= n - i\n for i in range(r):\n tmp //= r - i\n return tmp\n\nans = 1\nfor x in num:\n ans *= (comb(x[1] + n - 1, x[1]) % 1000000007)\n ans %= 1000000007\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s646651139', 's779865445'] | [3440.0, 3444.0] | [26.0, 24.0] | [451, 502] |
p03253 | u623687794 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import sys\nn,m=map(int,input().split())\nMOD = 10**9+7\nans=1\ndef inv_mod(a, p=MOD):\n def inv_mod_sub(a, p):\n if a == 1:\n return 1, 0\n else:\n d, r = p//a, p%a\n x, y = inv_mod_sub(r, a)\n return y-d*x, x\n if p < 0: p = -p\n a %= p\n return inv_mod_sub(a,p)[0] % p\n\ndef comb_mod(n, k):\n if k < 0 or k > n:\n return 0\n else:\n return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD\npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:pf[m]=1\nif n==1\nprint(1)\nsys.exit()\nMax=max(list(pf.values()))\nf_mod=[1]*(Max+n+1)\nf_mod_inverse=[1]*(Max+n+1)\nfor i in range(1,Max+n+1):\n f_mod[i]=(f_mod[i-1]*i)%MOD\n f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD \nfor i in pf.values():\n ans*=comb_mod(i+n-1,n-1)\nprint(ans%MOD)\n', 'import sys\nn,m=map(int,input().split())\nMOD = 10**9+7\nans=1\ndef inv_mod(a, p=MOD):\n def inv_mod_sub(a, p):\n if a == 1:\n return 1, 0\n else:\n d, r = p//a, p%a\n x, y = inv_mod_sub(r, a)\n return y-d*x, x\n if p < 0: p = -p\n a %= p\n return inv_mod_sub(a,p)[0] % p\n\ndef comb_mod(n, k):\n if k < 0 or k > n:\n return 0\n else:\n return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD\npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:pf[m]=1\nif m==1\nprint(1)\nsys.exit()\nMax=max(list(pf.values()))\nf_mod=[1]*(Max+n+1)\nf_mod_inverse=[1]*(Max+n+1)\nfor i in range(1,Max+n+1):\n f_mod[i]=(f_mod[i-1]*i)%MOD\n f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD \nfor i in pf.values():\n ans*=comb_mod(i+n-1,n-1)\nprint(ans%MOD)\n', 'n,m=map(int,input().split())\nMOD = 10**9+7\nans=1\ndef inv_mod(a, p=MOD):\n def inv_mod_sub(a, p):\n if a == 1:\n return 1, 0\n else:\n d, r = p//a, p%a\n x, y = inv_mod_sub(r, a)\n return y-d*x, x\n if p < 0: p = -p\n a %= p\n return inv_mod_sub(a,p)[0] % p\n\ndef comb_mod(n, k):\n if k < 0 or k > n:\n return 0\n else:\n return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD\nf_mod=[1]*(n+1)\nf_mod_inverse=[1]*(n+1)\nfor i in range(1,n+1):\n f_mod[i]=f_mod[i-1]*i%MOD\n f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(n)%MOD \npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:pf[m]=1\nfor i in pf.values():\n ans*=comb_mod(i+n-1,n-1)\nprint(ans)', 'n,m=map(int,input().split())\nMOD = 10**9+7\nans=1\ndef inv_mod(a, p=MOD):\n def inv_mod_sub(a, p):\n if a == 1:\n return 1, 0\n else:\n d, r = p//a, p%a\n x, y = inv_mod_sub(r, a)\n return y-d*x, x\n if p < 0: p = -p\n a %= p\n return inv_mod_sub(a,p)[0] % p\n\ndef comb_mod(n, k):\n if k < 0 or k > n:\n return 0\n else:\n return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD\nf_mod=[1]*(m+1)\nf_mod_inverse=[1]*(m+1)\nfor i in range(1,m+1):\n f_mod[i]=f_mod[i-1]*i%MOD\n f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i) % MOD \npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:pf[m]=1\nfor i in pf.values():\n ans*=comb_mod(i+n-1,n-1)\nprint(ans%MOD,f_mod)\n', 'import sys\nn,m=map(int,input().split())\nMOD = 10**9+7\nans=1\nif m==1:\n print(1)\n sys.exit()\ndef inv_mod(a, p=MOD):\n def inv_mod_sub(a, p):\n if a == 1:\n return 1, 0\n else:\n d, r = p//a, p%a\n x, y = inv_mod_sub(r, a)\n return y-d*x, x\n if p < 0: p = -p\n a %= p\n return inv_mod_sub(a,p)[0] % p\n\ndef comb_mod(n, k):\n if k < 0 or k > n:\n return 0\n else:\n return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD\npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:pf[m]=1\nMax=max(list(pf.values()))\nf_mod=[1]*(Max+n+1)\nf_mod_inverse=[1]*(Max+n+1)\nfor i in range(1,Max+n+1):\n f_mod[i]=(f_mod[i-1]*i)%MOD\n f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD \nfor i in pf.values():\n ans*=comb_mod(i+n-1,n-1)\nprint(ans%MOD)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s317963832', 's744742263', 's792867426', 's996193323', 's251740699'] | [3064.0, 3064.0, 11064.0, 2055412.0, 11076.0] | [18.0, 17.0, 447.0, 2128.0, 471.0] | [862, 862, 773, 786, 867] |
p03253 | u623819879 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m = map(int,input().split())\ndef div(x,y):\n if x%y!=0:\n return 0\n else:\n return 1+div(int(x/y),y)\n\np=[]\n\ndef fact(s):\n if len(p)!=0:\n k=p[-1]\n else:\n k=2\n for i in range(2,max(int(s**0.5) +2,2)):\n a=div(s,i)\n if a==0:\n 0\n else:\n p.append(a)\n s=int(s/i**a)\n \nfact(m)\ndef comb(nn,rr):\n rr=min(rr,nn-rr)\n rt=1\n for i in range(rr):\n #rt=rt*(nn-i)/(rr-i)\n rt*=(nn-i)\n for i in range(rr):\n rt//=(rr-i)\n return int(rt)\nprint(p)\nmo=10**9 +7\nans=1\nif len(p)==0:\n ans=1\nelse:\n for i in p:\n ans*=comb(i+n-1, i) % mo\n print(ans,comb(i+n-1, i),mo)\nprint(ans % mo)', 'n,m = map(int,input().split())\ndef div(x,y):\n if x%y!=0:\n return 0\n else:\n return 1+div(int(x/y),y)\n\np=[]\nq=[]\n\ndef fact(s):\n if len(p)!=0:\n k=p[-1]\n else:\n k=2\n for i in range(2,max(int(s**0.5) +2,2)):\n a=div(s,i)\n if a==0:\n 0\n else:\n p.append(a)\n q.append(i)\n s=int(s/i**a)\n if s!=1:\n p.append(1)\n \nfact(m)\ndef comb(nn,rr):\n rr=min(rr,nn-rr)\n rt=1\n for i in range(rr):\n #rt=rt*(nn-i)/(rr-i)\n rt*=(nn-i)\n for i in range(rr):\n rt//=(rr-i)\n return int(rt)\n#print(p,q,m)\nmo=10**9 +7\nans=1\nif len(p)==0:\n ans=1\nelse:\n for i in p:\n ans*=comb(i+n-1, i) % mo\nprint(ans % mo)'] | ['Wrong Answer', 'Accepted'] | ['s688967524', 's773079014'] | [3064.0, 3192.0] | [22.0, 22.0] | [716, 746] |
p03253 | u628262476 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m=map(int,input().split())\npw = []\nd = 2\nwhile d*d <= m:\n e = 0\n while m % d == 0:\n e += 1\n m //= d\n if e > 0: pw.append(e)\n d += 1\nif m > 1: pw.append(1)\nprint(pw)\nans = 1\nfor e in pw:\n comb = 1\n for i in range(e):\n comb = comb * (n+i) // (1+i)\n ans = ans * comb % 1000000007\nprint(ans)', 'n,m=map(int,input().split())\npw = []\nd = 2\nm0 = m\nwhile d*d <= m0:\n e = 0\n while m % d == 0:\n e += 1\n m //= d\n if e > 0: pw.append(e)\n d += 1\nans = 1\nfor e in pw:\n comb = 1\n for i in range(e):\n comb = comb * (n+i) // (1+i)\n ans = ans * comb % 1000000007\nprint(ans)', 'n,m=map(int,input().split())\npw = []\nd = 2\nwhile d*d <= m:\n e = 0\n while m % d == 0:\n e += 1\n m //= d\n if e > 0: pw.append(e)\n d += 1\nans = 1\nfor e in pw:\n comb = 1\n for i in range(e):\n comb = comb * (n+i) // (1+i)\n ans = ans * comb % 1000000007\nprint(ans)', 'n,m=map(int,input().split())\npw = []\nd = 2\nwhile d*d <= m:\n e = 0\n while m % d == 0:\n e += 1\n m //= d\n if e > 0: pw.append(e)\n d += 1\nif m > 1: pw.append(1)\nans = 1\nfor e in pw:\n comb = 1\n for i in range(e):\n comb = comb * (n+i) // (1+i)\n ans = ans * comb % 1000000007\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s016345538', 's270764107', 's386130792', 's060708722'] | [3064.0, 3064.0, 3064.0, 3064.0] | [19.0, 26.0, 19.0, 19.0] | [305, 280, 272, 295] |
p03253 | u631277801 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import sys\nstdin = sys.stdin\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter\n\ndef factorize(n: int):\n d = Counter()\n m= 2\n \n while m*m <= n:\n while n%m == 0:\n n //= m\n d[m] += 1\n \n m += 1\n \n if n > 1:\n d[n] += 1\n \n return d\n\n\ndef inv_mod(n:int, mod:int) -> list:\n inv = [0,1]\n for i in range(2,n+1):\n inv.append(mod - ((mod//i)*inv[mod%i]) % mod)\n return inv\n \n\ndef fact(n:int, mod:int) -> list:\n fac = [1,1]\n res = 1\n for i in range(2,n+1):\n res = res*i%mod\n fac.append(res)\n return fac\n\n\ndef fact_inv(n:int, inv:list, mod:int) -> list:\n facInv = [1,1]\n for i in range(2,n+1):\n facInv.append(facInv[i-1]*inv[i] % mod)\n return facInv\n \n\ndef nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:\n if not (0<=r and r<=n):\n return 0\n \n return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod\n\n\ndef nHr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:\n if r<0 or n<0:\n return 0\n \n else:\n return nCr(n+r-1,r,mod,fac,facInv)\n \nMOD = 10**9+7\n\nn,m = li()\n\nの準備\ninv = inv_mod(n+100,MOD)\nfac = fact(n+100,MOD)\nfac_inv = fact_inv(n+100,inv,MOD)\n\nprimes = factorize(n)\nans = 1\nfor p in primes.values():\n ans = ans * nHr(n,p,MOD,fac,fac_inv) % MOD\n \nprint(ans)', 'import sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10**5)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter\n\ndef factorize(n: int):\n d = Counter()\n m= 2\n \n while m*m <= n:\n while n%m == 0:\n n //= m\n d[m] += 1\n \n m += 1\n \n if n > 1:\n d[n] += 1\n \n return d\n\n\ndef inv_mod(n:int, mod:int) -> list:\n inv = [0,1]\n for i in range(2,n+1):\n inv.append(mod - ((mod//i)*inv[mod%i]) % mod)\n return inv\n \n\ndef fact(n:int, mod:int) -> list:\n fac = [1,1]\n res = 1\n for i in range(2,n+1):\n res = res*i%mod\n fac.append(res)\n return fac\n\n\ndef fact_inv(n:int, inv:list, mod:int) -> list:\n facInv = [1,1]\n for i in range(2,n+1):\n facInv.append(facInv[i-1]*inv[i] % mod)\n return facInv\n \n\ndef nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:\n if not (0<=r and r<=n):\n return 0\n \n return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod\n\n\ndef nHr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:\n if r<0 or n<0:\n return 0\n \n else:\n return nCr(n+r-1,r,mod,fac,facInv)\n\nn,m = li()\nMOD = 10**9+7\n\ninv = inv_mod(2*10**5, MOD)\nfac = fact(2*10**5, MOD)\nfacinv = fact_inv(2*10**5,inv,MOD)\n\nmd = factorize(m)\n\nans = 1\nfor k,v in md.items():\n ans *= nHr(n,v,MOD,fac,facinv)\n ans %= MOD\n \nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s704150066', 's590686135'] | [15392.0, 27276.0] | [103.0, 194.0] | [1849, 1855] |
p03253 | u633105820 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ["import math\nimport sys\nimport collections\n\n\nmod = 1000000007\nsys.setrecursionlimit(mod)\nfact = {1: 1}\n\n\ndef run(n, m):\n print('{}を{}個の数列で表現'.format(m, n))\n ans = 1\n primes = []\n for i in range(2, m):\n if m == 1:\n break\n if m % i == 0:\n cnt = 0\n while m % i == 0:\n cnt += 1\n m //= i\n primes.append(i)\n # ans *= comb(cnt+n-1, n-1)\n # ans %= mod\n counts = collections.Counter(primes)\n print(counts)\n for (k, v) in counts.items():\n ans *= comb(v+n-1, n-1)\n ans %= mod\n return ans\n\n\ndef comb(n, r):\n mul = math.factorial(n) // math.factorial(n - r)\n div = math.factorial(r)\n # mul = factorial(n) // factorial(n - r)\n # div = factorial(r)\n mul %= mod\n div %= mod\n return (mul * modpow(div, (mod-2))) % mod\n\n\n'''\ndef factorial(n):\n if n in fact:\n return fact[n]\n else:\n fact[n] = n*factorial(n-1)\n return fact[n]\n'''\n\n\ndef modpow(a, p):\n if p == 0:\n return 1\n if p % 2 == 0:\n halfp = p // 2\n half = modpow(a, halfp)\n return int((half * half) % mod)\n else:\n return int((a * modpow(a, p-1)) % mod)\n\n\ndef main():\n n, m = map(int, input().split())\n print(run(n, m))\n\n\nif __name__ == '__main__':\n main()\n", "import math\nimport sys\n\n\nmod = 1000000007\nsys.setrecursionlimit(mod)\nfact = {1: 1}\n\n\ndef run(n, m):\n print('{}を{}個の数列で表現'.format(m, n))\n ans = 1\n for i in range(2, m):\n if m == 1:\n break\n if m % i == 0:\n cnt = 0\n while m % i == 0:\n cnt += 1\n m //= i\n ans *= comb(cnt+n-1, n-1)\n ans %= mod\n print('{}が{}個'.format(i, cnt))\n print('now ans is', ans)\n return ans\n\n\ndef comb(n, r):\n mul = math.factorial(n) // math.factorial(n - r)\n div = math.factorial(r)\n # mul = factorial(n) // factorial(n - r)\n # div = factorial(r)\n mul %= mod\n div %= mod\n return (mul * modpow(div, (mod-2))) % mod\n\n\n'''\ndef factorial(n):\n if n in fact:\n return fact[n]\n else:\n fact[n] = n*factorial(n-1)\n return fact[n]\n'''\n\n\ndef modpow(a, p):\n if p == 0:\n return 1\n if p % 2 == 0:\n halfp = p // 2\n half = modpow(a, halfp)\n return int((half * half) % mod)\n else:\n return int((a * modpow(a, p-1)) % mod)\n\n\ndef main():\n n, m = map(int, input().split())\n print(run(n, m))\n\n\nif __name__ == '__main__':\n main()\n", "import math\nimport sys\nimport collections\n\n\nmod = 1000000007\nsys.setrecursionlimit(mod)\nfact = {1: 1}\n\n\ndef run(n, m):\n \n ans = 1\n primes = []\n for i in range(2, m):\n if m == 1:\n break\n if i*i > m:\n break\n if m % i == 0:\n cnt = 0\n while m % i == 0:\n cnt += 1\n m //= i\n primes.append(i)\n ans *= comb(cnt+n-1, n-1)\n ans %= mod\n # counts = collections.Counter(primes)\n # print(counts)\n # for (_, v) in counts.items():\n # ans *= comb(v+n-1, n-1)\n # ans %= mod\n if m != 1:\n ans *= n\n ans %= mod\n return ans\n\n\ndef comb(n, r):\n if r > (n-r):\n r = n-r\n mul = 1\n div = 1\n for i in range(r):\n mul *= n-i\n div *= i+1\n mul %= mod\n div %= mod\n # mul = math.factorial(n) // math.factorial(n - r)\n # div = math.factorial(r)\n # mul = factorial(n) // factorial(n - r)\n # div = factorial(r)\n mul %= mod\n div %= mod\n return (mul * modpow(div, (mod-2))) % mod\n\n\n'''\ndef factorial(n):\n if n in fact:\n return fact[n]\n else:\n fact[n] = n*factorial(n-1)\n return fact[n]\n'''\n\n\ndef modpow(a, p):\n if p == 0:\n return 1\n if p % 2 == 0:\n halfp = p // 2\n half = modpow(a, halfp)\n return int((half * half) % mod)\n else:\n return int((a * modpow(a, p-1)) % mod)\n\n\ndef main():\n n, m = map(int, input().split())\n print(run(n, m))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s407551965', 's997228186', 's666213493'] | [4728.0, 4444.0, 3316.0] | [2104.0, 2104.0, 22.0] | [1361, 1229, 1619] |
p03253 | u634461820 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\nmod = 1000000007\nN,M = list(map(int,input().strip().split()))\nl = []\n\ndef P(n, r):\n return math.factorial(n)//math.factorial(n-r)\ndef C(n, r):\n return P(n, r)//math.factorial(r)\n\ncnt = 0\nwhile M%2 == 0:\n M = M//2\n cnt += 1\nl.append(cnt)\n\n\nfor i in range(3,int(math.sqrt(M)),2):\n cnt = 0\n while M%i == 0:\n M = M//i\n cnt += 1\n if cnt != 0:\n l.append(cnt)\n \nans = 1\nfor i in l:\n ans *= C(N+i-1,i)\n \nprint(ans%mod)\n', 'import math\nmod = 1000000007\nN,M = list(map(int,input().strip().split()))\nl = []\n\nans = 1\ncnt = 0\nwhile M%2 == 0:\n M //= 2\n cnt += 1\nl.append(cnt)\ncnt = 0\n\ni = 3\nwhile i**2 <= M:\n cnt = 0\n while M%i == 0:\n M //= i\n cnt += 1\n if cnt != 0:\n l.append(cnt)\n cnt = 0\n i += 2\nif M != 1:\n l.append(1)\n\nfor i in l:\n for j in range(i):\n ans = ans*(N+j)//(j+1)\n\nprint(ans%mod)'] | ['Wrong Answer', 'Accepted'] | ['s058530839', 's207073383'] | [4408.0, 3064.0] | [2104.0, 19.0] | [443, 392] |
p03253 | u643495354 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from scipy.misc import comb\n\n\ndef main():\n n, m = map(int, input().split())\n MOD = 10 ** 9 + 7\n\n m0 = m\n primes = {}\n p = 2\n \n while m0 > 1:\n if m0 % p == 0:\n m0 /= p\n if p in primes:\n primes[p] += 1\n else:\n primes[p] = 1\n else:\n p += 1\n\n ans = 1\n for _, v in primes.items():\n ans *= comb(n - 1 + v, v, exact=True)\n ans %= MOD\n print(ans)\n\n\nmain()\n', 'from operator import mul\nfrom functools import reduce\n\n\ndef cmb(n, r):\n r = min(n-r, r)\n if r == 0:\n return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1, r + 1))\n return over // under\n\n\ndef main():\n n, m = map(int, input().split())\n MOD = 10 ** 9 + 7\n\n m0 = m\n primes = {}\n p = 2\n rtm = int(m ** 0.5 + 1)\n \n while m0 > 1:\n if m0 % p == 0:\n m0 /= p\n if p in primes:\n primes[p] += 1\n else:\n primes[p] = 1\n else:\n p += 1\n # m is prime\n if rtm <= p:\n primes[1] = 1\n break\n\n ans = 1\n for _, v in primes.items():\n ans *= cmb(n - 1 + v, v)\n ans %= MOD\n print(ans)\n\n\nmain()\n'] | ['Time Limit Exceeded', 'Accepted'] | ['s602394185', 's228395470'] | [15152.0, 3688.0] | [2108.0, 30.0] | [501, 807] |
p03253 | u652081898 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['def FACTOR(DICT, N):\n FACT = DICT\n LIM = int(N**0.5)+2\n for i in range(2, LIM):\n if N%i == 0:\n FACT[i] = 0\n while N%i == 0:\n FACT[i] += 1\n N //= i\n if len(FACT) == len(DICT):\n if N != 1:\n FACT[N] = 1\n return FACT\n return FACTOR(FACT, N)\n\ndef comb_rep(n, r):\n N = n+r-1\n ANS = 1\n for R in range(r):\n ANS *= N-R\n ANS /= R+1\n return int(ANS)\n\nMOD = 10**9+7\nn, m = map(int, input().split())\nfactor = FACTOR({}, m)\nans = 1\nfor i in factor:\n ans *= comb_rep(n, factor[i])\n ans %= MOD\n print(i, comb_rep(n, factor[i]))\nprint(factor, ans)', 'def FACTOR(DICT, N):\n FACT = DICT\n LIM = int(N**0.5)+2\n for i in range(2, LIM):\n if N%i == 0:\n FACT[i] = 0\n while N%i == 0:\n FACT[i] += 1\n N //= i\n if len(FACT) == len(DICT):\n if N != 1:\n FACT[N] = 1\n return FACT\n return FACTOR(FACT, N)\n\ndef comb_rep(n, r):\n N = n+r-1\n ANS = 1\n for R in range(r):\n ANS *= N-R\n for R in range(r):\n ANS //= r-R\n return int(ANS)\n\nMOD = 10**9+7\nn, m = map(int, input().split())\nfactor = FACTOR({}, m)\nans = 1\nfor i in factor:\n ans *= (comb_rep(n, factor[i])%MOD)\n ans %= MOD\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s089811549', 's760845798'] | [3064.0, 3064.0] | [23.0, 22.0] | [652, 637] |
p03253 | u652150585 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\n\nn,m=map(int,input().split())\na=math.floor(math.sqrt(m))+1\nl=[0]*(a+1)\nfor i in range(2,a+1):\n while m%i==0:\n l[i]+=1\n m//=i\nb=list(filter(lambda x:x!=0,l))\nshow=False\nif len(b)==0:\n show=True\nans=1\nprint(b)\nfor i in b:\n com=1\n for j in range(i):\n com*=n+i-1-j\n for j in range(i):\n com//=j+1\n ans*=com\nif show:\n print(n)\nelse:\n print(ans)', 'import collections\n\ndef factor(m):\n num=m\n s=[]\n i=2\n while i*i<=m:\n if num%i:\n i+=1\n else:\n s.append(i)\n num//=i\n if num!=1:\n s.append(num)\n return s\n\ndef conb(n,r):\n r=min(r,n-r)\n if r==0:\n return 1\n else:\n N,R=n,r\n \tfor i in range(1,r):\n \tN*=n-i\n \tR*=r-i\n \treturn N//R\n\t\nn,m=map(int,input().split())\na=factor(m)\nb=collections.Counter(a)\nmod=10**9+7\nans=1\nfor i in b.values():\n ans=(ans*conb(n+i-1,i))%mod\nprint(ans)', 'import collections\n\ndef factor(m):\n num=m\n s=[]\n i=2\n while i*i<=m:\n if num%i:\n i+=1\n else:\n s.append(i)\n num//=i\n if num!=1:\n s.append(num)\n return s\n\ndef conb(n,r):\n r=min(r,n-r)\n if r==0:\n return 1\n else:\n \tN,R=n,r\n\t\tfor i in range(1,r):\n \tN*=n-i\n \tR*=r-i\n \treturn N//R\n\t\nn,m=map(int,input().split())\na=factor(m)\nb=collections.Counter(a)\nmod=10**9+7\nans=1\nfor i in b.values():\n ans=(ans*conb(n+i-1,i))%mod\nprint(ans)', 'import collections\n\ndef factor(m):\n num=m\n s=[]\n i=2\n while i*i<=m:\n if num%i:\n i+=1\n else:\n s.append(i)\n num//=i\n if num!=1:\n s.append(num)\n return s\n\ndef conb(n,r):\n r=min(r,n-r)\n N,R=n,r\n if r==1:\n return n\n elif r==0:\n return 1\n else:\n for i in range(1,r):\n N*=n-i\n R*=r-i\n return N//R\n\t\nn,m=map(int,input().split())\na=factor(m)\nb=collections.Counter(a)\nmod=10**9+7\nans=1\nfor i in b.values():\n ans=(ans*conb(n+i-1,n-1))%mod\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s002444654', 's383191197', 's529146406', 's836882418'] | [3316.0, 2940.0, 2940.0, 3316.0] | [30.0, 17.0, 17.0, 27.0] | [402, 532, 528, 578] |
p03253 | u685263709 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import sympy\nsympy.factorint(2016)', 'N, M = map(int, input().split())\nmod = 10**9 + 7\n\n\ndef factorize(n):\n b = 2\n fct = {}\n while b * b <= n:\n while n % b == 0:\n n //= b\n if b in fct.keys():\n fct[b] += 1\n else:\n fct[b] = 1\n b = b + 1\n if n > 1:\n fct[n] = 1\n return fct\n\n\nfrom operator import mul\nfrom functools import reduce\n\n\ndef cmb(n, r):\n r = min(n-r, r)\n if r == 0:\n return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1, r + 1))\n return over // under\n\n\nfac_list = factorize(M)\nans = 1\nfor k, v in fac_list.items():\n ans *= cmb(v+N-1, v)\n if ans >= mod:\n ans %= mod\n\nprint(int(ans))'] | ['Runtime Error', 'Accepted'] | ['s267724180', 's173599506'] | [2940.0, 3572.0] | [17.0, 24.0] | [34, 709] |
p03253 | u690536347 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d=c()\n for i in range(2,1+int(n**0.5)):\n while n%i==0:\n d[i]+=1\n n/=i\n if n:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)', 'from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d,i=c(),2\n while i*i<=n:\n while n%i==0:\n n//=i\n d[i]+=1\n i += 1\n if n:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)', 'from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d=c()\n for i in range(2,1+int(n**0.5)):\n while n%i==0:\n d[i]+=1\n n//=i\n if n:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)', 'from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d,i=c(),2\n while i*i<=n:\n while n%i==0:\n n//=i\n d[i]+=1\n i+=1\n if n>1:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:((x%mod)*(y%mod))%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)', 'from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d,i=c(),2\n while i*i<=n:\n while n%i==0:\n n//=i\n d[i]+=1\n i+=1\n if n>1:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)', 'from collections import Counter as c\nfrom scipy.misc import comb\nfrom functools import reduce\n\ndef f(n):\n d,i=c(),2\n while i*i<=n:\n while n%i==0:\n n//=i\n d[i]+=1\n i+=1\n if n>1:d[n]+=1\n return d.values()\n\nn,m=map(int,input().split())\nmod=10**9+7\nprint(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)', 'def factorize(n):\n from collections import defaultdict\n d = defaultdict(int)\n for i in range(2, int(n**0.5)+1):\n while n%i==0:\n d[i] += 1\n n //= i\n if not n:\n break\n if n>1:\n d[n] += 1\n return d\n\n\nN, M = map(int, input().split())\nd = factorize(M)\n\nMOD = 10**9+7\nn = N+30\nfac = [1]*(n+1)\nrev = [1]*(n+1)\n \nfor i in range(1,n+1):\n fac[i] = i*fac[i-1]%MOD\n rev[i] = pow(fac[i], MOD-2, MOD)\n \ncomb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD\n\nv = 1\nfor i in d.values():\n v *= comb(i+N-1, i)\n v %= MOD\nprint(v)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s161876851', 's348545992', 's502821898', 's503843554', 's537023366', 's955077537', 's355168873'] | [15272.0, 13308.0, 13240.0, 13176.0, 15224.0, 22584.0, 11316.0] | [197.0, 162.0, 159.0, 159.0, 160.0, 325.0, 450.0] | [349, 346, 350, 364, 350, 346, 580] |
p03253 | u704284486 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['mod = 10**9+7\ndef prime(n,p):\n iteral = 0\n while n%p == 0:\n n //= p\n iteral += 1\n return iteral,n\ndef modpow(a,n):\n if n==0:\n return 1\n elif n==1:\n return a%mod\n elif n%2==0:\n return (modpow(a,n/2)**2)%mod\n else:\n return (a*modpow(a,n-1))%mod\ndef modfact(l,r):\n fact=1\n for i in range(l-r+1):\n fact=fact*(r+i)%mod\n return fact\ndef comb(n,x):\n S=modfact(n,n-x+1)\n fact=modfact(x,1)\n T=modpow(fact,mod-2)\n return S*T%mod\ndef main():\n N,M = map(int,input().split())\n b = []\n for i in range(2,int(M**0.5)+1):\n if M%i==0:\n num,M = prime(M,i)\n b.append(num)\n else:\n continue\n ans = 1\n for num in b:\n ans *= comb(num+N-1,num)\n ans %= mod\n print(ans)\n\nif __name__ == "__main__":\n main()', 'mod = 10**9+7\ndef prime(n,p):\n iteral = 0\n while n%p == 0:\n n //= p\n iteral += 1\n return iteral,n\ndef modpow(a,n):\n if n==0:\n return 1\n elif n==1:\n return a%mod\n elif n%2==0:\n return (modpow(a,n/2)**2)%mod\n else:\n return (a*modpow(a,n-1))%mod\ndef modfact(l,r):\n fact=1\n for i in range(l-r+1):\n fact=fact*(r+i)%mod\n return fact\ndef comb(n,x):\n S=modfact(n,n-x+1)\n fact=modfact(x,1)\n T=modpow(fact,mod-2)\n return S*T%mod\n\ndef sieve(N):\n prime = [0]*(N+1)\n isprime = [True]*(N+1)\n isprime[0]=isprime[1] = False\n num = 0\n for p in range(2,N+1):\n if isprime[p]:\n prime[num] = p\n num += 1\n for j in range(2*p,N+1,p):\n isprime[j] = False\n prime.sort()\n prime.reverse()\n for k in range(N-1):\n if prime[k+1] == 0:\n end = k\n break\n return prime[:end+1]\ndef main():\n N,M = map(int,input().split())\n b = {}\n for i in reversed(sieve(int(M**0.5)+10)):\n if M%i==0:\n num,M = prime(M,i)\n b[i] = num\n if M > 1:\n b[M] = 1\n ans = 1\n for num in b:\n ans *= comb(b[num]+N-1,b[num])\n ans %= mod\n print(ans)\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s280035482', 's833195797'] | [3192.0, 3700.0] | [20.0, 25.0] | [881, 1353] |
p03253 | u726615467 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['# encoding: utf-8\nimport math\nN, M = map(int, input().split())\n\ndef distribute(pos, full, tmp):\n return memo[tmp][pos]\n\n# define search range\np_max = int(M / 2) # M is prime if M has a factor p (> p_max)\nip_up = int(math.log2(p_max))\n\n#### O(MlogM) below (if M has a very large prime factor)\nM_tmp = M\nips = []\npsuedo_primes = [max((2, 2 * i + 1)) for i in range(p_max // 2)]\nfor p in psuedo_primes:\n # how many times M_tmp can be divided\n p_tmp = p\n for i_p in range(ip_up + 1):\n if M_tmp % p_tmp > 0: break\n p_tmp = p_tmp * p\n # escape if M_tmp cannot be divided\n if i_p < 1: continue\n \n ips.append(i_p)\n # next\n M_tmp = M_tmp // (p_tmp // p)\n if M_tmp == 1: break\n\n\n#### O(N) below\n# create memo\n## init\nif len(ips) > 0: ip_max = max(ips)\nelse: ip_max = 0\nmemo = [[None] * N for i in range(ip_max + 1)] \nfor j in range(N): memo[0][j] = 1\nfor i in range(1, ip_max + 1): memo[i][N - 1] = 1\n## fill\nfor i in range(1, ip_max + 1):\n sum_tmp = 0\n vals = list(memo[i - 1])[::-1]\n p_memo = memo[i]\n for j, val in enumerate(vals):\n sum_tmp += val\n p_memo[N - 1 - j] = sum_tmp\n#### O(N) above\n \n# calculate ans\nans = 1\nfor i_p in ips: ans = (ans * distribute(0, i_p, i_p)) % (10 ** 9 + 7) \n \nprint(ans)', '# encoding: utf-8\nN, M = map(int, input().split())\n\n\n\n# M_tmp = M\n# factors = []\n# for p in primes:\n# for i_p in range(32):\n# if M_tmp % (p ** (i_p + 1)) > 0: break\n# if i_p > 0: factors.append((p, i_p))\n# M_tmp = M_tmp // (p ** i_p)\n\n## memo\nmemo = [[None] * 33 for i in range(N)] \n\ndef distribute(pos, full, tmp):\n # read memo\n if memo[pos][tmp] != None: return memo[pos][tmp]\n # end\n if tmp == 0: return 1\n # next\n ret = 0\n if pos < N - 1:\n for i in range(tmp + 1): ret += distribute(pos + 1, full, tmp - i)\n else: ret += 1\n \n # write memo\n if memo[pos][tmp] != None: memo[pos][tmp] = ret\n return ret\n\n# ans = 1\n# for p, i_p in factors:\n# tmp = distribute(0, i_p, i_p)\n\n# # print("#", p, tmp)\n\nM_tmp = M\nans = 1\nfor p in range(2, 2 ** 32):\n # how many times M_tmp can be divided\n for i_p in range(33):\n if M_tmp % (p ** (i_p + 1)) > 0: break\n # escape if M_tmp cannot be divided\n # print("#", p, i_p)\n if i_p < 1: continue\n # ans update (dp)\n ## search and count\n ans_tmp = distribute(0, i_p, i_p)\n # print("###", ans_tmp)\n ## add\n ans = (ans * ans_tmp) % (10 ** 9 + 7)\n # next\n M_tmp = M_tmp // (p ** i_p)\n\nprint(ans)', '# encoding: utf-8\nimport math\nN, M = map(int, input().split())\n\ndef distribute(pos, full, tmp):\n return memo[tmp][pos]\n\n# define search range\np_max = int(M / 2) # M is prime if M has a factor p (> p_max)\nip_up = int(math.log2(p_max))\n\n#### O(MlogM) below (if M has a very large prime factor)\nM_tmp = M\nips = []\nfor p in range(2, p_max + 1):\n if M_tmp % p > 0: continue\n # how many times M_tmp can be divided\n p_tmp = p\n for i_p in range(ip_up + 1):\n if M_tmp % p_tmp > 0: break\n p_tmp = p_tmp * p\n \n ips.append(i_p)\n # next\n M_tmp = M_tmp // (p_tmp // p)\n if M_tmp == 1: break\n\n\n#### O(N) below\n# create memo\n## init\nif len(ips) > 0: ip_max = max(ips)\nelse: ip_max = 0\nmemo = [[None] * N for i in range(ip_max + 1)] \nfor j in range(N): memo[0][j] = 1\nfor i in range(1, ip_max + 1): memo[i][N - 1] = 1\n## fill\nfor i in range(1, ip_max + 1):\n sum_tmp = 0\n vals = list(memo[i - 1])[::-1]\n p_memo = memo[i]\n for j, val in enumerate(vals):\n sum_tmp += val\n p_memo[N - 1 - j] = sum_tmp\n#### O(N) above\n \n# calculate ans\nans = 1\nfor i_p in ips: ans = (ans * distribute(0, i_p, i_p)) % (10 ** 9 + 7)\n\nif ip_max = 0: print(N)\nelse: print(ans)', '# encoding: utf-8\nimport math\nN, M = map(int, input().split())\n\ndef distribute(pos, full, tmp):\n return memo[tmp][pos]\n\n# define search range\np_max = int(M / 2) # M is prime if M has a factor p (> p_max)\nip_max = int(math.log2(M))\n\nM_tmp = M\nips = []\nfor p in range(2, p_max + 1):\n # how many times M_tmp can be divided\n p_tmp = p\n for i_p in range(ip_max + 1):\n if M_tmp % p_tmp > 0: break\n p_tmp = p_tmp * p\n # escape if M_tmp cannot be divided\n if i_p < 1: continue\n \n ips.append(i_p)\n # next\n M_tmp = M_tmp // (p_tmp // p)\n if M_tmp == 1: break\n\n### test code\nprint("WA")', '# encoding: utf-8\nimport math\nN, M = map(int, input().split())\n\nips = []\nM_tmp = M\nfor p in range(2, int(math.sqrt(M)) + 1):\n if M_tmp % p > 0: continue\n for i_p in range(1, 33):\n if M_tmp % (p ** (i_p + 1)) > 0: break\n ips.append(i_p)\n M_tmp = M_tmp // (p ** i_p)\n if M_tmp == 1: break\nelse:\n ips.append(1)\n\n#### O(NlogM) below ?\n# create memo\n## init\nif len(ips) > 0: ip_max = max(ips)\nelse: ip_max = 0\nmemo = [[None] * N for i in range(ip_max + 1)] \nfor j in range(N): memo[0][j] = 1\nfor i in range(1, ip_max + 1): memo[i][N - 1] = 1\n## fill\nfor i in range(1, ip_max + 1):\n sum_tmp = 0\n vals = list(memo[i - 1])[::-1]\n ptr_memo = memo[i]\n for j, val in enumerate(vals):\n sum_tmp += val\n ptr_memo[N - 1 - j] = sum_tmp\n#### O(NlogM) above ?\n \n# calculate ans\nans = 1\nfor i_p in ips:\n ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)\n\nif M == 1: print(1)\nelif ip_max < 1: print(N)\nelse: print(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s177585940', 's300842774', 's747835001', 's950662347', 's230902413'] | [320816.0, 37620.0, 3064.0, 3064.0, 192284.0] | [2123.0, 2106.0, 17.0, 2104.0, 951.0] | [1330, 1331, 1255, 639, 960] |
p03253 | u727148417 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['def 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\n\n\ndef prepare(n, MOD):\n\n \n f = 1\n factorials = [1] \n for m in range(1, n + 1):\n f *= m\n f %= MOD\n factorials.append(f)\n \n inv = pow(f, MOD - 2, MOD)\n \n invs = [1] * (n + 1)\n invs[n] = inv\n for m in range(n, 1, -1):\n inv *= m\n inv %= MOD\n invs[m - 1] = inv\n\n return factorials, invs\n\nimport math\nfrom itertools import combinations\nfrom collections import Counter\nMOD = 1000000007\n\ndef solve():\n N, M = map(int, input().split())\n factorials, invs = prepare(N, MOD)\n #print(factorials, invs)\n temp = factorization(M)\n nums = []\n for i, j in temp:\n for k in range(j):\n nums.append(i)\n #print(nums)\n\n divisors = set()\n for i in range(1, len(nums)+1):\n for temp in combinations(nums, i):\n y = 1\n for x in temp:\n y = y * x\n divisors.add(y)\n \n\n pattern = set()\n for x in divisors:\n m = M // x\n temp_m = factorization(m)\n nums_m = []\n for i, j in temp_m:\n for k in range(j):\n nums_m.append(i)\n nums_m.append(x)\n nums_m.sort()\n pattern.add(tuple(nums_m))\n #print(pattern)\n\n ans = 0\n fact_N = factorials[N]\n for x in pattern:\n if 1 in x:\n ones = (N-len(x)) + 1\n cnt = Counter(list(x))\n print(cnt)\n perm = fact_N * invs[ones]\n print(perm)\n else:\n ones = (N-len(x))\n cnt = Counter(list(x))\n print(cnt)\n perm = fact_N\n for value in cnt.values():\n perm = perm * invs[value]\n perm = perm * invs[ones]\n print(perm)\n ans += perm\n print(ans % MOD)\n\nif __name__ == "__main__":\n solve()\n', 'from collections import defaultdict\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[i] = cnt\n\n if temp != 1:\n arr[temp] = 1\n if len(arr.keys()) == 0:\n arr[n] = 1\n return arr\n\n\ndef prepare(n, MOD):\n\n \n f = 1\n factorials = [1] \n for m in range(1, n + 1):\n f *= m\n f %= MOD\n factorials.append(f)\n \n inv = pow(f, MOD - 2, MOD)\n \n invs = [1] * (n + 1)\n invs[n] = inv\n for m in range(n, 1, -1):\n inv *= m\n inv %= MOD\n invs[m - 1] = inv\n\n return factorials, invs\n\nimport math\nfrom itertools import combinations\nfrom collections import Counter\nMOD = 1000000007\n\ndef solve():\n N, M = map(int, input().split())\n temp = factorization(M)\n #print(temp)\n max_num = max(temp.values())\n factorials, invs = prepare(N+max_num-1, MOD)\n #print(factorials, invs)\n ans = 1\n for i, j in temp.items():\n if i == 1:\n break\n ans *= factorials[N+j-1]\n ans %= MOD\n ans *= invs[N-1]\n ans %= MOD\n ans *= invs[j]\n ans %= MOD\n #print(ans)\n print(ans)\n\n\nif __name__ == "__main__":\n solve()\n'] | ['Runtime Error', 'Accepted'] | ['s440051757', 's028804183'] | [12644.0, 11508.0] | [2104.0, 70.0] | [2264, 1415] |
p03253 | u729008627 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import numpy as np\nN, M = map(int, input().split())\nbigp = 10**9+7\nL1 = []\nL2 = []\np = 2\nmax = np.sqrt(M)\nK = M\nwhile p <= max:\n if K%p == 0:\n L1.append(p)\n K = K//p\n if p not in L2:\n L2.append(p)\n else:\n p = p+1\n\nans = 1\ndef ModComb(n, r, p):\n N = n%p\n R = r%p\n if N<R:\n return 0\n if N < 2*R:\n R = N-R\n if R == 0:\n return 1\n else:\n return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)\n\n\nfor x in L2:\n primepower = L1.count(x)\n ans *= ModComb(N+primepower-1, primepower, bigp)%bigp\n\nprint(ans%bigp)\n', 'N, M = map(int, input().split())\nbigp = 10**9+7\nL = []\np, power = 2, 0\nK = M\nwhile p*p <= K:\n while K%p == 0:\n K = K//p\n power += 1\n if power > 0:\n L.append([p, power])\n if p == 2:\n p += 1\n else:\n p += 2\n power = 0\nif K > 1:\n L.append([K, 1])\n\n\nans = 1\ndef ModComb(n, r, p):\n N = n%p\n R = r%p\n if N<R:\n return 0\n if N < 2*R:\n R = N-R\n if R == 0:\n return 1\n else:\n return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)\n\n\nfor i in range(len(L)):\n power = L[i][1]\n ans *= ModComb(N+power-1, power, bigp)\n ans %= bigp\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s295983730', 's337565487'] | [12508.0, 3064.0] | [178.0, 18.0] | [592, 629] |
p03253 | u729133443 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from scipy.misc import comb\nn,m=map(int,input().split())\na=1\np=2\nwhile m>1:\n if m%p:\n p+=1\n continue\n c=0\n while not m%p:\n m//=p\n c+=1\n a=a*comb(n+c-1,c,exact=1)%(10**9+7)\nprint(a)', 'import math\nimport random\nclass Prime:\n seed_primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]\n def is_prime(self,n):\n is_prime_common=self.is_prime_common(n)\n if is_prime_common is not None:return is_prime_common\n if n<2000000:return self.is_prime_brute_force(n)\n return self.is_prime_miller_rabin(n)\n def is_prime_common(self,n):\n if n==1:return False\n if n in Prime.seed_primes:return True\n if any(map(lambda x:n%x==0,self.seed_primes)):return False\n def is_prime_brute_force(self,n):\n for k in range(2,int(math.sqrt(n))+1):\n if n%k==0:return False\n return True\n def is_prime_miller_rabin(self,n):\n d=n-1\n while d&1==0:d>>=1\n witnesses=self.get_witnesses(n)\n for w in witnesses:\n y=pow(w,d,n)\n while d!=n-1and y!=1and y!=n-1:\n y=y*y%n\n d<<=1\n if y!=n-1and d&1==0:return False\n return True\n def get_witnesses(self,num):\n def _get_range(num):\n if num<2047:return 1\n if num<1373653:return 2\n if num<25326001:return 3\n if num<3215031751:return 4\n if num<2152302898747:return 5\n if num<3474749660383:return 6\n if num<341550071728321:return 7\n if num<3825123056546413051:return 9\n return 12\n return self.seed_primes[:_get_range(num)]\n def gcd(self,a,b):\n if a<b:return self.gcd(b,a)\n if b==0:return a\n while b:a,b=b,a%b\n return a\n @staticmethod\n def f(x,n,seed):\n p=Prime.seed_primes[seed%len(Prime.seed_primes)]\n return(p*x+seed)%n\n def find_factor(self,n,seed=1):\n if self.is_prime(n):return n\n x,y,d=2,2,1\n count=0\n while d==1:\n count+=1\n x=self.f(x,n,seed)\n y=self.f(self.f(y,n,seed),n,seed)\n d=self.gcd(abs(x-y),n)\n if d==n:\n return self.find_factor(n,seed+1)\n return self.find_factor(d)\n \n def find_factors(self,n):\n primes={}\n if self.is_prime(n):\n primes[n]=1\n return primes\n while n>1:\n factor=self.find_factor(n)\n primes.setdefault(factor,0)\n primes[factor]+=1\n n//=factor\n return primes\nclass Factorial:\n def __init__(self,n,mod):\n self.f=[1]\n for i in range(1,n+1):\n self.f.append(self.f[-1]*i%mod)\n self.i=[pow(self.f[-1],mod-2,mod)]\n for i in range(1,n+1)[::-1]:\n self.i.append(self.i[-1]*i%mod)\n self.i.reverse()\n def factorial(self,i):\n return self.f[i]\n def ifactorial(self,i):\n return self.i[i]\n def comb(self,n,k):\n return self.f[n]*self.i[n-k]%mod*self.i[k]%mod\nmod=10**9+7\nn,m=map(int,input().split())\n*d,=Prime().find_factors(m).values()\nif d:f=Factorial(n+max(d),mod)\nans=1\nfor t in d:\n ans=ans*f.comb(n-1+t,t)%mod\nprint(ans)'] | ['Time Limit Exceeded', 'Accepted'] | ['s514396360', 's595359000'] | [14220.0, 11460.0] | [2109.0, 81.0] | [220, 3064] |
p03253 | u780529129 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n = int(input())\nm = int(input())\na = list(map(int,input().split()))\nM = 10000\n\ndp = [[0]*(m+1) for i in range(n+1)]\n\nfor i in range(n+1):\n dp[i][0] = 1\n \nfor i in range(n):\n for j in range(1,m+1):\n if j - 1 - a[i] >= 0:\n dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]] ) % M\n else:\n dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % M\n \nprint(dp)', 'def 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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\nfrom scipy.special import comb\nn, m = map(int, input().split())\na = factorization(m)\nM = 10**9 + 7\n\nans = 1\nif m == 1:\n print(1)\n exit()\nfor i in a:\n ans *= comb(n, i[1], exact=True, repetition=True)\n ans = ans%M\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s952167315', 's243845660'] | [9172.0, 42400.0] | [26.0, 188.0] | [419, 588] |
p03253 | u790905630 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from math import *\nfrom collections import *\n\ndef Prime_Factorization(M):\n factor_list = []\n\n for i in range(2, int(sqrt(M)) + 1):\n while M % i == 0:\n factor_list.append(i)\n M = M // i\n if (M == 1):\n break\n\n return factor_list\n\ndef comb(num_object, num_bar):\n return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))\n\ndef all_comb(N, factor_count_list):\n ans = 1\n for factor in factor_count_list:\n ans = (ans * comb(factor_count_list[factor] + N - 1, factor_count_list[factor])) % (10 ** 9 + 7)\n return ans\n\ndef main():\n N, M = map(int, input().split())\n factor_list = Prime_Factorization(M)\n \n if factor_list:\n factor_count_list = Counter(factor_list)\n print(all_comb(N, factor_count_list))\n else:\n print(N)\n\nif __name__ == "__main__":\n main()', 'from math import *\nfrom collections import *\n\ndef Prime_Factorization(M):\n factor_list = []\n\n for i in range(2, int(sqrt(M)) + 1):\n while M % i == 0:\n factor_list.append(i)\n M = M // i\n if (M == 1):\n break\n\n return factor_list\n\ndef comb(num_object, num_bar):\n return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))\n\ndef all_comb(N, factor_count_list):\n ans = 1\n for factor in factor_count_list:\n ans = (ans * comb(factor_count_list[factor] + N - 1, factor_count_list[factor])) % (10 ** 9 + 7)\n return ans\n\ndef main():\n N, M = map(int, input().split())\n factor_list = Prime_Factorization(M)\n factor_count_list = Counter(factor_list)\n print(all_comb(N, factor_count_list))\n\nif __name__ == "__main__":\n main()', 'from math import *\n\ndef Prime_Factorization(M):\n factor_count_list = []\n\n while True:\n root_M = int(sqrt(M))\n\n for i in range(2, root_M + 1):\n e = 0\n while M % i == 0:\n e += 1\n M = M // i\n if e > 0:\n factor_count_list.append(e)\n break\n if (M == 1):\n break\n else:\n break\n if M > root_M:\n factor_count_list.append(1)\n\n print(factor_count_list)\n return factor_count_list\n\ndef comb(num_object, num_bar):\n return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))\n\ndef all_comb(N, factor_count_list):\n ans = 1\n for factor in factor_count_list:\n ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)\n return ans\n\ndef main():\n N, M = map(int, input().split())\n factor_count_list = Prime_Factorization(M)\n\n print(all_comb(N, factor_count_list))\n\nif __name__ == "__main__":\n main()', 'from math import *\n\ndef Prime_Factorization(M):\n factor_count_list = []\n root_M = int(sqrt(M))\n\n while root_M > 1:\n root_M = int(sqrt(M))\n\n for i in range(2, root_M + 1):\n e = 0\n while M % i == 0:\n e += 1\n M = M // i\n if e > 0:\n factor_count_list.append(e)\n break\n else:\n break\n\n if M > root_M:\n factor_count_list.append(1)\n\n return factor_count_list\n\ndef comb(num_object, num_bar):\n numerator = 1\n\n for i in range(num_bar):\n numerator = (numerator * (num_object - i))\n\n return numerator // factorial(num_bar)\n\ndef all_comb(N, factor_count_list):\n ans = 1\n for factor in factor_count_list:\n ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)\n return ans\n\ndef main():\n N, M = map(int, input().split())\n factor_count_list = Prime_Factorization(M)\n\n print(all_comb(N, factor_count_list))\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s147087492', 's271490812', 's787980386', 's110919435'] | [4740.0, 4696.0, 4424.0, 3064.0] | [2104.0, 2104.0, 2104.0, 18.0] | [888, 828, 1010, 1020] |
p03253 | u803848678 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from collections import Counter\nmod = 10**9 + 7\nn, m = map(int, input().split())\n\ndef fact(m):\n c = Counter()\n s = 2\n while s**2 <= m:\n if m % s:\n s += 1\n continue\n while m % s == 0:\n c[s] += 1\n m //= s\n if m > 1:\n c[m] += 1\n return c\n\ndef comb(n, r):\n ret = 1\n for i in range(min(r, n-r)):\n ret = ret*(n-i)//(i+1)\n return ret\n\nans = 1\nfor cnt in fact(m).values():\n print(cnt)\n ans = ans*comb(cnt+n-1, cnt) % mod\n\n\nprint(ans % mod)', 'from collections import Counter\nmod = 10**9 + 7\nn, m = map(int, input().split())\n\ndef fact(m):\n c = Counter()\n s = 2\n while s**2 <= m:\n if m % s:\n s += 1\n continue\n while m % s == 0:\n c[s] += 1\n m //= s\n if m > 1:\n c[m] += 1\n return c\n\ndef comb(n, r):\n ret = 1\n for i in range(min(r, n-r)):\n ret = ret*(n-i)//(i+1)\n return ret\n\nans = 1\nfor cnt in fact(m).values():\n ans = ans*comb(cnt+n-1, cnt) % mod\n\n\nprint(ans % mod)'] | ['Wrong Answer', 'Accepted'] | ['s966889050', 's683460758'] | [3316.0, 3316.0] | [23.0, 23.0] | [595, 580] |
p03253 | u814986259 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['N, M = map(int, input().split())\n\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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range(2, N + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\nprint(primes)\nif N == 1:\n print(1)\n exit(0)\nans = 1\n\nfor p, cnt in primes:\n tmp = 0\n for i in range(1, min(cnt, N)+1):\n tmp += cmb(N, i, mod) * cmb(cnt-1, i-1, mod)\n #print(tmp, p, cnt, i)\n tmp %= mod\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'N, M = map(int, input().split())\n\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 return(arr)\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range(2, N + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\n\nans = 1\nfor p, cnt in primes:\n tmp = 0\n for i in range(1, min(cnt, N)+1):\n tmp += cmb(N, i, mod) * cmb(cnt-i + i-1, i-1, mod)\n #print(tmp, p, cnt, i)\n tmp %= mod\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'N, M = map(int, input().split())\n\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\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range(2, N + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\n\nif N == 1:\n print(1)\nans = 1\nfor p, cnt in primes:\n tmp = 0\n for i in range(1, min(cnt, N)+1):\n tmp += cmb(N, i, mod) * cmb(cnt-1, i-1, mod)\n #print(tmp, p, cnt, i)\n tmp %= mod\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'import math\nN, M = map(int, input().split())\n\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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range(2, N + int(math.log(M)+1) + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\nif N == 1:\n print(1)\n exit(0)\nans = 1\n\nfor p, cnt in primes:\n tmp = cmb(N+cnt-1, N-1, mod)\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'def main()\n N, M = map(int, input().split())\n\n def 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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n mod = 10**9 + 7\n\n def cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n g1 = [1, 1]\n g2 = [1, 1]\n inverse = [0, 1]\n for i in range(2, N+100 + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n primes = factorization(M)\n \n\n ans = 1\n\n for p, cnt in primes:\n tmp = cmb(N+cnt-1, N-1, mod)\n ans *= tmp\n ans %= mod\n\n print(ans)\n\n\nmain()\n', 'def main():\n N, M = map(int, input().split())\n\n def 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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n mod = 10**9 + 7\n\n def cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n g1 = [1, 1]\n g2 = [1, 1]\n inverse = [0, 1]\n for i in range(2, N+100 + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n primes = factorization(M)\n \n\n ans = 1\n\n for p, cnt in primes:\n tmp = cmb(N+cnt-1, N-1, mod)\n ans *= tmp\n ans %= mod\n\n print(ans)\n\n\nmain()\n', 'import math\nN, M = map(int, input().split())\n\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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range(2, N*2 + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\n\nans = 1\n\nfor p, cnt in primes:\n tmp = cmb(N+cnt-1, N-1, mod)\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'N, M = map(int, input().split())\n\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\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\nmod = 10**9 + 7\n\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range(2, N + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n\nprimes = factorization(M)\n\n\nif N == 1:\n print(1)\n exit(0)\nans = 1\nfor p, cnt in primes:\n tmp = 0\n for i in range(1, min(cnt, N)+1):\n tmp += cmb(N, i, mod) * cmb(cnt-1, i-1, mod)\n #print(tmp, p, cnt, i)\n tmp %= mod\n ans *= tmp\n ans %= mod\n\nprint(ans)\n', 'def main():\n N, M = map(int, input().split())\n\n def 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\n if arr == [] and n != 1:\n arr.append([n, 1])\n\n return arr\n\n mod = 10**9 + 7\n\n def cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n g1 = [1, 1]\n g2 = [1, 1]\n inverse = [0, 1]\n for i in range(2, N+100 + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n\n primes = factorization(M)\n \n\n ans = 1\n\n for p, cnt in primes:\n tmp = cmb(N+cnt-1, N-1, mod)\n ans *= tmp\n ans %= mod\n\n print(ans)\n\n\nmain()\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s188583536', 's330819172', 's371063456', 's373412448', 's393428621', 's419901136', 's597282764', 's613931662', 's605189811'] | [20876.0, 21260.0, 20900.0, 20948.0, 8996.0, 9000.0, 32956.0, 20724.0, 20876.0] | [121.0, 121.0, 129.0, 121.0, 23.0, 25.0, 221.0, 125.0, 103.0] | [1372, 1223, 1335, 1270, 1282, 1283, 1216, 1347, 1286] |
p03253 | u826263061 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['# -*- coding: utf-8 -*-\n"""\nCreated on Sun Sep 23 22:00:37 2018\nABC110D\n@author: maezawa\n"""\nimport collections\n\ndef comb(n, r):\n if n == 0 or r == 0:\n return 1\n return comb(n, r-1)*(n-r+1)//r\n\nn, m = list(map(int, input().split()))\n\nmod = 10**9+7\nnp = int(10**4.5 + 10)\nis_prime = [True]*(np+1)\n\nis_prime[0] = False\nis_prime[1] = False\n\nfor i in range(2, np//2):\n if is_prime[i] == True:\n for j in range(2*i,np+1,i):\n is_prime[j] = False\n\nprime_numbers = [i for i in range(np+1) if is_prime[i]]\n\npds = []\nfor i in prime_numbers:\n if i > m:\n break\n if m%i == 0:\n pds.append(i)\n md = m//i\n while md%i == 0:\n #print(md)\n pds.append(i)\n md = md//i\n #pds.append(md)\n\nprint(pds)\ncpds = collections.Counter(pds)\n#print(cpds)\nans = 1\nfor i in cpds.values():\n ans = ans*comb(n+i-1,i)%mod\n\nprint(ans)\n', '# -*- coding: utf-8 -*-\n"""\nCreated on Sun Sep 23 22:00:37 2018\nABC110D\n@author: maezawa\n"""\nimport collections\n\ndef comb(n, r):\n if n == 0 or r == 0:\n return 1\n return comb(n, r-1)*(n-r+1)//r\n\nn, m = list(map(int, input().split()))\n\nmod = 10**9+7\nnp = int(10**4.5 + 10)\nis_prime = [True]*(np+1)\n\nis_prime[0] = False\nis_prime[1] = False\n\nfor i in range(2, np//2):\n if is_prime[i] == True:\n for j in range(2*i,np+1,i):\n is_prime[j] = False\n\nprime_numbers = [i for i in range(np+1) if is_prime[i]]\n\npds = []\nfor i in prime_numbers:\n if i > m//2:\n break\n md = m\n while md%i == 0:\n pds.append(i)\n md = md//i\nmul = 1\nfor i in pds:\n mul *= i\nif m != mul:\n pds.append(m//mul)\n\n#print(pds)\ncpds = collections.Counter(pds)\n#print(cpds)\nans = 1\nfor i in cpds.values():\n ans = ans*comb(n+i-1,i)%mod\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s695931220', 's409211316'] | [3700.0, 3700.0] | [32.0, 34.0] | [903, 873] |
p03253 | u846150137 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['n,m=map(int,input().split())\ni=2\ns=[]\nwhile i*i<=m:\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\ni=2\ns=[]\nwhile i**2<=m:\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\nx=m\ni=2\ns=[]\nwhile 1<m :\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\n if i*i>x:\n break\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\ni=2\ns=[]\nwhile i**2<m:\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\nx=m\ni=2\ns=[]\nwhile 1<m and i**2<=x:\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\ni=2\ns=[]\nwhile i**2>m:\n j=0\n while m % (i**(j+1))==0:\n j+=1\n if j:\n m//=i**j\n s+=[j]\n i+=1\na=1\nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n', 'n,m=map(int,input().split())\ni=2\ns=[]\nwhile i*i<=m:\n j=0\n while m % i == 0:\n m//=i\n j+=1 \n if j:\n s+=[j]\n i+=1\na=1\nif m > 1:\n s+=[1]\n \nfor v in s:\n c = 1\n for i in range(v):\n c = c * (n+i) // (1+i)\n a = a * c % (10**9+7)\nprint(a)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s034771940', 's227754612', 's373150826', 's519240034', 's596197706', 's909416655', 's381954667'] | [3064.0, 3060.0, 3064.0, 3060.0, 3064.0, 3064.0, 3064.0] | [20.0, 22.0, 33.0, 22.0, 38.0, 2103.0, 19.0] | [238, 239, 262, 238, 251, 238, 251] |
p03253 | u875361824 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ["from collections import Counter\n\n\ndef main():\n \n N, M = map(int, input().split())\n\n ans = editorial(N, M)\n print(ans)\n\n\ndef factorize(N):\n \n import math\n factors = []\n while True:\n if N % 2 == 0:\n factors.append(2)\n N //= 2\n else:\n break\n m = int(math.sqrt(N))\n i = 3\n while i <= m:\n add = False\n while True:\n if N % i == 0:\n factors.append(i)\n N //= i\n add = True\n else:\n break\n if add:\n m = int(math.sqrt(N))\n i += 2\n if N > 1:\n factors.append(N)\n return factors\n\n\ndef f(N, M):\n \n ans = 0\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n print(c)\n return ans\n\n\ndef editorial(N, M):\n i = 2\n rest_M = M\n ans = 1\n mod = 10 ** 9 + 7\n while i ** 2 <= rest_M:\n div_count = 0\n while rest_M % i == 0:\n div_count += 1\n rest_M //= i\n\n if div_count > 0:\n # N - 1 == div_count\n ans *= calc_comb(N + div_count + 1, N - 1)\n ans %= mod\n\n if rest_M != 1:\n ans *= calc_comb(N + 1 + 1, N - 1)\n ans %= mod\n\n return ans\n\n\ndef calc_comb(n, r, mod=10 ** 9 + 7):\n if r > n - r:\n return calc_comb(n, n - r)\n\n ans_mul = 1\n ans_div = 1\n\n for i in range(r):\n # n! / (n - r)!\n ans_mul = ans_mul * (n - i) % mod\n # r!\n ans_div = ans_div * (i + 1) % mod\n\n \n return ans_mul * mod_pow(ans_div, mod - 2) % mod\n\n\ndef mod_pow(a, p, mod=10 ** 9 + 7):\n if p == 0:\n return 1\n\n if p % 2 == 0:\n half_p = p // 2\n half = mod_pow(a, half_p)\n return half ** 2 % mod\n else:\n return a * mod_pow(a, p - 1) % mod\n\n\ndef mod_pow_bit(a, p, mod=10 ** 9 + 7):\n \n ans = 1\n while p > 0:\n if (p & 1) == 1:\n ans = ans * a % mod\n\n a = a ** 2 % mod\n p >>= 1\n\n return ans\n\n\ndef ref(N, M):\n \n def create_tables(N, MOD):\n \n fact_mod = [0] * (N + 1)\n simod = [0] * (N + 1)\n fact_inv_mod = [0] * (N + 1)\n\n fact_mod[0] = fact_mod[1] = 1\n simod[0] = simod[1] = 1\n fact_inv_mod[0] = fact_inv_mod[1] = 1\n\n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n simod[i] = MOD - simod[MOD % i] * (MOD // i) % MOD\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n \n \n \n\n return fact_mod, fact_inv_mod\n\n def create_fact_mod(N, MOD):\n fact_mod = [0] * (N + 1)\n fact_mod[0] = 1\n fact_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n\n return fact_mod\n\n def create_seq_inv_mod(N, MOD):\n simod = [0] * (N + 1)\n simod[0] = 1 \n simod[1] = 1\n\n \n for i in range(2, N + 1):\n simod[i] = (MOD - MOD // i) * simod[MOD % i] % MOD\n \n \n\n return simod\n\n def create_fact_inv_mod(N, MOD, simod):\n fact_inv_mod = [0] * (N + 1)\n fact_inv_mod[0] = 1\n fact_inv_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n\n return fact_inv_mod\n\n def comb_mod(N, R, fact_mod, fact_inv_mod, MOD):\n \n return fact_mod[N] * fact_inv_mod[N - R] * fact_inv_mod[R] % MOD\n\n ans = 1\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n\n \n \n # http://betrue12.hateblo.jp/entry/2018/09/24/020414\n fact_mod = create_fact_mod(N + 100, m)\n simod = create_seq_inv_mod(N + 100, m)\n fact_inv_mod = create_fact_inv_mod(N + 100, m, simod)\n\n \n \n for i in c.values():\n ans *= comb_mod(N - 1 + i, i, fact_mod, fact_inv_mod, m)\n ans %= m\n\n return ans\n\n\nif __name__ == '__main__':\n main()\n", "from collections import Counter\n\n\ndef main():\n \n N, M = map(int, input().split())\n\n ans = editorial(N, M)\n print(ans)\n\n\ndef factorize(N):\n \n import math\n factors = []\n while True:\n if N % 2 == 0:\n factors.append(2)\n N //= 2\n else:\n break\n m = int(math.sqrt(N))\n i = 3\n while i <= m:\n add = False\n while True:\n if N % i == 0:\n factors.append(i)\n N //= i\n add = True\n else:\n break\n if add:\n m = int(math.sqrt(N))\n i += 2\n if N > 1:\n factors.append(N)\n return factors\n\n\ndef f(N, M):\n \n ans = 0\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n print(c)\n return ans\n\n\ndef editorial(N, M):\n i = 2\n rest_M = M\n ans = 1\n mod = 10 ** 9 + 7\n while i ** 2 <= rest_M:\n div_count = 0\n while rest_M % i == 0:\n div_count += 1\n\n if div_count > 0:\n # N - 1 == div_count\n ans *= calc_comb(N + div_count + 1, N - 1)\n ans %= mod\n\n if rest_M != 1:\n ans *= calc_comb(N + 1 + 1, N - 1)\n ans %= mod\n\n return ans\n\n\ndef calc_comb(n, r, mod=10 ** 9 + 7):\n if r > n - r:\n return calc_comb(n, n - r)\n\n ans_mul = 1\n ans_div = 1\n\n for i in range():\n # n! / (n - r)!\n ans_mul = ans_mul * (n - i) % mod\n # r!\n ans_div = ans_div * (i + 1) % mod\n\n \n return ans_mul * mod_pow(ans_div, mod - 2) % mod\n\n\ndef mod_pow(a, p, mod=10 ** 9 + 7):\n if p == 0:\n return 1\n\n if p % 2 == 0:\n half_p = p // 2\n half = mod_pow(a, half_p)\n return half ** 2 % mod\n else:\n return a * mod_pow(a, p - 1) % mod\n\n\ndef mod_pow_bit(a, p, mod=10 ** 9 + 7):\n \n ans = 1\n while p > 0:\n if (p & 1) == 1:\n ans = ans * a % mod\n\n a = a ** 2 % mod\n p >>= 1\n\n return ans\n\n\ndef ref(N, M):\n \n def create_tables(N, MOD):\n \n fact_mod = [0] * (N + 1)\n simod = [0] * (N + 1)\n fact_inv_mod = [0] * (N + 1)\n\n fact_mod[0] = fact_mod[1] = 1\n simod[0] = simod[1] = 1\n fact_inv_mod[0] = fact_inv_mod[1] = 1\n\n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n simod[i] = MOD - simod[MOD % i] * (MOD // i) % MOD\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n \n \n \n\n return fact_mod, fact_inv_mod\n\n def create_fact_mod(N, MOD):\n fact_mod = [0] * (N + 1)\n fact_mod[0] = 1\n fact_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n\n return fact_mod\n\n def create_seq_inv_mod(N, MOD):\n simod = [0] * (N + 1)\n simod[0] = 1 \n simod[1] = 1\n\n \n for i in range(2, N + 1):\n simod[i] = (MOD - MOD // i) * simod[MOD % i] % MOD\n \n \n\n return simod\n\n def create_fact_inv_mod(N, MOD, simod):\n fact_inv_mod = [0] * (N + 1)\n fact_inv_mod[0] = 1\n fact_inv_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n\n return fact_inv_mod\n\n def comb_mod(N, R, fact_mod, fact_inv_mod, MOD):\n \n return fact_mod[N] * fact_inv_mod[N - R] * fact_inv_mod[R] % MOD\n\n ans = 1\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n\n \n \n # http://betrue12.hateblo.jp/entry/2018/09/24/020414\n fact_mod = create_fact_mod(N + 100, m)\n simod = create_seq_inv_mod(N + 100, m)\n fact_inv_mod = create_fact_inv_mod(N + 100, m, simod)\n\n \n \n for i in c.values():\n ans *= comb_mod(N - 1 + i, i, fact_mod, fact_inv_mod, m)\n ans %= m\n\n return ans\n\n\nif __name__ == '__main__':\n main()\n", "from collections import Counter\n\n\ndef main():\n \n N, M = map(int, input().split())\n\n ans = editorial(N, M)\n print(ans)\n\n\ndef factorize(N):\n \n import math\n factors = []\n while True:\n if N % 2 == 0:\n factors.append(2)\n N //= 2\n else:\n break\n m = int(math.sqrt(N))\n i = 3\n while i <= m:\n add = False\n while True:\n if N % i == 0:\n factors.append(i)\n N //= i\n add = True\n else:\n break\n if add:\n m = int(math.sqrt(N))\n i += 2\n if N > 1:\n factors.append(N)\n return factors\n\n\ndef f(N, M):\n \n ans = 0\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n print(c)\n return ans\n\n\ndef editorial(N, M):\n i = 2\n rest_M = M\n ans = 1\n mod = 10 ** 9 + 7\n while i ** 2 <= rest_M:\n div_count = 0\n while rest_M % i == 0:\n div_count += 1\n rest_M //= i\n\n if div_count > 0:\n # N - 1 == div_count\n ans *= calc_comb(N + div_count + 1, N - 1)\n ans %= mod\n\n i += 1\n\n if rest_M != 1:\n ans *= calc_comb(N + 1 + 1, N - 1)\n ans %= mod\n\n return ans\n\n\ndef calc_comb(n, r, mod=10 ** 9 + 7):\n if r > n - r:\n return calc_comb(n, n - r)\n\n ans_mul = 1\n ans_div = 1\n\n for i in range(r):\n # n! / (n - r)!\n ans_mul = ans_mul * (n - i) % mod\n # r!\n ans_div = ans_div * (i + 1) % mod\n\n \n return ans_mul * mod_pow(ans_div, mod - 2) % mod\n\n\ndef mod_pow(a, p, mod=10 ** 9 + 7):\n if p == 0:\n return 1\n\n if p % 2 == 0:\n half_p = p // 2\n half = mod_pow(a, half_p)\n return half ** 2 % mod\n else:\n return a * mod_pow(a, p - 1) % mod\n\n\ndef mod_pow_bit(a, p, mod=10 ** 9 + 7):\n \n ans = 1\n while p > 0:\n if (p & 1) == 1:\n ans = ans * a % mod\n\n a = a ** 2 % mod\n p >>= 1\n\n return ans\n\n\ndef ref(N, M):\n \n def create_tables(N, MOD):\n \n fact_mod = [0] * (N + 1)\n simod = [0] * (N + 1)\n fact_inv_mod = [0] * (N + 1)\n\n fact_mod[0] = fact_mod[1] = 1\n simod[0] = simod[1] = 1\n fact_inv_mod[0] = fact_inv_mod[1] = 1\n\n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n simod[i] = MOD - simod[MOD % i] * (MOD // i) % MOD\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n \n \n \n\n return fact_mod, fact_inv_mod\n\n def create_fact_mod(N, MOD):\n fact_mod = [0] * (N + 1)\n fact_mod[0] = 1\n fact_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n\n return fact_mod\n\n def create_seq_inv_mod(N, MOD):\n simod = [0] * (N + 1)\n simod[0] = 1 \n simod[1] = 1\n\n \n for i in range(2, N + 1):\n simod[i] = (MOD - MOD // i) * simod[MOD % i] % MOD\n \n \n\n return simod\n\n def create_fact_inv_mod(N, MOD, simod):\n fact_inv_mod = [0] * (N + 1)\n fact_inv_mod[0] = 1\n fact_inv_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n\n return fact_inv_mod\n\n def comb_mod(N, R, fact_mod, fact_inv_mod, MOD):\n \n return fact_mod[N] * fact_inv_mod[N - R] * fact_inv_mod[R] % MOD\n\n ans = 1\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n\n \n \n # http://betrue12.hateblo.jp/entry/2018/09/24/020414\n fact_mod = create_fact_mod(N + 100, m)\n simod = create_seq_inv_mod(N + 100, m)\n fact_inv_mod = create_fact_inv_mod(N + 100, m, simod)\n\n \n \n for i in c.values():\n ans *= comb_mod(N - 1 + i, i, fact_mod, fact_inv_mod, m)\n ans %= m\n\n return ans\n\n\nif __name__ == '__main__':\n main()\n", "from collections import Counter\n\n\ndef main():\n \n N, M = map(int, input().split())\n\n ans = editorial(N, M)\n print(ans)\n\n\ndef factorize(N):\n \n import math\n factors = []\n while True:\n if N % 2 == 0:\n factors.append(2)\n N //= 2\n else:\n break\n m = int(math.sqrt(N))\n i = 3\n while i <= m:\n add = False\n while True:\n if N % i == 0:\n factors.append(i)\n N //= i\n add = True\n else:\n break\n if add:\n m = int(math.sqrt(N))\n i += 2\n if N > 1:\n factors.append(N)\n return factors\n\n\ndef f(N, M):\n \n ans = 0\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n print(c)\n return ans\n\n\ndef editorial(N, M):\n i = 2\n rest_M = M\n ans = 1\n mod = 10 ** 9 + 7\n while i ** 2 <= rest_M:\n div_count = 0\n while rest_M % i == 0:\n div_count += 1\n rest_M //= i\n\n if div_count > 0:\n \n ans *= calc_comb(N + div_count - 1, div_count)\n ans %= mod\n\n i += 1\n\n if rest_M != 1:\n ans *= calc_comb(N + 1 - 1, N - 1)\n ans %= mod\n\n return ans\n\n\ndef calc_comb(n, r, mod=10 ** 9 + 7):\n if r > n - r:\n return calc_comb(n, n - r)\n\n ans_mul = 1\n ans_div = 1\n\n for i in range(r):\n # n! / (n - r)!\n ans_mul = ans_mul * (n - i) % mod\n # r!\n ans_div = ans_div * (i + 1) % mod\n\n \n return ans_mul * mod_pow(ans_div, mod - 2) % mod\n\n\ndef mod_pow(a, p, mod=10 ** 9 + 7):\n if p == 0:\n return 1\n\n if p % 2 == 0:\n half_p = p // 2\n half = mod_pow(a, half_p)\n return half ** 2 % mod\n else:\n return a * mod_pow(a, p - 1) % mod\n\n\ndef mod_pow_bit(a, p, mod=10 ** 9 + 7):\n \n ans = 1\n while p > 0:\n if (p & 1) == 1:\n ans = ans * a % mod\n\n a = a ** 2 % mod\n p >>= 1\n\n return ans\n\n\ndef ref(N, M):\n \n def create_tables(N, MOD):\n \n fact_mod = [0] * (N + 1)\n simod = [0] * (N + 1)\n fact_inv_mod = [0] * (N + 1)\n\n fact_mod[0] = fact_mod[1] = 1\n simod[0] = simod[1] = 1\n fact_inv_mod[0] = fact_inv_mod[1] = 1\n\n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n simod[i] = MOD - simod[MOD % i] * (MOD // i) % MOD\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n \n \n \n\n return fact_mod, fact_inv_mod\n\n def create_fact_mod(N, MOD):\n fact_mod = [0] * (N + 1)\n fact_mod[0] = 1\n fact_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_mod[i] = (fact_mod[i - 1] * i) % MOD\n\n return fact_mod\n\n def create_seq_inv_mod(N, MOD):\n simod = [0] * (N + 1)\n simod[0] = 1 \n simod[1] = 1\n\n \n for i in range(2, N + 1):\n simod[i] = (MOD - MOD // i) * simod[MOD % i] % MOD\n \n \n\n return simod\n\n def create_fact_inv_mod(N, MOD, simod):\n fact_inv_mod = [0] * (N + 1)\n fact_inv_mod[0] = 1\n fact_inv_mod[1] = 1\n\n \n for i in range(2, N + 1):\n fact_inv_mod[i] = (fact_inv_mod[i - 1] * simod[i]) % MOD\n\n return fact_inv_mod\n\n def comb_mod(N, R, fact_mod, fact_inv_mod, MOD):\n \n return fact_mod[N] * fact_inv_mod[N - R] * fact_inv_mod[R] % MOD\n\n ans = 1\n m = 10 ** 9 + 7\n factors = factorize(M)\n c = Counter(factors)\n\n \n \n # http://betrue12.hateblo.jp/entry/2018/09/24/020414\n fact_mod = create_fact_mod(N + 100, m)\n simod = create_seq_inv_mod(N + 100, m)\n fact_inv_mod = create_fact_inv_mod(N + 100, m, simod)\n\n \n \n for i in c.values():\n ans *= comb_mod(N - 1 + i, i, fact_mod, fact_inv_mod, m)\n ans %= m\n\n return ans\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted'] | ['s280280542', 's762292071', 's845469035', 's025662235'] | [3332.0, 3336.0, 3332.0, 3332.0] | [2104.0, 2104.0, 24.0, 24.0] | [6527, 6501, 6543, 6572] |
p03253 | u883048396 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['iN,iM = [int(x) for x in input().split()]\niD = 10**9 +7 \n\ndef fPrimeCounter(iM):\n iS = int(iM ** 0.5) + 1\n aRet = []\n for i in range(2,iS):\n iCounter = 0\n while iM % i == 0:\n iM = iM // i\n iCounter += 1\n if 0 < iCounter : aRet.append(iCounter)\n return aRet\n\n\n\ndef fBiPow(iX,iN,iD):\n iY = 1\n while iN > 0:\n if iN % 2 == 0:\n iX = iX * iX % iD\n iN = iN // 2\n else:\n iY = iX * iY % iD\n iN = iN - 1\n return iY\n\naP = fPrimeCounter(iM)\nif aP == [] :\n print (1)\nelse:\n iMax = max(aP) + iN - 1\n aM = [1] * (iMax + 1)\n \n for i in range(1,iMax + 1):\n aM[i] = aM[i-1] * i % iD\n aInvM = [1]* (iMax + 1)\n aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)\n \n for i in range(iMax,0,-1):\n aInvM[i-1] = aInvM[i]*i % iD\n\n iRet = 1\n for i in aP:\n \n iRet *= aM[i+iN-1] * aInvM[iN-1] * aInvM[i] % iD\n iRet %= iD\n print(iRet)\n', 'iN,iM = [int(x) for x in input().split()]\niD = 10**9 +7 \n\ndef fPrimeCounter(iM):\n i = 2\n iS = int(iM ** 0.5) + 1\n aRet = []\n while i < iS:\n iCounter = 0\n while iM % i == 0:\n iM = iM // i\n iCounter += 1\n if 0 < iCounter : aRet.append(iCounter)\n i += 1\n\n return aRet\n\n\ndef fBiPow(iX,iN,iD):\n iY = 1\n while iN > 0:\n if iN % 2 == 0:\n iX = iX * iX % iD\n iN = iN // 2\n else:\n iY = iX * iY % iD\n iN = iN - 1\n return iY\n\naP = fPrimeCounter(iM)\nif aP == [] :\n print (1)\nelse:\n iMax = max(aP) + iN - 1\n aM = [1] * (iMax + 1)\n \n for i in range(1,iMax + 1):\n aM[i] = aM[i-1] * i % iD\n aInvM = [1]* (iMax + 1)\n aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)\n \n for i in range(iMax,0,-1):\n aInvM[i-1] = aInvM[i]*i % iD\n\n iRet = 1\n for i in aP:\n \n iRet *= aM[i+iN-1] * aInvM[iN-1] * aInvM[i] % iD\n iRet %= iD\n print(iRet)\n', 'iN,iM = [int(x) for x in input().split()]\niD = 10**9 +7 \n\ndef fPrimeCounter(iM):\n i = 2\n iS = int(iM ** 0.5) + 1\n aRet = []\n while i < iS:\n iCounter = 0\n while iM % i == 0:\n iM = iM // i\n iCounter += 1\n if 0 < iCounter : aRet.append(iCounter)\n i += 1\n if iM == 1: break\n\n return aRet\n\n\ndef fBiPow(iX,iN,iD):\n iY = 1\n while iN > 0:\n if iN % 2 == 0:\n iX = iX * iX % iD\n iN = iN // 2\n else:\n iY = iX * iY % iD\n iN = iN - 1\n return iY\n\naP = fPrimeCounter(iM)\nif aP == [] :\n print (1)\nelse:\n iMax = max(aP) + iN - 1\n aM = [1] * (iMax + 1)\n \n for i in range(1,iMax + 1):\n aM[i] = aM[i-1] * i % iD\n aInvM = [1]* (iMax + 1)\n aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)\n \n for i in range(iMax,0,-1):\n aInvM[i-1] = aInvM[i]*i % iD\n\n iRet = 1\n for i in aP:\n \n iRet *= aM[i+iN-1] * aInvM[iN-1] * aInvM[i] % iD\n iRet %= iD\n print(iRet)\n', '\niN,iM = [int(x) for x in input().split()]\niD = 10**9 +7 \n\ndef fPrimeCounter(iM):\n iS = int(iM ** 0.5) + 1\n aRet = []\n for i in range(2,iS + 1):\n iCounter = 0\n while iM % i == 0:\n iM /= i\n iCounter += 1\n if 0 < iCounter : aRet.append(iCounter)\n if iM == 1 : break\n if 1 < iM : aRet.append(1)\n return aRet\ndef fnCr(iN,iR,iD):\n iR = min(iR,iN-iR)\n if iR == 0 :\n return 1\n elif iR == 1 :\n return iN\n return (iN % iD) * pow(iR,iD-2,iD) * fnCr(iN-1,iR-1,iD) % iD\n\naP = fPrimeCounter(iM)\n#if aP == []:\n# print(1)\n# exit()\niRet = 1\nfor i in aP:\n \n iRet *= fnCr(i+iN-1,i,iD)\niRet %= iD\nprint(iRet)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s064455348', 's420285751', 's524120694', 's771828779'] | [10868.0, 10996.0, 10868.0, 3064.0] | [88.0, 91.0, 87.0, 24.0] | [1119, 1119, 1145, 717] |
p03253 | u894258749 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['inpl = lambda: list(map(int,input().split()))\nMOD = 10**9 + 7\nN, M = inpl()\n\ndef factorize(n):\n prime_list = []\n factorize_list = []\n i = 2\n while i <= n:\n for p in prime_list:\n if i % p == 0:\n break\n else:\n prime_list.append(i)\n k = 0\n while n % i == 0:\n n //= i\n k += 1\n factorize_list.append(k)\n return(factorize_list)\n\nans = 1\nfor k in factorize(M):\n h = 1\n L = k + N\n k = min(k,N)\n for j in range(k):\n h *= L-j\n for j in range(k):\n h //= j+1\n h //= MOD\n ans *= h\n ans //= MOD\n\nprint(ans)', 'inpl = lambda: list(map(int,input().split()))\nMOD = 10**9 + 7\nN, M = inpl()\n \ndef factorize(n):\n factorize_list = []\n i = 2\n while i*i <= n:\n k = 0\n while n % i == 0:\n n //= i\n k += 1\n if k > 0:\n factorize_list.append(k)\n i += 1\n if n > 1:\n factorize_list.append(1)\n return(factorize_list)\n\ndef H(n,k):\n h = 1\n L = n + k - 1\n k = min(n-1,k)\n for j in range(k):\n h *= L-j\n for j in range(k):\n h //= j+1\n return h\n\nans = 1\nfor k in factorize(M):\n ans *= H(N,k) % MOD\n ans %= MOD\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s546855300', 's034333234'] | [3064.0, 3064.0] | [2104.0, 19.0] | [563, 537] |
p03253 | u895515293 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['from math import factorial, sqrt\nN,M=map(int,input().split())\nprms={}\ntmp=M\nfor i in range(2, int(sqrt(M))+2):\n while not tmp%i:\n if not i in prms:\n prms[i]=1\n else:\n prms[i]+=1\n tmp //= i\nif tmp != 1:\n prms[tmp] = 1\n\nprint(prms)\n\nres=1\ndef cmb(a,b):\n res=1\n if a - b < b:\n b = a-b\n for i in range(b):\n res *= (a-i)\n res //= (i+1)\n return res\n\nfor p, cnt in prms.items():\n res *= cmb(cnt+N-1, cnt)\n res %= 1000000007\n\nprint(res % 1000000007)', 'from math import factorial, sqrt\nN,M=map(int,input().split())\nprms={}\ntmp=M\nfor i in range(2, int(sqrt(M))+2):\n while not tmp%i:\n if not i in prms:\n prms[i]=1\n else:\n prms[i]+=1\n tmp //= i\nif tmp != 1:\n prms[tmp] = 1\n\n# print(prms)\n\nres=1\ndef cmb(a,b):\n res=1\n if a - b < b:\n b = a-b\n for i in range(b):\n res *= (a-i)\n res //= (i+1)\n return res\n\nfor p, cnt in prms.items():\n res *= cmb(cnt+N-1, cnt)\n res %= 1000000007\n\nprint(res % 1000000007)\n'] | ['Wrong Answer', 'Accepted'] | ['s578779448', 's657147148'] | [3064.0, 3064.0] | [21.0, 21.0] | [529, 532] |
p03253 | u901098617 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\n\ndef isprime(n):\n if(n<2):\n return False\n for i in range(2,int(n**0.5)+1):\n if(n%i==0):\n return False\n return True\n\ndef primelist(n):\n return [i for i in range(n) if isprime(i)]\n\ndef factor(n):\n f = {}\n for p in primelist(int(n**0.5)+1):\n while(n % p == 0):\n f[p] = f.get(p, 0) + 1\n n //= p\n if(n != 1):\n f[n] = 1\n return f\n\n\n\n# (n+a)! / (n!a!)\nn,m=map(int, input().split())\nf = factor(m)\nans = 1\nfor k,v in f.items():\n ans *= (math.factorial(n-1+v)//(math.factorial(n-1)*math.factorial(v)))\n ans %= (int(1e9+7))\n\nprint(f)\nprint(ans)\n', 'import math\n\ndef factorize(n):\n ret={}\n i = 2\n while n >= i**2:\n cnt = 0\n while n % i == 0:\n n //= i\n cnt += 1\n if cnt != 0:\n ret[i] = cnt\n i += 1\n if n != 1:\n ret[n] = 1\n return ret\n\ndef combination(n,r):\n ret = 1\n r = min(r, n-r)\n for i in range(n-r+1, n+1):\n ret *= i\n for i in range(1, r+1):\n ret //= i\n return ret\n\n\n\n\n# n-1+a C n-1 \nn,m=map(int, input().split())\nf = factorize(m)\nans = 1\nfor k,v in f.items():\n ans *= combination(n-1+v, v)\n ans %= (int(1e9+7))\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s867777269', 's052007199'] | [4424.0, 3188.0] | [2104.0, 21.0] | [729, 688] |
p03253 | u903460784 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['# 2 6=>4 (1,6)*2,(2,3)*2\n# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3\nimport math\ndef comb(a,b): # aCb\n return math.factorial(a)//math.factorial(a-b)//math.factorial(b)\n\nn,m=map(int,input().split())\nrootm=int(m**0.5)\ndivisor={}\ntmp=m\nfor i in range(2,m+1):\n while tmp%i==0:\n tmp//=i\n divisor.setdefault(i,0)\n divisor[i]+=1\n if tmp==1:\n break\nprint(divisor)\ncnt=1\nfor key in divisor:\n tmp=0\n for c in range(1,divisor[key]+1):\n tmp+=comb(n,c)\n cnt*=tmp\nprint(cnt%1000000007)\n', '# 2 6=>4 (1,6)*2,(2,3)*2\n# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3\nimport math\ndef comb(a,b): # aCb\n return math.factorial(a)//math.factorial(a-b)//math.factorial(b)\n\nn,m=map(int,input().split())\nrootm=int(m**0.5)\ndivisor={}\ntmp=m\nfor i in range(2,m+1):\n while tmp%i==0:\n tmp//=i\n divisor.setdefault(i,0)\n divisor[i]+=1\n if tmp==1:\n break\nprint(divisor)\ncnt=1\nfor key in divisor:\n tmp=0\n for c in range(1,divisor[key]+1):\n tmp+=comb(n,c)\n cnt*=tmp\nprint(cnt%1000000007)\n', '# 2 6=>4 (1,6)*2,(2,3)*2\n# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3\nimport math\ndef comb(a,b): # aCb\n return math.factorial(a)//math.factorial(a-b)//math.factorial(b)\n\nn,m=map(int,input().split())\ndivisor={}\ntmp=m\n\ni=2\nwhile i*i<=m:\n while tmp%i==0:\n tmp//=i\n divisor.setdefault(i,0)\n divisor[i]+=1\n # if tmp==1:\n # break\n i+=1\nif tmp>1:\n divisor[tmp]=1\nprint(divisor)\ncnt=1\nfor key in divisor:\n c=divisor[key]\n cnt*=comb(c+n-1,c)\nprint(cnt%1000000007)\n', '\n# 2 6=>4 (1,6)*2,(2,3)*2\n# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3\n# import math\n\n# return math.factorial(a)//math.factorial(a-b)//math.factorial(b)\ndef comb(a,b): # aCb\n b=min(b,a-b)\n result=1\n for i in range(a,a-b,-1):\n result*=i\n for i in range(1,b+1):\n result//=i\n return result\n\nn,m=map(int,input().split())\ndivisor={}\ntmp=m\n\n# while tmp%i==0:\n# tmp//=i\n\n\n# if tmp==1:\n# break\ni=2\nwhile i*i<=m:\n while tmp%i==0:\n tmp//=i\n divisor.setdefault(i,0)\n divisor[i]+=1\n i+=1\nif tmp>1:\n divisor[tmp]=1\n\ncnt=1\nfor key in divisor:\n c=divisor[key]\n cnt*=comb(c+n-1,c)\nprint(cnt%1000000007)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s349839984', 's576755358', 's597341089', 's508679151'] | [4392.0, 4396.0, 4388.0, 3064.0] | [2107.0, 2104.0, 2104.0, 25.0] | [533, 533, 535, 845] |
p03253 | u920299620 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['def com(n,m):\n if(n-m < m):\n m=n-m\n result=1\n mylist=[i for i in range(1,m+1)]\n j=1\n for i in range(1,m+1):\n result*=(n+1-i)\n if(j<m):\n while(result%mylist[j]==0):\n result//=mylist[j]\n j+=1\n if(j>=m):\n break\n return result\n\nN,M=map(int,input().split())\nsoinsuubunkai={}\ntmp=1\ni=2\nM\nwhile(i*2 <=M):\n if(M%i==0):\n if(i in soinsuubunkai):\n soinsuubunkai[i]+=1\n else:\n soinsuubunkai[i]=1\n M//=i\n else:\n i+=1\n\ntmp=1\nfor k in list(soinsuubunkai.values()):\n tmp*=com(k+N-1,k)\n tmp%=10**9+7\nprint(tmp)', 'def com(n,m):\n if(n-m < m):\n m=n-m\n result=1\n mylist=[i for i in range(1,m+1)]\n j=1\n for i in range(1,m+1):\n result*=(n+1-i)\n if(j<m):\n while(result%mylist[j]==0):\n result//=mylist[j]\n j+=1\n if(j>=m):\n break\n return result\n\nN,M=map(int,input().split())\nsoinsuubunkai={}\ntmp=1\ni=2\n_M=M\nwhile(i <=M and i**2 <=_M):\n if(M%i==0):\n if(i in soinsuubunkai):\n soinsuubunkai[i]+=1\n else:\n soinsuubunkai[i]=1\n M//=i\n else:\n i+=1\n\ntmp=1\nfor k in list(soinsuubunkai.values()):\n tmp*=com(k+N-1,k)\n tmp%=10**9+7\nprint(tmp)', 'N,M=map(int,input().split())\nsoinsuubunkai={}\ntmp=1\ni=2\n_M=M\nwhile(i <=M and i**2 <=_M):\n if(M%i==0):\n if(i in soinsuubunkai):\n soinsuubunkai[i]+=1\n else:\n soinsuubunkai[i]=1\n M//=i\n else:\n i+=1\n\ntmp=1\nfor k in list(soinsuubunkai.values()):\n tmp*=com(k+N-1,k)\n tmp%=10**9+7\nprint(tmp)', 'def com(n,m):\n if(n-m < m):\n m=n-m\n result=1\n mylist=[i for i in range(1,m+1)]\n j=1\n for i in range(1,m+1):\n result*=(n+1-i)\n if(j<m):\n while(result%mylist[j]==0):\n result//=mylist[j]\n j+=1\n if(j>=m):\n break\n return result\n\ndef yakusuu(i,m):\n _i=i\n while(i**2<=m):\n if(m%i==0):\n return i\n else:\n i+=1\n for j in range(_i-1,0,-1):\n if(m%j==0):\n break\n return m//j\n \n\nN,M=map(int,input().split())\nsoinsuubunkai={}\ntmp=2\ni=2\n_M=M\nwhile(tmp <=M):\n tmp=yakusuu(tmp,M)\n\n if(tmp in soinsuubunkai):\n soinsuubunkai[tmp]+=1\n else:\n soinsuubunkai[tmp]=1\n M//=tmp\n if(M==1):\n break\n\n\ntmp=1\nfor k in list(soinsuubunkai.values()):\n tmp*=com(k+N-1,k)\n tmp%=10**9+7\nprint(tmp)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s171697662', 's511802515', 's804186925', 's832466071'] | [3064.0, 3064.0, 3064.0, 3192.0] | [2104.0, 30.0, 30.0, 19.0] | [669, 684, 346, 884] |
p03253 | u922901775 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import operator as op\nfrom itertools import groupby\nfrom functools import reduce\n\nNN = 10 ** 9 + 7\n\n\ndef prime_factors(n):\n i = 2\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n yield i\n if n > 1:\n yield i\n\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\n\nN, M = map(int, input().split())\nresult = 1\n\nfor k, g in groupby(prime_factors(M)):\n result = result * ncr(len(list(g)) + N - 1, N - 1)\n if result > NN:\n result = result % NN\n\nprint(result)\n', 'import operator as op\nfrom itertools import groupby\nfrom functools import reduce\n\nNN = 10 ** 9 + 7\n\n\ndef prime_factors(n):\n i = 2\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n yield i\n if n > 1:\n yield n\n\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\n\nN, M = map(int, input().split())\nresult = 1\n\nfor k, g in groupby(prime_factors(M)):\n result = result * ncr(len(list(g)) + N - 1, N - 1)\n if result > NN:\n result = result % NN\n\nprint(result)\n'] | ['Wrong Answer', 'Accepted'] | ['s673426024', 's533862339'] | [3696.0, 3568.0] | [97.0, 23.0] | [638, 638] |
p03253 | u938486382 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ["N, M = list(map(int, input().split(' ')))\nMOD = int(1e9 + 7)\nseeds = []\np = 2\nwhile p*p > M:\n while M % p == 0:\n seeds.append(p)\n M = M // p\n p += 1\nif M > 1:\n seeds.append(M)\n \ndef comb(n, k):\n ans = 1\n for i in range(1, k + 1):\n ans = (ans * (n + 1 - i) // i)\n return ans\n \nans = 1\nhogehoge = set(seeds)\nfor i in hogehoge:\n a_ct = seeds.count(i)\n ans = (ans * comb(a_ct + N-1, min(a_ct, N-1))) % MOD\nprint(ans)\n", "import math\nN, M = list(map(int, input().split(' ')))\nMOD = int(1e9 + 7)\nprimes = []\nif M % 2 == 0:\n primes.append(2)\ndef is_prime(n):\n for i in range(len(primes)):\n if n % primes[i] == 0:\n return False\n return True\nfor i in range(3, int(1e5)):\n if is_prime(i):\n primes.append(i)\n\nseeds = []\nfor p in primes:\n while M % p == 0:\n seeds.append(p)\n M = M // p\n\ndef comb(n, k):\n ans = 1\n for i in range(1, k + 1):\n ans = (ans * (n + 1 - i) // i)\n return ans\n\nans = comb(len(seeds)-1, N-1)\n\n\n\n\n\n\n# (a+b)!/(a!b!) = (a+b)Ca = (a+b)Cb\n\nans = 1\nhogehoge = set(seeds)\nfor i in hogehoge:\n a_ct = seeds.count(i)\n ans = (ans * comb(a_ct + N-1, min(a_ct, N-1))) % MOD\nprint(ans)\n", "N, M = list(map(int, input().split(' ')))\nMOD = int(1e9 + 7)\nseeds = []\np = 2\nwhile p*p <= M:\n while M % p == 0:\n seeds.append(p)\n M = M // p\n p += 1\nif M > 1:\n seeds.append(M)\n \ndef comb(n, k):\n ans = 1\n for i in range(1, k + 1):\n ans = (ans * (n + 1 - i) // i)\n return ans\n \nans = 1\nhogehoge = set(seeds)\nfor i in hogehoge:\n a_ct = seeds.count(i)\n ans = (ans * comb(a_ct + N-1, min(a_ct, N-1))) % MOD\nprint(ans)\n"] | ['Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s633371825', 's847166618', 's442081327'] | [3064.0, 3336.0, 3064.0] | [2103.0, 2104.0, 19.0] | [430, 1069, 431] |
p03253 | u942915776 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import math\n\nN, M = map(int, input().split())\nyakusu = dict()\nsqrt_M = int(math.sqrt(M))\nfor i in range(2, sqrt_M + 1):\n count = 0\n while M % i == 0:\n count += 1\n M //= i\n if count > 0:\n yakusu[i] = count\nif M > 1:\n yakusu[M] = 1\n\n\ndef nCr(n, r):\n if r > n - r:\n return nCr(n, n - r)\n ans = 1\n for i in range(n, n-r, -1):\n ans *= i\n for i in range(1, r+1):\n ans //= i\n return ans\n\n\nans = 1\nMOD = 10 ** 9 + 7\nfor n in yakusu.values():\n print(n)\n ans *= nCr(n + N - 1, N - 1)\n ans %= MOD\n\nprint(ans)\n', 'import math\n\nN, M = map(int, input().split())\nyakusu = dict()\nsqrt_M = int(math.sqrt(M))\nfor i in range(2, sqrt_M + 1):\n count = 0\n while M % i == 0:\n count += 1\n M //= i\n if count > 0:\n yakusu[i] = count\nif M > 1:\n yakusu[M] = 1\n\n\ndef nCr(n, r):\n if r > n - r:\n return nCr(n, n - r)\n ans = 1\n for i in range(n, n-r, -1):\n ans *= i\n for i in range(1, r+1):\n ans //= i\n return ans\n\n\nans = 1\nMOD = 10 ** 9 + 7\nfor n in yakusu.values():\n ans *= nCr(n + N - 1, N - 1)\n ans %= MOD\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s305985460', 's828922234'] | [3064.0, 3064.0] | [23.0, 23.0] | [576, 563] |
p03253 | u944209426 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import collections\ndef primes(n):\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 return [i for i in range(n + 1) if is_prime[i]]\ndef kaijo(x):\n a=1\n for i in range(1,x+1):\n a*=i\n return a\ndef perm(x,y):\n ans=1\n for i in range(x,x-y,-1):\n ans*=i\n return ans\ndef com(x,y):\n return perm(x,min(y,x-y))//kaijo(min(y,x-y))\n\nnn,m=map(int,input().split())\nx=primes(int(m**0.5))\ny=[]\nz=m\nfor t in x:\n while(z%t==0):\n y.append(t)\n z//=t\nif len(y)==0 and m>1:\n y.append(m)\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+nn-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef com(x,y):\n t=1\n for i in range(y):\n t*=x-i\n for i in range(y):\n t//=i+1\n return t\nn,m=map(int,input().split())\ny=[]\nz=m\nt=2\nwhile(t<=m):\n while(z%t==0):\n y.append(t)\n z//=t\n t+=1\n if t<m and t**2>m:\n t=m\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+n-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef primes(n):\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 return [i for i in range(n + 1) if is_prime[i]]\ndef kaijo(x):\n a=1\n for i in range(1,x+1):\n a*=i\n return a\ndef perm(x,y):\n ans=1\n for i in range(x,x-y,-1):\n ans*=i\n return ans\ndef com(x,y):\n return perm(x,min(y,x-y))//kaijo(min(y,x-y))\n\nnn,m=map(int,input().split())\nx=primes(int(m**0.5+1))\ny=[]\nz=m\nfor t in x:\n while(z%t==0):\n z//=t\n y.append(t)\nc=list(collections.Counter(y).values())\n\nans=1\nfor t in c:\n ans*=com(t+nn-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef kaijo(x):\n a=1\n for i in range(1,x+1):\n a*=i\n return a\ndef perm(x,y):\n ans=1\n for i in range(x,x-y,-1):\n ans*=i\n return ans\ndef com(x,y):\n return perm(x,min(y,x-y))//kaijo(min(y,x-y))\n\nnn,m=map(int,input().split())\ny=[]\nz=m\nt=2\nwhile(t**2<m):\n while(z%t==0):\n y.append(t)\n z//=t\n t+=1\nif len(y)==0 and m>1:\n y.append(m)\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+nn-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef kaijo(x):\n a=1\n for i in range(1,x+1):\n a*=i\n return a\ndef perm(x,y):\n ans=1\n for i in range(x,x-y,-1):\n ans*=i\n return ans\ndef com(x,y):\n return perm(x,min(y,x-y))//kaijo(min(y,x-y))\n\nnn,m=map(int,input().split())\nx=primes(int(m**0.5+1))\ny=[]\nz=m\nt=1\nwhile(t**2<=m):\n t+=1\n while(z%t==0):\n y.append(t)\n z//=t\nif len(y)==0 and m>1:\n y.append(m)\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+nn-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef kaijo(x):\n a=1\n for i in range(1,x+1):\n a*=i\n return a\ndef perm(x,y):\n ans=1\n for i in range(x,x-y,-1):\n ans*=i\n return ans\ndef com(x,y):\n return perm(x,min(y,x-y))//kaijo(min(y,x-y))\n\nnn,m=map(int,input().split())\ny=[]\nz=m\nt=2\nwhile(t<=m):\n while(z%t==0):\n y.append(t)\n z//=t\n t+=1\n if t<m and t**2>m:\n t=m\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+nn-1,t)\n ans%=mod\nprint(ans)', 'import collections\ndef com(x,y):\n y=min(y,x-y)\n a=1\n for i in range(x,x-y,-1):\n a*=i\n b=1\n for i in range(1,y+1):\n b*=i\n return a//b\nn,m=map(int,input().split())\ny=[]\ni=2\nz=m\nwhile(i*i<=m):\n if m%i:\n i+=1\n else:\n m//=i\n y.append(i)\nif m>1:\n y.append(m)\nc=collections.Counter(y).values()\nans=1\nmod=10**9+7\nfor t in c:\n ans*=com(t+n-1,t)\n ans%=mod\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s017303065', 's073273593', 's142882872', 's215762352', 's454263024', 's529242727', 's896568006'] | [3692.0, 3444.0, 3692.0, 3316.0, 3316.0, 3316.0, 3316.0] | [25.0, 39.0, 26.0, 35.0, 20.0, 39.0, 23.0] | [826, 392, 785, 511, 536, 506, 424] |
p03253 | u952708174 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | [' if M == 1:\n return 1\n\n def prime_factorization_power_list(n):\n i = 2\n table = {}\n while i**2 <= n:\n table[i] = 0\n while n % i == 0:\n table[i] += 1\n n //= i\n if table[i] == 0:\n table.pop(i)\n i += 1\n if n > 1:\n table[n] = 1\n return table\n\n MOD = 10**9 + 7\n prime_m = prime_factorization_power_list(M)\n b_max = max(prime_m.values()) \n \n factorial = [1] * (b_max + N) \n for k in range(1, b_max + N - 1):\n factorial[k + 1] = (factorial[k] * (k + 1)) % MOD\n \n fact_inv = [1] * (b_max + N)\n fact_inv[b_max + N - 1] = pow(factorial[b_max + N - 1], MOD - 2, MOD)\n for k in range(b_max + N - 1, 0, -1):\n fact_inv[k - 1] = (fact_inv[k] * k) % MOD\n\n def nCr(n, r, M):\n if n < 0 or r < 0 or n < r:\n return 0\n else:\n return (factorial[n] * fact_inv[r] * fact_inv[n - r]) % M\n\n ans = 1\n for b in prime_m.values():\n ans = (ans * nCr(b + N - 1, b, MOD)) % MOD\n\n return ans\n\nN, M = [int(i) for i in input().split()]\nprint(d_factorization(N, M))', "def d_factorization(MOD=10**9 + 7):\n N, M = [int(i) for i in input().split()]\n\n def prime_factorization_dict(n):\n if n == 1:\n return {2: 0} \n i, table = 2, {}\n while i**2 <= n:\n table[i] = 0\n while n % i == 0:\n table[i] += 1\n n //= i\n if table[i] == 0:\n table.pop(i)\n i += 1\n if n > 1:\n table[n] = 1\n return table\n\n class Combination(object):\n \n __slots__ = ['mod', 'factorial', 'inverse']\n\n def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):\n fac, inv = [1], []\n fac_append, inv_append = fac.append, inv.append\n\n for i in range(1, max_val_arg + 1):\n fac_append(fac[-1] * i % mod)\n\n inv_append(pow(fac[-1], mod - 2, mod))\n\n for i in range(max_val_arg, 0, -1):\n inv_append((inv[-1] * i) % mod)\n\n self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]\n\n def combination(self, n, r):\n if n < 0 or r < 0 or n < r:\n return 0\n return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod\n\n def combination_with_repetition(self, n, r):\n return self.combination(n + r - 1, r)\n\n prime_m = prime_factorization_dict(M)\n h = Combination(max(prime_m.values()) + N - 1).combination_with_repetition\n ans = 1\n for b in prime_m.values():\n ans = (ans * h(N, b)) % MOD\n return ans\n\nprint(d_factorization())"] | ['Runtime Error', 'Accepted'] | ['s538821602', 's142972337'] | [2940.0, 11824.0] | [17.0, 54.0] | [1375, 1702] |
p03253 | u969190727 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['import collections\nimport math\nn,m=map(int,input().split())\nflag=0\nP=[]\np=m\nwhile flag==0:\n cur=p\n for i in range(2,int(p**0.5)+1):\n if p%if==0:\n P.append(i)\n p//=i\n break\n if p==cur:\n P.append(p)\n flag=1\nc=collections.Counter(P)\nPrimes=set(P)\ndef f(i):\n return math.factorial(i)\ndef fn(i):\n return f(n+i-1)//(f(n-1)*f(i))\nans=1\nfor p in Primes:\n ans*=fn(c[p])\nprint(ans) ', 'import sys\ninput=lambda: sys.stdin.readline().rstrip()\nmod=10**9+7\nn,m=map(int,input().split())\nn_max=2*(10**5+1)\nF,FI=[0]*(n_max+1),[0]*(n_max+1)\nF[0],FI[0]=1,1\nfor i in range(n_max):\n F[i+1]=(F[i]*(i+1))%mod\nFI[n_max-1]=pow(F[n_max-1],mod-2,mod)\nfor i in reversed(range(n_max-1)):\n FI[i]=(FI[i+1]*(i+1))%mod\ndef comb(x,y):\n return (F[x]*FI[x-y]*FI[y])%mod\n\npf={}\nfor i in range(2,int(m**0.5)+1):\n while m%i==0:\n pf[i]=pf.get(i,0)+1\n m//=i\nif m>1:\n pf[m]=1\n\nans=1\nfor k in pf.keys():\n ans=(ans*comb(n-1+pf[k],pf[k]))%mod\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s905339394', 's306633287'] | [2940.0, 18932.0] | [18.0, 180.0] | [402, 544] |
p03253 | u984276646 | 2,000 | 1,048,576 | You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. | ['N, M = map(int, input().split())\nmod = int(1e+9 + 7)\na = mod - 2\nax = []\nwhile a != 0:\n ax = [a%2] + ax[:]\n a //= 2\ndef inved(x):\n y = 1\n for i in range(len(ax)):\n if ax[i] == 1:\n y *= x\n y %= mod\n if i != len(ax) - 1:\n y *= y\n y %= mod\n return y\n\np, n = 2, M\nL = []\ndig = 1\nwhile n != 1:\n i = 0\n while n % p == 0:\n n //= p\n dig *= p\n i += 1\n if i != 0:\n L.append([p, i])\n p += 1\n if p > int(M**(1/2)) and dig != M:\n if L != []:\n L.append([M//dig, 1])\n else:\n L.append([M, 1])\n break\nprint(L)\nif M == 1:\n print(1)\nelse:\n prod = 1\n mm = max(x[1] for x in L)\n fact = [1]\n for i in range(N + mm - 1):\n fact.append((fact[i] * (i + 1)) % mod)\n invf = inved(fact[N - 1])\n for i in L:\n pad = (fact[N - 1 + i[1]] * inved(fact[i[1]]) * invf) % mod\n prod *= pad\n prod %= mod\n print(prod)', 'N, M = map(int, input().split())\nmod = int(1e+9 + 7)\na = mod - 2\nax = []\nwhile a != 0:\n ax = [a%2] + ax[:]\n a //= 2\ndef inved(x):\n y = 1\n for i in range(len(ax)):\n if ax[i] == 1:\n y *= x\n y %= mod\n if i != len(ax) - 1:\n y *= y\n y %= mod\n return y\n\np, n = 2, M\nL = []\ndig = 1\nwhile n != 1:\n i = 0\n while n % p == 0:\n n //= p\n dig *= p\n i += 1\n if i != 0:\n L.append([p, i])\n p += 1\n if p > int(M**(1/2)) and dig != M:\n if L != []:\n L.append([M//dig, 1])\n else:\n L.append([M, 1])\n break\n\nif M == 1:\n print(1)\nelse:\n prod = 1\n mm = max(x[1] for x in L)\n fact = [1]\n for i in range(N + mm - 1):\n fact.append((fact[i] * (i + 1)) % mod)\n invf = inved(fact[N - 1])\n for i in L:\n pad = (fact[N - 1 + i[1]] * inved(fact[i[1]]) * invf) % mod\n prod *= pad\n prod %= mod\n print(prod)'] | ['Wrong Answer', 'Accepted'] | ['s931951109', 's043246687'] | [7108.0, 7212.0] | [69.0, 70.0] | [864, 856] |
p03254 | u006167882 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\ncount = 0\nfor i in range(N):\n x = x - a[i]\n if x >= 0:\n count += 1 \n\nprint(count)', 'N, x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\ncount = 0\nfor i in range(N):\n x = x - a[i]\n if x < 0:\n break\n count += 1 \nif x > 0:\n count -= 1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s012615873', 's331649831'] | [3060.0, 3060.0] | [17.0, 17.0] | [171, 204] |
p03254 | u007886915 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['# -*- coding: utf-8 -*-\nimport sys\nimport itertools\nimport math\n#w=input()\nN, x=input().split()\nN=int(N)\nx=int(x)\n#x=[]\n#y=[]\n\n\n\n\n#l=0\n#t[0],x[0],y[0]=[0, 0, 0]\n\n\n# t[i+1], x[i+1], y[i+1] = map(int, input().split())\nchild_i = list(map(int, input().split()))\n#w_len=len(w)\n#w_list=list(w)\n#print(len(w_list))\n#print(w_list)\nchild_il=sorted(child_i)\n\ni=0\nj=0\nfor i in range(N):\n x=x-child_il[i]\n if x < 0:\n print(j)\n sys.exit()\n else:\n j=j+1\n\nprint(j)\n', '# -*- coding: utf-8 -*-\nimport sys\nimport itertools\nimport math\n#w=input()\nN, x=input().split()\nN=int(N)\nx=int(x)\n#x=[]\n#y=[]\n\n\n\n\n#l=0\n#t[0],x[0],y[0]=[0, 0, 0]\n\n\n# t[i+1], x[i+1], y[i+1] = map(int, input().split())\nchild_i = list(map(int, input().split()))\n#w_len=len(w)\n#w_list=list(w)\n#print(len(w_list))\n#print(w_list)\nchild_il=sorted(child_i)\n\ni=0\nj=0\nfor i in range(N):\n x=x-child_il[i]\n if x < 0:\n print(j)\n sys.exit()\n elif i==N-1 and x!=0:\n break \n else:\n j=j+1\n\nprint(j)\n'] | ['Wrong Answer', 'Accepted'] | ['s957999462', 's912895492'] | [3060.0, 3060.0] | [17.0, 18.0] | [871, 905] |
p03254 | u013202780 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\nl1=list(map(int,input().split()))\nl1.sort()\nans=0\nwhile len(l1)>0:\n t1=l1.pop(0)\n if x>=t1:\n x-=t1\n ans+=1\nprint (ans)', 'n,x=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort()\nans=ac=0\nfor i in l:\n ac+=i\n if x>=ac:\n ans+=1\nif ac<x:\n ans-=1\nprint (ans)'] | ['Wrong Answer', 'Accepted'] | ['s069828345', 's441188342'] | [3060.0, 3060.0] | [17.0, 17.0] | [167, 162] |
p03254 | u013408661 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\na.reverse()\nans=0\nwhile x>0:\n if len(a)==0:\n break\n if a[-1]<=x:\n x-=a.pop()\n ans+=1\n else:\n break\nprint(ans)', 'n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\na.reverse()\nans=0\nwhile x>0:\n if x==0:\n break\n elif len(a)==0:\n ans-=1\n break\n if a[-1]<=x:\n x-=a.pop()\n ans+=1\n else:\n break\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s190628602', 's375536905'] | [3064.0, 3060.0] | [18.0, 18.0] | [195, 229] |
p03254 | u017810624 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\nb=a[0]\nif b>x:c=0\nelse:c=1\nfor i in range(n):\n b=b+a[i]\n if b>x:\n break\n c+=1\nif c>n:c=n\nprint(c)', 'n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\nc=0\nfor i in range(n-1):\n x=x-a[i]\n if x>=0:c+=1\nif x==a[n-1]:c+=1\nprint(c)'] | ['Wrong Answer', 'Accepted'] | ['s106340133', 's990709897'] | [3316.0, 3316.0] | [23.0, 21.0] | [174, 148] |
p03254 | u021548497 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n, x = map(int, input().split())\na = [int(x) for x in input().split()]\na.sort()\nans = 0\nfor i in range(n):\n if a[i] <= x:\n ans += 1\n x -= a[i]\n else:\n break\nprint(ans)', 'n, x = map(int, input().split())\na = [int(x) for x in input().split()]\na.sort()\nans = 0\nfor i in range(n):\n if a[i] <= x:\n ans += 1\n x -= a[i]\n if i == n-1 and x != 0:\n ans -= 1\n else:\n break\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s380653812', 's989300170'] | [2940.0, 3060.0] | [17.0, 17.0] | [178, 221] |
p03254 | u022215787 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n, x = map(int, input().split())\na_l = list(map(int, input().split()))\na_l = sorted(a_l)\nans = 0\nfor a in a_l:\n x = x-a\n if x < 0:\n break\n ans += 1\nprint(ans)', 'n, x = map(int, input().split())\na_l = list(map(int, input().split()))\na_l = sorted(a_l)\nans = 0\nfor a in a_l:\n x = x-a\n if x < 0:\n break\n ans += 1\nif x > 0:\n ans -= 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s665087973', 's452896593'] | [9124.0, 9184.0] | [30.0, 26.0] | [174, 197] |
p03254 | u038107109 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\nchild_list = list(map(int, input().split()))\n\ncount = 0\nfor child in sorted(child_list):\n x -= child\n if x < 0:\n break\n count += 1\n\n\nprint(count)', 'N, x = map(int, input().split())\nchild_list = list(map(int, input().split()))\n\ncount = 0\nfor child in sorted(child_list):\n x -= child\n if x < 0:\n break\n count += 1\n\ncount = N if count >= N else count\nprint(count)', 'N, x = map(int, input().split())\nchild_list = list(map(int, input().split()))\n\ncount = 0\nfor i, child in enumerate(sorted(child_list)):\n x -= child\n if x < 0:\n break\n if (i == len(child_list) - 1) and x != 0:\n break\n count += 1\n\nprint(count)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s392830583', 's849336529', 's557861770'] | [9104.0, 9100.0, 9132.0] | [27.0, 26.0, 28.0] | [184, 218, 251] |
p03254 | u039860745 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort()\nsum = 0\nans = 0\nfor i,a in enumerate(A):\n sum += a\n\n if sum == x:\n ans = i + 1\n break\n elif sum > x:\n break\n ans = i + 1\n\n\nprint(ans)\n', 'N, x = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort()\nsum = 0\nans = 0\nfor i,a in enumerate(A):\n sum += a\n\n if sum == x:\n ans = i + 1\n break\n elif sum > x:\n break\n elif i + 1 == N and sum < x:\n ans = i\n break\n ans = i + 1\n\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s993721923', 's113091362'] | [9088.0, 9092.0] | [29.0, 29.0] | [245, 308] |
p03254 | u041382530 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N,x=map(int,input().split())\ncount=0\nc=list(map(int,input().split()))\nc.sort()\nfor i in range(N):\n\tx=x-int(c[i])\n\tif x>=0:\n\t\tcount+=1\nprint(count)', 'N,x=map(int,input().split())\ncount=0\nc=list(map(int,input().split()))\nc.sort()\nfor i in range(N):\n\tx=x-int(c[i])\n\tif x>=0:\n\t\tcount+=1\nif x>0:\n\tcount=count-1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s829814316', 's206458596'] | [2940.0, 3060.0] | [18.0, 17.0] | [146, 169] |
p03254 | u044026875 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\ncount=0\n\nfor i in range(n):\n if x>0:\n x-=a[i]\n count+=1\n else:\n break\nprint(count)', 'n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\ncount=0\n\nfor i in range(n-1):\n if x>=a[i]:\n x-=a[i]\n count+=1\n else:\n break\n\nif x==a[-1]:\n count+=1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s637586714', 's712549492'] | [2940.0, 3060.0] | [17.0, 21.0] | [180, 213] |
p03254 | u045408189 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N,x=map(int,input().split())\na=sorted(list(map(int,input().split())))\n_=0\nans=0\nfor i in range(N):\n _+=a[i]\n if _ <= x:\n ans += 1\nprint(ans)\n \n', 'n,x=map(int,input().split())\na=list(map(int,input().split()))\nA=0\nfor i in range(len(a)):\n A += a[i]\nif A < x:\n print(n-1)\nelse:\n b=sorted(a)\n c=0\n ans=0\n for _ in range(len(a)):\n c += b[_]\n if c <= x:\n ans += 1\n else:\n break\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s742475423', 's450053739'] | [2940.0, 3060.0] | [17.0, 18.0] | [163, 264] |
p03254 | u048176319 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, X = map(int, input().split())\nla = sorted(list(map(int, input().split())))\n\nprint(la)\n\nif X < la[0]:\n print(0)\nelif X > sum(la):\n print(N-1)\nelif X == sum(la):\n print(N)\nelse:\n j = 0\n while X > 0:\n X = X - la[j]\n j += 1\n print(j)', 'N, X = map(int, input().split())\nla = sorted(list(map(int, input().split())))\n\nif X < la[0]:\n print(0)\nelif X > sum(la):\n print(N-1)\nelif X == sum(la):\n print(N)\nelse:\n j = 0\n while X > 0:\n X = X - la[j]\n j += 1\n if X < 0:\n print(j-1)\n else:\n print(j)'] | ['Wrong Answer', 'Accepted'] | ['s531008292', 's319111364'] | [3060.0, 3064.0] | [17.0, 17.0] | [264, 300] |
p03254 | u064408584 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int, input().split())\na=list(map(int, input().split()))\na.sort()\ncount=0\ni=0\nwhile x>0 and i<n:\n x-=a[i]\n if x>=0:count+=1\n i+=1 \nprint(count)', 'n,x=map(int, input().split())\na=list(map(int, input().split()))\na.sort()\ncount=0\ni=0\nwhile x>0 and i<n:\n x-=a[i]\n if x>=0:count+=1\n i+=1 \nif x!=0 and count==n:count-=1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s598733725', 's929198747'] | [3060.0, 3064.0] | [17.0, 17.0] | [159, 189] |
p03254 | u066455063 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nans = 0\n\nfor i in range(N):\n if x > 0:\n if x >= a[i]:\n ans += 1\n x -= a[i]\n \n else:\n break\n \nprint(ans)', 'N, x = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nans = 0\n\nfor i in range(N):\n if x >= 0:\n if x >= a[i]:\n ans += 1\n x -= a[i]\n \n else:\n break\n \nprint(ans)', 'N, x = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nans = 0\n\nif x <= sum(a):\n for i in range(N):\n if x > 0:\n if x >= a[i]:\n ans += 1\n x -= a[i]\n\n else:\n break\nelse:\n memo = x - sum(a)\n x -= memo\n a[-1] += memo\n \n for i in range(N):\n if x > 0:\n if x >= a[i]:\n ans += 1\n x -= a[i]\n\n else:\n break\n \n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s072116406', 's176894877', 's502832680'] | [3060.0, 3060.0, 3064.0] | [17.0, 17.0, 19.0] | [233, 234, 478] |
p03254 | u067227603 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\na = sorted(list(map(int, input().split())))\n\nchild = 0\ncandy = 0\n\nprint(a)\n\nfor i in a:\n candy += i\n if candy <= x:\n child += 1\n\nif sum(a) < x:\n child -= 1\n\nprint(child)', 'N, x = map(int, input().split())\na = sorted(list(map(int, input().split())))\n\nchild = 0\ncandy = 0\n\nprint(a)\n\nfor i in a:\n candy += i\n if candy <= x:\n child += 1\n\nif sum(a) < x:\n child -= 1\n\nprint(int(child))', 'N, x = map(int, input().split())\na = sorted(list(map(int, input().split())))\n\nchild = 0\ncandy = 0\n\nfor i in a:\n candy += i\n if candy <= x:\n child += 1\n\nif sum(a) < x:\n child -= 1\n\nprint(int(child))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s253640434', 's275519792', 's215792525'] | [3060.0, 3064.0, 3064.0] | [17.0, 18.0, 17.0] | [218, 223, 213] |
p03254 | u067983636 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['import bisect\n\nN, x = map(int, input().split())\nA = list(map(int, input().split()))\nS = [0] * (N + 1)\nA.sort()\n\nfor i, a in enumerate(A):\n S[i + 1] = S[i] + a\n\nif S[-1] > x:\n print(N - 1)\nelif S[-1] == x:\n print(N)\nelse:\n print(bisect.bisect_right(S, x))\n\n', 'import bisect\n\nN, x = map(int, input().split())\nA = list(map(int, input().split()))\nS = [0] * (N + 1)\nA.sort()\n\nfor i, a in enumerate(A):\n S[i + 1] = S[i] + a\n\nprint(bisect.bisect_left(S, x))\n', 'import bisect\n\nN, x = map(int, input().split())\nA = list(map(int, input().split()))\nS = [0] * (N + 1)\nA.sort()\n\nfor i, a in enumerate(A):\n S[i + 1] = S[i] + a\n\nres = bisect.bisect_right(S, x) - 1\nif res == N and S[-1] != x:\n print(res - 1)\nelse:\n print(res)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s294490164', 's705441242', 's923604805'] | [3060.0, 3060.0, 3060.0] | [19.0, 17.0, 18.0] | [268, 195, 267] |
p03254 | u075012704 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\nans = 0\nfor a in A:\n if x >= a:\n x -= a\n ans += 1\n\nprint(ans)', 'N, x = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\nans = 0\nfor a in A:\n if x >= a:\n x -= a\n ans += 1\n\nif ans == N:\n print(ans - (x != 0))\nelse:\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s039755399', 's578872676'] | [3316.0, 2940.0] | [21.0, 17.0] | [156, 206] |
p03254 | u076306174 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN,x=map(int, input[0].split()) \na=list(map(int,input[1].split())) \n\nheapq.heapify(a) \n\nfor i in range(N):\n x-=heapq.heappop(a) \n #print(x,a)\n if x<=0 or i==N-1:\n print(i+1)\n break', 'import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN,x=map(int, input().split()) \na=list(map(int,input().split())) \n\nheapq.heapify(a) \n\nfor i in range(N):\n x-=heapq.heappop(a) \n #print(x,a)\n if x<=0 or i==N-1:\n print(i+1)\n break\n\n\n', 'import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN,x=map(int, input().split()) \na=list(map(int,input().split())) \n\nheapq.heapify(a) \n\nfor i in range(N):\n x-=heapq.heappop(a) \n print(x,a)\n if x<=0 or i==N-1:\n if x==0:\n print(i+1)\n else:\n print(i)\n break\n \n\n\n', 'import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN,x=map(int, input().split()) \na=list(map(int,input().split())) \n\nheapq.heapify(a) \n\nfor i in range(N):\n x-=heapq.heappop(a) \n #print(x,a)\n if x<=0 or i==N-1:\n if x==0:\n print(i+1)\n else:\n print(i)\n break\n \n\n\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s001333676', 's414656381', 's498020343', 's025604837'] | [3316.0, 3316.0, 3444.0, 3316.0] | [20.0, 21.0, 21.0, 21.0] | [733, 734, 798, 799] |
p03254 | u077291787 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['# AGC027A - Candy Distribution Again\n# greedy algorithm\nfrom itertools import accumulate\n\n\ndef main():\n # maximize the number of proper distribution -> begin with small values\n n, x = tuple(map(int, input().rstrip().split()))\n A = sorted(map(int, input().rstrip().split()))\n ans = sum(i <= x for i in accumulate(A))\n print(ans)\n\n\nif __name__ == "__main__":\n main()', '# AGC027A - Candy Distribution Again\n# greedy algorithm\nfrom itertools import accumulate as acc\n\n\ndef main():\n # maximize the number of proper distribution -> begin with small values\n N, X, *A = map(int, open(0).read().split())\n A.sort()\n ac = list(acc(A))\n if ac[-1] < x: # the last one receives more than expected -> ans - 1\n ans = n - 1\n else:\n ans = sum(i <= x for i in ac)\n print(ans)\n\n\nif __name__ == "__main__":\n main()', '# AGC027A - Candy Distribution Again\n# greedy algorithm\nfrom itertools import accumulate as acc\n\n\ndef main():\n # maximize the number of proper distribution -> begin with small values\n N, X, *A = map(int, open(0).read().split())\n A.sort()\n ac = list(acc(A))\n if ac[-1] < X: # the last one receives more than expected -> ans - 1\n ans = N - 1\n else:\n ans = sum(i <= X for i in ac)\n print(ans)\n\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s405433319', 's493510783', 's897988921'] | [3060.0, 3060.0, 3060.0] | [17.0, 18.0, 18.0] | [382, 465, 465] |
p03254 | u078349616 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, X = map(int, input().split())\nA = sorted(list(map(int, input().split())))\nans = 0\nfor i in range(N):\n if X >= A[i]:\n X -= A[i]\n ans += 1\nprint(ans)', 'N, X = map(int, input().split())\nA = sorted(list(map(int, input().split())))\nl = [0]*N\nfor i in range(N):\n if X >= A[i]:\n if i == N-1:\n l[i] = X\n X -= X\n else:\n l[i] = A[i]\n X -= A[i]\n else:\n l[i] = X\n X -= X\nans = [A[i]-l[i] for i in range(N)].count(0)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s325598850', 's047960559'] | [2940.0, 3064.0] | [17.0, 17.0] | [157, 298] |
p03254 | u090436701 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['import sys\n\nN, x = sys.stdin.readline().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in sys.stdin.readline().split()]\n\nal.sort()\n\nused = 0\nans = N\nfor i, a in enumerate(al):\n if used+a > x:\n ans = i\n break\n used += a\n\nprint(ans)\n \n \n \n', 'import sys\n\nN, x = sys.stdin.readline().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in sys.stdin.readline().split()]\n\nal.sort()\n\nused = 0\nans = N\nfor i, a in enumerate(al):\n if used+a > x:\n ans = i\n break\n elif used+a == x:\n ans = i+1\n break\n used += a\n\nprint(ans)\n \n \n \n', 'N, x = input().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in input().split()]\n\nal.sort()\n\nused = 0\nans = 0\nfor a in enumerate(al:\n if used+a > x:\n break\n used += a\n ans += 1\n\nprint(ans)\n \n \n \n', 'N, x = input().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in input().split()]\n\nal.sort()\n\nused = 0\nans = N\nfor i, a in enumerate(al):\n if used+a > x:\n ans = i\n break\n used += a\n\nprint(ans)\n \n \n \n', 'N, x = input().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in input().split()]\n\nal.sort()\n\nused = 0\nans = 0\nfor a in al:\n if used+a > x:\n break\n used += a\n ans += 1\n\nprint(ans)\n \n \n \n', 'N, x = input().split()\nN = int(N)\nx = int(x)\nal = [int(a) for a in input().split()]\n\nal.sort()\n\ncum = [sum(al[:i+1])for i in range(len(al))]\n\nans = N-1\nfor i in range(len(al)):\n if cum[i] == x:\n ans = i+1\n break\n elif cum[i]>x:\n ans = i\n break\nprint(ans)\n \n \n \n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s068673739', 's184530913', 's567617447', 's638521830', 's743994306', 's733787393'] | [3060.0, 3060.0, 2940.0, 3060.0, 3060.0, 3064.0] | [17.0, 17.0, 17.0, 17.0, 18.0, 17.0] | [276, 330, 231, 238, 221, 312] |
p03254 | u092244748 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n, x = map(int, input().split())\narray = list(map(int, input().split()))\n\ncount = 0\narray = sorted(array, reverse=True)\nfor i in range(n):\n x = x - array[i]\n if x >= 0:\n count += 1\n else:\n break\nprint(count)', 'n, x = map(int, input().split())\narray = list(map(int, input().split()))\n\ncount = 0\narray = sorted(array)\nfor i in range(n):\n x = x - array[i]\n if x >= 0:\n count += 1\n else:\n break\nif x > 0:\n count -= 1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s941265947', 's646020912'] | [3060.0, 3064.0] | [18.0, 17.0] | [230, 241] |
p03254 | u094191970 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['from sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\n\nn,x=nii()\na=lnii()\na.sort()\n\na_sum=0\nfor i in range(n):\n a_sum+=a[i]\n if a_sum>x:\n print(i)\n exit()\n\nprint(n)', 'from sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\nfrom bisect import bisect\nfrom itertools import accumulate\n\nn,x=nii()\na=lnii()\na.sort()\n\nb=list(accumulate(a))\n\nif b[-1]<x:\n print(n-1)\nelse:\n inx=bisect(b,x)\n print(inx)'] | ['Wrong Answer', 'Accepted'] | ['s471078169', 's349465727'] | [9072.0, 9124.0] | [29.0, 29.0] | [237, 292] |
p03254 | u094999522 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x,*a=map(int,open(0).read().split())\na.sort()\ns=0\ni=0\nwhile s<x or i<=n:\n i+=1\n s+=a[i]\nprint(~-i)', 'n,x,*a=map(int, open(0).read().split())\na.sort()\nfor i in range(n):\n x-=a[i]\n if x<0:\n print(i)\n exit()\nprint(n)', 'n,x,*a=map(int, open(0).read().split())\na.sort()\nfor i in range(n):\n x-=a[i]\n if x<0:\n print(i)\n exit()\n elif x==0:\n print(-~i)\n exit()\nprint(n-1)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s004729209', 's475614660', 's237459482'] | [2940.0, 2940.0, 2940.0] | [18.0, 17.0, 19.0] | [106, 128, 175] |
p03254 | u100277898 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['\nin1 = input()\nin2 = input()\nN, x = in1.split()\nN = int(N)\nx = int(x)\na = list()\nfor i in in2.split():\n a.append(int(i))\na.sort()\ncount = 0\nfor ai in a:\n if x > ai:\n count += 1\n x -= ai\n elif x == ai:\n count += 1\n break\n else:\n break\nprint(count)', 'in1 = input()\nin2 = input()\nN, x = in1.split()\nN = int(N)\nx = int(x)\na = list()\nfor i in in2.split():\n a.append(int(i))\na.sort()\ncount = 0\nfor ai in a:\n if x > ai:\n count += 1\n x -= ai\n elif x == ai:\n count += 1\n break\n else:\n break\nprint(count)\n', 'in1 = input()\nin2 = input()\nN, x = in1.split()\nN = int(N)\nx = int(x)\na = list()\nfor i in in2.split():\n a.append(int(i))\na.sort()\ncount = 0\nfor ai in a:\n if x > ai:\n count += 1\n x -= ai\n elif x == ai:\n count += 1\n x -= ai\n break\n else:\n break\nif x != 0 and count > 0:\n count -= 1\ncount += 1\nprint(count)\n', 'in1 = input()\nin2 = input()\nN, x = in1.split()\nN = int(N)\nx = int(x)\na = list()\nfor i in in2.split():\n a.append(int(i))\na.sort()\ncount = 0\nfor ai in a:\n if x > ai:\n count += 1\n x -= ai\n elif x == ai:\n count += 1\n x -= ai\n break\n else:\n x -= ai\n break\nif x > 0 and count > 0:\n count -= 1\nprint(count)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s212857373', 's301958357', 's314301019', 's773960362'] | [3064.0, 3060.0, 3060.0, 3060.0] | [17.0, 17.0, 17.0, 18.0] | [265, 265, 326, 326] |
p03254 | u102242691 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['\nn,x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nb = []\nnum = a[0]\ni = 1\n\nwhile num <= x:\n num += a[i]\n if x - a[i] > 0:\n x -= a[i]\n b.append(a[i])\n i += 1\n else:\n b.append(max(0,a[i]))\n break\n\nprint(a)\nprint(b)\nprint(num)\n\nans = 0\nfor i in range(min(len(a),len(b))):\n if a[i] == b[i]:\n ans += 1\nprint(ans)\n\n', '\nn,x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nb = []\nnum = a[0]\ni = 1\n\nwhile num <= x:\n num += a[i]\n if x - a[i] > 0:\n x -= a[i]\n b.append(a[i])\n i += 1\n else:\n b.append(max(0,a[i]))\n break\n"""\nprint(a)\nprint(b)\nprint(num)\n"""\nans = 0\nfor i in range(min(len(a),len(b))):\n if a[i] == b[i]:\n ans += 1\nprint(ans)\n\n', '\nN,x = map(int,input().split())\na = list(map(int,input().split()))\na = sorted(a)\nans = 0\n\nfor i in range(N - 1):\n if x >= a[i]:\n x -= a[i]\n ans += 1\n else:\n break\n\nif x == a[-1]:\n ans += 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s360012888', 's858190864', 's258987454'] | [3064.0, 3064.0, 3060.0] | [17.0, 17.0, 17.0] | [389, 395, 231] |
p03254 | u102461423 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['import numpy as np\nN,x = map(int,input().split())\nA = np.array(input().split(), dtype = np.int64)\nA.sort()\nA = A.cumsum()\nanswer = (A <= x).sum()\nprint(answer)', 'import numpy as np\nN,x = map(int,input().split())\nA = np.array(input().split(), dtype = np.int64)\nA.sort()\nnp.cumsum(A, out = A)\nanswer = (A <= x).sum()\nprint(answer)', 'import numpy as np\nN,x = map(int,input().split())\nA = np.array(input().split(), dtype = np.int64)\nA.sort()\nnp.cumsum(A, out = A)\nanswer = (A <= x).sum()', 'import numpy as np\nN,x = map(int,input().split())\nA = np.array(input().split(), dtype = np.int64)\nA.sort()\nnp.cumsum(A, out = A)\nanswer = (A <= x).sum()\nprint(answer)\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom bisect import bisect_right\nimport itertools\n\nN,X,*A = map(int,read().split())\n\nA.sort()\nAcum = list(itertools.accumulate(A))\n\nanswer = bisect_right(Acum,X)\nif answer == N:\n if Acum[-1] < X:\n answer -= 1\nprint(answer)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s078852642', 's186466860', 's665490087', 's864069192', 's444535945'] | [12396.0, 20384.0, 20748.0, 12396.0, 3060.0] | [152.0, 298.0, 311.0, 148.0, 18.0] | [159, 166, 152, 167, 348] |
p03254 | u102902647 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['\nN, x = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nA = sorted(A)\nres = 0\nfor a in A:\n x -= a\n if x <= 0:\n break\n else:\n res += 1\nprint(res)\n\n', '# -*- coding: utf-8 -*-\n"""\nCreated on Sat Sep 15 23:36:39 2018\n\n@author: Yuki\n"""\n\nN, x = map(int, input().split())\nA = sorted([int(i) for i in input().split()])\n\n\ncnt=0\nres=0\nfor i in range(0,N):\n cnt += A[i]\n if cnt > x:\n res = i\n break\n elif cnt == x:\n res = i+1\n break\n if i == N-1 and cnt < x:\n res = N-1\nif A[0] > x:\n res=0\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s982836425', 's323304692'] | [2940.0, 3064.0] | [17.0, 17.0] | [186, 391] |
p03254 | u102960641 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nn = 0\nfor i in a:\n n += 1\n x -= i\n if x < 0:\n n -= 1\n break\nprint(n)\n', 'n,x = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nn = 0\nfor i in a:\n n += 1\n x -= i\n if x < 0:\n n -= 1\n break\nif x > 0:\n n -= 1\nprint(n)\n'] | ['Wrong Answer', 'Accepted'] | ['s818316672', 's376991085'] | [2940.0, 3060.0] | [17.0, 17.0] | [153, 172] |
p03254 | u103902792 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\nA=list(map(int,input().split()))\nA.sort()\nans=0\nfor a in A:\n x-=a\n if x>=0:\n ans+=1\n else:\n print(ans)\n break', 'n,x=map(int,input().split())\nA=list(map(int,input().split()))\nA.sort()\nans=0\nfor a in A[:-1]:\n x-=a\n if x>=0:\n ans+=1\n else:\n break\nif A[-1]==x:\n ans+=1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s244946516', 's823967760'] | [2940.0, 3060.0] | [18.0, 17.0] | [150, 173] |
p03254 | u105302073 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nret = 0\nfor a in A:\n if a <= X:\n ret += 1\n X -= a\nprint(ret)', 'N, X = list(map(int, input().split()))\nA = sorted(list(map(int, input().split())))\nlast_index = len(A) - 1\nret = 0\nfor i, a in enumerate(A):\n if a <= X:\n ret += 1\n X -= a\nif ret == N and X > 0:\n ret -= 1\nprint(ret)'] | ['Wrong Answer', 'Accepted'] | ['s147138699', 's947395640'] | [2940.0, 3060.0] | [17.0, 17.0] | [152, 234] |
p03254 | u106118504 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['children = list(map(int,input().split())) \nchildren.sort()\ncount=0\nc = 0\nif x < children[0]:\n print(0)\n exit()\nfor i in range(n):\n count += children[i]\n c += 1\n if count == x:\n print(c)\n exit()\n elif count > x:\n print(c-1)\n exit()\n\nprint(n-1)', 'n, x = map(int,input().split())\nchildren = list(map(int,input().split())) \nchildren.sort()\ncount=0\nc = 0\nif x < children[0]:\n print(0)\n exit()\nfor i in range(n):\n count += children[i]\n c += 1\n if count == x:\n print(c)\n exit()\n elif count > x:\n print(c-1)\n exit()\n\nprint(n-1)\n'] | ['Runtime Error', 'Accepted'] | ['s653003427', 's674870695'] | [9176.0, 9116.0] | [21.0, 27.0] | [260, 293] |
p03254 | u106778233 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x = map(int,input().split()) \nA= list(map(int,input().split())) \nA.sort()\na_sum=0 \nfor i in range(n):\n a_sum+= A[i]\n if x<a_sum:\n print(i)\n exit() \n\nprint(n)', 'n,x = map(int,input().split()) \nA= list(map(int,input().split())) \nA.sort()\na_sum=0 \nfor i in range(n):\n a_sum+= A[i]\n if x<a_sum:\n print(i)\n exit() \n\nif a_sum== sum(A):\n print(n)\nelse:\n print(n-1)', 'n,x = map(int,input().split()) \nA= list(map(int,input().split())) \nA.sort()\na_sum=0 \nfor i in range(n):\n a_sum+= A[i]\n if x<a_sum:\n print(i)\n exit() \n\nif a_sum== x:\n print(n)\nelse:\n print(n-1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s046515365', 's651017251', 's242737349'] | [9044.0, 8984.0, 9172.0] | [27.0, 31.0, 26.0] | [180, 224, 219] |
p03254 | u106971015 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N,x=map(int,input().split())\na = list(map(int,input().split()))\ncnt = 0\na.sort()\nfor i in a:\n if x >= i:\n x -= i\n cnt +=1\n else:\n print(cnt)\n exit()\nprint(cnt)', 'N,x=map(int,input().split())\na = list(map(int,input().split()))\ncnt = 0\na.sort()\nfor i in a:\n if x >= i:\n x -= i\n cnt +=1\n else:\n print(cnt)\n exit()\nif x ==0:\n print(cnt)\nelse:\n print(cnt-1)'] | ['Wrong Answer', 'Accepted'] | ['s315479653', 's049124437'] | [2940.0, 3060.0] | [17.0, 18.0] | [193, 230] |
p03254 | u107915058 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['N, x = map(int, input().split())\na = sorted(map(int, input().split()))\ncnt = 0\nfor i in a:\n if x < i:\n break\n cnt += 1\n x -= i\n if x > 0:\n cnt -= 1\nprint(cnt)', 'N, x = map(int, input().split())\na = sorted(map(int, input().split()))\ncnt = 0\nfor i in a:\n if x < i:\n break\n cnt += 1\n x -= i\nelse:\n if x > 0:\n cnt -= 1\nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s203278683', 's510944873'] | [9096.0, 8916.0] | [27.0, 26.0] | [184, 190] |
p03254 | u108990937 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ["n, x = (int(i) for i in input().split(' '))\na = [int(i) for i in input().split(' ')]\n\nch = 0 \n\nwhile x != 0: \n if x - a[i] < 0: \n x = 0\n else:\n x -= a[i]\n ch += 1\n\nprint(ch) \n \n ", "n, x = (int(i) for i in input().split(' '))\na = sorted([int(i) for i in input().split(' ')])\n\nch = 0 \ns = 0\nfor i in range(n):\n if x < a[i]:\n x = 0\n elif x >= a[i]:\n x -= a[i]\n ch += 1\n \nif x > 0:\n ch = ch -1\n\nprint(ch)"] | ['Runtime Error', 'Accepted'] | ['s854060021', 's325838518'] | [2940.0, 3064.0] | [17.0, 17.0] | [306, 282] |
p03254 | u111421568 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\ndef score(a, m, x):\n ans = x*(n+m)\n l = n//m\n for i in range(n):\n t = (n-1-i)//m\n if i < m:\n ans += ((t+2)**2) * a[i]\n else:\n ans += ((t+2)**2) * (a[i] - a[i-m])\n for i in range(m):\n ans += a[n-1-i]\n return ans\n \ndef search(left, right, l_score, r_score, a, x):\n tri = (right-left)//3\n u_score = score(a, left+tri, x)\n v_score = score(a, left+tri*2, x)\n if right-left <= 3:\n return min(u_score, v_score, l_score, r_score)\n elif l_score < u_score:\n return search(left, left+tri, l_score, u_score, a, x)\n elif r_score < v_score:\n return search(left+tri*2, right, v_score, r_score, a, x)\n elif u_score < v_score:\n return search(left, left+tri*2, l_score, v_score, a, x)\n else:\n return search(left+tri, right, u_score, r_score, a, x)\n \n \ndef sub_search(r, a, x):\n ans = score(a, r//2+1, x)\n #print(ans)\n for i in range(r//2):\n j = r//2 - i\n ddd = score(a, j, x)\n #print(ddd)\n if ddd <= ans:\n ans = ddd\n else:\n break\n return ans\n \n \n#k = search(1, n, score(a, 1, x), score(a, n, x), a, x)\nk = sub_search(n, a, x)\nprint(k)', 'n, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\na = sorted(a)\nans = 0\nf = 1\nfor i in range(n):\n x -= a[i]\n if x<0:\n f = 0\n break\n ans += 1\n \nif x != 0 and f == 1:\n ans -= 1\n \nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s577329250', 's264877808'] | [3064.0, 3316.0] | [20.0, 19.0] | [1299, 241] |
p03254 | u113107956 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\ncnt=0\nfor i in range(n):\n if a[i]<=x:\n x-=a[i]\n cnt+=1\n else:\n break\nprint(cnt)\n', 'n,x=map(int,input().split())\na=list(map(int,input().split()))\nb=[0]*n\na.sort()\ncnt=0\nfor i in range(n):\n if a[i]<=x:\n x-=a[i]\n if i==n-1 and x!=0:\n break\n cnt+=1\n else:\n break\nprint(cnt)\n'] | ['Wrong Answer', 'Accepted'] | ['s746361310', 's398842769'] | [9116.0, 9092.0] | [28.0, 32.0] | [178, 232] |
p03254 | u114954806 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\nlst=sorted(list(map(int,input().split())))\nans=0\nfor i in range(1,n+1):\n if sum(lst[:i]) <= x:\n ans = len(lst[:i])\nprint(ans)', 'N,x=map(int,input().split())\nA=sorted(list(map(int,input().split())))\na=[0]*N\na[0]=A[0]\nfor i in range(N-1):\n a[i+1]=a[i]+A[i+1]\nans=0\nfor i in a:\n if i<=x:\n ans+=1\nprint(ans if x<=a[-1] else ans-1)\n'] | ['Wrong Answer', 'Accepted'] | ['s763825790', 's537621028'] | [3060.0, 3060.0] | [18.0, 17.0] | [164, 212] |
p03254 | u125545880 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['def main():\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort()\n if sum(a) <= x:\n print(N)\n return\n for i in range(N):\n x -= a[i]\n if x < 0:\n break\n ans = i\n print(ans)\n\nif __name__ == "__main__":\n main()\n', 'def main():\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort()\n if sum(a) == x:\n print(N)\n return\n for i in range(N):\n x -= a[i]\n if x < 0:\n break\n ans = i\n print(ans)\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s874487901', 's130639045'] | [3060.0, 3060.0] | [17.0, 18.0] | [297, 297] |
p03254 | u127499732 | 2,000 | 1,048,576 | There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children. | ['n,x=map(int,input().split())\na=sorted(list(map(int,input().split())))\nc,i=0,0\nwhile(i<n and x>0):\n if a[i]<=x:\n x-=a[i]\n c+=1\n i+=1\n else:\n break\nprint(c)', 'n,x=map(int,input().split())\na=sorted(list(map(int,input().split())))\nc,i=0,0\nwhile(i<n and x>0):\n if a[i]<=x:\n x-=a[i]\n c+=1\n i+=1\n else:\n break\nprint(c)', 'n,x=map(int,input().split())\na=sorted(list(map(int,input().split())))\nc,i=0,0\nwhile(i<n and x>0):\n if a[i]<=x:\n x-=a[i]\n c+=1\n else:\n break\n if i==n-1 and x!=0:\n c-=1\n i+=1\nprint(c)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s411941619', 's993303861', 's745030708'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 22.0] | [168, 168, 197] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.