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
p02781
u780475861
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['import sys\nread = sys.stdin.read\nn, k = map(int, read().split())\n\n\ndef count(digit, k):\n elif k == 0:\n return 1\n elif k == 1:\n return digit\n elif k == 2:\n return digit * (digit - 1) // 2\n else:\n return digit * (digit - 1) * (digit - 2) // 6\n\n\ndef solve(n, k):\n if k == 0:\n return 1\n digit = len(str(n))\n res = 0\n if digit > k:\n res += count(digit - 1, k) * (9 ** k)\n pow10 = 10 ** (digit - 1)\n d, mod = n // pow10, n % pow10\n res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)\n res += solve(mod, k - 1)\n return res\n\n\nprint(solve(n, k))\n', 'import sys\nread = sys.stdin.read\nn, k = map(int, read().split())\n\n\ndef count(digit, k):\n if k == 0:\n return 1\n elif k == 1:\n return digit\n elif k == 2:\n return digit * (digit - 1) // 2\n else:\n return digit * (digit - 1) * (digit - 2) // 6\n\n\ndef solve(n, k):\n if k == 0:\n return 1\n digit = len(str(n))\n res = 0\n if digit > k:\n res += count(digit - 1, k) * (9 ** k)\n pow10 = 10 ** (digit - 1)\n d, mod = n // pow10, n % pow10\n res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)\n res += solve(mod, k - 1)\n return res\n\n\nprint(solve(n, k))\n']
['Runtime Error', 'Accepted']
['s566768590', 's711920864']
[2940.0, 3064.0]
[17.0, 17.0]
[624, 622]
p02781
u798445123
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['N = input()\nK = int(input())\n\ndef F(N, K):\n if N < 10:\n if K == 0:\n return 1\n if K == 1:\n return N\n return 0\n q, r = divmod(N, 10)\n ret = 0\n if K >= 1:\n ret += F(q, K-1) * r\n ret += F(q-1, K-1) * (9-r)\n ret += F(q, K)\n return ret\n\nprint(F(N, K))', 'from functools import lru_cache\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, K = map(int,read().split())\n\n@lru_cache(None)\ndef F(N, K):\n if N < 10:\n if K == 0:\n return 1\n if K == 1:\n return N\n return 0\n q, r = divmod(N, 10)\n ret = 0\n if K >= 1:\n ret += F(q, K-1) * r\n ret += F(q-1, K-1) * (9-r)\n ret += F(q, K)\n return ret\n\nprint(F(N, K))']
['Runtime Error', 'Accepted']
['s152593767', 's151411574']
[3188.0, 3940.0]
[18.0, 27.0]
[320, 488]
p02781
u825378567
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['import math\nN=list(input())\nK=int(input())\nans=0\nnot_zero=0\ndef cmb(n, r):\n if n-r>=1 and n>=1 and r>=1: \n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n elif n==r==1 or n==r==0:\n return 1\n else:\n return 1\nfor i in range(len(N)):\n if N[i]!="0":\n ans+=cmb(len(N[i+1:]),K-not_zero) * (9**(K-not_zero))\n ans+=cmb(len(N[i+1:]), K-not_zero-1) *(int(N[i])-1)* (9**(K-not_zero-1))\n not_zero+=1\n print(ans)\n if not_zero==K:\n ans+=1\n break\nprint(ans)\n ', 'import math\nN=list(input())\nK=int(input())\nans=0\nnot_zero=0\ndef cmb(n, r):\n if n-r>=1 and n>=1 and r>=1: \n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n elif n==r or n==r:\n return 1\n elif r==0:\n return 1\n else:\n return 0\nfor i in range(len(N)):\n if N[i]!="0":\n ans+=cmb(len(N[i+1:]),K-not_zero) * (9**(K-not_zero))\n ans+=cmb(len(N[i+1:]), K-not_zero-1) *(int(N[i])-1)* (9**(K-not_zero-1))\n not_zero+=1\n #print(ans)\n if not_zero==K:\n ans+=1\n break\nprint(ans)\n ']
['Wrong Answer', 'Accepted']
['s929861815', 's100201257']
[3188.0, 3064.0]
[19.0, 18.0]
[508, 529]
p02781
u864197622
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['from functools import lru_cache\nimport sys\nsys.setrecursionlimit(1000000)\n\ndef g(m, k):\n if k == 0:\n return 1\n if k == 1:\n return m * 9\n if k == 2:\n return m * (m-1) // 2 * 81\n if k == 3:\n return m * (m-1) * (m-2) // 6 * 729\n\n@lru_cache(maxsize=None)\ndef f(n, k):\n if n == 0: return 0\n if k == 0: return 1\n S = str(n)\n t = int(S[0])\n m = len(S)\n return f(int("0" + S[1:]), k-1) + ((t-1) * g(m-1, k-1) if t else 0) + g(m-1, k)\n\nN = int(input())\nK = int(input())\nprint(f(N, K))', 'from functools import lru_cache\nimport sys\nsys.setrecursionlimit(1000000)\n\ndef g(m, k):\n if k == 0:\n return 1\n if k == 1:\n return m * 9\n if k == 2:\n return m * (m-1) // 2 * 81\n if k == 3:\n return m * (m-1) * (m-2) // 6 * 729\n\n@lru_cache(maxsize=None)\ndef f(n, k):\n if n == 0 and k:\n return 0\n if k == 0:\n return 1\n S = str(n)\n t = int(S[0])\n m = len(S)\n return f(int("0" + S[1:]), k-1) + ((t-1) * g(m-1, k-1) if t else 0) + g(m-1, k)\n\nN = int(input())\nK = int(input())\nprint(f(N, K))']
['Wrong Answer', 'Accepted']
['s433538974', 's508510989']
[3684.0, 3572.0]
[24.0, 25.0]
[533, 555]
p02781
u865741247
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['import math\nN = int(input())\nK = int(input())\n\nS = str(N)\nketa = len(S)\n\n\ndp = [ [ [ 0 ]* (keta + 1) for _ in range(100)] for _ in range(2)]\n\n\ni = int(S[0])\ndp[0][0][0] = 1\n\nfor n in range(0,keta):\n \n for k in range(0, K + 1):\n num = int(S[n]) \n num_to_9 = 9 - num \n num_hiku1_to_1 = max(0,num - 1) \n \n \n\n dp[1][k+ 1 ][n + 1] += dp[1][k][n] * 9\n \n dp[1][k][n + 1] += dp[1][k][n] * 1 \n \n \n \n dp[1][k + 1][n + 1] += dp[0][k][n] * num_hiku1_to_1 \n dp[1][k][n + 1] += dp[0][k][n] * 1 \n\n \n if num == 0: \n dp[0][k][n + 1] += dp[0][k][n]\n else: \n dp[0][k + 1][n + 1] += dp[0][k][n]\n\nprint(dp[0][K][keta] + dp[1][K][keta])\n\n\n', 'import math\nN = int(input())\nK = int(input())\n\nS = str(N)\nketa = len(S)\n\n\ndp1 = [ [ 0 ]* (keta + 1) for _ in range(100) ] \ndp2 = [ [ 0 ]* (keta + 1) for _ in range(100) ] \n\n\ni = int(S[0])\ndp2[0][0] = 1 \n\nfor n in range(0,keta):\n \n for k in range(0, K + 1):\n num = int(S[n]) \n num_to_9 = 9 - num \n num_hiku1_to_1 = max(0,num - 1) \n \n \n\n if num == 0:\n dp1[k + 1][n + 1] += dp1[k][n] * 9 # 1~ 9\n dp1[k][n + 1] += dp1[k][n] \n # dp1[k][n + 1] += dp2[k][n]\n dp2[k][n + 1] += dp2[k][n] \n\n else:\n dp1[k + 1][n + 1] += dp1[k][n] * 9 \n dp1[k + 1][n + 1] += dp2[k][n] * (num - 1) \n dp2[k + 1][n + 1] += dp2[k][n] \n\n \n dp1[k][n + 1] += dp1[k][n] \n \n\n dp1[k][n + 1] += dp2[k][n] \n \n \n\n\nprint(dp1[K][keta] + dp2[K][keta])\n\n\n']
['Wrong Answer', 'Accepted']
['s710885009', 's440521095']
[3188.0, 3188.0]
[19.0, 18.0]
[1456, 1868]
p02781
u872887731
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['ii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\nn = ii()\nk = ii()\nn2 = n\n\nn_keta = 1\nwhile n2:\n n2 = n2 //10\n if n2 == 0:\n break\n n_keta += 1\n\nfrom math import factorial as fc\ndef func(keta,kazu,ima):\n ans = 0\n n = n_keta - keta -1\n r = k - kazu\n if n-r <0:\n return 0\n ans += (ima-1) *fc(n) //fc (r)//fc(n-r) * (9 **(k-kazu))\n print(ans)\n if n - r -1 >= 0: ans += fc(n) // fc (r+1) // fc(n-r-1) *(9**(k-kazu +1))\n print(ans)\n return ans\nn_in = str(n)\nkk = 0\nlis = []\n\nfor i in range(n_keta):\n if n_in[i] != 0:\n lis.append([i,kk+1,int(n_in[i])]) \n kk += 1\n if kk ==k:\n break\nanss = 0\nfor lil in lis:\n anss += func(lil[0],lil[1],lil[2])\nprint(int(anss+1))\n', 'ii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\ns = input()\nk = ii()\n\n\nn = len(s)\ndp = [[0]*(n) for _ in range(4)]\ndp[0][0] = 1\nfor i in range(1,n):\n \n dp[0][i] = dp[0][i-1] \n \n dp[1][i] = dp[0][i-1] * 9 + dp[1][i-1]\n \n dp[2][i] = dp[1][i-1]*9 + dp[2][i-1]\n dp[3][i] = dp[2][i-1]*9 + dp[3][i-1]\n\nans = 0\nfor i in range(n):\n ima = int(s[i])\n if i ==-1 :\n ans += (ima -1) * dp[k-1][n-1-i]\n k -= 1\n else:\n if ima != 0:\n ans += (ima -1) * dp[k-1][n-1-i] + dp[k][n-1-i]\n k -= 1\n if k == 0:\n ans += 1\n break\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s150238740', 's110867384']
[3192.0, 3188.0]
[18.0, 20.0]
[800, 750]
p02781
u875541136
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['N = [0] + list(map(int, input()))\nK = int(input())\nn = len(N)\n\nDP = [\n [[0] * (K+1) for _ in range(2)] for _ in range(n)\n]\n\n\nDP[0][0][0] = 1\n\nfor i in range(1, n):\n for k in range(K):\n if N[i] != 0:\n DP[i][0][k+1] += DP[i-1][0][k]\n DP[i][1][k] += DP[i-1][0][k]\n DP[i][1][k+1] += DP[i-1][0][k] * (N[i] - 1)\n else:\n DP[i][0][k] += DP[i-1][0][k]\n DP[i][1][k] += DP[i-1][1][k]\n DP[i][1][k+1] += DP[i-1][1][k] * 9\nprint(DP[n-1][1][K] + DP[n-1][0][K])', 'N = [0] + list(map(int, input()))\nK = int(input())\nn = len(N)\n\nDP = [\n [[0] * (K+2) for _ in range(2)] for _ in range(n)\n]\n\n\nDP[0][0][0] = 1\n\nfor i in range(1, n):\n for k in range(K+1):\n if N[i] != 0:\n DP[i][0][k+1] += DP[i-1][0][k]\n DP[i][1][k] += DP[i-1][0][k]\n DP[i][1][k+1] += DP[i-1][0][k] * (N[i] - 1)\n else:\n DP[i][0][k] += DP[i-1][0][k]\n DP[i][1][k] += DP[i-1][1][k]\n DP[i][1][k+1] += DP[i-1][1][k] * 9\nprint(DP[n-1][1][K] + DP[n-1][0][K])']
['Wrong Answer', 'Accepted']
['s923892937', 's003722619']
[3192.0, 3064.0]
[18.0, 19.0]
[547, 549]
p02781
u902151549
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['# coding: utf-8\nimport re\nimport math\nimport itertools\nfrom copy import deepcopy\nimport fractions\nimport random\nfrom functools import lru_cache\nfrom heapq import heappop,heappush\nimport time\nimport sys\nreadline = sys.stdin.readline\nsys.setrecursionlimit(2000)\n#import numpy as np\nalphabet="abcdefghijklmnopqrstuvwxyz"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n if b:\n print("yes")\n else:\n print("no")\ndef Yn(b):\n if b:\n print("Yes")\n else:\n print("No")\ndef YN(b):\n if b:\n print("YES")\n else:\n print("NO")\nclass union_find():\n def __init__(self,n):\n self.n=n\n self.P=[a for a in range(N)]\n self.rank=[0]*n\n \n def find(self,x):\n if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n return self.P[x]\n \n def same(self,x,y):\n return self.find(x)==self.find(y)\n \n def link(self,x,y):\n if self.rank[x]<self.rank[y]:\n self.P[x]=y\n elif self.rank[y]<self.rank[x]:\n self.P[y]=x\n else:\n self.P[x]=y\n self.rank[y]+=1\n \n def unite(self,x,y):\n self.link(self.find(x),self.find(y))\n \n def size(self):\n S=set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\ndef bin_(num,size):\n A=[0]*size\n for a in range(size):\n if (num>>(size-a-1))&1==1:\n A[a]=1\n else:\n A[a]=0\n return A\ndef fac_list(n,mod_=0):\n A=[1]*(n+1)\n for a in range(2,len(A)):\n A[a]=A[a-1]*a\n if(mod>0):A[a]%=mod_\n return A\ndef comb(n,r,mod,fac):\n if(n-r<0):return 0\n return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef next_comb(num,size):\n x=num&(-num)\n y=num+x\n z=num&(~y)\n z//=x\n z=z>>1\n num=(y|z)\n if(num>=(1<<size)):return False\n else:\n return num\ndef get_primes(n,type="int"):\n A=[True]*(n+1)\n A[0]=False\n A[1]=False\n for a in range(2,n+1):\n if A[a]:\n for b in range(a*2,n+1,a):\n A[b]=False\n if(type=="bool"):return A\n B=[]\n for a in range(n+1):\n if(A[a]):B.append(a)\n return B\ndef is_prime(num):\n if(num<=2):return False\n i=2\n while i*i<=num:\n if(num%i==0):return False\n i+=1\n return True\ndef join(A,c=" "):\n n=len(A)\n A=list(map(str,A))\n s=""\n for a in range(n):\n s+=A[a]\n if(a<n-1):s+=c\n return s\n#main\n\n@lru_cache(maxsize=None)\ndef f(num,k):\n if(num==0 and k==0):return 1\n elif(num<=0 or k<=0):return 0\n else:\n r=num-(num//10)*10\n m=num//10\n return f(m,k-1)*r+f(m-1,k-1)*(10-r)+f(m,k)\ns=int(input())\nk=int(input())\nprint(f(s,k))\n', '# coding: utf-8\nimport re\nimport math\nimport itertools\nfrom copy import deepcopy\nimport fractions\nimport random\nfrom functools import lru_cache\nfrom heapq import heappop,heappush\nimport time\nimport sys\nreadline = sys.stdin.readline\nsys.setrecursionlimit(2000)\n#import numpy as np\nalphabet="abcdefghijklmnopqrstuvwxyz"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n if b:\n print("yes")\n else:\n print("no")\ndef Yn(b):\n if b:\n print("Yes")\n else:\n print("No")\ndef YN(b):\n if b:\n print("YES")\n else:\n print("NO")\nclass union_find():\n def __init__(self,n):\n self.n=n\n self.P=[a for a in range(N)]\n self.rank=[0]*n\n \n def find(self,x):\n if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n return self.P[x]\n \n def same(self,x,y):\n return self.find(x)==self.find(y)\n \n def link(self,x,y):\n if self.rank[x]<self.rank[y]:\n self.P[x]=y\n elif self.rank[y]<self.rank[x]:\n self.P[y]=x\n else:\n self.P[x]=y\n self.rank[y]+=1\n \n def unite(self,x,y):\n self.link(self.find(x),self.find(y))\n \n def size(self):\n S=set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\ndef bin_(num,size):\n A=[0]*size\n for a in range(size):\n if (num>>(size-a-1))&1==1:\n A[a]=1\n else:\n A[a]=0\n return A\ndef fac_list(n,mod_=0):\n A=[1]*(n+1)\n for a in range(2,len(A)):\n A[a]=A[a-1]*a\n if(mod>0):A[a]%=mod_\n return A\ndef comb(n,r,mod,fac):\n if(n-r<0):return 0\n return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef next_comb(num,size):\n x=num&(-num)\n y=num+x\n z=num&(~y)\n z//=x\n z=z>>1\n num=(y|z)\n if(num>=(1<<size)):return False\n else:\n return num\ndef get_primes(n,type="int"):\n A=[True]*(n+1)\n A[0]=False\n A[1]=False\n for a in range(2,n+1):\n if A[a]:\n for b in range(a*2,n+1,a):\n A[b]=False\n if(type=="bool"):return A\n B=[]\n for a in range(n+1):\n if(A[a]):B.append(a)\n return B\ndef is_prime(num):\n if(num<=2):return False\n i=2\n while i*i<=num:\n if(num%i==0):return False\n i+=1\n return True\ndef join(A,c=" "):\n n=len(A)\n A=list(map(str,A))\n s=""\n for a in range(n):\n s+=A[a]\n if(a<n-1):s+=c\n return s\n#main\n\n@lru_cache(maxsize=None)\ndef f(num,k):\n if(num==0 and k==0):return 1\n elif(num<=0 or k<0):return 0\n else:\n r=num-(num//10)*10\n m=num//10\n return f(m,k-1)*r+f(m-1,k-1)*(9-r)+f(m,k)\ns=int(input())\nk=int(input())\nprint(f(s,k))\n']
['Wrong Answer', 'Accepted']
['s189744998', 's568791666']
[5744.0, 5864.0]
[44.0, 46.0]
[2716, 2714]
p02781
u905203728
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['N = input()\nK = int(input())\nm = len(N)\ndp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]\ndp[0][0][0] = 1\n\n\nfor i in range(1, m + 1):\n l = int(N[i - 1])\n for k in range(K + 1):\n dp[i][1][k] += dp[i - 1][1][k]\n if l != 0:\n dp[i][1][k] += dp[i - 1][0][k]\n else:\n dp[i][0][k] += dp[i - 1][0][k]\n if k - 1 >= 0:\n dp[i][1][k] += 9 * dp[i - 1][1][k - 1]\n if l != 0:\n dp[i][0][k] += dp[i - 1][0][k - 1]\n dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1]\n\nprint(dp[m][1][K])', 'n=input()\nK=int(input())\nm=len(n)\n\nDP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)]\nDP[0][0][0]=1\n\nfor i in range(1,m+1):\n for flag in range(2):\n num=9 if flag else int(n[i-1])\n for j in range(K+1):\n for k in range(num+1):\n if k==0:DP[i][flag or k<num][j] +=DP[i-1][flag][j]\n else:DP[i][flag or k<num][j] +=DP[i-1][flag][j-1]\n\nprint(DP[m][0][K]+DP[m][1][K])']
['Wrong Answer', 'Accepted']
['s056157026', 's550914206']
[3064.0, 3064.0]
[18.0, 21.0]
[613, 421]
p02781
u909616675
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['N=int(input())\nK=int(input())\nimport math\nans=0\nn=str(N)\na=len(n)\nprint(a)\ndef combi(p,q):\n return math.factorial(p)//(math.factorial(q)*math.factorial(p-q))\nif a<K:\n ans=0\nelse:\n if a>K:\n ans+=combi(a-1,K)*(9**K)\n print(ans)\n if K==1:\n ans+=int(n[0])\n elif K==2:ans+=int(n[0])*(a-2)*9+(int(n[0])-1)*9+int(n[1])\n else:ans+=(int(n[0])-1)*81*(combi(a-1,2))+combi(a-2,2)*81+9*(a-2)*(int(n[1])-1)+int(n[2])+(a-3)*9\n\nprint(ans)', 'N=9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\nK=3\nimport math\nans=0\nn=str(N)\na=len(n)\ndef combi(p,q):\n return math.factorial(p)//(math.factorial(q)*math.factorial(p-q))\ndef mi(i):\n if int(n[i])==0:\n return 0\n else:\n return int(n[i])-1\n\n\nif a<K:\n ans=0\nelse:\n if a>K:\n ans+=combi(a-1,K)*(9**K)\n if K==1:ans+=int(n[0])\n elif K==2:ans+=mi(0)*(a-1)*9+(a-2)*9+int(n[1])\n elif a==3 : ans+=mi(0)*81*(combi(a-1,2))+9*mi(1)+int(n[2])\n else:ans+=mi(0)*81*(combi(a-1,2))+combi(a-2,2)*81+9*(a-2)*mi(1)+int(n[2])+(a-3)*9\n\nprint(ans)', 'N=int(input())\nK=int(input())\nimport math\nans=0\nn=str(N)\na=len(n)\ndef combi(p,q):\n if p<q : return 0\n else: return math.factorial(p)//(math.factorial(q)*math.factorial(p-q))\ndef mi(i):\n if i==0:\n return 0\n else:\n return i-1\ndef zero(i):\n if int(n[i])==0:\n return 0\n else:\n return 1\nif a<K:\n ans=0\nelse:\n if a>K:\n ans+=combi(a-1,K)*(9**K)\n if K==1:ans+=int(n[0])\n elif K==2:\n x=0\n i=1\n b=0\n bs=0\n while True:\n if (int(n[i])!=0) and (x==0):\n b=int(n[i])\n bs=a-i\n x+=1\n if (x==1) or (i==len(n)-1):\n break\n i+=1\n ans+=mi(int(n[0]))*(a-1)*9+mi(bs)*9+b\n elif a==3 : ans+=mi(int(n[0]))*81*(combi(a-1,2))+9*mi(int(n[1]))+int(n[2])\n else:\n x=0\n i=1\n b=0\n bs=0\n c=0\n cs=0\n while True:\n if (int(n[i])!=0) and (x==0):\n b=int(n[i])\n bs=a-i\n x+=1\n elif (int(n[i])!=0) and (x==1):\n c=int(n[i])\n cs=a-i\n x+=1\n if (x==2) or (i==len(n)-1):\n break\n i+=1\n ans+=mi(int(n[0]))*81*(combi(a-1,2))+combi(bs-1,2)*81+9*(a-2)*mi(b)+c+mi(cs)*9\n\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s742467511', 's913257710', 's827621401']
[3064.0, 3064.0, 3192.0]
[18.0, 17.0, 18.0]
[461, 624, 1338]
p02781
u919730120
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
["from math import factorial\n\ndef combinations_count(n, r):\n \n return factorial(n) // (factorial(n - r) * factorial(r))\n\nn=int(input())\nk=int(input())\nans=0\nnstr=str(n)\nnl=len(nstr)\nfor i in range(k,nl):\n ans+=combinations_count(i-1,k-1)\nans*=9**k\nzerocnt=0\nfor i in range(nl):\n if zerocnt<=nl-k:\n if i==0:\n ans+=(int(nstr[0])-1)*combinations_count(nl-1,k-1)*(9**(k-1))\n else:\n if nstr[i]=='0':\n zerocnt+=1\n else:\n ans+=(int(nstr[i])-1)*combinations_count(nl-i-1,k-i+zerocnt-1)*9**(k-i+zerocnt-1)\n else:\n break\nprint(ans)", 's=input()\nK=int(input())\nn=len(s)\ndp=[[[0]*2 for _ in range(K+1)] for _ in range(n+1)]\ndp[0][0][0]=1\nfor i in range(n):\n for j in range(K+1):\n for k in range(2):\n nd=int(s[i])\n for d in range(10):\n ni,nj,nk=i+1,j,k\n if d!=0:\n nj+=1\n if nj>K:\n continue\n if nk==0:\n if nd<d:\n continue\n if nd>d:\n nk=1\n dp[ni][nj][nk]+=dp[i][j][k]\nprint(dp[n][K][0]+dp[n][K][1])']
['Runtime Error', 'Accepted']
['s122944054', 's714327618']
[3064.0, 3188.0]
[18.0, 24.0]
[641, 587]
p02781
u932465688
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['n = int(input())\nk = int(input())\nif k == 1:\n flag = True\n cnt = 0\n while flag:\n for i in range(101):\n for j in range(1,10):\n if j*(10**i) <= n:\n cnt += 1\n else:\n flag = False\n break\nelif k == 2:\n flag = True\n cnt = 0\n while flag:\n for i in range(1,101):\n for j in range(1,10):\n for l in range(i):\n for m in range(1,10):\n if j*(10**i)+m*(10**l) <= n:\n cnt += 1\n else:\n flag = False\n break\nelse:\n \nprint(cnt)', "n = input()\nk = int(input())\ndp = [[[0,0,0,0],[0,0,0,0]] for i in range(len(n))]\n\n\n\n\ndp[0][0][0] = 0\ndp[0][0][1] = 1\ndp[0][1][0] = 1\ndp[0][1][1] = int(n[0])-1\nfor i in range(1,len(str(n))):\n if n[i] != '0':\n dp[i][0][0] = 0 \n dp[i][0][1] = dp[i-1][0][0] \n dp[i][0][2] = dp[i-1][0][1]\n dp[i][0][3] = dp[i-1][0][2]\n dp[i][1][0] = dp[i-1][1][0] \n dp[i][1][1] = dp[i-1][0][0]*(int(n[i])-1)+dp[i-1][0][1]+dp[i-1][1][1]+dp[i-1][1][0]*9\n dp[i][1][2] = dp[i-1][0][1]*(int(n[i])-1)+dp[i-1][0][2]+dp[i-1][1][2]+dp[i-1][1][1]*9\n dp[i][1][3] = dp[i-1][0][2]*(int(n[i])-1)+dp[i-1][0][3]+dp[i-1][1][3]+dp[i-1][1][2]*9\n else:\n dp[i][0][0] = dp[i-1][0][0]\n dp[i][0][1] = dp[i-1][0][1]\n dp[i][0][2] = dp[i-1][0][2]\n dp[i][0][3] = dp[i-1][0][3]\n dp[i][1][0] = dp[i-1][1][0] \n dp[i][1][1] = dp[i-1][1][0]*9+dp[i-1][1][1]\n dp[i][1][2] = dp[i-1][1][1]*9+dp[i-1][1][2]\n dp[i][1][3] = dp[i-1][1][2]*9+dp[i-1][1][3]\nprint(dp[len(n)-1][0][k]+dp[len(n)-1][1][k])"]
['Runtime Error', 'Accepted']
['s814172394', 's094620155']
[3064.0, 3192.0]
[17.0, 18.0]
[548, 1647]
p02781
u946996108
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['mod = 10**9 + 7\nfrom collections import deque\n\ndef main():\n N = iip(False)\n K = iip(False)\n ret = solve(N, K)\n print(ret)\n\ndef solve(N, K):\n\n strn = str(N)\n\n A = []\n B = []\n\n for i in range(len(strn), 0, -1):\n if strn[len(strn)-i] != "0":\n A.append(int(strn[len(strn)-i]))\n B.append(i)\n\n\n if K == 1:\n return 9*(B[0]-1) + A[0]\n\n\n if K == 2:\n if len(strn) < 2:\n return 0\n ret = 0\n ret += (B[0]-1) * (B[0]-2) // 2 * (9**2) \n ret += (A[0]-1) * 9 * (B[0]-1) \n if len(B) >= 2 and len(A) >= 2:\n ret += (B[1]-1) * 9 + A[1] \n return ret\n\n ret = 0\n ret += (B[0] - 1) * (B[0] - 2) * (B[0] - 3) // 6 * 9**3 \n ret += (A[0] - 1) * (B[0] - 1) * (B[0] - 2) // 2 * 9**2 \n\n \n if len(strn) < 3:\n return 0\n if len(B) >= 2:\n ret += (B[1]-1) * (B[1]-2) // 2 * 9**2 \n if len(B) >= 2 and len(A) >= 2:\n ret += (A[1] - 1) * (B[1]-1) * 9 \n if len(B) >= 3 and len(A) >= 3:\n ret += (B[2] - 1) * 9 + A[2] \n return ret\n\n\n\n\ndef split_print_space(s):\n print(" ".join([str(i) for i in s]))\n\ndef split_print_enter(s):\n print("\\n".join([str(i) for i in s]))\n\n\ndef searchsorted(sorted_list, n, side):\n if side not in ["right", "left"]:\n raise Exception("sideはrightかleftで指定してください")\n\n l = 0\n r = len(sorted_list)\n\n if n > sorted_list[-1]:\n \n return len(sorted_list)\n if n < sorted_list[0]:\n return 0\n\n while r-l > 1:\n x = (l+r)//2\n if sorted_list[x] > n:\n r = x\n elif sorted_list[x] < n:\n l = x\n else:\n if side == "left":\n r = x\n elif side == "right":\n l = x\n\n if side == "left":\n if sorted_list[l] == n:\n return r - 1\n else:\n return r\n\n if side == "right":\n if sorted_list[l] == n:\n return l + 1\n else:\n return l\n\n\ndef iip(listed):\n ret = [int(i) for i in input().split()]\n if len(ret) == 1 and not listed:\n return ret[0]\n return ret\n\ndef soinsuu_bunkai(n):\n ret = []\n for i in range(2, int(n**0.5)+1):\n while n % i == 0:\n n //= i\n ret.append(i)\n if i > n:\n break\n if n != 1:\n ret.append(n)\n return ret\n\n\ndef conbination(n, r, mod, test=False):\n if n <=0:\n return 0\n if r == 0:\n return 1\n if r < 0:\n return 0\n if r == 1:\n return n\n ret = 1\n for i in range(n-r+1, n+1):\n ret *= i\n ret = ret % mod\n\n bunbo = 1\n for i in range(1, r+1):\n bunbo *= i\n bunbo = bunbo % mod\n\n ret = (ret * inv(bunbo, mod)) % mod\n if test:\n #print(f"{n}C{r} = {ret}")\n pass\n return ret\n\n\ndef inv(n, mod):\n return power(n, mod-2)\n\ndef power(n, p):\n if p == 0:\n return 1\n if p % 2 == 0:\n return (power(n, p//2) ** 2) % mod\n if p % 2 == 1:\n return (n * power(n, p-1)) % mod\n\n\nif __name__ == "__main__":\n main()', 'mod = 10**9 + 7\nfrom collections import deque\n\ndef main():\n N = iip(False)\n K = iip(False)\n ret = solve(N, K)\n print(ret)\n\ndef solve(N, K):\n\n strn = str(N)\n\n A = []\n B = []\n\n for i in range(len(strn), 0, -1):\n if strn[len(strn)-i] != "0":\n A.append(int(strn[len(strn)-i]))\n B.append(i)\n\n\n if K == 1:\n return 9*(B[0]-1) + A[0]\n\n\n if K == 2:\n if len(strn) < 2:\n return 0\n ret = 0\n ret += (B[0]-1) * (B[0]-2) // 2 * (9**2) \n ret += (A[0]-1) * 9 * (B[0]-1) \n if len(B) >= 2 and len(A) >= 2:\n ret += (B[1]-1) * 9 + A[1] \n return ret\n\n ret = 0\n ret += (B[0] - 1) * (B[0] - 2) * (B[0] - 3) // 6 * 9**3 \n ret += (A[0] - 1) * (B[0] - 1) * (B[0] - 2) // 2 * 9**2 \n\n \n if len(strn) < 3:\n return 0\n if len(B) >= 2:\n ret += (B[1]-1) * (B[1]-2) // 2 * 9**2 \n if len(B) >= 2 and len(A) >= 2:\n ret += (A[1] - 1) * (B[1]-1) * 9 \n if len(B) >= 3 and len(A) >= 3:\n ret += (B[2] - 1) * 9 + A[2] \n return ret\n\n\n\n\ndef split_print_space(s):\n print(" ".join([str(i) for i in s]))\n\ndef split_print_enter(s):\n print("\\n".join([str(i) for i in s]))\n\n\ndef searchsorted(sorted_list, n, side):\n if side not in ["right", "left"]:\n raise Exception("sideはrightかleftで指定してください")\n\n l = 0\n r = len(sorted_list)\n\n if n > sorted_list[-1]:\n \n return len(sorted_list)\n if n < sorted_list[0]:\n return 0\n\n while r-l > 1:\n x = (l+r)//2\n if sorted_list[x] > n:\n r = x\n elif sorted_list[x] < n:\n l = x\n else:\n if side == "left":\n r = x\n elif side == "right":\n l = x\n\n if side == "left":\n if sorted_list[l] == n:\n return r - 1\n else:\n return r\n\n if side == "right":\n if sorted_list[l] == n:\n return l + 1\n else:\n return l\n\n\ndef iip(listed):\n ret = [int(i) for i in input().split()]\n if len(ret) == 1 and not listed:\n return ret[0]\n return ret\n\ndef soinsuu_bunkai(n):\n ret = []\n for i in range(2, int(n**0.5)+1):\n while n % i == 0:\n n //= i\n ret.append(i)\n if i > n:\n break\n if n != 1:\n ret.append(n)\n return ret\n\n\ndef conbination(n, r, mod, test=False):\n if n <=0:\n return 0\n if r == 0:\n return 1\n if r < 0:\n return 0\n if r == 1:\n return n\n ret = 1\n for i in range(n-r+1, n+1):\n ret *= i\n ret = ret % mod\n\n bunbo = 1\n for i in range(1, r+1):\n bunbo *= i\n bunbo = bunbo % mod\n\n ret = (ret * inv(bunbo, mod)) % mod\n if test:\n #print(f"{n}C{r} = {ret}")\n pass\n return ret\n\n\ndef inv(n, mod):\n return power(n, mod-2)\n\ndef power(n, p):\n if p == 0:\n return 1\n if p % 2 == 0:\n return (power(n, p//2) ** 2) % mod\n if p % 2 == 1:\n return (n * power(n, p-1)) % mod\n\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s300981965', 's391283508']
[3064.0, 3444.0]
[17.0, 21.0]
[3578, 3582]
p02781
u952491523
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
["def comb(n,k):\n if n == 0:\n return 0\n if n == k:\n return 1\n \n num = 1\n for i in range(n-k+1,n+1):\n num *= i\n \n for i in range(2,k+1):\n num //= i\n \n\n return num\n \ndef syou(n,k):\n if k == 0:\n return 1\n \n if len(n) < k:\n return 0\n \n if len(n) == 1:\n return int(n)\n \n l = len(n)\n if n[0] == '0':\n return syou(n[1:l], k)\n \n ans = comb(l-1, k) * (9**k)\n \n top = int(n[0])\n ans += comb(l-1, k-1) * (top-1) * (9**(k-1))\n \n ans += syou(n[1:l], k-1)\n print('tmp:', n,k,ans)\n return ans\n\n\nn = input()\nk = int(input())\n\nprint(syou(n, k))", "def comb(n,k):\n if n == 0:\n return 0\n if n == k:\n return 1\n \n num = 1\n for i in range(n-k+1,n+1):\n num *= i\n \n for i in range(2,k+1):\n num //= i\n \n\n return num\n \ndef syou(n,k):\n if k == 0:\n return 1\n \n if len(n) < k:\n return 0\n \n if len(n) == 1:\n return int(n)\n \n if n[0] == '0':\n return syou(n[1:l], k-1)\n \n l = len(n)\n ans = comb(l-1, k) * (9**k)\n \n top = int(n[0])\n ans += comb(l-1, k-1) * (top-1) * (9**(k-1))\n \n ans += syou(n[1:l], k-1)\n print('tmp:', n,k,ans)\n return ans\n\n\nn = input()\nk = int(input())\n\nprint(syou(n, k))", "def comb(n,k):\n if n == 0:\n return 0\n if n == k:\n return 1\n \n num = 1\n for i in range(n-k+1,n+1):\n num *= i\n \n for i in range(2,k+1):\n num //= i\n \n\n return num\n \ndef syou(n,k):\n if k == 0:\n return 1\n \n if len(n) < k:\n return 0\n \n if len(n) == 1:\n return int(n)\n \n l = len(n)\n if n[0] == '0':\n return syou(n[1:l], k)\n \n ans = comb(l-1, k) * (9**k)\n \n top = int(n[0])\n ans += comb(l-1, k-1) * (top-1) * (9**(k-1))\n \n ans += syou(n[1:l], k-1)\n return ans\n\n\nn = input()\nk = int(input())\n\nprint(syou(n, k))"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s513723594', 's727615089', 's914939212']
[3064.0, 3064.0, 3188.0]
[17.0, 18.0, 20.0]
[582, 584, 557]
p02781
u964966380
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['def mondai(n, k):\n\n keta = 0\n a = n\n b = []\n ans = 0\n d = 0\n\n while a >= 10:\n c = a % 10\n b.append(c)\n a = a // 10\n keta = keta + 1\n \n for i in range(len(b)):\n d = d + b[i] * (10 ** i)\n\n if k == 1:\n ans = keta * 9 + a\n\n elif k == 2:\n if keta == 0:\n ans = 0\n elif keta == 1:\n ans = keta * 9 * (a - 1) + mondai(d, 1)\n else:\n for i in range(1, keta):\n ans = ans + i * 81\n ans = ans + keta * 9 * (a - 1) + mondai(d, 1)\n \n else:\n if keta == 0 or keta == 1:\n ans = 0\n elif keta == 2:\n ans = keta * 81 * (a - 1) + mondai(d, 2)\n \n else:\n for i in range(2, keta):\n ans = ans + i * (i - 1) / 2 * 9 * 9 * 9\n ans = ans + keta * (keta - 1) / 2 * 81 * (a - 1) + mondai(d, 2) \n \n \n return ans\n\nn = int(input())\nk = int(input())\n\nans = mondai(n, k)', 'def mondai(n, k):\n\n keta = 0\n a = n\n b = []\n ans = 0\n d = 0\n\n while a >= 10:\n c = a % 10\n b.append(c)\n a = a // 10\n keta = keta + 1\n \n for i in range(len(b)):\n d = d + b[i] * (10 ** i)\n\n if k == 1:\n ans = keta * 9 + a\n\n elif k == 2:\n if keta == 0:\n ans = 0\n elif keta == 1:\n ans = keta * 9 * (a - 1) + mondai(d, 1)\n else:\n for i in range(1, keta):\n ans = ans + i * 81\n ans = ans + keta * 9 * (a - 1) + mondai(d, 1)\n \n else:\n if keta == 0 or keta == 1:\n ans = 0\n elif keta == 2:\n ans = keta * 81 * (a - 1) + mondai(d, 2)\n \n else:\n for i in range(2, keta):\n ans = ans + i * (i - 1) / 2 * 9 * 9 * 9\n ans = ans + keta * (keta - 1) / 2 * 81 * (a - 1) + mondai(d, 2) \n \n \n return ans\n\nn = int(input())\nk = int(input())\n\nans = int(mondai(n, k))\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s456275369', 's626641778']
[3064.0, 3064.0]
[18.0, 18.0]
[1010, 1031]
p02781
u969190727
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['N=input()\nk=int(input())\nln=len(N)\nDP=[[[0]*2 for _ in range(k+1)] for _ in range(len(N)+1)]\nDP[0][0][0]=1\nfor i in range(1,len(N)+1):\n DP[i][0][1]=1\nfor i in range(len(N)):\n ni=int(N[i])\n for j in range(1,k+1):\n DP[i+1][j][1]=DP[i][j][1]+max(0,ni-1)*DP[i][j-1][0]+9*DP[i][j-1][1]+DP[i][j][0]\n if ni==0:\n DP[i+1][j][0]=DP[i][j][0]\n else:\n DP[i+1][j][0]=DP[i][j-1][0]\nprint(DP[ln][k][0]+DP[ln][k][1])\n\n', 'N=input()\nk=int(input())\nln=len(N)\nDP=[[[0]*2 for _ in range(k+1)] for _ in range(len(N)+1)]\nDP[0][0][0]=1\nfor i in range(1,len(N)+1):\n DP[i][0][1]=1\nfor i in range(len(N)):\n ni=int(N[i])\n for j in range(1,k+1):\n DP[i+1][j][1]=DP[i][j][1]+max(0,ni-1)*DP[i][j-1][0]+9*DP[i][j-1][1]\n if ni==0:\n DP[i+1][j][0]=DP[i][j][0]\n else:\n DP[i+1][j][0]=DP[i][j-1][0]\n DP[i+1][j][1]+=DP[i][j][0]\nprint(DP[ln][k][0]+DP[ln][k][1])\n']
['Wrong Answer', 'Accepted']
['s286483722', 's652197777']
[3064.0, 3064.0]
[18.0, 19.0]
[423, 443]
p02781
u977141657
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['n = input()\nk = input()\nnl = len(n)\n\ndp = [[[0]*(k+1) for _ in range(2)]for _ in range(nl+1)]\n\ndp[0][0][0] = 1\n\nfor i in range(nl):\n for j in range(2):\n for l in range(k+1):\n c = int(n[i])\n if j == 1:\n dp[i+1][j][l] += dp[i][j][l]\n if l < k:\n dp[i+1][j][l+1] += dp[i][j][l]*9\n else:\n if c == 0:\n dp[i+1][0][l] += dp[i][j][l]\n else:\n dp[i+1][1][l] += dp[i][j][l]\n if l < k:\n dp[i+1][1][l+1] += dp[i][j][l]*(c-1) \n dp[i+1][0][l+1] += dp[i][j][l] \n \nprint(dp[nl][0][k]+dp[nl][1][k])\n \n\n', 'n = input()\nk = int(input())\nnl = len(n)\n\ndp = [[[0]*(k+1) for _ in range(2)]for _ in range(nl+1)]\n\ndp[0][0][0] = 1\n\nfor i in range(nl):\n for j in range(2):\n for l in range(k+1):\n c = int(n[i])\n if j == 1:\n dp[i+1][j][l] += dp[i][j][l]\n if l < k:\n dp[i+1][j][l+1] += dp[i][j][l]*9\n else:\n if c == 0:\n dp[i+1][0][l] += dp[i][j][l]\n else:\n dp[i+1][1][l] += dp[i][j][l]\n if l < k:\n dp[i+1][1][l+1] += dp[i][j][l]*(c-1) \n dp[i+1][0][l+1] += dp[i][j][l] \n \nprint(dp[nl][0][k]+dp[nl][1][k])']
['Runtime Error', 'Accepted']
['s140886883', 's629834883']
[3064.0, 3064.0]
[17.0, 18.0]
[870, 862]
p02781
u995004106
2,000
1,048,576
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
['def modpow(a,n,p):\n if n==0:\n return 1\n x=modpow(a,n//2,p)\n x=(x*x)%p\n if (n%2)==1:\n x=(x*a)%p\n return x%p\ndef modinv(a,p):\n return modpow(a,p-2,p)\n\nr1,c1,r2,c2=map(int,input().split())\nn1=r2+c2+2\nn2=r2+c1+1\nn3=r1+c2+1\nn4=r1+c1\nl=[r2+1,r2+1,r1,r1]\np=10**9+7\nbuf=1\ncnt=0\nl=[0]*(10**6+10)\nl2=[0]*20\ninv=[0]*(10**6+10)\nfor i in range(2,n1+3,1):#n1+1\n l[i]=(l[i-1]*i)%p\nprint((((l[n1]*modinv(l[r2+1],p)*modinv(l[n1-r2-1],p))%p)-(l[n2]*modinv(l[r2+1],p)*modinv(l[n2-r2-1],p))-(l[n3]*modinv(l[r1],p)*modinv(l[n3-r1],p))+(l[n4]*modinv(l[r1],p)*modinv(l[n4-r1],p)))%p)', '\nimport numpy as np\n\nN=input()\nK=input()\ndp=np.zeros((len(str(N))+10,len(str(N))+10,2))\ndp=dp.tolist()\n\n\nx0=int(N[0])\ndp[0][0][0]=1\n\n\nfor i in range(0,len(N),1):\n for j in range(0,4,1):\n for k in range(0,2,1):\n nd=int(N[i])\n for d in range(0,10,1):\n ni=i+1\n nj=j\n nk=k\n if not(d==0):\n nj=nj+1\n if ((k==0)and(d<nd)):\n nk=1\n if (not(nj>int(K)))and(not((k==0)and(d>nd))):\n dp[ni][nj][nk]=dp[ni][nj][nk]+dp[i][j][k]\n\n\nprint(int(dp[len(N)][int(K)][0]+dp[len(N)][int(K)][1]))\n']
['Runtime Error', 'Accepted']
['s369928933', 's937975107']
[3064.0, 13892.0]
[17.0, 162.0]
[595, 649]
p02782
u002539468
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['mod = 10 ** 9 + 7\nN = 2 * 10 ** 6\n\nfac = [0] * N\nfinv = [0] * N\ninv = [0] * N\n\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\ninv[1] = 1\nfor i in range(2, N):\n fac[i] = fac[i - 1] * i % mod\n \n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\n\ndef com(n, k):\n global fac, finv, mod\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n\n\nr1, c1, r2, c2 = map(int, input().split())\nanswer = 0\n\nfor r in range(r1, r2 + 1):\n for c in range(c1, c2 + 1):\n answer += com(r + c, c)\n answer %= mod\nprint(answer)\n', 'mod = 10 ** 9 + 7\nN = 2 * 10 ** 6 + 10\n\nfac = [0] * N\nfinv = [0] * N\ninv = [0] * N\n\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\ninv[1] = 1\nfor i in range(2, N):\n fac[i] = fac[i - 1] * i % mod\n \n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\n\ndef com(n, k):\n global fac, finv, mod\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n\ndef g(r, c):\n return (com(r + c + 2, r + 1) - 1) % mod\n\nr1, c1, r2, c2 = map(int, input().split())\n\nanswer = g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)\nanswer %= mod\nprint(answer)\n', 'def main():\n mod = 10 ** 9 + 7\n N = 2 * 10 ** 6 + 3\n\n fac = [0] * N\n finv = [0] * N\n inv = [0] * N\n\n fac[0] = fac[1] = 1\n finv[0] = finv[1] = 1\n inv[1] = 1\n for i in range(2, N):\n fac[i] = fac[i - 1] * i % mod\n \n # inv[i] = mod - inv[mod % i] * (mod // i) % mod\n # finv[i] = finv[i - 1] * inv[i] % mod\n \n finv[N // 2] = pow(fac[N // 2], mod - 2, mod)\n for i in reversed(range(N // 2)):\n finv[i] = (finv[i + 1] * (i + 1)) % mod\n\n def com(r, c):\n ans = fac[r + c] * finv[r] * finv[c]\n return ans % mod\n\n def g(r, c):\n return (com(r + 1, c + 1) - 1) % mod\n\n r1, c1, r2, c2 = map(int, input().split())\n\n answer = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)\n answer %= mod\n print(answer)\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s169040152', 's420419989', 's151265629']
[219892.0, 228812.0, 145140.0]
[2114.0, 2115.0, 706.0]
[680, 703, 919]
p02782
u018679195
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n t,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,t)+comb(t,b))%MOD)\n \nif _name_ == "_main_":\n main()\n#print the result', 'import sys\nimport math\nimport numpy\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s687989880', 's819815013']
[3064.0, 91408.0]
[17.0, 612.0]
[476, 485]
p02782
u077291787
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['# F - Many Many Paths\ndef get_factorials(lim: int, MOD: int) -> list:\n """Compute a table of factorials (1-indexed)."""\n factorials = [1] * (lim + 1)\n x = 1\n for i in range(1, lim + 1):\n x *= i % MOD\n factorials[i] = x\n return factorials\n\n\ndef mod_comb_with_pow(n: int, k: int, MOD: int) -> int:\n """Compute nCr % MOD using pow(), not an inverse factorial table."""\n return fact[n] * pow(fact[k], MOD - 2, MOD) * pow(fact[n - k], MOD - 2, MOD) % MOD\n\n\ndef main():\n global fact\n MOD = 10 ** 9 + 7\n R1, C1, R2, C2 = map(int, input().split())\n fact = get_factorials(2 * 10 ** 6 + 10, MOD)\n f = lambda x, y: mod_comb_with_pow(x, y, MOD)\n ans = (f(C1 + R1, R1) - f(C1 + R2 + 1, R2 + 1) - f(C2 + R1 + 1, R1) + f(C2 + R2 + 2, R2 + 1)) % MOD\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', '# F - Many Many Paths\ndef get_factorials(lim: int, MOD: int) -> list:\n """Compute a table of factorials (1-indexed)."""\n factorials = [1] * (lim + 1)\n x = 1\n for i in range(1, lim + 1):\n x = (x * i) % MOD\n factorials[i] = x\n return factorials\n\n\ndef mod_comb_with_pow(n: int, k: int, MOD: int) -> int:\n """Compute nCr % MOD using pow(), not an inverse factorial table."""\n return fact[n] * pow(fact[k], MOD - 2, MOD) * pow(fact[n - k], MOD - 2, MOD) % MOD\n\n\ndef main():\n global fact\n MOD = 10 ** 9 + 7\n R1, C1, R2, C2 = map(int, input().split())\n fact = get_factorials(2 * 10 ** 6 + 10, MOD)\n f = lambda x, y: mod_comb_with_pow(x, y, MOD)\n ans = (f(C1 + R1, R1) - f(C1 + R2 + 1, R2 + 1) - f(C2 + R1 + 1, R1) + f(C2 + R2 + 2, R2 + 1)) % MOD\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Accepted']
['s578619527', 's849156566']
[0.0, 82164.0]
[2300.0, 406.0]
[842, 847]
p02782
u123579949
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\nsys.setrecursionlimit(2000000000)\n\np = 10 ** 9 + 7\nN = 2*10 ** 6 \nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv = [0, 1] \n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef comb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\n\n\na1,b1,a2,b2=map(int,input().split())\nscore=comb(a2+b2+2,a2+1,p)-comb(a2+b1+1,a2+1,p)-comb(a1+b2+1,a1,p)+comb(a1+b1,a1,p)\nprint(score%(10**9+7))', 'import sys\nsys.setrecursionlimit(2000000000)\n\ndef comb(n,r):\n def cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\n p = 10 ** 9 + 7\n N = 10 ** 6 \n fact = [1, 1] # fact[n] = (n! mod p)\n factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\n inv = [0, 1] \n\n for i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n return cmb(n, r, p)\n\na1,b1,a2,b2=map(int,input().split())\nscore=comb(a2+b2+2,a2+1)-comb(a2+b1+1,a2+1)-comb(a1+b2+1,a1)+comb(a1+b1,a1)\nprint(score%(10**9+7))', 'a1,b1,a2,b2=map(int,input().split())\n\nimport sys\nsys.setrecursionlimit(2000000000)\n\np = 10 ** 9 + 7\nN = a2+b2+2 \nR = max(a2+1,b2+1)\nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv = [0, 1] \n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n \nfor i in range(2, R + 1):\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef comb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\nscore=comb(a2+b2+2,a2+1,p)-comb(a2+b1+1,a2+1,p)-comb(a1+b2+1,a1,p)+comb(a1+b1,a1,p)\nprint(score%(10**9+7))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s641190399', 's682846177', 's645204006']
[246312.0, 144292.0, 167012.0]
[2212.0, 2209.0, 1296.0]
[658, 726, 703]
p02782
u201234972
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
["#import sys\n#input = sys.stdin.readline\nQ = 10**9+7\ndef getInv(N):\n inv = [0] * (N + 1)\n inv[0] = 1\n inv[1] = 1\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q%i]) % Q\n return inv\n\n\n# inv = [0] * (N + 1)\n# inv[0] = 1\n# inv[1] = 1\n\n\n# inv[i] = (-(Q // i) * inv[Q%i]) % Q\n# ret[i] = ret[i-1]*inv[i]\n# return ret\n\ndef getFactorial(N):\n ret = [1]*(N+1)\n for i in range(2,N+1):\n ret[i] = ret[i-1]*i%Q\n return ret\n\ndef main():\n r1, c1, r2, c2 = map( int, input().split())\n F = getFactorial(2*(10**6))\n J = getInv(2*(10**6))\n I = [0]*(2*(10**6)+1)\n I[0] = 1\n I[1] = 1\n for i in range(2,2*(10**6)+1):\n I[i] = I[i-1]*J[i]%Q\n #print(F[5]*I[5]%Q)\n a = 0\n b = 0\n c = 0\n d = 0\n for i in range(1, c2+1):\n a += F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1\n# print(F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1)\n a %= Q\n if r1 == 1:\n b = 0\n else:\n for i in range(1, c2+1):\n b += F[r1+i]*I[i]%Q*I[r1]%Q-1\n b %= Q\n if c1 == 1:\n c = 0\n else:\n for i in range(1, c1):\n c += F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1\n c %= Q\n if c1 == 1 or r1 == 1:\n d = 0\n else:\n for i in range(1, c1):\n d += F[r1+i]*I[i]%Q*I[r1]%Q-1\n d %= Q\n# print(a, b,c, d)\n print((a-b-c+d)%Q)\nif __name__ == '__main__':\n main()\n", "Q = 10**9+7\ndef getInv(N):\n inv = [0] * (N + 1)\n inv[0] = 1\n inv[1] = 1\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q%i]) % Q\n return inv\n\ndef getFactorialInv(N):\n inv = [0] * (N + 1)\n inv[0] = 1\n inv[1] = 1\n ret = [1]*(N+1)\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q%i]) % Q\n ret[i] = ret[i-1]*inv[i]%Q\n return ret\n\ndef getFactorial(N):\n ret = [1]*(N+1)\n for i in range(2,N+1):\n ret[i] = ret[i-1]*i%Q\n return ret\n\ndef main():\n r1, c1, r2, c2 = map( int, input().split())\n F = getFactorial(2*10**6+2)\n I = getFactorialInv(10**6+1)\n\n def G(a, b):\n return F[a+b+2]*I[a+1]%Q*I[b+1]%Q\n \n print( ( G(r2,c2) - G(r2, c1-1) - G(r1-1, c2) + G(r1-1, c1-1))%Q)\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s936446198', 's442754657']
[240372.0, 161304.0]
[2116.0, 1192.0]
[1497, 814]
p02782
u211160392
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['MOD = 10**9+7\nlist_size = (10**6+10)*4\n\nf_list = [1]*list_size\nf_r_list = [1]*list_size\n\nfor i in range(list_size - 1):\n f_list[i+1] = ((f_list[i] * (i+2)) % MOD)\n\nf_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)\n\nfor i in range(-2, -list_size-1, -1):\n f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)\n\n\n\nr1,c1,r2,c2 = map(int,input().split())\n\nans = f_list[(r2+c2)*2]*f_r_list[r2*2]*f_r_list[c2*2]\nans %= MOD\nans += f_list[(r1+c1-2)*2]*f_r_list[r1*2-2]*f_r_list[c1*2-2]\nans %= MOD\nans -= f_list[(r2+c1)*2]*f_r_list[r2*2]*f_r_list[c1*2]\nans %= MOD\nans -= f_list[(c2+r1)*2]*f_r_list[c2*2]*f_r_list[r1*2]\nans %= MOD\n\nprint(ans)\n\n\n', 'MOD = 10**9+7\nlist_size = (10**6+10)*4\n\nf_list = [1]*list_size\nf_r_list = [1]*list_size\n\nfor i in range(list_size - 1):\n f_list[i+1] = ((f_list[i] * (i+2)) % MOD)\n\nf_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)\n\nfor i in range(-2, -list_size-1, -1):\n f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)\n\n\n\nr1,c1,r2,c2 = map(int,input().split())\n\nans = f_list[(r2+c2)*2]*f_r_list[r2*2]*f_r_list[c2*2]\nans %= MOD\nans += f_list[(r1+c1)*2]*f_r_list[r1*2]*f_r_list[c1*2]\nans %= MOD\nans -= f_list[(r2+c1)*2]*f_r_list[r2*2]*f_r_list[c1*2]\nans %= MOD\nans -= f_list[(c2+r1)*2]*f_r_list[c2*2]*f_r_list[r1*2]\nans %= MOD\n\nprint(ans)\n\n\n', 'MOD = 10**9+7\nr1,c1,r2,c2 = map(int,input().split())\n\nsize = 1010000*2\nf_list = [1]*(size)\nfor i in range(1,size):\n f_list[i] = (f_list[i-1]*i)%MOD\n\ndef func(r,c):\n return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))\n\nans = func(r2+1,c2+1)-1\nans += func(r1,c1)-1\nans -= func(r2+1,c1)-1\nans -= func(r1,c2+1)-1\nprint(ans%MOD)\n\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s564632046', 's998089216', 's597850309']
[262388.0, 262260.0, 82940.0]
[2117.0, 2116.0, 684.0]
[641, 635, 350]
p02782
u255382385
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['#from scipy.special import comb\nr1, c1, r2, c2 = map(int, input().split())\n#mod = 1000000007\n#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod\n#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod\n#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod\n\n\n\np = 10 ** 9 + 7\nN = 10 ** 6 * 2 + 100\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\nhole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)\nrect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)\nrect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)\nduplicate = (cmb(r1 + c1, r1, p) - 1)\nans = (hole - rect1 - rect2 + duplicate) % p\nprint(ans)', 'from scipy.misc import comb\nr1, c1, r2, c2 = map(int, input().split())\nmod = 1000000007\nhole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod\nrect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod\nrect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod\nduplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod\nans = (hole - rect1 - rect2 + duplicate) % mod\nprint(ans)', '#from scipy.special import comb\nr1, c1, r2, c2 = map(int, input().split())\n#mod = 1000000007\n#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod\n#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod\n#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod\n\n\n\np = 10 ** 9 + 7\nN = 1010000*2 \nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\nhole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)\nrect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)\nrect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)\nduplicate = (cmb(r1 + c1, r1, p) - 1)\nans = (hole - rect1 - rect2 + duplicate) % p\nprint(ans)', 'r1, c1, r2, c2 = map(int, input().split())\n\np = 10 ** 9 + 7\nsize = 1010000 * 2\nf_list = [1] * size\nfor i in range(1, size):\n f_list[i] = (f_list[i - 1] * i) % p\n\ndef cmb(n, r):\n return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p\n\nhole = cmb(r2 + 1, c2 + 1) - 1\nrect1 = cmb(r2 + 1, c1) - 1\nrect2 = cmb(r1, c2 + 1) - 1\nduplicate = cmb(r1, c1) - 1\nans = (hole - rect1 - rect2 + duplicate) % p\nprint(ans)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s338124838', 's668700990', 's758153239', 's585745135']
[222996.0, 14312.0, 223404.0, 82932.0]
[2119.0, 2108.0, 2120.0, 683.0]
[1011, 376, 1004, 430]
p02782
u333700164
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['r1,c1,r2,c2=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n-k<k:\n k=n-k\n c=1\n for x in range(n-k+1,n+1):\n c=(c*x)%mod\n d=1\n for x in range(1,k+1):\n d=(d*x)%mod\n c=c*pow(d,mod-2,mod)\n return c%mod\ndef f(i,j):\n return comb(i+j,i,mod)\nans=f(r2+1,c2+1)-f(r2+1,c1+1)-f(r1+1,c2+1)+f(r1+1,r2+1)\nans%=mod\nprint(ans)', 'r1,c1,r2,c2=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n-k<k:\n k=n-k\n c=1\n for x in range(n-k+1,n+1):\n c=(c*x)%mod\n d=1\n for x in range(1,k+1):\n d=(d*x)%mod\n c=c*pow(d,mod-2,mod)\n return c%mod\ndef f(i,j):\n return comb(i+j,i,mod)\nans=f(r2+1,c2+1)-f(r2+1,c1+1)-f(r1+1,c2+1)+f(r1+1,c1+1)\nans%=mod\nprint(ans)\n', 'r1,c1,r2,c2=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n-k<k:\n k=n-k\n c=1\n for x in range(n-k+1,n+1):\n c=(c*x)%mod\n d=1\n for x in range(1,k+1):\n d=(d*x)%mod\n c=c*pow(d,mod-2,mod)\n return c%mod\ndef f(i,j):\n return comb(i+j,i,mod)\nans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,r2)\nans%=mod\nprint(ans)\n', 'r1,c1,r2,c2=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n-k<k:\n k=n-k\n c=1\n for x in range(n-k+1,n+1):\n c=(c*x)%mod\n d=1\n for x in range(1,k+1):\n d=(d*x)%mod\n c=c*pow(d,mod-2,mod)\n return c%mod\ndef f(i,j):\n return comb(i+j,i,mod)\nans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1)\nans%=mod\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s090679229', 's596437044', 's940441129', 's353451215']
[9204.0, 9144.0, 9064.0, 8984.0]
[806.0, 802.0, 797.0, 794.0]
[361, 362, 354, 354]
p02782
u389910364
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import os\nimport sys\n\nfrom scipy.misc import comb\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\n# MOD = 998244353\n\n\nR1, C1, R2, C2 = list(map(int, sys.stdin.buffer.readline().split()))\n\n\n\n\n# ncr(n, r) == ncr(n-1,r) + (n-1,r-1)\n# nhr(n, r) == sum([nhr(n-1,k) for k in range(r)])\n\n\n# g(R2, C2) - g(R1-1, C2) - g(R2, C1-1) + g(R1-1, C1-1)\n\ndef f(n, r):\n return comb(n + r, r, exact=True)\n\n\n# @debug\ndef g(r, c):\n \n \n \n \n\n \n return f(r + 1, c + 1) - f(r, 0)\n\n\nans = g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)\nans %= MOD\nprint(ans)\n', 'import os\nimport sys\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\n\n# MOD = 998244353\n\n\ndef mod_invs(max, mod):\n \n invs = [1] * (max + 1)\n invs[0] = 0\n for x in range(2, max + 1):\n invs[x] = (-(mod // x) * invs[mod % x]) % mod\n return invs\n\n\ndef factorial_invs(max, mod):\n \n ret = [1]\n r = 1\n for inv in mod_invs(max, mod)[1:]:\n r = r * inv % mod\n ret.append(r)\n return ret\n\n\ndef get_factorials(max, mod=None):\n \n ret = [1]\n n = 1\n if mod:\n for i in range(1, max + 1):\n n *= i\n n %= mod\n ret.append(n)\n else:\n for i in range(1, max + 1):\n n *= i\n ret.append(n)\n return ret\n\n\nclass Combination:\n def __init__(self, max, mod):\n \n self._factorials = get_factorials(max, mod)\n self._finvs = factorial_invs(max, mod)\n self._mod = mod\n\n def ncr(self, n, r):\n """\n :param int n:\n :param int r:\n :rtype: int\n """\n if n < r:\n return 0\n return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod\n\n\nR1, C1, R2, C2 = list(map(int, sys.stdin.buffer.readline().split()))\n\ncomb = Combination(max=10 ** 6 * 2 + 100, mod=MOD)\n\n\n\n\n# ncr(n, r) == ncr(n-1,r) + (n-1,r-1)\n# nhr(n, r) == sum([nhr(n-1,k) for k in range(r)])\n\n\n# g(R2, C2) - g(R1-1, C2) - g(R2, C1-1) + g(R1-1, C1-1)\n\ndef f(n, r):\n return comb.ncr(n + r, r)\n\n\n# @debug\ndef g(r, c):\n \n \n \n \n\n \n return f(r + 1, c + 1) - f(r, 0)\n\n\nans = g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)\nans %= MOD\nprint(ans)\n']
['Time Limit Exceeded', 'Accepted']
['s814960187', 's558422011']
[15296.0, 258584.0]
[2109.0, 1780.0]
[908, 2351]
p02782
u600402037
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\nfrom math import factorial\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nK = ir()\nlength = len(str(N))\n\ndef F(length, K, N):\n if length < K:\n return 0\n if K == 0:\n return 1\n if length == 1: \n return N\n ret = 0\n top = int(str(N)[0])\n if length-K >= 1:\n ret += factorial(length-1) // factorial(K) // factorial(length-K-1) * 9 ** K \n ret += factorial(length-1) // factorial(K-1) // factorial(length-K) * (top-1) * 9 ** (K-1) \n \n if K > 1: \n N = int(str(N)[1:])\n length = len(str(N))\n ret += F(length, K-1, N)\n else:\n ret += 1 \n return ret\n\nanswer = F(length, K, N)\nprint(answer)\n', '# coding: utf-8\nimport sys\nimport numpy as np\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nMOD = 10 ** 9 + 7\n\ndef cmb(n, k):\n if k < 0 or k > n: return 0 \n return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD\n\ndef cumprod(arr, MOD):\n L = len(arr); Lsq = int(L**.5+1)\n arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)\n for n in range(1, Lsq):\n arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD\n for n in range(1, Lsq):\n arr[n] *= arr[n-1, -1]; arr[n] %= MOD\n return arr.ravel()[:L]\n\ndef make_fact(U, MOD):\n x = np.arange(U, dtype=np.int64); x[0] = 1\n fact = cumprod(x, MOD)\n x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)\n fact_inv = cumprod(x, MOD)[::-1]\n return fact, fact_inv\n\nU = 2 * 10 ** 6 + 3 \nfact, fact_inv = make_fact(U, MOD)\n\nr1, c1, r2, c2 = lr()\nanswer = cmb(r2+c2+2, r2+1) - 1\nanswer -= cmb(r2+c1+1, r2+1) - 1\nanswer -= cmb(r1+c2+1, c2+1) - 1\nanswer += cmb(r1+c1, r1) - 1\nprint(answer % MOD)\n# 26']
['Runtime Error', 'Accepted']
['s629358041', 's068684892']
[3064.0, 90532.0]
[17.0, 355.0]
[875, 1081]
p02782
u638456847
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['MOD = 10**9+7\nfac = [1, 1]\nf_inv = [1, 1]\ninv = [0, 1]\n\ndef prepare(n, mod):\n for i in range(2, n+1):\n fac.append((fac[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod//i)) % mod)\n f_inv.append((f_inv[-1] * inv[-1]) % mod)\n\n\ndef modcmb(n, r, mod):\n if n < 0 or r < 0 or r > n:\n return 0\n\n return fac[n] * f_inv[r] * f_inv[n-r] % mod\n\n\ndef f(r, c):\n return modcmb(r+c, r, MOD)\n\n\ndef g(x, y):\n return ((y+2) * modcmb(x+y+2, x, MOD) - (x+1)) * pow(x+1, MOD-2, MOD)\n\n\ndef main():\n prepare(2*10**6+10, MOD)\n r1,c1,r2,c2 = map(int, input().split())\n\n ans = g(r2, c2) - g(r1-1, c2) - g(r2, c1-1) + g(r1-1, c1-1)\n ans %= MOD\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', '###################\n# AC:1102 ms(PyPy)\n###################\n\nMOD = 10**9+7\nfac = [1, 1]\nf_inv = [1, 1]\ninv = [0, 1]\n\ndef prepare(n, mod):\n for i in range(2, n+1):\n fac.append((fac[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod//i)) % mod)\n f_inv.append((f_inv[-1] * inv[-1]) % mod)\n\n\ndef modcmb(n, r, mod):\n if n < 0 or r < 0 or r > n:\n return 0\n\n return fac[n] * f_inv[r] * f_inv[n-r] % mod\n\n\ndef f(r, c):\n return modcmb(r+c, r, MOD)\n\n\ndef main():\n prepare(2*10**6+10, MOD)\n r1,c1,r2,c2 = map(int, input().split())\n\n ans = 0\n for c in range(c1,c2+1):\n ans += ((r2+1) * modcmb(c+r2+1, r2+1, MOD) - r1 * modcmb(c+r1, r1, MOD)) * pow(c+1, MOD-2, MOD)\n ans %= MOD\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', 'MOD = 10**9+7\nfac = [1, 1]\nf_inv = [1, 1]\ninv = [0, 1]\n\ndef prepare(n, mod):\n for i in range(2, n+1):\n fac.append((fac[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod//i)) % mod)\n f_inv.append((f_inv[-1] * inv[-1]) % mod)\n\n\ndef modcmb(n, r, mod):\n if n < 0 or r < 0 or r > n:\n return 0\n\n return fac[n] * f_inv[r] * f_inv[n-r] % mod\n\n\ndef f(r, c):\n return modcmb(r+c, r, MOD)\n\n\ndef main():\n prepare(2*10**6+10, MOD)\n r1,c1,r2,c2 = map(int, input().split())\n\n ans = 0\n for i in range(1,c2+2):\n ans += f(r2, i)\n ans %= MOD\n\n for i in range(1,c2+2):\n ans -= f(r1-1, i)\n ans %= MOD\n\n for i in range(1,c1+1):\n ans -= f(r2, i)\n ans %= MOD\n\n for i in range(1,c1+1):\n ans += f(r1-1, i)\n ans %= MOD\n\n print(ans % MOD)\n\n\nif __name__ == "__main__":\n main()\n', 'MOD = 10**9+7\nfac = [1, 1]\n\ndef prepare(n, mod):\n for i in range(2, n+1):\n fac.append((fac[-1] * i) % mod)\n\n\ndef modcmb(n, r, mod):\n if n < 0 or r < 0 or r > n:\n return 0\n\n return fac[n] * pow(fac[r], mod-2, mod) * pow(fac[n-r], mod-2, mod) % mod\n\n\ndef f(r, c):\n return modcmb(r+c, r, MOD)\n\n\ndef g(x, y):\n return ((y+2) * modcmb(x+y+2, x, MOD) - (x+1)) * pow(x+1, MOD-2, MOD)\n\n\ndef main():\n prepare(2*10**6+10, MOD)\n r1,c1,r2,c2 = map(int, input().split())\n\n ans = g(r2, c2) - g(r1-1, c2) - g(r2, c1-1) + g(r1-1, c1-1)\n ans %= MOD\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s248815416', 's792690268', 's921165149', 's552350335']
[240748.0, 240620.0, 242484.0, 82220.0]
[2119.0, 2121.0, 2119.0, 489.0]
[729, 785, 870, 628]
p02782
u693716675
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['#F\nfrom operator import mul\nfrom functools import reduce\n\nr1, c1, r2, c2 = [int(i) for i in input().split()]\nmod = 10**9 + 7\n\n#pre-caluculation of the factorial\nnum = 10**7\nfact=[0] * num\nfact[0]=1\nfor i in range(1, num):\n fact[i] = (fact[i-1] * i) % mod\n\ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n\ndef f(rr,cc):\n \n #print(rr+cc+2, cc+1)\n #print(combinations_count(rr+cc+2, cc+1))\n #return combinations_count(rr+cc+2, cc+1) - 1\n return (fact[rr+cc+2]%mod * pow(fact[rr+1]*fact[cc+1], mod-2, mod)) % mod -1\n\nans = f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)\nprint(ans % mod)', '#F\nfrom operator import mul\nfrom functools import reduce\n\nr1, c1, r2, c2 = [int(i) for i in input().split()]\nmod = 10**9 + 7\n\n#pre-caluculation of the factorial\nnum = 10**6*2+3\nfact=[0] * num\nfact[0]=1\nfor i in range(1, num):\n fact[i] = (fact[i-1] * i) % mod\n\ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n\ndef f(rr,cc):\n \n #print(rr+cc+2, cc+1)\n #print(combinations_count(rr+cc+2, cc+1))\n #return combinations_count(rr+cc+2, cc+1) - 1\n return (fact[rr+cc+2]%mod * pow(fact[rr+1]*fact[cc+1], mod-2, mod)) % mod -1\n\nans = f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)\nprint(ans % mod)']
['Time Limit Exceeded', 'Accepted']
['s047420189', 's172020794']
[325480.0, 82660.0]
[2123.0, 715.0]
[786, 790]
p02782
u704284486
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['mod = 10**9+7\n\ndef f(n,k,p):\n n1, k = n+1, min(k, n-k)\n numer = denom = 1\n for i in range(1,k+1):\n numer = numer*(n1-i)\n denom = denom*i\n return numer*pow(denom,p-2,p)%p\n\nr1,c1,r2,c2 = map(int,input().split(" "))\nans = f(r2+c2+2,c2+1,mod)-g(r2+c1+1,c1,mod)-g(r1+c2+1,c2+1,mod)+g(r1+c1,c1,mod)\nprint(ans%mod)', 'mod = 10**9+7\n\nf = [1]*(2*10**6+5)\nf[0] = 1\nfor i in range(1,2*10**6+4):\n f[i] = f[i-1]*i%mod\n\ndef inv(i):\n return pow(f[i],mod-2,mod)\n\ndef g(x,y):\n return f[x+y]*inv(x)*inv(y)%mod\n\nr1,c1,r2,c2 = map(int,input().split(" "))\nans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)\nprint(ans%mod)']
['Runtime Error', 'Accepted']
['s338053393', 's204775109']
[3516.0, 82164.0]
[2104.0, 813.0]
[333, 297]
p02782
u780475861
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\nfrom itertools import product\nfrom collections import defaultdict\nread = sys.stdin.read\nsys.setrecursionlimit(1000000)\n\nr1, c1, r2, c2 = map(int, read().split())\nmod = 10 ** 9 + 7\ndic = {}\n\n\ndef count(r, c):\n if r * c == 0:\n return 1\n if (r - 1, c) in dic:\n a = dic[(r - 1, c)]\n else:\n a = dic[(r - 1, c)] = count(r - 1, c) % mod\n if (r, c - 1) in dic:\n b = dic[(r, c - 1)]\n else:\n b = dic[(r, c - 1)] = count(r, c - 1) % mod\n return (a + b) % mod\n\n\ndic[(r1 - 1, c2)] = count(r1 - 1, c2)\ndic[(r2, c1 - 1)] = count(r2, c1 - 1)\nres = 0\nfor r, c in product(range(r1, r2 + 1), range(c1, c2 + 1)):\n tmp = dic[(r, c)] = dic[(r - 1, c)] + dic[(r, c - 1)]\n res += tmp % mod\nprint(res % mod)', 'import sys\nfrom itertools import product\nread = sys.stdin.read\nsys.setrecursionlimit(1000000)\n\nr1, c1, r2, c2 = map(int, read().split())\nmod = 10 ** 9 + 7\ndic = {}\n\n\ndef count(r, c):\n if r * c == 0:\n return 1\n if (r - 1, c) in dic:\n a = dic[(r - 1, c)]\n else:\n a = dic[(r - 1, c)] = count(r - 1, c) % mod\n if (r, c - 1) in dic:\n b = dic[(r, c - 1)]\n else:\n b = dic[(r, c - 1)] = count(r, c - 1) % mod\n return (a + b) % mod\n\n\ndic[(r1 - 1, c2)] = count(r1 - 1, c2)\ndic[(r2, c1 - 1)] = count(r2, c1 - 1)\nres = 0\nfor r, c in product(range(r1, r2 + 1), range(c1, c2 + 1)):\n tmp = dic[(r, c)] = dic[(r - 1, c)] + dic[(r, c - 1)]\n res += tmp % mod\nprint(res % mod)', 'import numpy as np\nimport sys\nread = sys.stdin.read\nr1, c1, r2, c2 = map(int, read().split())\nMOD = 10 ** 9 + 7\n\n\ndef cumprod(A, MOD=MOD):\n L = len(A)\n Lsq = int(L**.5 + 1)\n A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)\n for n in range(1, Lsq):\n A[:, n] *= A[:, n - 1]\n A[:, n] %= MOD\n for n in range(1, Lsq):\n A[n] *= A[n - 1, -1]\n A[n] %= MOD\n return A.ravel()[:L]\n\n\ndef make_fact(U, MOD=MOD):\n x = np.arange(U, dtype=np.int64)\n x[0] = 1\n fact = cumprod(x, MOD)\n x = np.arange(U, 0, -1, dtype=np.int64)\n x[0] = pow(int(fact[-1]), MOD - 2, MOD)\n fact_inv = cumprod(x, MOD)[::-1]\n fact.flags.writeable = False\n fact_inv.flags.writeable = False\n return fact, fact_inv\n\n\nfac, finv = make_fact(2 * 10**6 + 10, MOD)\n\n\ndef comb(n, k, mod=MOD, fac=fac, finv=finv):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n\n\nanswer = comb(r2 + c2 + 2, r2 + 1) - comb(r1 + c2 + 1, r1) - \\\n comb(c1 + r2 + 1, c1) + comb(r1 + c1, r1)\nanswer %= MOD\nprint(answer)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s183569681', 's767779756', 's377550644']
[690260.0, 690012.0, 90600.0]
[2143.0, 2151.0, 357.0]
[752, 716, 1095]
p02782
u781163713
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['r1, c1, r2, c2 = map(int, input().split())\nL = 10 ** 9 + 7\n \n\ndef get_combi (n, k):\n\n r = k if k > n - k else n - k\n s = n - r\n M = [0] * (s + 1)\n N = 1\n for i in range(n, r, -1):\n for j in range(2, s + 1):\n if M[j] == 0 and i % j == 0:\n i = i / j\n M[j] = 1\n N *= i\n N = N % L\n\n return (N)\n\ncombi1 = get_combi(r2 + c2 + 2, r2 + 1)\ncombi2 = get_combi(r2 + c1 + 1, c1)\ncombi3 = get_combi(r1 + c2 + 1, r1)\ncombi4 = get_combi(r1 + c1, r1)\n\nprint (combi1)\nprint (combi2)\nprint (combi3)\nprint (combi4)\nprint (combi1 - combi2 - combi3 + combi4)', 'r1, c1, r2, c2 = map(int, input().split())\nL = 10 ** 9 + 7\n \n\ndef get_combi (n, k):\n\n r = k if k > n - k else n - k\n s = n - r\n M = [0] * (s + 1)\n N = 1\n for i in range(n, r, -1):\n for j in range(2, s + 1):\n if M[j] == 0 and i % j == 0:\n i = i / j\n M[j] = 1\n N *= i\n N = N % L\n\n return (N)\n\ncombi1 = get_combi(r2 + c2 + 2, r2 + 1)\ncombi2 = get_combi(r2 + c1 + 1, c1)\ncombi3 = get_combi(r1 + c2 + 1, r1)\ncombi4 = get_combi(r1 + c1, r1)\n\nprint (combi1 - combi2 - combi3 + combi4)', 'r1, c1, r2, c2 = map(int, input().split())\nL = 10 ** 9 + 7\n\n\ndef get_euclidian (A, B):\n if B == 1:\n return (1)\n else:\n return (int((1 - A * get_euclidian (B, A % B)) / B))\n\n\nF = [1]\nfor i in range(1, r2 + c2 + 3):\n F.append((F[i - 1] * i) % L)\n\n\ndef get_combi (n, r):\n\n Euc = get_euclidian(L, (F[r] * F[n - r]) % L)\n return ((F[n] * Euc) % L)\n\ncombi1 = get_combi(r2 + c2 + 2, r2 + 1)\ncombi2 = get_combi(r2 + c1 + 1, c1)\ncombi3 = get_combi(r1 + c2 + 1, r1)\ncombi4 = get_combi(r1 + c1, r1)\n\nprint ((int(combi1 - combi2 - combi3 + combi4) + L) % L)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s171268093', 's614615493', 's059697843']
[10868.0, 10868.0, 82220.0]
[2104.0, 2104.0, 719.0]
[595, 535, 604]
p02782
u816631826
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n K= c+d+5\n fac = [0 for i in range(K+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,K+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(e,f):\n return (fac[e+f]*pow(fac[e],MOD-2,MOD)*pow(fac[f],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()\n#print the result', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n K= c+d+5\n fac = [0 for _ in range(K+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,K+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(e,f):\n return (fac[e+f]*pow(fac[e],MOD-2,MOD)*pow(fac[f],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()\n#print the result', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()', 'def findTrailingZeros(n): \n\n \n\n # If n is odd \n\n if (n & 1): \n\n return 0\n\n \n\n # If n is even \n\n else: \n\n ans = 0\n\n \n\n # Find the trailing zeros \n\n # in n/2 factorial \n\n n //= 2\n\n while (n): \n\n ans += n // 5\n\n n //= 5\n\n \n\n # Return the required answer \n\n return ans \n\n \n# Driver code \n\n \n\nn = 12\n\n \n\nprint(findTrailingZeros(n))', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MODE = 10**9+7\n NU = c+d+5\n fac = [0 for _ in range(NU+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,NU+1):\n fac[i] = (fac[i-1]*i)%MODE\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MODE-2,MODE)*pow(fac[y],MODE-2,MODE))%MODE\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MODE)\n \nif _name_ == "_main_":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n P= c+d+5\n fac = [0 for _ in range(P+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,P+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()\n', 'import sys\nimport math\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s158021195', 's370903053', 's411538209', 's472768430', 's698608221', 's998780485', 's226388487']
[3064.0, 3064.0, 3064.0, 2940.0, 3064.0, 3064.0, 82200.0]
[18.0, 18.0, 17.0, 17.0, 18.0, 17.0, 486.0]
[475, 475, 458, 427, 469, 458, 474]
p02782
u863370423
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n K = c+d+5\n fac = [0 for _ in range(K+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,K+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for j in range(2,N+1):\n fac[j] = (fac[j-1]*j)%MOD\n \n def comb(x,y):\n return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif _name_ == "_main_":\n main()', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n t,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(x1,y2):\n return (fac[x1+y2]*pow(fac[x1],MOD-2,MOD)*pow(fac[y2],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,t)+comb(t,b))%MOD)\n \nif _name_ == "_main_":\n main()\n#print the result', 'import sys\ninput = sys.stdin.buffer.readline\n \ndef main():\n a,b,c,d = map(int,input().split())\n MOD = 10**9+7\n N = c+d+5\n fac = [0 for _ in range(N+1)]\n fac[0],fac[1] = 1,1\n \n for i in range(2,N+1):\n fac[i] = (fac[i-1]*i)%MOD\n \n def comb(g,h):\n return (fac[g+h]*pow(fac[g],MOD-2,MOD)*pow(fac[h],MOD-2,MOD))%MOD\n \n print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)\n \nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s484515830', 's625789222', 's727137347', 's908648956']
[3064.0, 3064.0, 3064.0, 82200.0]
[18.0, 17.0, 17.0, 491.0]
[458, 458, 482, 462]
p02782
u984276646
2,000
1,048,576
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: * f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above) Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).
['r1, c1, r2, c2 = map(int, input().split())\nmod = int(1e+9) + 7\ndef inved(x):\n a, b, c, d, k, l = 1, 0, 0, 1, x, mod\n while l != 0:\n a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)\n k, l = l, k & l\n return a % mod\nfrac = [1]\nfor i in range(r2 + c2 + 2):\n frac.append(((i+1) * frac[i]) % mod)\nfracr2c2 = frac[r2 + c2 + 2]\nfracr1c2 = frac[r1 + c2 + 1]\nfracr2c1 = frac[r2 + c1 + 1]\nfracr1c1 = frac[r1 + c1]\nfracr2 = frac[r2 + 1]\nfracr1 = frac[r1]\nfracc2 = frac[c2 + 1]\nfracc1 = frac[c1]\ng = 0\ng += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod\ng %= mod\ng += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod\ng %= mod\ng -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod\ng %= mod\ng -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod\ng %= mod\nprint(g)', 'r1, c1, r2, c2 = map(int, input().split())\nmod = int(1e+9) + 7\ndef inved(x):\n a, b, c, d, k, l = 1, 0, 0, 1, x, mod\n while l != 0:\n a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)\n k, l = l, k % l\n return a % mod\nfrac = [1]\nfor i in range(r2 + c2 + 2):\n frac.append(((i+1) * frac[i]) % mod)\nfracr2c2 = frac[r2 + c2 + 2]\nfracr1c2 = frac[r1 + c2 + 1]\nfracr2c1 = frac[r2 + c1 + 1]\nfracr1c1 = frac[r1 + c1]\nfracr2 = frac[r2 + 1]\nfracr1 = frac[r1]\nfracc2 = frac[c2 + 1]\nfracc1 = frac[c1]\ng = 0\ng += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod\ng %= mod\ng += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod\ng %= mod\ng -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod\ng %= mod\ng -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod\ng %= mod\nprint(g)\n']
['Time Limit Exceeded', 'Accepted']
['s631337965', 's541793417']
[82220.0, 82220.0]
[2109.0, 664.0]
[765, 766]
p02783
u004823354
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a = map(int,input().split())\nif h % a = 0:\n print(h//a)\nelse:\n print(h//a+1)\n', 'h,a = map(int,input().split())\nif h % a == 0:\n print(h//a)\nelse:\n print(h//a+1)']
['Runtime Error', 'Accepted']
['s775265939', 's735293662']
[8992.0, 9072.0]
[34.0, 25.0]
[81, 81]
p02783
u005317312
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H=int(input())\nA=int(input())\na=int(H/A)\nif H%A!=0:\n a+=1\nprint(a)', 'H,A=map(int,input().split())\na=int(H/A)\nif H%A!=0:\n a+=1\nprint(a)']
['Runtime Error', 'Accepted']
['s356667118', 's447623297']
[2940.0, 2940.0]
[17.0, 17.0]
[69, 68]
p02783
u006425112
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split())\n\n index = 0\n while h > 0:\n h -= a\n index += 1\n\nprint(index)', 'h, a = map(int, input().split())\n\nindex = 0\nwhile h > 0:\n h -= a\n index += 1\n \nprint(index)']
['Runtime Error', 'Accepted']
['s383346577', 's197615796']
[2940.0, 2940.0]
[17.0, 19.0]
[100, 100]
p02783
u010262832
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['input_line = list(map(int,input().split()))\nif input_line[0] % input_line[1]:\n result = input_line[0] // input_line[1]\nelse:\n result = input_line[0] // input_line[1] + 1\n\nprint(result)', 'input_line = list(map(int,input().split()))\nif input_line[0] % input_line[1] == 0:\n result = input_line[0] // input_line[1]\nelse:\n result = input_line[0] // input_line[1] + 1\n\nprint(result)']
['Wrong Answer', 'Accepted']
['s128495487', 's189505650']
[2940.0, 3064.0]
[17.0, 18.0]
[190, 195]
p02783
u010777300
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a=map(int,input.split())\nif h>a:\n print(h//a)\nif h<a:\n print(1)', 'h,a=map(int,input().split())\nif h>a:\n print(h//a)\nif h<=a:\n print(1)', 'h,a=map(int,input.split())\nif h>a:\n print(h//a)\nif h<=a:\n print(1)', 'h,a=map(int,input().split())\nif h>a:\n if h%a==0:print(h//a)\n if h%a>0:print(h//a+1)\nif h<=a:\n print(1)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s239065886', 's972187928', 's981560127', 's579474659']
[9080.0, 9092.0, 8996.0, 9112.0]
[23.0, 26.0, 23.0, 28.0]
[67, 70, 68, 105]
p02783
u011062360
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['n = int(input())\na = [1]\n\nif n % 2 == 1:\n n -= 1\n\nif n % 2 == 0:\n for i in range(int(n / 2)):\n a.append(2 * a[i])\n\nprint(a[-1]*2 - 1)', 'a, b = map(int, input().split())\nans = 0\nif a % b ==0:\n ans = a//b\nelse:\n ans = a//b + 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s853746826', 's479772703']
[2940.0, 2940.0]
[18.0, 18.0]
[146, 106]
p02783
u013582910
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a=def main():\n h,a=map(int,input().split())\n if h % a:\n print(h//a+1)\n else:\n print(h//a)\n\nmain()', 'def main():\n h,a=map(int,input().split())\n if h % a:\n print(h//a+1)\n else:\n print(h//a)\n \nmain()']
['Runtime Error', 'Accepted']
['s643869626', 's666099966']
[2940.0, 2940.0]
[18.0, 17.0]
[122, 119]
p02783
u016753669
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['import math\nA,B = [int(c) for o in input().spit()]\nprint(math.ceil(A/B))', 'import math\nH,A = [int(x) for x in input().spit()] print(math.ceil(A/B)) ', 'import math H,A = [int(c) for c in input().spit()] print(math.ceil(A/B))', 'import math A,B = [int(c) for o in input().spit()] print(math.ceil(A/B))', 'import math A,B = [int(c) for o in input().spit()]\nprint(math.ceil(A/B))', 'import math\n\nH, A = [int(x) for x in input().split()]\nprint(math.ceil(H/A))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s539551194', 's543217872', 's642738626', 's919479643', 's937110975', 's898263370']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 17.0, 17.0, 18.0]
[72, 73, 72, 72, 72, 75]
p02783
u017624958
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['import math\n\nH = 10000\nA = 1\n\nanswer = math.ceil(H / A)\n\nprint(answer)\n', 'import math\n\ninputted = list(map(int, input().split()))\n\nH = inputted[0]\nA = inputted[1]\n\nanswer = math.ceil(H / A)\n\nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s693632094', 's410956655']
[2940.0, 2940.0]
[17.0, 17.0]
[71, 131]
p02783
u018679195
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H = int(input())\nK = int(input())\ncnt=0\nwhile(H>0):\n H=H-K\n cnt=cnt+1\n\nprint(cnt)', 'n,b=map(int,input().split())\nimport math\nprint(math.ceil(n/b))']
['Runtime Error', 'Accepted']
['s044856178', 's537185775']
[2940.0, 2940.0]
[18.0, 17.0]
[83, 62]
p02783
u019355060
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H,N=map(int, input().split())\nv = list(input().split())\nv = [int(x) for x in v]\nif H <= sum(v):\n print("Yes")\nelse:\n print("No")', 'import math\nH,A=map(int, input().split())\nprint(math.ceil(H / A))']
['Runtime Error', 'Accepted']
['s493869922', 's931984270']
[2940.0, 2940.0]
[17.0, 18.0]
[134, 65]
p02783
u021916304
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nh,a = iim()\n\n\nprint((h+1)//a)', 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nh,a = iim()\nif h%a == 0:\n f = 0\nelse:\n f = 1\n\nprint(h//a+f)']
['Wrong Answer', 'Accepted']
['s624285334', 's687659371']
[2940.0, 3060.0]
[17.0, 18.0]
[148, 184]
p02783
u025241948
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["import math\nimport copy\nH,N=map(int,input().split())\n\ninf=float('inf')\ndp=[0]+[inf]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=copy.deepcopy(dp)\n for j in range(A,H+1):\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n if j > H-A:\n ndp[-1]=min(ndp[-1],ndp[j]+B)\n\n dp=ndp\n\nprint(dp[-1])", "import math\n\nH,N=map(int,input().split())\nA_list=[]\nB_list=[]\nfor i in range(N):\n A,B=map(int,input().split())\n A_list.append(A)\n B_list.append(B)\n\namax=max(A_list)\n\ninf=float('inf')\ndp=[0]+[inf]*(H+amax)\n\nfor i in range(N):\n A=A_list[i]\n B=B_list[i]\n if A > H and B<dp[-1]:\n dp[-1]=B\n continue\n\n for j in range(A,1+H):\n if dp[j-A]+B<dp[j]:\n dp[j]=dp[j-A]+B\n \n minA=min(dp[H-A:])+B\n if minA < dp[-1]:\n dp[-1]=minA\n\nprint(dp[-1])\n", 'H,A = map(int,input().split())\n\nN=0\nwhile H > 0:\n N+=1\n H-=A\n\nprint(N)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s092076052', 's491689726', 's300865048']
[3572.0, 3064.0, 2940.0]
[22.0, 18.0, 18.0]
[318, 498, 76]
p02783
u026862065
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, n = map(int, input().split())\nl = list(map(int, input().split()))\nif h > sum(l):\n print("No")\nelse:\n print("Yes")', 'h, a = map(int, input().split())\ncount = 0\nwhile h > 0:\n h -= a\n count += 1\nprint(count)']
['Runtime Error', 'Accepted']
['s292874766', 's500273386']
[3064.0, 2940.0]
[17.0, 19.0]
[122, 94]
p02783
u027403702
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H,A = map(int, input().split())\n# N = int(input())\n\n# C = int(input())\n# s= input()\ni=0\nwhile H < 0:\n H - A\n i += 1\nprint(i)', 'H,A = map(int, input().split())\n# N = int(input())\n\n# C = int(input())\n# s= input()\ni=1\nwhile H < 0:\n H - A\n i += 1\nprint(i)', 'H,A = map(int, input().split())\n# N = int(input())\n\n# C = int(input())\n# s= input()\ni=0\nwhile H > 0:\n H = H - A\n i += 1\nprint(i)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s603541150', 's640546391', 's805408866']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 19.0]
[148, 148, 153]
p02783
u031115006
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split())\n\nq= h//a\n\nprint(q)\n', 'h, a = map(int, input().split())\n\nq= h//a\n\nprint(a)', 'import math\n\nh, a = map(int, input().split())\nq= h/a\n\nprint(math.ceil(q))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s160805560', 's549069454', 's879046354']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 18.0]
[52, 51, 73]
p02783
u032222383
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split())\nprint((h+a-1)/a)', 'h, a = map(int, input().split())\nprint(int((h+a-1)/a))']
['Wrong Answer', 'Accepted']
['s082655798', 's477005465']
[2940.0, 2940.0]
[17.0, 17.0]
[49, 54]
p02783
u034243122
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H=int(input())\nA=int(input())\ncount=0\nwhile H>0:\n H=H-A\n count+=1\nelse:\nprint(count)', 'H=int(input())\nA=int(input())\ncount=0\nwhile H>0:\n H=H-A\n count+=1\nelse:\n print(count)', 'H,A=map(int, input().split())\ncount=0\nwhile H>0:\n H=H-A\n count+=1\nelse:\n print(count)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s145443611', 's157463868', 's772872588']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 19.0]
[90, 94, 94]
p02783
u034459102
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["h, n = (int(x) for x in input().split())\nA = list(map(int, input().split()))\n\nif n == len(A):\n if sum(A) >= h:\n print('yes')\n else:\n print('No')", 'a,b=(int(x) for x in input().split())\n\nprint(-(-a//b))']
['Runtime Error', 'Accepted']
['s483282616', 's526919801']
[2940.0, 2940.0]
[18.0, 17.0]
[164, 54]
p02783
u039355749
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, n = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(n)]\n\n\na_max = max(a for a, b in ab)\n\ndp = [0]*(h + a_max)\n\nfor i in range(h + a_max):\n\tdp[i] = min(dp[i - a] + b for a, b in ab)\n\nprint(min(dp[h:]))', 'h, a = map(int, input().split())\n\nq = h // a\nmod = h % a\n\nif(mod == 0):\n ans = q\nelse:\n ans = q + 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s070326019', 's401998525']
[3060.0, 2940.0]
[17.0, 17.0]
[313, 115]
p02783
u046592970
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a = map(int,input().split())\nprint(h//a)', 'h,a = map(int,input().split())\nprint((h + a - 1) // a)']
['Wrong Answer', 'Accepted']
['s580347615', 's886886863']
[2940.0, 2940.0]
[17.0, 17.0]
[42, 54]
p02783
u049979154
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['import math\nh, a = map(int, input().split())\n\nprint(math.ceil(h // a))', 'import math\nh, a = map(int, input().split())\n\nprint(math.ceil(h / a))']
['Wrong Answer', 'Accepted']
['s285166921', 's080388128']
[2940.0, 2940.0]
[17.0, 17.0]
[70, 69]
p02783
u051401873
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['import math \nh, a = map(float, input().split())\n\nprint(-(-h//a))', 'import math \nh, a = map(float, input().split())\n\nprint(int(-(-h//a)))']
['Wrong Answer', 'Accepted']
['s393076040', 's001481046']
[2940.0, 2940.0]
[17.0, 17.0]
[64, 69]
p02783
u051496905
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['print(a)', 'a = 1\nprint(a)', 'h, a = [int(i) for i in input().split()]\ni = h//a + 1\nif h%a == 0:\n i -= 1\nprint(i)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s750622673', 's947140122', 's438769689']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[8, 14, 85]
p02783
u051928503
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['N,K=map(int,input().split())\na=list(map(int,input().split()))\nif K>=N:\n\tprint(0)\nelse:\n\tb=sorted(a)\n\tc=0\n\tfor i in range(N-K):\n\t\tc+=b[i]\n\tprint(c)', 'H, A=map(int,input().split())\nif H//A==H/A:\n\tprint(H//A)\nelse:\n\tprint(H//A+1)']
['Runtime Error', 'Accepted']
['s094988365', 's637104499']
[3060.0, 2940.0]
[17.0, 18.0]
[146, 77]
p02783
u053909865
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['import numpy as np\n\nN, K = map(int, input().split())\nli = list(map(int,input().split()))\nlist.sort(li, reverse = True)\n\n\na = list(np.zeros(K))\nb = list(np.ones(N-K))\na.extend(b)\n\nprint(np.dot(a, li))', '\nH, A = map(int, input().split())\n\n\ns = 0\ncounter = 1\nwhile counter>0:\n if H - A >=0:\n H = H - A\n s = s + 1\n counter = counter\n else:\n H = H - A\n s = s\n counter = counter - 1\n print(s)', 'import numpy as np\n\nN, K = map(int, input().split())\nli = list(map(int,input().split()))\nlist.sort(li, reverse = True)\n\n\na = list(np.zeros(K))\nb = list(np.ones(N-K))\na.extend(b)\n\nprint(np.dot(a, li))', '\nH, A = map(int, input().split())\n\n\ns = 0\ncounter = 1\nwhile counter>0:\n if H - A >0:\n H = H - A\n s = s + 1\n counter = counter\n else:\n counter = counter - 1\n print(s)', '\nH, A = map(int, input().split())\n\n\ns = 1\ncounter = 1\nwhile counter>0:\n if H - A >0:\n H = H - A\n s = s + 1\n counter = counter\n else:\n H = H - A\n s = s\n counter = counter - 1\n print(s)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s331297633', 's455165336', 's593835364', 's718802306', 's925187735']
[12488.0, 3060.0, 20748.0, 2940.0, 3064.0]
[149.0, 20.0, 296.0, 20.0, 20.0]
[213, 253, 213, 220, 252]
p02783
u055007876
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, N = map(int, input().split())\nx = [list(map(int, input().split())) for n in range(N)]\nx = [[tmp[i] for tmp in x] for i in range(len(x[0]))]\nA = x[0]\nB = x[1]\n\ndef ibis(H, A, B):\n maxA = max(A)\n HmaxA = H + maxA\n minB = min(B)\n dp = [max(B) * H] * (HmaxA + 1)\n dp[0] = 0\n for h in range(HmaxA):\n for n in range(N):\n dp[h + 1] = min(dp[h + 1], dp[h] + minB)\n hp = h + A[n]\n if hp <= HmaxA:\n dp[hp] = min(dp[hp], dp[h] + B[n])\n return min(dp[H:HmaxA+1])\n\nprint(ibis(H, A, B))', 'H, A = map(int, input().split())\nprint(H // A + (H % A > 0))']
['Runtime Error', 'Accepted']
['s342301676', 's522954626']
[3064.0, 3060.0]
[17.0, 20.0]
[551, 60]
p02783
u055244973
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["H = int(input('H: '))\nA = int(input('A: '))\n \nif H%A == 0:\n x = H//A\n print(x)\nelse:\n x = (H//A)-1\n print(x)", 'H = int(input())\nA = int(input())\n\nif H%A == 0:\n x = H//A\n else:\n x = (H//A)-1', 'h,a=map(int,input().split())\nif h%a==0:\n print(h//a)\nelse:\n print(h//a+1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s158273438', 's844988423', 's828366138']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 19.0]
[112, 83, 75]
p02783
u055854974
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, A = list(map(int, input().split()))\n\nprint((H+1)//A)', 'H, A = list(map(int,input().split()))\n\nprint((H+A-1)//A)']
['Wrong Answer', 'Accepted']
['s064787451', 's863289638']
[2940.0, 2940.0]
[17.0, 17.0]
[55, 56]
p02783
u056659569
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, A = map(int, input().split())\nprint(int((H+A-1))/A)', '\nH, M = map(int, input().split())\nprint(int((H+M-1))/M)\n', 'import math\nH, M = map(int, input().split())\nprint(math.ceil(H/M))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s245751719', 's571512516', 's605288319']
[3064.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[54, 56, 66]
p02783
u056830573
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['atcoder = input().split()\n\nH = int(atcoder[0])\nA = int(atcoder[1])\n\nprint(H // A)', 'H, N = [int(x) for x in input().split()]\nattacks = [int(x) for x in input().split()]\nprint("Yes" if H - sum(attacks) <= 0 else "No")', 'H, N = [int(x) for x in input().split()]\nattacks = [int(x) for x in input().split()]\nprint("Yes" if H - sum(attacks) <= 0 else "No")', 'import math\n\nH, A = [int(x) for x in input().split()]\nprint(math.ceil(H/A))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s114212388', 's609332027', 's985537770', 's588298690']
[3060.0, 2940.0, 2940.0, 2940.0]
[20.0, 18.0, 17.0, 17.0]
[81, 132, 132, 75]
p02783
u057996804
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, k = map(int, input().split())\nlis = list(map(int, input().split()))\nif h >= k:\n lis.sort(reverse=True)\n lis = lis[k:]\nelse:\n lis = []\n \nprint(sum(lis))', 'H, A = map(int, input().split())\nfrom math import ceil\nn = int(ceil(H/A))\nprint(n)']
['Runtime Error', 'Accepted']
['s756859146', 's027490948']
[2940.0, 2940.0]
[17.0, 17.0]
[166, 82]
p02783
u059588695
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = input().split()\n\nprint((h - 1) // 4 + 1)', 'h, a = map(int, input().split())\n\nprint((h - 1) // a + 1)']
['Runtime Error', 'Accepted']
['s200218855', 's842886105']
[2940.0, 2940.0]
[17.0, 17.0]
[47, 57]
p02783
u062068953
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['x=input().split()\nh=int(x[0])\nn=int(x[1])\na=[]\nb=[]\nc=[]\nfor k in range(n):\n x=input().split()\n a.append(int(x[0]))\n b.append(int(x[1]))\n c.append(int(x[0])/int(x[1]))\ns=0 \nwhile H>0:\n maxim=0\n for k in range(n):\n m=H//a[k]\n d=a[k]*(H//a[k]+1)\n if (d+1)*b[k]>maxim:\n maxim=(d+1)*b[k]\n s+=maxim\nprint(s) ', 'x=input().split()\nh=int(x[0])\nn=int(x[1])\na=[]\nb=[]\nfor k in range(n):\n x=input().split()\n a.append(int(x[0]))\n b.append(int(x[1])) \nm=max(a) \ndp=[10**9]*(h+m)\ndp[0]=0\nfor k in range(h+m):\n for i in range(n):\n if k-a[i]<0:\n continue\n new=dp[k-a[i]]+b[i]\n if new < dp[k]:\n dp[k]=new\nprint(min(dp[h:h+m]))\n \n ', 'x=input().split()\nh=int(x[0])\nn=int(x[1])\nimport numpy as np\na=np.full(n,0,int)\nb=np.full(n,0,int)\nfor k in range(n):\n x=input().split()\n a[k]=int(x[0])\n b[k]=int(x[1])\nm=max(a) \ninf=10**8\ndp=np.full(h+m+1,inf,int)\ndp[0]=0\nfor k in range(1,h+m):\n dp[k]=(dp[np.max(k-a,-1)]+b).min()\nprint(dp[h:h+m].min())\n\n ', 'x=input().split()\nh=int(x[0])\nn=int(x[1])\na=[]\nb=[]\nfor k in range(n):\n x=input().split()\n a.append(int(x[0]))\n b.append(int(x[1])) \nm=max(a) \ndp=[10**8]*(h+m)\ndp[0]=0\nfor k in range(h+m):\n for i in range(n):\n if k-a[i]<0:\n continue\n new=dp[k-a[i]]+b[i]\n if new < dp[k]:\n dp[k]=new\nprint(min(dp[h:h+m]))\n \n ', 'x=input().split()\nH=int(x[0])\nA=int(x[1])\nif H%A==0:\n print(H//A)\nelse:\n print(H//A+1)\n ']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s328320174', 's570595449', 's644284698', 's963980016', 's805748689']
[3064.0, 3064.0, 12624.0, 3064.0, 2940.0]
[17.0, 20.0, 148.0, 17.0, 17.0]
[326, 342, 313, 342, 91]
p02783
u063073794
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['a,b=map(int,input().split())\nprint(1+(a-1//b))\n', 'a,b=map(int,input().split())\nprint(a//b)', 'a,b=map(int,input().split())\nimport math\n\nprint(math.ceil(a//b))', 'import math\nh,a=map(int,input().split())\nprint (math.ceil(h/a))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s035912866', 's736620633', 's818377664', 's816568138']
[2940.0, 2940.0, 3064.0, 2940.0]
[17.0, 17.0, 17.0, 17.0]
[47, 40, 64, 64]
p02783
u064563749
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["H,N=map(int,input().split())\nA=list(map(int,input().split())\nif H<=sum(A):\n print('Yes')\nelse:\n print('No')", 'H,A=list(map(int,input().split()))\ncount=0\nwhile H>0:\n H=H-A\n count +=1\nreturn count', 'H,A=list(map(int,input().split()))\ncount=0\nwhile H>0:\n H=H-A\n count +=1\nprint(count)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s593453445', 's954186635', 's771609791']
[3064.0, 2940.0, 2940.0]
[17.0, 17.0, 19.0]
[119, 90, 90]
p02783
u067986264
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split())\nc = 0\nwhile h > a:\n c += 1\n a += a\nprint(c)\n', 'h, a = map(int, input().split())\nif h <= a:\n print(1)\n quit()\nc = 0\nwhile h > a:\n c += 1\n a += a\nprint(c)\n', 'h, a = map(int, input().split())\nif h % a == 0:\n print(h//a)\nelse:\n print(h//a+1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s167512600', 's489066059', 's693288538']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[83, 114, 84]
p02783
u069978048
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split())\nAns = 0\nAns2 = 0\n\nwhile Ans =< 0:\n\tAns = h-a\n\tAns2+=1\n\nprint(Ans2)', 'H, A = map(int, input().split())\nAns = 0\n\nwhile (Ans =< 0):\n\tH -= A\n\tAns += 1\n\nprint(Ans)\n', 'H, A = map(int, input().split())\nAns = 0\n \nwhile (H =< 0):\n\tH -= A\n\tAns += 1\n \nprint(Ans)', 'h, a = map(int, input().split())\nAns = 0\nAns2 = 0\n \nwhile Ans =< 0:\n\tAns = h-a\n\tAns2 += 1\n \nprint(Ans2)', 'H = input()\nA = input()\n\nwhile Ans =< 0:\n\tAns = H-A\n\tAns2++\n\nprint(Ans)', 'H, A = map(int, input().split())\nAns = 0\n \nwhile (H > 0):\n\tH -= A\n\tAns += 1\n \nprint(Ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s044941356', 's142444164', 's426024443', 's846440505', 's896945053', 's296490991']
[3068.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 18.0, 18.0, 19.0]
[99, 90, 89, 103, 71, 88]
p02783
u070201429
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["h, n = map(int, input().split())\na, b = [], []\nfor _ in range(n):\n i, j = map(int, input().split())\n a.append(i)\n b.append(j)\n\n# DP\nl = [0]\nfor i in range(1,h+1):\n cand = []\n for j in range(n):\n if i - a[j] >= 0 and l[i - a[j]] != 'none':\n cand.append(l[i - a[j]] + b[j])\n if cand == []:\n l.append('none')\n else:\n l.append(min(cand))\nfor i in range(h+1, h+max(a)):\n cand = []\n for j in range(n):\n if 0 <= i - a[j] < h and l[i - a[j]] != 'none':\n cand.append(l[i - a[j]] + b[j])\n if cand == []:\n l.append('none')\n else:\n l.append(min(cand))\nl = l[h:]\nl = [i for i in l if type(i) == int]\nprint(min(l))", 'h, a = map(int, input().split())\nif h % a == 0:\n print(h//a)\nelse:\n print(h//a + 1)']
['Runtime Error', 'Accepted']
['s548850293', 's712114859']
[3064.0, 2940.0]
[17.0, 17.0]
[697, 89]
p02783
u072717685
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h a = map(int, input().split())\nif h%a == 0:\n print(int(h/a))\nelse:\n print(int((h//a) + 1))', 'h a = map(int, input().split())\nprint(h//a + 1)', 'h, a = map(int, input().split())\nif h%a == 0:\n print(int(h/a))\nelse:\n print(int((h//a) + 1))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s091370752', 's911239636', 's371253866']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[93, 47, 94]
p02783
u072812663
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h, a = map(int, input().split)\n\nif h%a == 0:\n print((int))h/a))\nelse:\n print((int)(h/a)+1)', 'h, a = map(int, input().split)\n\nif h%a == 0:\n print(h/a)\nelse:\n print((int)(h/a)+1)', 'h, a = map(int, input().split)\n\nprint(h%a+1)', 'h, a = map(int, input().split)\n\nprint(int(h/a))', 'h, a = map(int, input().split())\n\nif h%a == 0:\n print((int))h/a))\nelse:\n print((int)(h/a)+1)', 'h, a = map(int, input().split)\n\nif h%a == 0:\n print((int)h/a)\nelse:\n print((int)(h/a)+1)', 'h, a = map(int, input().split())\n\nif h%a == 0:\n print((int)(h/a))\nelse:\n print((int)(h/a)+1)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s309086111', 's415945536', 's536336765', 's585841433', 's757866961', 's937421286', 's880473689']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0]
[92, 85, 44, 47, 94, 90, 94]
p02783
u077291787
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['print("Hello")', '\ndef main():\n H, A = map(int, input().split())\n print((H + A - 1) // A)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s139568866', 's854373149']
[2940.0, 3060.0]
[17.0, 19.0]
[14, 141]
p02783
u081899737
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nif result <= 0:\n print("Yes")\nelse:\n print("No")\n', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\ndef attack2(l1, l2):\n H = l1[0]\n N = l1[1]\n A = sum(l2)\n result = H - A\n if result >0:\n return "No"\n else:\n return "Yes"\n \nprint(attack2(l1, l2))', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nif result <= 0:\n rint("Yes")\nelse:\n rint("No")\n', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\ndef attack2(l1, l2):\n H = l1[0]\n N = l1[1]\n A = sum(l2)\n result = H - A\n if result >0:\n return "No"\n else:\n return "Yes"\n \nprint(attack2(l1, l2))', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = l1[0]\nN = l1[1]\nA = sum(l2)\nresult = H - A\nif result <= 0:\n print("Yes")\nelse:\n print("No")', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nbreak\nresult = H - A\nif result <= 0:\n print("Yes")\nelse:\n print("No")', 'l = list(map(int, input().split()))\n\ndef attack(l):\n H = l[0]\n A = l[1]\n cnt = 0\n while H >= 0:\n H = H - A\n cnt += 1\n return cnt\n\nprint(cnt)\n', 'l = list(map(int, input().split()))\n\ndef attack(l):\n H = l[0]\n A = l[1]\n cnt = 0\n while H >= 0:\n H = H - A\n cnt += 1\n print(cnt)', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nif result <= 0:\n rint("Yes")\nelse:\n rint("No")\n', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nif result <= 0:\n print("Yes")\nelse:\n print("No")', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nprint(A)\nif result <= 0:\n print("Yes")\nelse:\n print("No")', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nH = l1[0]\nN = l1[1]\nA = sum(l2)\nresult = H - A\nif result >0:\n print("No")\nelse:\n print("Yes")', 'l1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\n\nprint(l1)\nH = int(l1[0])\nN = int(l1[1])\nA = int(sum(l2))\nresult = H - A\nif result <= 0:\n print("Yes")\nelse:\n print("No")', 'l1 = list(map(int, input().split()))\n\nH = l1[0]\nA = l1[1]\n\nT = H%A\nif T == 0:\n print(H//A)\nelse:\n print(H//A+1)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s133290301', 's147765683', 's174319779', 's228966980', 's234620889', 's300372125', 's306131005', 's369226325', 's715430884', 's796039854', 's805305770', 's899539780', 's994309980', 's697873540']
[2940.0, 3060.0, 3064.0, 3060.0, 3064.0, 3060.0, 2940.0, 2940.0, 3060.0, 3064.0, 3060.0, 3060.0, 3064.0, 2940.0]
[17.0, 18.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0]
[191, 257, 190, 257, 176, 197, 170, 157, 190, 191, 200, 174, 201, 113]
p02783
u083858683
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, A = input().split()\n\nprint(int(H/A)+1)\n', 'H, A = input().split()\nH = int(H) \nA = int(A)\nif(H <= A):\n \tanswer = 1\nelse:\n\tanswer = int(H / A)\n\tif( H % A != 0):\n \t\tanswer += 1\n\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s965908783', 's404625061']
[2940.0, 2940.0]
[17.0, 17.0]
[42, 148]
p02783
u084327817
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['HP, A = map(int, input().split())\n\ncount = 0\nwhile HP<0:\n HP = HP - A\n count += 1\n\nprint(count)', 'HP, A = map(int, input().split())\n\ncount = 0\nwhile HP > 0:\n HP = HP - A\n count += 1\n\nprint(count)']
['Wrong Answer', 'Accepted']
['s131063085', 's463101275']
[2940.0, 2940.0]
[17.0, 19.0]
[101, 103]
p02783
u086127549
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a = tuple(map(int,input().rstrip().sprit()))\nprint((h+a-1)//a)', 'h,a = tuple(map(int,input().rstrip().sprit()))\nprint((h+a-1)//a)\n', 'h,a = tuple(map(int,input().rstrip().split()))\nprint((h+a-1)//a)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s291827279', 's531484854', 's456306051']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[64, 65, 65]
p02783
u086503932
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
["H,N=map(int,input().split())\nprint('NYoe s'[H<=sum(list(map(int,input().split())))::2])", 'H,A = map(int,input().split())\nprint(1 + H // A) if H % A != 0 else print(H // A)\n']
['Runtime Error', 'Accepted']
['s266106094', 's914000711']
[2940.0, 2940.0]
[17.0, 18.0]
[87, 82]
p02783
u088078693
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['a,b=map(int,input().split())\nprint(-(-b//a))', 'h,a = map(int, input().split())\nprint(h//a if !h%a else h//a + 1)', 'h,a = map(int, input().split())\nprint(int(h/a) if !h%a else int(h/a) + 1)', 'h,a = map(int, input().split())\nprint(-(h//a))', 'h,a = map(int, input().split())\nprint(-(-h//a))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s182179373', 's338065809', 's638819047', 's671460719', 's349561705']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 17.0, 17.0]
[44, 65, 73, 46, 47]
p02783
u088115428
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['n,p = map(int, input().split())\ncount = 0\nif (n>0):\n n = n-p\n count = count +1\nprint(count)', 'n,p = map(int, input().split())\ncount = 0\nwhile(n>0):\n n = n-p\n count = count +1\nprint(count)']
['Wrong Answer', 'Accepted']
['s352589620', 's467323440']
[2940.0, 2940.0]
[17.0, 19.0]
[97, 99]
p02783
u089230684
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['def attack( K, H):\n cnt=0\n while(H>0):\n H=H-K\n cnt=cnt+1\n\n return cnt', 'from math import ceil\nfrom sys import stdin\nn,m = map(int,stdin.readline().split())\nprint(ceil(n/m))']
['Wrong Answer', 'Accepted']
['s347063619', 's076668372']
[2940.0, 2940.0]
[17.0, 18.0]
[78, 100]
p02783
u089644470
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h a = list(map(int, input().split()))\n\na_total = 0\ncount = 0\nfor i in range(0,h):\n a_total += a\n count += 1\n if h <= a_total:\n print(count)\n break\n', 'list = list(map(int, input().split()))\n\nq, mod = divmod(list[0], list[1])\nif mod == 0 :\n print(q)\nelse :\n print(int(q+1))']
['Runtime Error', 'Accepted']
['s121184321', 's328312653']
[2940.0, 2940.0]
[24.0, 17.0]
[156, 123]
p02783
u089786098
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, A = map(int, input().split())\nH, A = int(H. A)\ndef a(H,A):\n if H/B <= 0:\n print(H//A+1)\n else:\n print(H/A)\n return\n\na(H,B)', 'H, A =map(int, input().split())\nif H%A == 0:\n print(int(H/A))\nelse:\n print(H//A+1)\n']
['Runtime Error', 'Accepted']
['s933989033', 's454625652']
[2940.0, 2940.0]
[17.0, 17.0]
[136, 85]
p02783
u091412190
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H,A = map(int,input().split())\nprint(H//A if H%A=0 else H//A+1)', 'H,A = map(int,input().split())\nprint(H//A if H%A==0 else H//A+1)']
['Runtime Error', 'Accepted']
['s081694725', 's131064099']
[2940.0, 2940.0]
[17.0, 17.0]
[63, 64]
p02783
u094425865
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H,A = map(int,input().split())\nn = 0\nwhile H<= 0:\n H -= A\n n += 1\nprint(n)', 'h,a = map(int,input().split())\nn = 0\nwhile h> 0:\n h -= a\n n += 1\nprint(n)']
['Wrong Answer', 'Accepted']
['s737062754', 's490033587']
[2940.0, 2940.0]
[17.0, 19.0]
[76, 75]
p02783
u096294926
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['i = input()\na,b = map(int, i.split())\nc = 1\n\nwhile a > b:\n a -= b\n c += 1\n else:\n print(c)', 'i = input()\na,b = map(int, i.split())\ncnt = 1\n\nwhile(a>b) :\n a -= b\n cnt +=1\n\n\nprint(cnt)']
['Runtime Error', 'Accepted']
['s976325995', 's604021661']
[2940.0, 3060.0]
[17.0, 19.0]
[104, 95]
p02783
u096616343
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, A = map(int,input().split())\na = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"\nfor i in a:\n print(i)', 'H, A = map(int,input().split())\na = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"\nfor i in a:\n print(i)', 'H, A = map(int,input().split())\nprint(-(-H // A))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s415057613', 's641851538', 's909171224']
[3060.0, 3060.0, 2940.0]
[18.0, 17.0, 18.0]
[548, 548, 49]
p02783
u103902792
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a = map(int,input().split())\nprint(h//a if h%a else int(h//a)+1)', 'h,a = map(int,input().split())\nprint(int(h//a)+1 if h%a else h//a)\n\n']
['Wrong Answer', 'Accepted']
['s450439991', 's295858345']
[2940.0, 3064.0]
[17.0, 19.0]
[66, 68]
p02783
u103915901
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,a=map(int,input().split())\nans=h//a\nif h&a!=0:\n ans+=1\nprint(ans)\n', 'h,a=map(int,input().split())\nans=h//a\nif h%a!=0:\n ans+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s957323245', 's258262905']
[2940.0, 3064.0]
[17.0, 17.0]
[71, 70]
p02783
u104005543
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, n = map(int, input().split())\nList = [[0 for i in range(4)] for j in range(n)]\nfor i in range(n):\n a, b = map(int, input().split())\n List[i][0] = b / a\n List[i][1] = b / H\n List[i][2] = a\n List[i][3] = b\n\ndef recal():\n for i in range(n):\n b = List[i][3]\n List[i][1] = b / H\n\nsList = sorted(List)\nMP = 0\nk = 0\nwhile H > 0:\n if sList[k][2] <= H:\n H -= sList[k][2]\n MP += sList[k][3]\n recal()\n else:\n if sList[k + 1][2] <= H:\n if sList[k][1] <= sList[k + 1][0]:\n H -= sList[k][2]\n MP += sList[k][3]\n recal()\n break\n else:\n H -= sList[k + 1][2]\n MP += sList[k + 1][3]\n recal()\n k += 1\n else:\n if sList[k][1] <= sList[k + 1][1]:\n H -= sList[k][2]\n MP += sList[k][3]\n recal()\n break\n else:\n H -= sList[k + 1][2]\n MP += sList[k + 1][3]\n recal()\n k += 1\nprint(MP)', 'h, a = map(int, input().split())\nprint(-1 * (-1 * h // a))']
['Runtime Error', 'Accepted']
['s107399442', 's996486378']
[4212.0, 2940.0]
[25.0, 17.0]
[1115, 58]
p02783
u115110170
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['h,n = map(int,input().split())\n\nls = [list(map(int,input().split())) for _ in range(n)]\n\namax = max(a for a,b in ls)\n\ndp = [0]*(h+amax)\n\nfor i in range(1,h+amax):\n dp[i] = min(dp[max(0,i-a)]+b for a,b in ls)\n\nprint(min(dp[h:]))\n\n', 'import math\n\na,b = map(int,input().split())\n\nprint(math.ceil(a/b))']
['Runtime Error', 'Accepted']
['s358219456', 's970068961']
[3060.0, 2940.0]
[18.0, 17.0]
[230, 66]
p02783
u115877451
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['a,b=map(int,input().split())\nc=0\nwhile a<=0:\n a-b\n c+=1\n a=a-b\nprint(c)', 'a,b=map(int,input().split())\nc=0\nwhile a>0:\n a=a-b\n c+=1\nprint(c)']
['Wrong Answer', 'Accepted']
['s394261712', 's940352211']
[2940.0, 2940.0]
[17.0, 18.0]
[74, 67]
p02783
u121698457
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['print((lambda x: x[0]//x[1])(list(map(int,input().split()))))', 'print((lambda x: x[0]//x[1])(map(int,input().split())))', 'print((lambda x: (x[0]-1)//x[1]+1)(list(map(int,input().split()))))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s122812617', 's177280009', 's190561064']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0]
[61, 55, 67]
p02783
u121700322
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['H, N = map(int, input().split())\n# AB = [list(map(int, input().split())) for _ in range(N)]\n\nAB = []\nfor i in range(N):\n A, B = map(int, input().split())\n AB.append((A, B))\n\n\nd = [0] + [10**18] * H\n\nfor hp in range(1, H + 1):\n for ab in AB:\n # print(ab)\n hp_remain = hp - ab[0]\n if hp_remain < 0: hp_remain = 0\n # print(hp_remain)\n c = d[hp_remain] + ab[1]\n if c < d[hp]: d[hp] = c\n\nprint(d[H])\n\n\n', 'H, N = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(N)]\n\n# AB = []\n\n# A, B = map(int, input().split())\n\n\n\nd = [0] + [10**18] * H\n\nfor hp in range(1, H + 1):\n for ab in AB:\n # print(ab)\n hp_remain = hp - ab[0]\n if hp_remain < 0: hp_remain = 0\n # print(hp_remain)\n c = d[hp_remain] + ab[1]\n if c < d[hp]: d[hp] = c\n\nprint(d[H])\n\n\n', 'H, A = map(int, input().split())\n\nans = 0\n\na, b = H // A, H % A\nif b == 0:\n print(a)\nelse:\n print(a+1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s397184341', 's869096475', 's517497233']
[3064.0, 3060.0, 2940.0]
[17.0, 17.0, 17.0]
[448, 454, 104]
p02783
u123745130
2,000
1,048,576
Serval is fighting with a monster. The _health_ of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning.
['a,b=map(int,input().split())\nprint(-(-a/b))\n', 'a,b=map(int,input(),split())\nprint(-(-a/b))', 'a,b=map(int,input().split())\nprint(-(-a//b))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s193367848', 's212840903', 's831576183']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0]
[44, 43, 45]