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
|
---|---|---|---|---|---|---|---|---|---|---|
p03282 | u978167553 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ["s = input()\nk = input()\n\nans = '1'\nfor c in k:\n if c != '1':\n ans = c\n break\nprint(ans)\n", "s = input()\nk = input()\n\nans = '1'\nfor i in range(k):\n if k[i] != '1':\n ans = k[i]\n break\nprint(ans)\n", "s = input()\nk = int(input())\n\nans = '1'\nfor i in range(k):\n if s[i] != '1':\n ans = s[i]\n break\nprint(ans)\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s191187750', 's580190966', 's714802633'] | [9068.0, 9092.0, 9156.0] | [30.0, 24.0, 30.0] | [105, 118, 123] |
p03282 | u978313283 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['S=list(input())\nK=int(input())\nl=0\nfor i in range(len(S)):\n if S[i]==1:\n l+=1\n else:\n a=S[i]\n break\nif l>=K:\n print(1)\nelse:\n print(a)\n', "S=list(input())\nK=int(input())\nl=0\nfor i in range(len(S)):\n if S[i]=='1':\n l+=1\n else:\n a=S[i]\n break\nif l>=K:\n print(1)\nelse:\n print(a)\n"] | ['Wrong Answer', 'Accepted'] | ['s330726202', 's628090355'] | [2940.0, 2940.0] | [18.0, 17.0] | [168, 170] |
p03282 | u978494963 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ["def main():\n S = map(int,list(input()))\n K = int(input())\n for i,n in enumerate(S):\n if n == 1:\n K -= n\n if K>0:\n return n\n else:\n return 1\n return 1\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n S = map(int,list(input()))\n K = int(input())\n for i,n in enumerate(S):\n if n == 1:\n K -= n\n continue\n if K>0:\n return n\n else:\n return 1\n return 1\n\nif __name__ == '__main__':\n print(main())\n"] | ['Wrong Answer', 'Accepted'] | ['s439292908', 's099319302'] | [2940.0, 2940.0] | [19.0, 17.0] | [222, 237] |
p03282 | u982945424 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ["S = input()\nK = int(input())\ns = len(str(S))\nl = [str(x) for x in S]\ni = 0\nwhile i <= s - 1:\n if l[i] == '1':\n i = i + 1\n else:\n break\n\nif i == 100:\n print(1)\nif K < 99:\n print(l[K-1])\nelse:\n print(l[i-1])", "S = input()\nK = int(input())\ns = len(str(S))\nl = [str(x) for x in S]\ni = 0\nwhile i <= s - 1:\n if l[i] == '1':\n i = i + 1\n else:\n break\n\nif i == 100:\n print(1)\nif K < 99:\n print(l[K-1])\nelse:\n print(l[i-1])\n", "S = input()\nK = input()\ns = len(str(S))\ni=0\n\nwhile i < s-1:\n if S[i] == '1':\n i = i + 1\n else:\n break\nif int(K) > i:\n print(S[k])\nelse:\n print(1)", "S = input()\nK = int(input())\ns = len(str(S))\nl = [str(x) for x in S]\ni = 0\nwhile i <= s - 1:\n if l[i] == '1':\n i = i + 1\n else:\n break\n\nif i == 100:\n print(1)\nif K < 99:\n print(l[K-1])\nelse:\n print(l[i-1])\n", "S = input()\nK = int(input())\ns = len(str(S))\nl = [str(x) for x in S]\ni = 0\nwhile i <= s - 1:\n if l[i] == '1':\n i = i + 1\n else:\n break\n\nif i == s:\n print(1)\nelse:\n print(l[K-1])", "S = input()\nK = input()\ns = len(str(S))\ni=0\n\nwhile i < s-1:\n if S[i] == '1':\n i = i + 1\n else:\n break\nif K > i:\n print(S[k])\nelse:\n print(1)", "S = input()\nK = input()\ns = len(str(S))\ni=0\n\nwhile i < s-1:\n if S[i] == '1':\n i = i + 1\n else:\n break\nif K > i:\n print(S[k])\nelse:\n print(1)", "S = input()\nK = int(input())\ns = len(str(S))\n\nl = [str(x) for x in S]\ni = 0\nwhile i <= s - 1:\n if l[i] == '1':\n i = i + 1\n else:\n break\nif i == s:\n print(1)\nelse:\n print(l[K])", "S = input()\nK = int(input())\ns = len(str(S))\ni=0\n\nwhile i < s-1:\n if S[i] == '1':\n i = i + 1\n else:\n break\n\nif K > i:\n print(S[i])\nelse:\n print(1)"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s019456930', 's241141520', 's322985036', 's431490925', 's515801932', 's575220082', 's585717827', 's906081960', 's185903869'] | [3064.0, 3060.0, 2940.0, 3060.0, 3060.0, 2940.0, 3060.0, 3060.0, 2940.0] | [17.0, 18.0, 23.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0] | [216, 217, 155, 217, 187, 150, 150, 185, 156] |
p03282 | u983853152 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ["\ndef main():\n S = input()\n K = input()\n\n cnt = 0\n while S[cnt]=='1':\n cnt = cnt + 1\n \n if K<=cnt:\n print(S[0])\n else:\n print(S[cnt+1])\n\n\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n S = input()\n K = int(input())\n\n cnt = 0\n while cnt<len(S) and S[cnt]=='1':\n cnt = cnt + 1\n \n if K<=cnt:\n print(S[0])\n elif cnt==len(S):\n print(S[cnt-1])\n else:\n print(S[cnt])\n\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s056001730', 's374024046'] | [2940.0, 3060.0] | [17.0, 18.0] | [221, 282] |
p03282 | u983918956 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['S = list(input())\nK = int(input())\n# 5000000000000000 = 5 * 10**15\nS = [int(e) for e in set(S)]\nnumber = 0\ndays = 5 * 10**15\nfor e in S:\n result = 1\n if e == 1:\n number += 1\n continue\n for f in range(days):\n initial = number\n result *= e\n number = initial + result\n if number >= K:\n print(e)\n exit()\n number = initial', 'S = input()\nK = int(input())\n\nfor i in range(len(S)):\n if S[i] != "1":\n break\n\nif K-1 < i:\n print(1)\nelse:\n print(S[i])'] | ['Wrong Answer', 'Accepted'] | ['s178054644', 's067558795'] | [3064.0, 2940.0] | [17.0, 17.0] | [397, 135] |
p03282 | u984465701 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ["S = input()\nk = int(input())\n\nif len(S) == 1:\n print(S)\nelse:\n for i in range(len(S)):\n if i + 1 == k:\n print(1)\n break\n if S[i] != '1':\n print(S[i])\n break\n print(1)\n", "S = input()\nk = int(input())\n\nif len(S) == 1:\n print(S)\nelif k == 1:\n print(S[0])\nelif S[0] == '1':\n print(1)\nelse:\n print(S[0])\n", "S = input()\nk = int(input())\n\n\ndef ans():\n if len(S) == 1:\n return S\n else:\n for i in range(len(S)):\n if i + 1 == k:\n return S[i]\n if S[i] != '1':\n return S[i]\n\n return 1\n\n\nprint(ans())\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s242570288', 's450805387', 's442293906'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [234, 141, 261] |
p03282 | u989345508 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['s=list(map(int,list(input())))\nk=int(input())\nfor i in range(len(s)):\n if s[i]!=1:\n if i*(5000000000000+1)>k:\n print(1)\n else:\n print(s[i])\n break\nelse:\n print(1)\n\n', 's=input()\nk=int(input())\nl=0\nfor i in s:\n if i=="1":\n l+=1\n else:\n break\nprint("1" if k<=l else s[l])\n'] | ['Wrong Answer', 'Accepted'] | ['s594949588', 's669939286'] | [3060.0, 2940.0] | [18.0, 18.0] | [523, 122] |
p03282 | u993435350 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['S = input()\nK = input()\n\nif S[0] == 1:\n print(int(S[1]))\nelse:print(int(S[0]))', 'S = input()\nK = int(input())\n\ncon = 0\n\nfor i in range(0,len(S)):\n if S[i] == "1":\n con += 1\n else:break\n\nif K <= con:\n print(1)\nelse:\n if S[0] == "1":\n S = S.replace("1","")\n print(int(S[0]))\n else:\n print(int(S[0]))'] | ['Wrong Answer', 'Accepted'] | ['s810211272', 's538993846'] | [2940.0, 3060.0] | [17.0, 17.0] | [79, 233] |
p03282 | u993642190 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['S = input()\nK = long(input())\n\nfor i in range(len(S)) :\n\tif (S[i] == "1") :\n\t\tcontinue\n\t\n\tprint(S[i])\n\tbreak', 'def main() :\n\tS = input()\n\tK = int(input())\n\n\tis_1 = True\n\tfor i in range(K) :\n\t\tif (len(S) < i) :\n\t\t\tbreak\n\n\t\t# print("S[i] : " + S[i])\n\t\tif (S[i] != "1") :\n\t\t\tis_1 = False\n\t\t\tbreak\n\n\tif (is_1) :\n\t\tprint("1")\n\t\treturn\n\n\tfor i in range(len(S)) :\n\t\tif (S[i] == "1") :\n\t\t\tcontinue\n\n\t\tprint(S[i])\n\t\tbreak\n\n\nmain()\n'] | ['Runtime Error', 'Accepted'] | ['s530594637', 's488948141'] | [2940.0, 3060.0] | [17.0, 18.0] | [108, 311] |
p03282 | u999750647 | 2,000 | 1,024,000 | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows: * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`. For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days? | ['s = list(input())\nk = int(input())\nif s[0] == 1:\n print(s[1])\nelse:\n print(s[0])', "import sys\ns = input()\nk = int(input())\nfor i in range(k):\n if s[i] != '1':\n print(s[i])\n sys.exit()\n else:\n continue\nprint(1)"] | ['Wrong Answer', 'Accepted'] | ['s006718296', 's617432477'] | [2940.0, 2940.0] | [17.0, 17.0] | [86, 153] |
p03283 | u029000441 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi,factorial\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print(\'\\n\'.join(x))\ndef printni(x): print(\'\\n\'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\nu=input().rstrip()\nn=int(u)\nu=list(u)\ns=int(u[-1])\nsm=0\nfor i in u:\n sm+=int(i)\n\nimport math\ndef judprime(x):\n y=math.sqrt(x)\n count=0\n for j in range(2,int(y)+1):\n if x%j==0:\n count+=1\n if count==0:\n return 1\n else:\n return 0\n\n\npri =[1,3,7,9]\nif judprime(n)==1:\n print("Prime")\nelse:\n if s in pri and sm%3!=0:\n print("Prime")\n \n else:\n print("Not Prime")\n \n\n\n \n \n\n\n\n \n \n\n\n \n ', "\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi,factorial\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\nn,m,que=MI()\nlis=[[0]*n for i in range(n)]\nfor i in range(m):\n l,r=MI()\n lis[l-1][r-1]+=1\nfor i in range(n):\n lis[i]=list(accumulate(lis[i]))\nfor i in range(n):\n for j in range(n-1):\n lis[j+1][i]+=lis[j][i]\n#print(lis)\n#print(lis)\nfor i in range(que):\n p,q=MI()\n if p==1:\n ans=lis[q-1][q-1]\n else:\n ans=lis[q-1][q-1]-lis[p-2][q-1]\n print(ans)"] | ['Runtime Error', 'Accepted'] | ['s141878390', 's699254782'] | [9496.0, 19368.0] | [25.0, 382.0] | [1305, 1179] |
p03283 | u029169777 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["N,M,Q=map(int,input().split())\n\n\n\nanswer=[[0]*N for i in range(N)]\nfor i in range(M):\n L,R=map(int,input().split())\n answer[N-L][R-1]+=1\n\nfor i in range(1,N):\n answer[0][i]+=answer[0][i-1]\n answer[i][0]+=answer[i-1][0]\n \nprint(answer[0])\nfor i in range(1,N):\n for j in range(1,N):\n answer[i][j]+=answer[i-1][j]\n answer[i][j]+=answer[i][j-1]\n answer[i][j]-=answer[i-1][j-1]\nfor i in range(Q):\n p,q=map(int,input().split())\n print(answer[N-p][q-1])\n\n\n\n'''\nfor i in range(Q):\n answer=0\n Query=list(map(int,input().split()))\n for j in range(M):\n if train[j][0]>=Query[0] and train[j][1]<=Query[1]:\n answer+=1\n print(answer)\n'''\n ", "N,M,Q=map(int,input().split())\n\n\nQuery=[]\nanswer=[[0]*N for i in range(N)]\nfor i in range(M):\n L,R=map(int,input().split())\n answer[N-L][R-1]+=1\n\nfor i in range(1,N):\n answer[0][i]+=answer[0][i-1]\n answer[i][0]+=answer[i-1][0]\n \nfor i in range(1,N):\n for j in range(1,N):\n answer[i][j]+=answer[i-1][j]\n answer[i][j]+=answer[i][j-1]\n answer[i][j]-=answer[i-1][j-1]\nfor i in range(Q):\n p,q=map(int,input().split())\n print(answer[N-p][q-1])\n'''\nfor i in range(Q):\n answer=0\n Query=list(map(int,input().split()))\n for j in range(M):\n if train[j][0]>=Query[0] and train[j][1]<=Query[1]:\n answer+=1\n print(answer)\n'''\n "] | ['Wrong Answer', 'Accepted'] | ['s631955367', 's908053011'] | [9348.0, 9348.0] | [1589.0, 1554.0] | [1373, 643] |
p03283 | u044459372 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['\ndef solve(s,e):\n\tres=0\n\tfor i in range(s,e+1):\n\t\tres+=train[i][e+1]-train[i][s]\n\treturn res\n\ncity,dnum,qnum=map(int,input().split())\n\ntrain=[[0 for i in range(city+1)] for i in range(city+1)]\n\nfor i in range(dnum):\n\tl,r=map(int,input().split())\n\ttrain[l][r]+=1\n\nfor i in train:\n\ttmp=0\n\tfor j in i:\n\t\ttmp+=j\n\t\tj=tmp\n\t\nquerry=[list(map(int,input().split())) for i in range(qnum)]\n\nfor q in querry:\n\tprint(solve(*q))', 'city,dnum,qnum=map(int,input().split())\n\ndata,querry=[],[]\ndapp=data.append()\nqapp=querry.append()\nfor i in range(dnum):\n\tdapp(list(map(int,input().split())))\n\nfor i in range(qnum):\n\tqapp(list(map(int,input().split())))\n\t\ndef solve(start,end):\n\tres=0\n\tfor j in range(dnum):\n\t\tif start<=data[j][0] and data[j][1]<=end:\n\t\t\tres+=1\n\treturn res\n\t\nfor i in range(qnum):\n\tprint(solve(querry[i][0],querry[i][1]))', "def main():\n n, m, Q = map(int, input().split())\n Train= [[0 for _ in range(n)] for _ in range(n)]\n \n for i in range(m):\n l, r = map(int, input().split())\n l, r = l - 1, r - 1\n Train[l][r] += 1\n \n P_Train = [[0 for _ in range(n)] for _ in range(n)]\n for i in range(n):\n tmp = 0\n for j in range(n):\n tmp += Train[i][j]\n P_Train[i][j] = tmp\n\n for i in range(Q):\n p, q = map(int, input().split())\n p, q = p - 1, q - 1\n ans = solve(P_Train, n, p, q)\n print(ans)\n\ndef solve(P_Train, n, p, q):\n ans = 0\n for i in range(p, q + 1):\n ans += P_Train[i][q] - P_Train[i][p]\n return ans\n\n\nif __name__ == '__main__':\n main()", "import sys\n\ninput = lambda :sys.stdin.readline().rstrip()\n\ndef main():\n n, m, Q = map(int, input().split())\n Train= [[0 for _ in range(n)] for _ in range(n)]\n \n for i in range(m):\n l, r = map(int, input().split())\n l, r = l - 1, r - 1\n Train[l][r] += 1\n \n P_Train = [[0 for _ in range(n + 1)] for _ in range(n + 1)]\n for i in range(n):\n for j in range(n):\n P_Train[i + 1][j + 1] = P_Train[i][j + 1] + P_Train[i + 1][j] + Train[i][j] - P_Train[i][j]\n \n #print(*P_Train, sep = '\\n')\n\n for i in range(Q):\n p, q = map(int, input().split())\n p, q = p - 1, q - 1\n ans = solve(P_Train, p, q)\n print(ans)\n\ndef solve(P_Train, p, q):\n ans = 0\n ans = P_Train[q + 1][q + 1] -P_Train[p][q + 1] - P_Train[q + 1][p] + P_Train[p][p]\n return ans\n\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s191171305', 's506600115', 's589910347', 's666068224'] | [26376.0, 3064.0, 11252.0, 15784.0] | [964.0, 17.0, 3156.0, 751.0] | [414, 404, 738, 874] |
p03283 | u059210959 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | [' N, M, Q = map(int, input().split())\n rail = []\n for i in range(M):\n r = list(map(int, input().split()))\n rail.append(r)\n \n query = []\n for i in range(Q):\n q = list(map(int, input().split()))\n query.append(q)\n \n f = [[0 for i in range(N)] for j in range(N)]\n g = [[0 for i in range(N)] for j in range(N)]\n \n for i in range(M):\n f[rail[i][0]-1][rail[i][1]-1] += 1\n \n for i in range(N):\n j = 0\n while j + i < N:\n if i == 0:\n g[j][j+i] = f[j][j+i]\n else:\n g[j][j+i] = f[j][j+i] + g[j+1][j+i] + g[j][j+i-1] - g[j+1][j+i-1]\n j += 1\n \n for i in range(Q):\n print(g[query[i][0]-1][query[i][1]-1])', '#encoding utf-8\n\nimport numpy as np\n\nN, M, Q = map(int, input().split())\n\nL = []\nR = []\nfor i in range(M):\n l, r = map(int, input().split())\n L.append(l)\n R.append(r)\n\np = []\nq = []\n\nfor i in range(Q):\n pa, qa = map(int, input().split())\n p.append(pa)\n q.append(qa)\n\nMAP = np.zeros((N, N))\nfor i in range(M):\n MAP[L[i]-1][R[i]-1] += 1\n\nC = np.zeros((N, N))\nC[0][0] = MAP[0][0]\nfor i in range(N):\n count = 0\n for j in range(N):\n count += MAP[i][j]\n C[i][j] = count\n\nprint(MAP)\nprint(C)\n\nfor i in range(Q):\n count = 0\n for j in range(q[i]-p[i]+1):\n if j == 0:\n count += C[p[i]-1+j][q[i]-1]\n else:\n count += C[p[i]-1+j][q[i]-1]-C[p[i]-1+j][p[i]-1]\n print(int(count))\n', '#encoding utf-8\n\nimport numpy as np\n\nN, M, Q = map(int, input().split())\n\nL = []\nR = []\nfor i in range(M):\n l, r = map(int, input().split())\n L.append(l)\n R.append(r)\n\np = []\nq = []\n\nfor i in range(Q):\n pa, qa = map(int, input().split())\n p.append(pa)\n q.append(qa)\n\nMAP = np.zeros((N, N))\nfor i in range(M):\n MAP[L[i]-1][R[i]-1] += 1\n\nC = np.zeros((N, N))\nC[0][0] = MAP[0][0]\nfor i in range(N):\n count = 0\n for j in range(N):\n count += MAP[i][j]\n C[i][j] = count\n\n\nfor i in range(Q):\n count = 0\n for j in range(q[i]-p[i]+1):\n count += C[p[i]-1+j][q[i]-1]-C[p[i]-1+j][p[i]-1]\n print(int(count))\n', '\nN, M, Q = map(int, input().split())\nrail = []\nfor i in range(M):\n r = list(map(int, input().split()))\n rail.append(r)\n \nquery = []\nfor i in range(Q):\n q = list(map(int, input().split()))\n query.append(q)\n \nf = [[0 for i in range(N)] for j in range(N)]\ng = [[0 for i in range(N)] for j in range(N)]\n \nfor i in range(M):\n f[rail[i][0]-1][rail[i][1]-1] += 1\n \nfor i in range(N):\n j = 0\n while j + i < N:\n if i == 0:\n g[j][j+i] = f[j][j+i]\n else:\n g[j][j+i] = f[j][j+i] + g[j+1][j+i] + g[j][j+i-1] - g[j+1][j+i-1]\n j += 1\n \nfor i in range(Q):\n print(g[query[i][0]-1][query[i][1]-1])\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s043795670', 's609467936', 's948494384', 's101179435'] | [2940.0, 30864.0, 30284.0, 75412.0] | [17.0, 3162.0, 3162.0, 1364.0] | [757, 750, 652, 647] |
p03283 | u075595666 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['class segment_():\n def __init__(self,A,n,ide_ele,segfunc):\n self.ide_ele = ide_ele\n self.num = 1 << n.bit_length()\n self.seg = [self.ide_ele] * 2 * self.num\n self.segfunc = segfunc\n\n def update1(self, k):\n k += self.num\n self.seg[k] += 1\n while k:\n k >>= 1\n self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])\n\n def query(self, p, q):\n if q < p:\n return self.ide_ele\n p += self.num;\n q += self.num\n res = self.ide_ele\n while p < q:\n if p & 1 == 1:\n res = self.segfunc(res, self.seg[p])\n p += 1\n if q & 1 == 1:\n q -= 1\n res = self.segfunc(res, self.seg[q])\n p >>= 1;\n q >>= 1\n return res\n \nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom operator import itemgetter\n\nN,M,Q = map(int,readline().split())\nS = segment_(N,0,lambda a, b: max(a,b))\nchk = []\nfor i in range(M):\n L,R = map(int,readline().split())\n chk.append((1,L,R,i))\nfor i in range(Q):\n l,r = map(int,readline().split())\n chk.append((2,l,r,i))\n \nchk.sort(key=itemgetter(2))\nans = [0]*Q\nfor a,l,r,i in chk:\n if a == 1:\n S.update1(l)\n else:\n ans[i] = S.query(l,r+1)\n \nfor i in ans:\n print(i)', "class segment_():\n def __init__(self,n,ide_ele,segfunc):\n self.ide_ele = ide_ele\n self.num = 1 << n.bit_length()\n self.seg = [self.ide_ele] * 2 * self.num\n self.segfunc = segfunc\n\n def update1(self, k):\n k += self.num\n self.seg[k] += 1\n while k:\n k >>= 1\n self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])\n\n def query(self, p, q):\n if q < p:\n return self.ide_ele\n p += self.num;\n q += self.num\n res = self.ide_ele\n while p < q:\n if p & 1 == 1:\n res = self.segfunc(res, self.seg[p])\n p += 1\n if q & 1 == 1:\n q -= 1\n res = self.segfunc(res, self.seg[q])\n p >>= 1;\n q >>= 1\n return res\n\ndef main():\n import sys\n read = sys.stdin.buffer.read\n readline = sys.stdin.buffer.readline\n readlines = sys.stdin.buffer.readlines\n from operator import itemgetter\n\n N,M,Q = map(int,readline().split())\n S = segment_(N,0,lambda a, b: a+b)\n chk = []\n for i in range(M):\n L,R = map(int,readline().split())\n chk.append((1,L,R,i))\n for i in range(Q):\n l,r = map(int,readline().split())\n chk.append((2,l,r,i))\n\n chk.sort(key=itemgetter(2))\n ans = [0]*Q\n for a,l,r,i in chk:\n if a == 1:\n S.update1(l)\n else:\n ans[i] = S.query(l,r+1)\n\n print(*ans,sep='\\n')\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s859354528', 's603382541'] | [3188.0, 54736.0] | [20.0, 1959.0] | [1394, 1465] |
p03283 | u102902647 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["import numpy as np\ndef main():\n N, M, Q = map(int, input().split())\n LR = []\n for i in range(M):\n l, r = map(int, input().split())\n LR.append([l-1, r])\n PQ = []\n for i in range(Q):\n p, q = map(int, input().split())\n PQ.append([p-1, q-1])\n ar = np.zeros([M, N])\n for m in range(M):\n ar[m, LR[m][0]:LR[m][1]] = 1\n flags_start = [np.ones(M, dtype=np.bool)]\n flags_end = []\n for i in range(1, N):\n flags_start.append((ar[:, :i].max(axis=1)==0))# * (ar[:, i:].max(axis=1)==1))\n flags_end.append((ar[:, i:].max(axis=1)==0))# * (ar[:, :i].max(axis=1)==1))\n flags_end.append(np.ones(M, dtype=np.bool))\n for q in range(Q):\n left = PQ[q][0]\n right = PQ[q][1]\n print(sum(flags_start[left] * flags_end[right]))\n\nif __name__=='__main__':\n main()", 'N, M, Q = map(int, input().split())\nLR = []\nfor i in range(M):\n l, r = map(int, input().split())\n LR.append([l-1, r])\nPQ = []\nfor i in range(Q):\n p, q = map(int, input().split())\n PQ.append([p-1, q-1])\n\n\nimport numpy as np\nar = np.zeros([M, N])\nfor m in range(M):\n ar[m, LR[m][0]:LR[m][1]] = 1\n\nfor q in range(Q):\n left = PQ[q][0]\n right = PQ[q][1]\n if left != 0 and right!=9:\n flag = (ar[:, left-1] == 0)* (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)\n print(sum(flag))\n elif left == 0 and right!=9:\n flag = (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)\n print(sum(flag))\n elif left != 0 and right==9:\n flag = (ar[:, left-1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)\n print(sum(flag))\n else:\n print(M)\n', 'N, M, Q = map(int, input().split())\nLR = []\nfor i in range(M):\n l, r = map(int, input().split())\n LR.append([l-1, r])\nPQ = []\nfor i in range(Q):\n p, q = map(int, input().split())\n PQ.append([p-1, q-1])\n \n\nimport numpy as np\nar = np.zeros([M, N])\nfor m in range(M):\n ar[m, LR[m][0]:LR[m][1]] = 1\nflags_start = [np.ones(M, dtype=np.bool)]\nflags_end = []\nfor i in range(1, N):\n flags_start.append((ar[:, :i].max(axis=1)==0))# * (ar[:, i:].max(axis=1)==1))\n flags_end.append((ar[:, i:].max(axis=1)==0))# * (ar[:, :i].max(axis=1)==1))\nflags_end.append(np.ones(M, dtype=np.bool))\nfor q in range(Q):\n left = PQ[q][0]\n right = PQ[q][1]\n print(sum(flags_start[left] * flags_end[right]))\n', 'import numpy as np\nN, M, Q = map(int, input().split())\nLR = []\nfor i in range(M):\n l, r = map(int, input().split())\n LR.append([l, r])\nPQ = []\nfor i in range(Q):\n p, q = map(int, input().split())\n PQ.append([p, q])\nar_sec = np.zeros([N, N])\nfor i in range(M):\n l, r = LR[i][0], LR[i][1]\n ar_sec[l-1][r-1] += 1\n\n\nar_sum = np.zeros([N+1, N+1])\nfor i in range(N):\n for j in range(N):\n ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]\n\nfor i in range(Q):\n p, q = PQ[i][0], PQ[i][1]\n print(int(ar_sum[q][q]-ar_sum[p-1][q]))\n'] | ['Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Accepted'] | ['s313830153', 's438477025', 's728178679', 's707767439'] | [840272.0, 837804.0, 839532.0, 56964.0] | [3166.0, 3165.0, 3165.0, 2396.0] | [841, 821, 711, 579] |
p03283 | u118642796 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import sys\ns = sys.stdin.readlines()\nN,M,Q = map(int,s[0].split())\n\nSection = [[0]*N for _ in range(N)]\nfor L,R in (map(int, e.split()) for e in s[1:M+1):\n Section[L-1][R-1] += 1\n\nSum = [[0]*(N+1) for _ in range(N+1)]\nfor i in range(N):\n for j in range(N):\n Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]\n\nAns = [[0]*N for _ in range(N)]\nfor i in range(N):\n for j in range(i,N):\n Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]\n\nfor p,q in (map(int, e.split()) for e in s[M+1:]\n print(Ans[p-1][q-1])', 'import sys\ns = sys.stdin.readlines()\n\nN,M,Q = map(int,s[0].split())\n\nSection = [[0]*N for _ in [0]*N]\nfor L,R in (map(int, e.split()) for e in s[1:M+1]):\n Section[L-1][R-1] += 1\n\nSum = [[0]*(N+1) for _ in [0]*(N+1)]\nfor i in range(N):\n for j in range(N):\n Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]\n\nfor p,q in (map(int, e.split()) for e in s[M+1:]):\n print(Sum[q][q]-Sum[p-1][q])'] | ['Runtime Error', 'Accepted'] | ['s955312361', 's898301937'] | [2940.0, 36872.0] | [17.0, 667.0] | [532, 417] |
p03283 | u124592621 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\ncum = [[0]\nfor i in range(m):\n li, ri = map(int, input().split())\n lis.append(li)\n ris.append(ri)\n\nfor i in range(q):\n pi, qi = map(int, input().split())\n total = 0\n for (li, ri) in zip(lis, ris):\n if pi <= li and ri <= qi:\n total += 1\n print(total)\n\n', 'n, m, qq = map(int, input().split())\nlr = [[0] * n for _ in range(n)]\nfor _ in range(m):\n l, r = map(int, input().split())\n lr[l - 1][r - 1] += 1\n\nfor i in range(n):\n for j in range(n - 1):\n lr[i][j + 1] += lr[i][j]\nfor j in range(n):\n for i in range(n-1, 0, -1):\n lr[i - 1][j] += lr[i][j]\n\nfor _ in range(qq):\n p, q = map(int, input().split())\n if q == n:\n print(lr[p - 1][q - 1])\n else:\n print(lr[p - 1][q - 1] - lr[q][q - 1])\n'] | ['Runtime Error', 'Accepted'] | ['s224152957', 's712975570'] | [2940.0, 9332.0] | [17.0, 1599.0] | [326, 478] |
p03283 | u136090046 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\nlr_array = [[int(x) for x in input().split()] for y in range(m)]\npq_array = [[int(x) for x in input().split()] for y in range(q)]\n\n\ndef solve1():\n table = [[0 for x in range(n + 1)] for y in range(n + 1)]\n for l, r in lr_array:\n table[l][r] += 1\n # for row in table:\n # print(row)\n # print("---------")\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i][j - 1] + table[i][j]\n # for row in table:\n # print(row)\n for p, q in pq_array:\n res = 0\n for i in range(p, q + 1):\n # print(i)\n res += table[i][q]\n print(res)\n\n return 0\n\n\n\n\n\ndef solve2():\n table = [[0 for x in range(n + 1)] for y in range(n + 1)]\n for l, r in lr_array:\n table[l][r] += 1\n # for row in table:\n # print(row)\n # print("---------")\n\n \n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i][j - 1] + table[i][j]\n\n \n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i - 1][j] + table[i][j]\n\n \n \n for p, q in pq_array:\n print(table[q][q] + table[p][p] - table[q][p-1] - table[p-1][q])\n\n\nif __name__ == \'__main__\':\n # solve1()\n solve2()\n', 'n, m, q = map(int, input().split())\nlr_array = [[int(x) for x in input().split()] for y in range(m)]\npq_array = [[int(x) for x in input().split()] for y in range(q)]\n\n\ndef solve1():\n table = [[0 for x in range(n + 1)] for y in range(n + 1)]\n for l, r in lr_array:\n table[l][r] += 1\n # for row in table:\n # print(row)\n # print("---------")\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i][j - 1] + table[i][j]\n # for row in table:\n # print(row)\n for p, q in pq_array:\n res = 0\n for i in range(p, q + 1):\n # print(i)\n res += table[i][q]\n print(res)\n\n return 0\n\n\n\n\n\ndef solve2():\n table = [[0 for x in range(n + 1)] for y in range(n + 1)]\n for l, r in lr_array:\n table[l][r] += 1\n # for row in table:\n # print(row)\n # print("---------")\n\n \n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i][j - 1] + table[i][j]\n\n \n for i in range(1, n + 1):\n for j in range(1, n + 1):\n table[i][j] = table[i - 1][j] + table[i][j]\n\n # for row in table:\n # print(row)\n\n \n \n for p, q in pq_array:\n print(table[q][q] + table[p-1][p-1] - table[q][p-1] - table[p-1][q])\n\n\nif __name__ == \'__main__\':\n # solve1()\n solve2()\n'] | ['Wrong Answer', 'Accepted'] | ['s715853893', 's791883897'] | [58480.0, 58480.0] | [1164.0, 1141.0] | [1559, 1609] |
p03283 | u140251125 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['# input\nN, M, Q = map(int, input().split())\ntrain_query = {} \nfor i in range(M + Q):\n train_query[i] = list(map(int, input().split()))\n\ntrain_query = sorted(train_query.items(), key=lambda x: x[1][1])\nprint(train_query)\n\n\na = [0 for _ in range(N)]\n\nfor j in range(M + Q):\n if train_query[j][0] < M: \n a[train_query[j][1][0] - 1] += 1\n else: \n ans = sum(a[(train_query[j][1][0] - 1):(train_query[j][1][1])])\n print(ans)', '# input\nN, M, Q = map(int, input().split())\ntrain_query = {} \nfor i in range(M + Q):\n train_query[i] = list(map(int, input().split()))\n\ntrain_query = sorted(train_query.items(), key=lambda x: x[1], reverse = True)\n\n\na = [0 for _ in range(N)]\n\nfor j in range(M + Q):\n if train_query[j][0] < M: \n a[train_query[j][1][0]] = 1\n else: \n ans = sum(a[train_query[j][1][0]:train_query[j][1][1]])\n print(ans)\n', '# input\nN, M, Q = map(int, input().split())\ntrain_query = {} \nfor i in range(M + Q):\n train_query[i] = list(map(int, input().split()))\n\ntrain_query = sorted(train_query.items(), key=lambda x: x[1][1])\n\n\nStartPoints = [0 for _ in range(N)] \nans = [0 for _ in range(Q)] \n\nfor j in range(M + Q):\n if train_query[j][0] < M: \n StartPoints[train_query[j][1][0] - 1] += 1\n else: \n ans[train_query[j][0] - M] = sum(StartPoints[(train_query[j][1][0] - 1):(train_query[j][1][1])])\n\nfor i in range(Q):\n print(ans[i])\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s218967455', 's272680774', 's716530856'] | [114376.0, 111964.0, 111944.0] | [2561.0, 2423.0, 2293.0] | [591, 573, 736] |
p03283 | u148019779 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["#!/usr/bin/env python3\n\nimport sys\n\n\ndef main():\n n, m, q = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n\n x = [[0 for j in range(n+1)] for i in range(n+1)]\n c = [[0 for j in range(n+1)] for i in range(n+1)]\n z = [[0 for j in range(n+1)] for i in range(n+1)]\n\n for i in range(m):\n l, r = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n x[l][r] += 1\n \n for i in range(1, n+1):\n for j in range(1, n+1):\n c[i][j] = c[i][j-1] + x[i][j]\n\n for j in range(1, n+1):\n for i in range(1, n+1):\n z[i][j] = z[i-1][j] + c[i][j]\n \n for i in range(q):\n qp, qq = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n print(z[qq][qq] - z[qq][qp-1] - z[qp-1][qq] + z[qp][qp])\n\n\nif __name__=='__main__':\n main()", "#!/usr/bin/env python3\n\nimport sys\n\n\ndef main():\n n, m, q = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n\n x = [[0 for j in range(n+1)] for i in range(n+1)]\n c = [[0 for j in range(n+1)] for i in range(n+1)]\n z = [[0 for j in range(n+1)] for i in range(n+1)]\n\n for i in range(m):\n l, r = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n x[l][r] += 1\n \n for i in range(1, n+1):\n for j in range(1, n+1):\n c[i][j] = c[i][j-1] + x[i][j]\n\n for j in range(1, n+1):\n for i in range(1, n+1):\n z[i][j] = z[i-1][j] + c[i][j]\n \n for i in range(q):\n qp, qq = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]\n print(z[qq][qq] - z[qq][qp-1] - z[qp-1][qq] + z[qp-1][qp-1])\n\n\nif __name__=='__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s810635345', 's608603247'] | [19764.0, 19764.0] | [765.0, 746.0] | [820, 824] |
p03283 | u170201762 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import bisect\nimport numpy as np\nN,M,Q = map(int,input().split())\nlr = [0]*M\nfor i in range(M):\n l,r = map(int,input().split())\n lr[i] = [l,r]\nlr = sorted(lr,key=lambda x:x[0])\nlr_t = list(np.array(lr).transpose())\nindex_dict={}\nr_dict={} \nd = {}\nfor i in range(N):\n index_dict[i+1]=bisect.bisect_left(lr_t[0],i+1)\n r_dict[i+1]=sorted(lr_t[1][index_dict[i+1]:])\nfor i in range(Q):\n p,q = map(int,input().split())\n if p not in d:\n d[p]={}\n else:\n if q not in d[p]:\n I = index_dict[p]\n r = r_dict[p]\n I = bisect.bisect(r,q)\n print(I)\n d[p][q]=I\n else:\n print(d[p][q])\n ', 'import numpy as np\nN,M,Q = map(int,input().split())\nS = [[0]*N for i in range(N)]\nfor i in range(M):\n L,R = map(int,input().split())\n S[L-1][R-1] += 1\n\nS = np.cumsum(np.cumsum(np.array(S),axis=0),axis=1)\n\nfor i in range(Q):\n p,q = map(int,input().split())\n p -= 1\n q -= 1\n ans = S[q][q]\n if p > 0:\n ans += S[p-1][p-1]-S[p-1][q]-S[q][p-1]\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s220696734', 's829356241'] | [255936.0, 18248.0] | [3175.0, 2643.0] | [678, 380] |
p03283 | u186967328 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N,M,Q = map(int,input().split())\n\ntrain = [[0 for i in range(N)] for j in range(N)]\nfor m in range(M):\n L,R = map(int,input().split())\n train[L-1][R-1] += 1\n\nc = [[0 for i in range(N)] for j in range(N)]\nfor i in range(N):\n cnt = 0\n for j in range(N):\n cnt += train[i][j]\n c[i][j] = cnt\n\n\n\nfor x in range(Q):\n p,q = map(int,input().split())\n p -= 1\n q -= 1\n cnt2 = 0\n for i in range(p,q+1):\n cnt2 += c[i][q] - c[i][p]\n print(cnt2)', 'N,M,Q = map(int,input().split())\n\ntrain = [[0 for i in range(N+1)] for j in range(N+1)]\nfor m in range(M):\n L,R = map(int,input().split())\n train[L][R] += 1\n\nc = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n cnt = 0\n for j in range(1,N+1):\n c[i][j] = train[i][j] + c[i-1][j] + c[i][j-1] - c[i-1][j-1]\n\nfor x in range(Q):\n p,q = map(int,input().split())\n print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])'] | ['Wrong Answer', 'Accepted'] | ['s926563157', 's349025375'] | [11124.0, 15528.0] | [3156.0, 1600.0] | [481, 449] |
p03283 | u189479417 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int,input().split())\ngraph = [[0 for i in range(N+1)] for j in range(N+1)]\nfor _ in range(M):\n L, R = map(int,input().split())\n graph[L-1][R] += 1\n\nprint(graph)\n\nfor i in range(N-1,-1,-1):\n for j in range(1,N+1):\n graph[i][j] += graph[i+1][j] + graph[i][j-1]\n\nprint(graph)\n\nfor _ in range(Q):\n p, q = map(int,input().split())\n print(graph[p-1][q])', 'N, M, Q = map(int,input().split())\ngraph = [[0 for i in range(N+1)] for j in range(N+1)]\nfor _ in range(M):\n L, R = map(int,input().split())\n graph[L-1][R] += 1\n\nfor i in range(N-1,-1,-1):\n for j in range(1,N+1):\n graph[i][j] += graph[i+1][j] + graph[i][j-1] - graph[i+1][j-1]\n\nprint(graph)\n\nfor _ in range(Q):\n p, q = map(int,input().split())\n print(graph[p-1][q])', 'N, M, Q = map(int,input().split())\ngraph = [[0 for i in range(N+1)] for j in range(N+1)]\nfor _ in range(M):\n L, R = map(int,input().split())\n graph[L-1][R] += 1\n\nfor i in range(N-1,-1,-1):\n for j in range(1,N+1):\n graph[i][j] += graph[i+1][j] + graph[i][j-1] - graph[i+1][j-1]\n\nfor _ in range(Q):\n p, q = map(int,input().split())\n print(graph[p-1][q])'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s603717614', 's867758138', 's338143467'] | [35336.0, 12424.0, 11144.0] | [1656.0, 1542.0, 1514.0] | [383, 387, 373] |
p03283 | u189487046 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['2 3 1\n1 1\n1 2\n2 2\n1 2', 'n, m, Q = map(int, input().split())\nM = [[0]*n for _ in range(n)]\nfor i in range(m):\n l, r = map(int, input().split())\n M[r-1][l-1] += 1\n\nfor q in range(n):\n for p in reversed(range(1, n)):\n M[q][p-1] += M[q][p]\nfor p in range(n):\n for q in range(n-1):\n M[q+1][p] += M[q][p]\n\nfor i in range(Q):\n p, q = map(int, input().split())\n print(M[q-1][p-1])\n'] | ['Runtime Error', 'Accepted'] | ['s009296734', 's418789429'] | [2940.0, 10992.0] | [17.0, 1554.0] | [21, 381] |
p03283 | u191829404 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import math\nimport copy\nfrom operator import mul\nfrom functools import reduce\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\n\nfrom itertools import product\n\nfrom itertools import permutations\n\nfrom itertools import combinations\n\nfrom itertools import accumulate\nfrom bisect import bisect_left, bisect_right\n\nimport re\n# import numpy as np\n# from scipy.misc import comb\n\ndef inside(y, x, H, W):\n return 0 <= y < H and 0 <= x < W\n\n\ndy = [0, -1, 0, 1]\ndx = [1, 0, -1, 0]\n \ndef i_inpl(): return int(input())\ndef l_inpl(): return list(map(int, input().split()))\ndef line_inpl(x): return [i_inpl() for _ in range(x)]\n\nINF = int(1e18)\nMOD = int(1e9)+7 # 10^9 + 7\n\n\ndef create_grid(W, H, value = 0):\n return [[ value for _ in range(H)] for _ in range(W)]\n\n########\nN, H = l_inpl()\na, b = [], []\n\nfor _ in range(N):\n ai, bi = l_inpl()\n a.append(ai)\n b.append(bi)\n\na.sort()\nb.sort()\nmax_a = max(a)\n\nans = 0\nfor bi in b[bisect_right(b, max_a):]:\n H -= bi\n ans += 1\n if H <= 0:\n break\n\nif H > 0:\n ans += math.ceil(H / max_a)\n\nprint(ans)', 'import math\nimport copy\nfrom operator import mul\nfrom functools import reduce\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\n\nfrom itertools import product\n\nfrom itertools import permutations\n\nfrom itertools import combinations\n\nfrom itertools import accumulate\nfrom bisect import bisect_left, bisect_right\n\nimport re\n# import numpy as np\n# from scipy.misc import comb\n\ndef inside(y, x, H, W):\n return 0 <= y < H and 0 <= x < W\n\n\ndy = [0, -1, 0, 1]\ndx = [1, 0, -1, 0]\n \ndef i_inpl(): return int(input())\ndef l_inpl(): return list(map(int, input().split()))\ndef line_inpl(x): return [i_inpl() for _ in range(x)]\n\nINF = int(1e18)\nMOD = int(1e9)+7 # 10^9 + 7\n\n\ndef create_grid(W, H, value = 0):\n return [[ value for _ in range(H)] for _ in range(W)]\n\n########\nN, M, Q = l_inpl()\n\nl, r = [], []\nfor _ in range(M):\n li, ri = l_inpl()\n l.append(li)\n r.append(ri)\n\np, q = [], []\nfor _ in range(Q):\n pi, qi = l_inpl()\n p.append(pi)\n q.append(qi)\n\ns = create_grid(N+1, N+1)\n\nfor i in range(M):\n s[l[i]][r[i]] += 1\n\nfor hi in range(1, N+1):\n for wi in range(1, N+1):\n s[hi][wi] += s[hi-1][wi]\n s[hi][wi] += s[hi][wi-1]\n s[hi][wi] -= s[hi-1][wi-1]\n\nfor i in range(Q):\n pi, qi = p[i], q[i]\n print(s[qi][qi] - s[qi][pi-1] - s[pi-1][qi] + s[pi-1][pi-1])'] | ['Runtime Error', 'Accepted'] | ['s924016255', 's140300747'] | [3824.0, 28572.0] | [26.0, 1454.0] | [1410, 1648] |
p03283 | u201234972 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map( int, input().split())\nNN = [ [0]*N for _ in range(N)]\nfor _ in range(M):\n L, R = map( int, input().split())\n NN[L-1][R-1] += 1\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n NN[i][j] += NN[i][j-1]+NN[i-1][j]+NN[i-1][j]-NN[i-1][j-1]\nfor _ in range(Q):\n p, q = map( int, input().split())\n print(NN[p-1][q-1])', 'N, M, Q = map( int, input().split())\nNN = [ [0 for _ in range(N+1)] for _ in range(N+1)]\nfor _ in range(M):\n L, R = map( int, input().split())\n NN[L][R] += 1\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n NN[i][j] += NN[i][j-1]+NN[i-1][j]+NN[i-1][j]-NN[i-1][j-1]\nfor _ in range(Q):\n p, q = map( int, input().split())\n print(NN[q][q]-NN[q][p-1]-NN[p-1][q]+NN[p-1][p-1])', 'N, M, Q = map( int, input().split())\nNN = [ [0]*(N+1) for _ in range(N+1)]\nfor _ in range(M):\n L, R = map( int, input().split())\n NN[L][R] += 1\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n NN[i][j] += NN[i][j-1]+NN[i-1][j]+NN[i-1][j]-NN[i-1][j-1]\nfor _ in range(Q):\n p, q = map( int, input().split())\n print(NN[p-1][q-1])', 'N, M, Q = map( int, input().split())\nNN = [ [ 0 for _ in range(N)] for _ in range(N)]\nfor _ in range(M):\n L, R = map( int, input().split())\n NN[L-1][R-1] += 1\n\nfor i in range(1,N):\n for j in range(1,N):\n NN[j][j+1] += NN[j][j+i-1] + NN[j+1][i+j] - NN[j+1][j+i-1]\nfor _ in range(Q):\n p, q = map( int, input().split())\n print(NN[p-1][q-1])', 'N, M, Q = map( int, input().split())\nNN = [ [0 for _ in range(N+1)] for _ in range(N+1)]\nfor _ in range(M):\n L, R = map( int, input().split())\n NN[L][R] += 1\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n NN[i][j] += NN[i][j-1]+NN[i-1][j]-NN[i-1][j-1]\nfor _ in range(Q):\n p, q = map( int, input().split())\n print(NN[q][q]-NN[q][p-1]-NN[p-1][q]+NN[p-1][p-1])'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s052307090', 's101724420', 's105136071', 's257895476', 's838665347'] | [4980.0, 69692.0, 46980.0, 5108.0, 13416.0] | [590.0, 1997.0, 1692.0, 620.0, 1592.0] | [345, 392, 347, 359, 381] |
p03283 | u210827208 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,Q=map(int,input().split())\nM=[[0]*n for _ in range(n)]\nfor i in range(m):\n l,r=map(int,input().split())\n M[r-1][l-1]+=1\n\nfor q in range(n):\n for p in reversed(range(1,n)):\n M[q][p-1]+=M[q][p]\nfor p in range(n):\n for q in range(n-1):\n M[q+1][p]+=M[q][p] \nprint(M)\nfor i in range(Q):\n p,q=map(int,input().split())\n print(M[q-1][p-1])', 'n,m,Q=map(int,input().split())\nM=[[0]*n for _ in range(n)]\nfor i in range(m):\n l,r=map(int,input().split())\n M[r-1][l-1]+=1\n\nfor q in range(n):\n for p in reversed(range(1,n)):\n M[q][p-1]+=M[q][p]\nfor p in range(n):\n for q in range(n-1):\n M[q+1][p]+=M[q][p] \n\nfor i in range(Q):\n p,q=map(int,input().split())\n print(M[q-1][p-1])'] | ['Wrong Answer', 'Accepted'] | ['s651392313', 's872323951'] | [12568.0, 9332.0] | [1538.0, 1532.0] | [374, 366] |
p03283 | u215115622 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["import sys\nfrom itertools import accumulate\nN, M, Q = [int(i) for i in input().strip().split(' ')]\n \nflag = False\ncounter = M\n \nd = []\nd2 = []\nfor i in range(N):\n d.append([0] * N)\nfor i in range(N):\n d2.append([0] * N)\n \n \nfor line in sys.stdin:\n L, R = [int(i) for i in line.strip().split(' ')]\n if not flag:\n d[L-1][R-1] += 1\n\n# for j in range(N - R + 1):\n# d[i][R + j - 1] += 1\n counter -= 1\n if counter == 0:\n# print(d)\n for i in range(N):\n d[i] = d[i][::-1]\n# print(d)\n for i in range(N):\n if i == 0:\n d[N-1] = list(accumulate(d[N-1][::-1]))[::-1]\n else:\n for j in range(N):\n if j == 0:\n temp = d[N-1-i][N-1-j]\n else:\n temp += d[N-1-i][N-1-j]", 'import sys\ns = sys.stdin.readlines()\n \nN,M,Q = map(int,s[0].split())\n \nSection = [[0]*N for _ in [0]*N]\nfor L,R in (map(int, e.split()) for e in s[1:M+1]):\n Section[L-1][R-1] += 1\n \nSum = [[0]*(N+1) for _ in [0]*(N+1)]\nfor i in range(N):\n for j in range(N):\n Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]\n \nfor p,q in (map(int, e.split()) for e in s[M+1:]):\n print(Sum[q][q]-Sum[p-1][q])'] | ['Wrong Answer', 'Accepted'] | ['s812758343', 's446814906'] | [7028.0, 36864.0] | [593.0, 677.0] | [962, 421] |
p03283 | u222668979 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['from copy import deepcopy\n\nn, m, q = map(int, input().split())\nlr = [list(map(int, input().split())) for _ in range(m)]\npq = [list(map(int, input().split())) for _ in range(q)]\n\ncnt = [[0] * (n + 1) for _ in range(n + 1)]\nfor l, r in lr:\n cnt[l][r] += 1\n\nacc = cnt.deepcopy()\nfor i in range(n):\n for j in range(n):\n tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]\n acc[i + 1][j + 1] += tmp\n\nfor p, q in pq:\n p -= 1\n ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]\n print(ans)\n', 'from copy import deepcopy\n\nn, m, q = map(int, input().split())\nlr = [list(map(int, input().split())) for _ in range(m)]\npq = [list(map(int, input().split())) for _ in range(q)]\n\ncnt = [[0] * (n + 1) for _ in range(n + 1)]\nfor l, r in lr:\n cnt[l][r] += 1\n\nacc = deepcopy(cnt)\nfor i in range(n):\n for j in range(n):\n tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]\n acc[i + 1][j + 1] += tmp\n\nfor p, q in pq:\n p -= 1\n ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]\n print(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s983282211', 's577742281'] | [56040.0, 65964.0] | [619.0, 928.0] | [509, 508] |
p03283 | u236127431 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N,M,Q=map(int,input().split())\nTown=[[int(i) for i in range(M)]]\nTown.sort(key=lambda x:x[0])\n\ndef BS_left(x,L):\n L_copy=L[:]\n l=len(L_copy)\n left=0\n if L[l-1]<x:\n return l-1\n else:\n while l>2:\n if L_copy[l//2]<x:\n L_copy=L_copy[l//2:l]\n left+=l//2\n else:\n L_copy=L_copy[0:l//2+1]\n l=len(L_copy)\n if L[left]>=x:\n return left-1\n else:\n return left\n\ndef BS_right(x,L):\n L_copy=L[:]\n l=len(L_copy)\n right=l-1\n if L[0]>x:\n return 0\n else:\n while l>2:\n if L_copy[l//2]<=x:\n L_copy=L_copy[l//2:l]\n else:\n L_copy=L_copy[0:l//2+1]\n right+=-l//2+1\n l=len(L_copy)\n if L[right]<=x:\n return right+1\n else:\n return right\n\nans=[0]*Q\nfor i in range(Q):\n p,q=map(int,input().split())\n TownL=list(zip(*Town))[0]\n newTown=Town[BS_left(p,TownL)+1:BS_right(q,TownL)]\n if len(newTown)==0:\n print(0)\n else:\n newTown.sort(key=lambda x:x[1])\n TownR=list(zip(*newTown))[1]\n if BS_right(q,TownR)==1 and TownR[0]>q:\n print(0)\n else:\n print(BS_right(q,TownR))', 'N,M,Q=map(int,input().split())\nTown=[[int(i) for i in input().split()] for i in range(M)]\nTown.sort(key=lambda x:x[0])\n\ndef BS_left(x,L,s):\n L_copy=L[:]\n left=0\n if L[s-1]<x:\n return s-1\n else:\n while s>2:\n if L_copy[s//2]<x:\n L_copy=L_copy[s//2:s]\n left+=s//2\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n s=s//2+1\n if L[left]>=x:\n return left-1\n else:\n return left\n\ndef BS_right(x,L,s):\n L_copy=L[:]\n right=s-1\n if L[0]>x:\n return 0\n else:\n while s>2:\n if L_copy[s//2]<=x:\n L_copy=L_copy[s//2:s]\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n right+=-s//2+1\n s=s//2+1\n if L[right]<=x:\n return right+1\n else:\n return right\n\nans=[0]*Q\nfor i in range(Q):\n p,q=map(int,input().split())\n TownL=list(zip(*Town))[0]\n a=BS_left(p,TownL,M)+1\n b=BS_right(q,TownL,M)\n newTown=Town[a:b]\n if b-a==0:\n print(0)\n else:\n newTown.sort(key=lambda x:x[1])\n TownR=list(zip(*newTown))[1]\n c=BS_right(q,TownR,b-a)\n if c==1 and TownR[0]>q:\n print(0)\n else:\n print(c-1)\n', 'N,M,Q=map(int,input().split())\nTown=[[int(i) for i in input().split()] for i in range(M)]\nTown.sort(key=lambda x:x[0])\n\ndef BS_left(x,L,s):\n L_copy=L[:]\n left=0\n if L[s-1]<x:\n return s-1\n else:\n while s>2:\n if L_copy[s//2]<x:\n L_copy=L_copy[s//2:s]\n left+=s//2\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n s=s//2+1\n if L[left]>=x:\n return left-1\n else:\n return left\n\ndef BS_right(x,L,s):\n L_copy=L[:]\n right=s-1\n if L[0]>x:\n return 0\n else:\n while s>2:\n if L_copy[s//2]<=x:\n L_copy=L_copy[s//2:s]\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n right+=-s//2+1\n s=s//2+1\n if L[right]<=x:\n return right+1\n else:\n return right\n\nans=[0]*Q\nfor i in range(Q):\n p,q=map(int,input().split())\n for i in zip(*Town):\n TownL=i\n break\n a=BS_left(p,TownL,M)+1\n newTown=Town[a:]\n if M-a==0:\n print(0)\n else:\n newTown.sort(key=lambda x:x[1])\n e=0\n for i in zip(*newTown):\n if e==0:\n e+=1\n else:\n TownR=i\n break\n b=BS_right(q,TownR,M-a)\n if b==1 and TownR[0]>q:\n print(0)\n else:\n print(b-1)\n', 'N,M,Q=map(int,input().split())\nTown=[[int(i) for i in input().split()] for i in range(M)]\nTown.sort(key=lambda x:x[0])\n\ndef BS_left(x,L,s):\n L_copy=L[:]\n left=0\n if L[s-1]<x:\n return s-1\n else:\n while s>2:\n if L_copy[s//2]<x:\n L_copy=L_copy[s//2:s]\n left+=s//2\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n s=s//2+1\n if L[left]>=x:\n return left-1\n else:\n return left\n\ndef BS_right(x,L,s):\n L_copy=L[:]\n right=s-1\n if L[0]>x:\n return 0\n else:\n while s>2:\n if L_copy[s//2]<=x:\n L_copy=L_copy[s//2:s]\n s=s-s//2\n else:\n L_copy=L_copy[0:s//2+1]\n right+=-s//2+1\n s=s//2+1\n if L[right]<=x:\n return right+1\n else:\n return right\n\nans=[0]*Q\nfor i in range(Q):\n p,q=map(int,input().split())\n for i in zip(*Town):\n TownL=i\n break\n a=BS_left(p,TownL,M)+1\n b=BS_right(q,TownL,M)\n newTown=Town[a:b]\n if b-a==0:\n print(0)\n else:\n newTown.sort(key=lambda x:x[1])\n e=0\n for i in zip(*newTown):\n if e==0:\n e+=1\n else:\n TownR=i\n break\n c=BS_right(q,TownR,b-a)\n if c==1 and TownR[0]>q:\n print(0)\n else:\n print(1+c)\n', 'N,M,Q=map(int,input().split())\nTown=[[0,0] for i in range(M)]\nfor i in range(M):\n Town[i][0],Town[i][1]=map(int,input().split())\nTown.sort(key=lambda x:x[0])\n\ndef BS_left(x,L):\n L_copy=L[:]\n l=len(L_copy)\n left=0\n if L[l-1]<x:\n return l-1\n else:\n while l>2:\n if L_copy[l//2]<x:\n L_copy=L_copy[l//2:l]\n left+=l//2\n else:\n L_copy=L_copy[0:l//2+1]\n l=len(L_copy)\n if L[left]>=x:\n return left-1\n else:\n return left\n\ndef BS_right(x,L):\n L_copy=L[:]\n l=len(L_copy)\n right=l-1\n if L[0]>x:\n return 0\n else:\n while l>2:\n if L_copy[l//2]<=x:\n L_copy=L_copy[l//2:l]\n else:\n L_copy=L_copy[0:l//2+1]\n right+=-l//2+1\n l=len(L_copy)\n if L[right]<=x:\n return right+1\n else:\n return right\n\nans=[0]*Q\nfor i in range(Q):\n p,q=map(int,input().split())\n TownL=list(zip(*Town))[0]\n newTown=Town[BS_left(p,TownL)+1:BS_right(q,TownL)]\n if len(newTown)==0:\n print(0)\n else:\n newTown.sort(key=lambda x:x[1])\n TownR=list(zip(*newTown))[1]\n if BS_right(q,TownR)==1 and TownR[0]>q:\n print(0)\n else:\n print(BS_right(q,TownR)-1)', 'N,M,Q=map(int,input().split())\nTrain=[[int(i) for i in input().split()] for i in range(M)]\nMap=[[0]*(N+1) for i in range(N+1)]\nfor i in Train:\n x,y=i[0],i[1]\n Map[y][x]+=1\nfor a in range(1,N+1):\n for b in range(1,N+1):\n if b<=N-1:\n Map[a][b+1]=Map[a][b]+Map[a][b+1]\n if a>=2:\n Map[a][b]=Map[a-1][b]+Map[a][b]\nfor i in range(Q):\n p,q=map(int,input().split())\n print(Map[q][q]-Map[q][p-1]-Map[p-1][q]+Map[p-1][p-1])\n\n \n\n\n '] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s075124979', 's310706319', 's326779037', 's605923831', 's963506480', 's223418500'] | [24540.0, 58736.0, 58816.0, 58812.0, 54156.0, 43264.0] | [3157.0, 3159.0, 3159.0, 3158.0, 3158.0, 1717.0] | [1087, 1118, 1183, 1208, 1154, 445] |
p03283 | u239528020 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['#!/usr/bin/env python3\nfrom itertools import accumulate\nimport numpy as np\n\nn, m, q = list(map(int, input().split()))\nlr = [list(map(int, input().split())) for _ in range(m)]\npq = [list(map(int, input().split())) for _ in range(q)]\n\ndata = [[0]*500 for i in range(500)]\n\n\nfor l, r in lr:\n data[l-1][r-1] += 1\n\n\n\n\n\n# print(data)\n# for p, q in pq:\n# ans = 0\n# if p == 1:\n\n# ans += data[i][q-1]\n# else:\n\n# ans += data[i][q-1]-data[i][p-1-1]\n# print(ans)\n\ndata = np.array(data)\n\ndata = np.cumsum(data, axis=1)\ndata = np.cumsum(data, axis=0)\n\nprint(data[:10, :10])\nfor p, q in pq:\n ans = 0\n if p == 1:\n ans = data[q-1][q-1]\n else:\n ans = data[q-1][q-1]-data[p-1-1][p-1-1]\n print(ans)\n# for p, q in pq:\n# ans = 0\n# if p == 1:\n\n# ans += data[i][q-1]\n# else:\n\n# ans += data[i][q-1]-data[i][p-1-1]\n# print(ans)\n', '#!/usr/bin/env python3\nfrom itertools import accumulate\nimport numpy as np\n\nn, m, q = list(map(int, input().split()))\nlr = [list(map(int, input().split())) for _ in range(m)]\npq = [list(map(int, input().split())) for _ in range(q)]\n\ndata = [[0]*500 for i in range(500)]\n\n\nfor l, r in lr:\n data[l-1][r-1] += 1\n\n\n\n\n\n# print(data)\n# for p, q in pq:\n# ans = 0\n# if p == 1:\n\n# ans += data[i][q-1]\n# else:\n\n# ans += data[i][q-1]-data[i][p-1-1]\n# print(ans)\n\ndata = np.array(data)\n\ndata = np.cumsum(data, axis=1)\ndata = np.cumsum(data, axis=0)\n\n# print(data[:10, :10])\nfor p, q in pq:\n ans = 0\n if p == 1:\n ans = data[q-1][q-1]\n else:\n ans = data[q-1][q-1]-data[p-1-1][q-1]\n print(ans)\n# for p, q in pq:\n# ans = 0\n# if p == 1:\n\n# ans += data[i][q-1]\n# else:\n\n# ans += data[i][q-1]-data[i][p-1-1]\n# print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s081386821', 's566080182'] | [76364.0, 76164.0] | [886.0, 910.0] | [1161, 1161] |
p03283 | u263654061 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['for qi in range(Q):\n out = 0\n for i in range(m):\n if(l[i]>=p[qi] and r[i]<=q[qi]):\n out += 1\n print(out)', 'n,m,Q = list(map(int, input().split()))\n\nl=[]\nr=[]\nfor j in range(m):\n l_tmp, r_tmp = list(map(int, input().split()))\n l.append(l_tmp)\n r.append(r_tmp)\n\np=[]\nq=[]\nfor k in range(Q):\n p_tmp, q_tmp = list(map(int, input().split()))\n p.append(p_tmp)\n q.append(q_tmp)\n \nsu = [[0 for _ in range(n+1)] for __ in range(n+1)]\n\ndef sumTable(L, R):\n for i in range(m):\n su[L[i]][R[i]] += 1\n \n for i in range(1,n+1):\n for j in range(1, n+1):\n su[i][j] += su[i-1][j]\n su[i][j] += su[i][j-1]\n su[i][j] -= su[i-1][j-1]\n\ndef getSum(ll,rr):\n ans = su[rr][rr] - su[rr][ll-1] -su[ll-1][rr] + su[ll-1][ll-1]\n return ans\n \nsumTable(l,r)\n\nimport copy\nss = copy.copy(su)\n\nfor qi in range(Q):\n su = copy.copy(ss)\n print(getSum(p[qi], q[qi]))'] | ['Runtime Error', 'Accepted'] | ['s591732227', 's601391920'] | [2940.0, 28292.0] | [17.0, 1591.0] | [131, 808] |
p03283 | u279493135 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom fractions import gcd\nfrom bisect import bisect\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN, M, Q = MAP()\nLR = [LIST() for _ in range(M)]\n\nx = [[0]*N for _ in range(N)]\nfor L, R in LR:\n\tx[L-1][R-1] += 1\n\npq = [LIST() for _ in range(Q)]\n\nC = [[0]*N for _ in range(N)]\n\nfor i in range(N):\n\ttmp = 0\n\tfor j in range(N):\n\t\ttmp += x[i][j]\n\t\tC[i][j] = tmp\n\nfor p, q in pq:\n\tp = p-1\n\tq = q-1\n\tans = 0\n\tfor i in range(p, q+1):\n\t\tif p-1 <= -1:\n\t\t\tans += C[i][q]\n\t\telse:\n\t\t\tans += C[i][q]-C[i][p-1]\n\tprint(ans)\n\n", 'import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom fractions import gcd\nfrom bisect import bisect\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float(\'inf\')\nmod = 10 ** 9 + 7\n\n\ndef main():\n\tN, M, Q = MAP()\n\tLR = [LIST() for _ in range(M)]\n\n\tx = [[0]*N for _ in range(N)]\n\tfor L, R in LR:\n\t\tx[L-1][R-1] += 1\n\n\tpq = [LIST() for _ in range(Q)]\n\n\tC = [[0]*N for _ in range(N)]\n\n\tfor i in range(N):\n\t\ttmp = 0\n\t\tC[i] = list(accumulate(x[i]))\n\n\tfor p, q in pq:\n\t\tp = p-1\n\t\tq = q-1\n\t\tans = 0\n\t\tfor i in range(p, q+1):\n\t\t\tif p-1 <= -1:\n\t\t\t\tans += C[i][q]\n\t\t\telse:\n\t\t\t\tans += C[i][q]-C[i][p-1]\n\t\tprint(ans)\n\nif __name__ == "__main__":\n\tmain()\n', "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\nimport numpy as np\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN, M, Q = MAP()\nLR = [LIST() for _ in range(M)]\npq = [LIST() for _ in range(Q)]\n\nx = np.zeros((N+1, N+1), dtype=np.int64)\nfor L, R in LR:\n x[L, R] += 1\nx = x.cumsum(axis=0).cumsum(axis=1)\n\nfor p, q in pq:\n print(x[q][q]-x[q][p-1]-x[p-1][q]+x[p-1][p-1])\n"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s113074488', 's263116591', 's137492996'] | [76704.0, 75260.0, 77948.0] | [3161.0, 3161.0, 815.0] | [1025, 1083, 1051] |
p03283 | u284854859 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import sys\ninput = sys.stdin.readline\nn,m,q = map(int,input().split())\n\nres = [[0]*n for i in range(n)]\nfor i in range(m):\n L,r = map(int,input().split())\n L -= 1\n r -= 1\n res[r][0] += 1\n if L != n-1:\n res[r][L+1] -= 1\nprint(res)\nfor i in range(n):\n for j in range(1,n):\n res[i][j] += res[i][j-1]\nfor i in range(n):\n for j in range(1,n):\n res[j][i] += res[j-1][i]\nprint(res)\nfor i in range(q):\n p,q = map(int,input().split())\n print(res[q-1][p-1])\n', 'import sys\ninput = sys.stdin.readline\nn,m,q = map(int,input().split())\n\nres = [[0]*n for i in range(n)]\nfor i in range(m):\n L,r = map(int,input().split())\n L -= 1\n r -= 1\n res[r][0] += 1\n if L != n-1:\n res[r][L+1] -= 1\n\nfor i in range(n):\n for j in range(1,n):\n res[i][j] += res[i][j-1]\nfor i in range(n):\n for j in range(1,n):\n res[j][i] += res[j-1][i]\nfor i in range(q):\n p,q = map(int,input().split())\n print(res[q-1][p-1])\n'] | ['Wrong Answer', 'Accepted'] | ['s175574656', 's184595458'] | [13884.0, 9660.0] | [770.0, 704.0] | [496, 475] |
p03283 | u323827773 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['num_city, num_train, num_question = [int(i) for i in input().split()]\n \n\nfor i in range(0, num_train):\n start, arrive = [int(j) for j in input().split()]\n\nfor i in range(0, num_question):\n start, arrive = [int(j) for j in input().split()]', 'num_city, num_train, num_question = [int(i) for i in input().split()]\n\n\ntrains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor i in range(0, num_train):\n start, arrive = [int(j) for j in input().split()]\n trains[start][arrive] += 1\n\n\ntrains_cumulative_sum = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor start in range(0, num_city + 1):\n for arrive in range(0, num_city + 1):\n trains_cumulative_sum[start][arrive] = trains_cumulative_sum[start][arrive - 1] + trains[start][arrive]', 'num_city, num_train, num_question = [int(i) for i in input().split()]\n\n\ntrains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor i in range(0, num_train):\n start, arrive = [int(j) for j in input().split()]\n\n\n\ncumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\n\nfor i in range(0, num_question):\n start, arrive = [int(j) for j in input().split()]', 'num_city, num_train, num_question = [int(i) for i in input().split()]\n\n\ntrains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor i in range(0, num_train):\n start, arrive = [int(j) for j in input().split()]\n trains[start][arrive] += 1\n\n\ntrains_cumulative_sum = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor start in range(0, num_city + 1):\n for arrive in range(0, num_city + 1):\n trains_cumulative_sum[start][arrive] = trains_cumulative_sum[start][arrive - 1] + trains[start][arrive]\n\nfor i in range(0, num_question):\n start, arrive = [int(j) for j in input().split()]\n result = 0\n #for j in range(start, arrive + 1):\n \n print(result)\n', 'num_city, num_train, num_question = [int(i) for i in input().split()]\n\n\ntrains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor i in range(0, num_train):\n start, arrive = [int(j) for j in input().split()]\n trains[start][arrive] += 1\n\n\ncumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city + 1)]\nfor start in range(0, num_city + 1):\n for arrive in range(0, num_city + 1):\n cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]\n\nfor start in range(0, num_city + 1):\n for arrive in range(0, num_city + 1):\n cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]\n\nfor i in range(0, num_question):\n start, arrive = [int(j) for j in input().split()]\n result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]\n print(result)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s106935387', 's289511571', 's802349773', 's859348160', 's250590586'] | [3060.0, 8820.0, 7028.0, 9076.0, 15320.0] | [776.0, 702.0, 780.0, 1437.0, 1691.0] | [257, 558, 558, 810, 945] |
p03283 | u334712262 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\nclass SegmentTree():\n # to par: (n-1) // 2\n # to chr: 2n+1, 2n+2\n def __init__(self, N):\n self.__N = 2**int(math.ceil(math.log2(N)))\n self.__table = [[] for _ in range(self.__N * 2 - 1)]\n\n def update(self, idx, x):\n i = self.__N - 1 + idx \n self.__table[i].append(x)\n while i != 0:\n pi = (i - 1) // 2 # parent\n self.__table[pi].append(x)\n # if self.__table[i] < self.__table[pi]:\n # self.__table[pi] = self.__table[i]\n # else:\n # break\n i = pi\n\n def __query(self, a, b, k, l, r):\n if r <= a or b <= l:\n return []\n if a <= l and r <= b:\n return self.__table[k]\n\n vl = self.__query(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = self.__query(a, b, 2 * k + 2, (l + r) // 2, r)\n\n return vl + vr\n\n def query(self, a, b):\n return self.__query(a, b, 0, 0, self.__N)\n\n def print(self):\n print(self.__table)\n\n\n@mt\ndef slv(N, M, Q, LR, PQ):\n\n st = SegmentTree(N)\n for i, (l, r) in enumerate(LR):\n st.update(l, i)\n st.update(r, i)\n\n for p, q in PQ:\n l = st.query(p, q+1)\n n = len(l)\n m = len(set(l))\n print(n-m)\n\n\ndef main():\n N, M, Q = read_int_n()\n LR = [read_int_n() for _ in range(M)]\n PQ = [read_int_n() for _ in range(Q)]\n slv(N, M, Q, LR, PQ)\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\nclass RectangleSum():\n def __init__(self, N, M):\n self.N = N\n self.M = M\n self.s = [[0] * (M+1) for _ in range(N+1)]\n\n def add(self, i, j, v):\n self.s[i+1][j+1] += v\n\n def build(self):\n for i in range(self.N+1):\n for j in range(self.M):\n self.s[i][j+1] += self.s[i][j]\n\n for i in range(self.N):\n for j in range(self.M+1):\n self.s[i+1][j] += self.s[i][j]\n\n def sum(self, i, j, h, w):\n ret = self.s[i][j]\n ret += self.s[i+h][j+w]\n ret -= self.s[i+h][j]\n ret -= self.s[i][j+w]\n\n return ret\n\n\n@mt\ndef slv(N, M, Q, LR, PQ):\n rs = RectangleSum(N+1, N+1)\n for l, r in LR:\n rs.add(l, r, 1)\n\n rs.build()\n\n for p, q in PQ:\n print(rs.sum(p, p, q-p+1, q-p+1))\n\n\ndef main():\n N, M, Q = read_int_n()\n LR = [read_int_n() for _ in range(M)]\n PQ = [read_int_n() for _ in range(Q)]\n slv(N, M, Q, LR, PQ)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s210048340', 's699439507'] | [134668.0, 79512.0] | [3163.0, 1373.0] | [2455, 1998] |
p03283 | u335038698 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["N, M, Q = map(int, input().split())\nLR = [[0] * (N+1) for _ in range(N+1)]\nfor m in range(M):\n l, r = map(int, input().split())\n LR[l][r] += 1\n\n\nLR_sum = [[0] * (N+1) for _ in range(N+1)]\nLR_sum[1][1] = LR[1][1]\n\nfor i in range(1, N+1):\n LR_sum[1][i] = LR_sum[1][i-1] + LR[1][i]\n LR_sum[i][1] = LR_sum[i-1][1] + LR[i][1]\n\nfor i in range(2, N+1):\n for j in range(2, N+1):\n LR_sum[i][j] = LR_sum[i-1][j] + LR_sum[i][j-1] - LR_sum[i-1][j-1] + LR[i][j]\n\nfor tmp in LR:\n print(tmp)\nprint('sum')\nfor tmp in LR_sum:\n print(tmp)\n\nfor q in range(Q):\n l, r = map(int, input().split())\n print(LR_sum[r][r] - LR_sum[r][l-1] - LR_sum[l-1][r] + LR_sum[l-1][l-1])\n # print(LR_sum[r-1][l-1])\n", 'N, M, Q = map(int, input().split())\nLR = [[0] * (N+1) for _ in range(N+1)]\nfor m in range(M):\n l, r = map(int, input().split())\n LR[l][r] += 1\n\n\nLR_sum = [[0] * (N+1) for _ in range(N+1)]\nLR_sum[1][1] = LR[1][1]\n\nfor i in range(1, N+1):\n LR_sum[1][i] = LR_sum[1][i-1] + LR[1][i]\n LR_sum[i][1] = LR_sum[i-1][1] + LR[i][1]\n\nfor i in range(2, N+1):\n for j in range(2, N+1):\n LR_sum[i][j] = LR_sum[i-1][j] + LR_sum[i][j-1] - LR_sum[i-1][j-1] + LR[i][j]\n\nfor q in range(Q):\n l, r = map(int, input().split())\n print(LR_sum[r][r] - LR_sum[r][l-1] - LR_sum[l-1][r] + LR_sum[l-1][l-1])\n'] | ['Wrong Answer', 'Accepted'] | ['s724858253', 's233660688'] | [19560.0, 15336.0] | [1621.0, 1596.0] | [775, 667] |
p03283 | u342563578 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int,input().split())\nMlist = [input().split() for l in range(M)]\nQlist = [input().split() for l in range(Q)]\nMlist.sort()\nfor i in range(len(Mlist)):\n for j in range(len(Mlist[i])):\n Mlist[i][j] = int(Mlist[i][j])\nfor i in range(len(Qlist)):\n for j in range(len(Qlist[i])):\n Qlist[i][j] = int(Qlist[i][j])\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n if j - 1> 0:\n q = q - r[j-1][j-2]\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = [input().split() for l in range(M)]\nQlist = [input().split() for l in range(Q)]\nMlist.sort()\nfor i in range(len(Mlist)):\n for j in range(len(Mlist[i])):\n Mlist[i][j] = int(Mlist[i][j])\nfor i in range(len(Qlist)):\n for j in range(len(Qlist[i])):\n Qlist[i][j] = int(Qlist[i][j])\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(N):\n for j in range(N):\n r[i][j] = r[i][j-1] + p[i][j]\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n print(q)\nprint(p)\nprint(r)', 'N, M, Q = map(int,input().split())\nMlist = [input().split() for l in range(M)]\nQlist = [input().split() for l in range(Q)]\nMlist.sort()\nfor i in range(len(Mlist)):\n for j in range(len(Mlist[i])):\n Mlist[i][j] = int(Mlist[i][j])\nfor i in range(len(Qlist)):\n for j in range(len(Qlist[i])):\n Qlist[i][j] = int(Qlist[i][j])\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(N):\n for j in range(N):\n if j > 0:\n r[i][j] = r[i][j-1] + p[i][j]\n else:\n r[i][j] = p[i][j]\nfor i in range(len(Qlist)):\n q = 0\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Mlist.append(array)\nQlist = []\nfor i in range(Q):\n array = list(map(int, input().strip().split()))\n Qlist.append(array)\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(N):\n for j in range(N):\n if j > 0:\n r[i][j] = r[i][j-1] + p[i][j]\n else:\n r[i][j] = p[i][j]\nfor i in range(len(Qlist)):\n q = 0\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Mlist.append(array)\nQlist = []\nfor i in range(Q):\n array = list(map(int, input().strip().split()))\n Qlist.append(array)\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n if j - 1> 0:\n q = q - r[j-1][j-2]\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = [input().split() for l in range(M)]\nQlist = [input().split() for l in range(Q)]\nMlist.sort()\nfor i in range(len(Mlist)):\n for j in range(len(Mlist[i])):\n Mlist[i][j] = int(Mlist[i][j])\nfor i in range(len(Qlist)):\n for j in range(len(Qlist[i])):\n Qlist[i][j] = int(Qlist[i][j])\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(10):\n for j in range(10):\n r[i][j] = r[i][j-1] + p[i][j]\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n if j - 1> 0:\n q = q - r[j-1][j-2]\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Mlist.append(array)\nQlist = []\nfor i in range(Q):\n array = list(map(int, input().strip().split()))\n Qlist.append(array)\nr = [[0 for i in range(N)] for j in range(N)]\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n if j - 1> 0:\n q = q - r[j-1][j-2]\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Mlist.append(array)\nQlist = []\nfor i in range(Q):\n array = list(map(int, input().strip().split()))\n Qlist.append(array)\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(len(Qlist)):\n q = 0\n for j in range(Qlist[i][0],Qlist[i][1]+1):\n q = q + r[j-1][Qlist[i][1]-1]\n if j - 1> 0:\n q = q - r[j-1][j-2]\n print(q)', 'N, M, Q = map(int,input().split())\nMlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Mlist.append(array)\nQlist = []\nfor i in range(Q):\n array = list(map(int, input().strip().split()))\n Qlist.append(array)\np = [[0 for i in range(N)] for j in range(N)]\nq = 0\nr = [[0 for i in range(N)] for j in range(N)]\ndef count(k,l):\n s = k\n j = l\n p[s-1][j-1] = p[s-1][j-1] + 1\nfor i in range(len(Mlist)):\n count(Mlist[i][0],Mlist[i][1])\nfor i in range(N):\n for j in range(N):\n if i == 0:\n r[i][j] = p[i][j] + r[i][j-1] \n elif j == 0:\n r[i][j] = p[i][j] +r[i-1][j]\n else:\n r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + p[i][j]\nfor i in range(len(Qlist)):\n q = 0\n if Qlist[i][0] == 1:\n b = r[Qlist[i][1]-1][Qlist[i][1]-1]\n else:\n b = r[Qlist[i][1]-1][Qlist[i][1]-1] - r[Qlist[i][0]-2][Qlist[i][1]-1]\n print(b)\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s124525516', 's232482017', 's267585537', 's327228580', 's502870815', 's596478423', 's657860165', 's892226664', 's358357386'] | [100680.0, 100312.0, 100808.0, 73476.0, 66604.0, 102600.0, 70716.0, 73408.0, 79340.0] | [3164.0, 3162.0, 1848.0, 1358.0, 1090.0, 3163.0, 3160.0, 3161.0, 1563.0] | [759, 804, 767, 674, 435, 841, 481, 666, 940] |
p03283 | u346308892 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['\nimport numpy as np\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN,M,Q=acinput()\n\nA=np.zeros([N+1,N+1])\n\nfor i in range(M):\n tmp=acinput()\n A[tmp[0],tmp[1]]+=1\nAcs=np.cumsum(A,axis=1 )\nAcs=np.cumsum(Acs,axis=0)\n\nfor i in range(Q):\n tmp=acinput()\n print(Acs[tmp[1], tmp[1]]-Acs[tmp[1],tmp[0]-1]-Acs[tmp[0]-1,tmp[1]]+Acs[tmp[0]-1, tmp[0]-1])\n\n', '\nimport numpy as np\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN,M,Q=acinput()\n\nA=np.zeros([N+1,N+1])\n\nfor i in range(M):\n tmp=acinput()\n A[tmp[0],tmp[1]]+=1\nAcs=np.cumsum(A,axis=1 )\nAcs=np.cumsum(Acs,axis=0)\n\nfor i in range(Q):\n tmp=acinput()\n print(int(Acs[tmp[1], tmp[1]]-Acs[tmp[1],tmp[0]-1]-Acs[tmp[0]-1,tmp[1]]+Acs[tmp[0]-1, tmp[0]-1]))\n'] | ['Wrong Answer', 'Accepted'] | ['s201992832', 's720898448'] | [18376.0, 18968.0] | [2994.0, 2640.0] | [1160, 1164] |
p03283 | u350248178 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['l=[]\nr=[]\nfor i in range(m):\n a,b=map(int,input().split())\n l.append(a)\n r.append(b)\n\np=[]\nq=[] \nfor i in range(Q):\n c,d=map(int,input().split())\n p.append(c)\n q.append(d)\n \nfor i in range(Q):\n answer=0\n for j in range(m):\n if p[i]<=l[j] and r[j]<=q[i]:\n answer+=1\n print(answer)', 'n,m,q=map(int,input().split())\ndef ruiseki(a):\n l=[0]\n for i in range(len(a)):\n l.append(l[i]+a[i])\n del l[0]\n return l\nl=[]\ndef niruiseki(a):\n l.append(ruiseki(a[0]))\n for i in range(1,len(a)):\n p=[l[i-1][0]+a[i][0]]\n q=[a[i][0]]\n for j in range(1,len(a[i])):\n q.append(q[j-1]+a[i][j])\n p.append(q[j]+l[i-1][j])\n l.append(p)\nll=[[0]*(n+1) for i in range(n+1)]\nfor i in range(m):\n a,b=map(int,input().split())\n ll[a][b]+=1\nniruiseki(ll)\nfor i in range(q):\n a,b=map(int,input().split())\n print(l[b][b]+l[a-1][a-1]-l[a-1][b]-l[b][a-1])'] | ['Runtime Error', 'Accepted'] | ['s151851482', 's172074111'] | [3064.0, 15444.0] | [17.0, 1555.0] | [330, 620] |
p03283 | u353797797 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\n\ndef f():\n nc, nt, nq = map(int, input().split())\n t = [list(map(int, input().split())) for _ in range(nt)]\n q = [list(map(int, input().split())) for _ in range(nq)]\n dp = np.zeros((nc + 1, nc + 1), dtype="i8")\n for l, r in t:\n dp[:l + 1, r:] += 1\n for l, r in q:\n print(dp[l][r])\n print(dp)\n\n\nf()\n', 'def f(nc, nt, nq):\n dp = [[0] * (nc + 1) for _ in range(nc + 1)]\n for _ in range(nt):\n l, r = map(int, input().split())\n dp[l][r] += 1\n for i in range(1, nc + 1):\n dpi = dp[i]\n s = dpi[0]\n for j in range(1, nc + 1):\n dpi[j] = s = dpi[j] + s\n for j in range(1, nc + 1):\n s = dp[0][j]\n for i in range(1, nc + 1):\n dp[i][j] = s = dp[i][j] + s\n for _ in range(nq):\n l, r = map(int, input().split())\n print(dp[r][r] - dp[l - 1][r] - dp[r][l - 1] + dp[l - 1][l - 1])\n\n\nnc, nt, nq = map(int, input().split())\nf(nc, nt, nq)\n'] | ['Wrong Answer', 'Accepted'] | ['s553840321', 's467363180'] | [77556.0, 13300.0] | [3165.0, 1430.0] | [353, 616] |
p03283 | u357810840 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\nn, m, q = map(int, input().split())\n\nmat = np.zeros((n, n), dtype=np.uint32)\n\nfor i in range(m):\n l, r = map(int, input().split())\n mat[l-1, r-1] += 1\nmat = np.flipud(mat)\nmatmul = np.cumsum(mat, axis=0)\nmatmul = np.flipd[matmul]\nmatmul2 = np.cumsum(matmul, axis=1)\n\nfor i in range(q):\n p, q = map(int, input().split())\n ans = matmul2[p-1, q-1]\n print(ans)', 'import numpy as np\n\nn, m, q = map(int, input().split())\n\nmat = np.zeros((n, n), dtype=int)\n\nfor i in range(m):\n l, r = map(int, input().split())\n mat[l-1, r-1] += 1\nmat = np.flipud(mat)\nmatmul = np.cumsum(mat, axis=0)\nmatmul = np.flipud(matmul)\nmatmul2 = np.cumsum(matmul, axis=1)\n\nfor i in range(q):\n p, q = map(int, input().split())\n ans = matmul2[p-1, q-1]\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s090841469', 's600364265'] | [18480.0, 18896.0] | [2587.0, 2777.0] | [391, 386] |
p03283 | u375616706 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M, Q = map(int, input().split())\n\nmat = [[0]*(N+1) for _ in range(N+1)]\n\nfor _ in range(M):\n a, b = map(int, input().split())\n mat[a][b] = 1\n\n\ndef solve():\n\n for i in range(N+1):\n for j in range(1, N+1):\n mat[i][j] += mat[i][j-1]\n\n ans = []\n\n for _ in range(Q):\n ql, qr = map(int, input().split())\n tmp = 0\n for i in range(ql, qr+1):\n tmp += mat[i][qr] - mat[i][ql-1]\n ans.append(tmp)\n\n for a in ans:\n print(a)\n\n\ndef solve2():\n\n for i in range(1, N+1):\n for j in range(1, N+1):\n mat[i][j] = mat[i][j] + mat[i-1][j] + \\\n mat[i][j-1] - mat[i-1][j-1]\n\n ans = [0]*Q\n for i in range(Q):\n ql, qr = map(int, input().split())\n t = mat[qr][qr] - mat[ql-1][qr] - mat[qr][ql-1] + mat[ql-1][ql-1]\n ans[i] = t\n\n for a in ans:\n print(a+1)\n\n\nsolve2()\n', '# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M, Q = map(int, input().split())\nkukan = []\n\nfor i in range(M):\n l, r = map(int, input().split())\n kukan.append([r, -1, l])\n\nfor i in range(Q):\n p, q = map(int, input().split())\n kukan.append([q, i, p])\n\nkukan.sort()\n\nli = [0]*(N+1)\nans = [0]*Q\n\nfor t, flag, s in kukan:\n if flag == -1:\n li[s] += 1\n else:\n ans[flag] = sum(li[s:t+1])\n\nfor a in ans:\n print(a)\n'] | ['Wrong Answer', 'Accepted'] | ['s845027793', 's114026129'] | [17336.0, 51336.0] | [633.0, 1459.0] | [962, 496] |
p03283 | u404676457 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['(n, m, q) = map(int, input().split(" "))\n\nns = [[0 for _ in range(n + 1)]for _ in range(n + 1)]\n\nfor i in range(m):\n (l, r) = map(int, input().split(" "))\n ns[l][r] += 1\n\nprint(ns)\n\nfor i in range(q):\n count = 0\n (ql, qr) = map(int, input().split(" "))\n for j in range(ql, qr + 1):\n for k in range(j, qr + 1):\n count += ns[j][k]\n print(count)\n', '(n, m, q) = map(int, input().split(" "))\n\nns = [[0 for _ in range(n + 1)]for _ in range(n + 1)]\n\nfor i in range(m):\n (l, r) = map(int, input().split(" "))\n ns[l][r] += 1\n\nfor i in range(1, n + 1):\n for j in range(i, n + 1):\n ns[i][j] += ns[i][j - 1]\nfor j in range(1, n + 1):\n for i in range(1, j + 1):\n ns[i][j] += ns[i - 1][j]\n\nfor i in range(q):\n count = 0\n (l, r) = map(int, input().split(" "))\n print(ns[r][r] - ns[l - 1][r])'] | ['Wrong Answer', 'Accepted'] | ['s972289908', 's617645483'] | [7448.0, 9716.0] | [3156.0, 1483.0] | [379, 465] |
p03283 | u427344224 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\n\nx = [[0 for i in range(N + 1)] for j in range(N + 1)]\n\nfor i in range(M):\n l, r = map(int, input().split())\n x[l][r] += 1\n\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n x[i][j] += x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1]\n\nfor i in range(Q):\n p, q = map(int, input().split())\n\n ans = x[p][q]\n print(ans)', 'N, M, Q = map(int, input().split())\n\nx = [[0 for i in range(N + 1)] for j in range(N + 1)]\n\nfor i in range(M):\n l, r = map(int, input().split())\n x[l][r] += 1\n\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n x[i][j] += x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1]\n\nfor i in range(Q):\n p, q = map(int, input().split())\n\n ans = x[N][q] - x[p - 1][q]\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s513102465', 's551426030'] | [13420.0, 13424.0] | [1501.0, 1545.0] | [375, 389] |
p03283 | u463655976 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\n\nimport numpy as np\nmatrix = np.array([[0 for _ in range(N+1)] for _ in range(N+1)], dtype=np.int16)\n\npairs = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor L, R in (map(int, input().split()) for _ in range(M)):\n pairs[L][R] += 1\n\nfor i in range(1, N+1):\n for j in range(i, N+1):\n w = pairs[i][j]\n if w > 0:\n matrix[:i+1,j:] += w\n\npairs = [[matrix[i,j] for j in range(N+1)] for i in range(N+1)]\n', 'N, M, Q = map(int, input().split())\n\nimport numpy as np\nmatrix = np.array([[0 for _ in range(N+1)] for _ in range(N+1)], dtype=np.int16)\n\nfor L, R in (map(int, input().split()) for _ in range(M)):\n matrix[:L+1,R:] += 1\n', 'N, M, Q = map(int, input().split())\n\nclass Cell:\n def __init__(self):\n self.value = 0\n self.L = 0\n def __repr__(self):\n return str((self.value, self.L))\n\npairs = [[Cell() for _ in range(N+1)] for _ in range(N+1)]\nfor L, R in (map(int, input().split()) for _ in range(M)):\n cell = pairs[L][R]\n cell.value += 1\n cell.L = cell.value\n\nfor i in range(N-1, 0, -1):\n for j in range(i+1, N+1):\n cell = pairs[i][j]\n cell.L += pairs[i][j-1].L\n cell.value = cell.L + pairs[i+1][j].value\nfor p, q in (map(int, input().split()) for _ in range(Q)):\n print(pairs[p][q].value)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s506258709', 's845484208', 's634193095'] | [24852.0, 14956.0, 53108.0] | [3160.0, 3160.0, 1794.0] | [465, 222, 624] |
p03283 | u475065881 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10', 'N, M , Q = map(int, input().split())\n\nLR = [[0 for _ in range(N+2-i) for _ in range(N+2)]\nfor i in range(M):\n L, R = map(int, input().split())\n LR[L][R-L+1] += 1\n\n \nfor i in range(2,N+2):\n for j in range(1,N-i+2):\n LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]\n \nfor i in range(Q):\n p, q = map(int, input().split())\n print(LR[p][q-p+1]-LR[q+1][0])\n', 'import numpy as np\nN, M , Q = map(int, input().split())\n\nLR = np.array([np.zeros(N+2-i, dtype=np.int) for i in range(N+2)])\nfor i in range(M):\n L, R = map(int, input().split())\n LR[L][R-L+1] += 1\n\n \nfor i in range(2,N+2):\n for j in range(1,N-i+2):\n LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]\n \nfor i in range(Q):\n p, q = map(int, input().split())\n print(LR[p][q-p+1]-LR[q+1][0])\n', 'N, M , Q = map(int, input().split())\n\nLR = [[0 for _ in range(N+2-i)] for _ in range(N+2)]\nfor i in range(M):\n L, R = map(int, input().split())\n LR[L][R-L+1] += 1\n\n \nfor i in range(2,N+2):\n for j in range(1,N-i+2):\n LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]\n \nfor i in range(Q):\n p, q = map(int, input().split())\n print(LR[p][q-p+1]-LR[q+1][0])\n', 'import sys\nfrom itertools import accumulate\nN, M, Q = map(int, sys.stdin.readline().split())\n \nLR = [[0 for _ in range(N-i)] for i in range(N)]\nfor i in range(M):\n L, R = map(int, sys.stdin.readline().split())\n LR[L-1][R-L] += 1\n \nfor i in range(N-2,-1,-1):\n acc = accumulate(LR[i])\n next(acc)\n for j in range(1, N-i):\n LR[i][j] = next(acc) + LR[i+1][j-1]\n \nfor i in range(Q):\n p, q = map(int, sys.stdin.readline().split())\n sys.stdout.write(str(LR[p-1][q-p])+"\\n")\n'] | ['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Accepted'] | ['s012798510', 's402435434', 's530350609', 's738028189', 's596454357'] | [2940.0, 2940.0, 14444.0, 3064.0, 8668.0] | [17.0, 17.0, 3066.0, 17.0, 554.0] | [94, 367, 401, 368, 476] |
p03283 | u480138356 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\ndef main():\n N, M, Q = map(int, input().split())\n\n check = np.zeros((N+1, N+1))\n\n for i in range(M):\n l, r = map(int, input().split())\n check[r][l] += 1\n\n # print(check)\n for i in range(1, N+1):\n check[i] += check[i-1]\n for i in range(1, N+1):\n check[:,i] += check[:,i-1]\n # print(check)\n\n for i in range(Q):\n p, q = map(int, input().split())\n print(check[q][q] - check[q][p-1] - check[p-1][q] + check[p-1][p-1])\n\nif __name__ == "__main__":\n main()\n', 'import sys\nimport numpy as np\ninput = sys.stdin.readline\n\ndef main():\n N, M, Q = map(int, input().split())\n\n check = np.zeros((N+1, N+1))\n\n for i in range(M):\n l, r = map(int, input().split())\n check[r][l] += 1\n\n # print(check)\n for i in range(1, N+1):\n check[i] += check[i-1]\n for i in range(1, N+1):\n check[:,i] += check[:,i-1]\n # print(check)\n\n for i in range(Q):\n p, q = map(int, input().split())\n print(int(check[q][q] - check[q][p-1] - check[p-1][q] + check[p-1][p-1]))\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s646184004', 's744859742'] | [15188.0, 15256.0] | [2860.0, 1333.0] | [538, 581] |
p03283 | u480200603 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['# import sys\n# input = sys.stdin.readlines()\nn, m, q = map(int, input().split())\n\nd = [[0 for j in range(n + 1)] for i in range(n + 1)]\na = [[0 for j in range(n + 1)] for i in range(n + 1)]\n\nfor _ in range(m):\n l, r = map(int, input().split())\n a[l][r] += 1\n\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n d[i][j] = d[i - 1][j] + d[i][j - 1] + a[i][j] - d[i - 1][j - 1]\n\n\nfor i in range(n + 1):\n print(d[i])\nfor _ in range(q):\n l, r = map(int, input().split())\n print(d[r][r] - d[r][l - 1] - d[l - 1][r] + d[l - 1][l - 1])\n', '# import sys\n# input = sys.stdin.readlines()\nn, m, q = map(int, input().split())\n\nd = [[0 for j in range(n + 1)] for i in range(n + 1)]\na = [[0 for j in range(n + 1)] for i in range(n + 1)]\n\nfor _ in range(m):\n l, r = map(int, input().split())\n a[l][r] += 1\n\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n d[i][j] = d[i - 1][j] + d[i][j - 1] + a[i][j] - d[i - 1][j - 1]\n\nfor _ in range(q):\n l, r = map(int, input().split())\n print(d[r][r] - d[r][l - 1] - d[l - 1][r] + d[l - 1][l - 1])\n'] | ['Wrong Answer', 'Accepted'] | ['s444394689', 's010753371'] | [17244.0, 17116.0] | [1666.0, 1602.0] | [555, 515] |
p03283 | u497046426 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\ntable = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor _ in range(M):\n l, r = map(int, input().split())\n table[l][r] += 1\ncum_sum2 = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor i, j in product(range(1, N+1), repeat=2):\n cum_sum2[i][j] += table[i][j] + cum_sum2[i-1][j] + cum_sum2[i][j-1] - cum_sum2[i-1][j-1]\nfor _ in range(Q):\n p, q = map(int, input().split())\n ans = cum_sum2[q][q] - cum_sum2[p-1][q] - cum_sum2[q][p-1] + cum_sum2[p-1][p-1]\n print(ans)', 'from itertools import product\n\nN, M, Q = map(int, input().split())\ntable = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor _ in range(M):\n l, r = map(int, input().split())\n table[l][r] += 1\ncum_sum2 = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor i, j in product(range(1, N+1), repeat=2):\n cum_sum2[i][j] += table[i][j] + cum_sum2[i-1][j] + cum_sum2[i][j-1] - cum_sum2[i-1][j-1]\nfor _ in range(Q):\n p, q = map(int, input().split())\n ans = cum_sum2[q][q] - cum_sum2[p-1][q] - cum_sum2[q][p-1] + cum_sum2[p-1][p-1]\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s804598383', 's379888172'] | [7156.0, 15552.0] | [628.0, 1633.0] | [517, 548] |
p03283 | u497625442 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int,input().split())\n\nC = [[0 for in range(N)] in range(N)]\nfor i in range(M):\n\tL,R = map(int,input().split())\n\tC[L][R] += 1\n\nfor j in range(Q):\n\tp,q = map(int,input().split())\n\ts = 0\n\tfor i in range(p,q+1):\n\t\tfor j in range(p,q+1):\n\t\t\ts += C[i][j]\n\tprint(s)\n', 'N, M, Q = map(int,input().split())\n\nC = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(M):\n\tL,R = map(int,input().split())\n\tC[L][R] += 1\n\n\nD = [[0 for i in range(N+4)] for j in range(N+4)]\nE = [0 for i in range(N+4)]\nF = [[0 for i in range(N+4)] for j in range(N+4)]\nfor i in range(N+1):\n\tfor j in range(N+1):\n\t\tD[i][j+1] = D[i][j] + C[i][j]\nfor i in range(N+1):\n\tE[i+1] = E[i] + D[i][i]\nfor i in range(N+2):\n\tfor j in range(N+2):\n\t\tF[i+1][j] = F[i][j] + D[i][j]\n\n# C[l][l] + ... + C[l][r] = D[l][r+1] - D[l][l]\n# C[i][i] + ... + C[i][r] = D[i][r+1] - D[i][i]\n# C[r][r] + ... + C[r][r] = D[r][r+1] - D[r][r]\n\nfor j in range(Q):\n\tp,q = map(int,input().split())\n\ts = F[q+1][q+1] - F[p][q+1] - (E[q+1] - E[p])\n\tprint(s)\n\n'] | ['Runtime Error', 'Accepted'] | ['s455775331', 's772868645'] | [2940.0, 19484.0] | [17.0, 1638.0] | [273, 732] |
p03283 | u518378780 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = [int(_) for _ in input().split()]\ntrain = [[int(_) for _ in input().split()] for i in range(M)]\nquestion = [[int(_) for _ in input().split()] for i in range(Q)]\n\nnl = [[0 for i in range(N)] for j in range(N)]\nfor t in train:\n i = t[0] - 1\n j = t[1] - 1\n nl[i][j] += 1\n\nl = [[0 for i in range(N)] for j in range(N)]\nfor i in range(N):\n s = 0\n for j in range(N):\n l[i][j] = s + nl[i][j]\n s = l[i][j]\n\nprint(nl, l)\n\nfor k in range(Q):\n p = question[k][0]\n q = question[k][1]\n ans = 0\n for i in range(p-1, q):\n if p == 1:\n d = l[i][q-1]\n else:\n d = l[i][q-1] - l[i][p-2]\n ans += d\n print(ans)\n\n', 'N, M, Q = [int(_) for _ in input().split()]\n\nl = [[0 for i in range(N+1)] for j in range(N+2)]\nfor t in [input().split() for _ in range(M)]:\n i = int(t[0])\n j = int(t[1])\n l[i][j] += 1\n\nfor k in range(N):\n for i in range(1, N-k+1):\n j = i + k\n l[i][j] += l[i][j-1] + l[i+1][j] - l[i+1][j-1]\n\nfor k in [input().split() for _ in range(Q)]:\n p = int(k[0])\n q = int(k[1])\n print(l[p][q])\n'] | ['Wrong Answer', 'Accepted'] | ['s325771365', 's385603402'] | [58284.0, 63100.0] | [3160.0, 925.0] | [687, 419] |
p03283 | u523764640 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\nn, m, q = map(int, input().split())\n\nmat = np.zeros((n, n), dtype=int)\n\nfor _ in range(m):\n l, r = map(int, input().split())\n mat[l-1][r-1] += 1\n\nans = np.cumsum(mat, axis=1)[::-1], axis=0)[::-1]\n\nfor _ in range(q):\n l, r = map(int, input().split())\n print(ans[l-1][r-1])\n', 'import numpy as np\n\nn, m, q = map(int, input().split())\n\nmat = np.zeros((n, n), dtype=int)\n\nfor _ in range(m):\n l, r = map(int, input().split())\n mat[l-1][r-1] += 1\n\nans = np.cumsum(np.cumsum(mat, axis=1)[::-1], axis=0)[::-1]\n\nfor _ in range(q):\n l, r = map(int, input().split())\n print(ans[l-1][r-1])\n'] | ['Runtime Error', 'Accepted'] | ['s682713387', 's610286475'] | [2940.0, 18380.0] | [17.0, 2869.0] | [304, 314] |
p03283 | u540761833 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N,M,Q = map(int,input().split())\nnum = [[0 for i in range(N)] for j in range(N)]\nlr = [list(map(int,input().split())) for i in range(M)]\nfor l,r in lr:\n num[l-1][r-1] += 1\n\nfor j in range(N):\n for i in range(N-1,0,-1):\n num[i-1][j] += num[i][j]\nfor i in range(N):\n for j in range(N-1):\n num[i][j+1] += num[i][j]\npq = [list(map(int,input().split())) for i in range(M)]\nfor p,q in pq:\n print(num[p-1][q-1])\n', "import sys\ndef input(): return sys.stdin.readline().strip()\nN,M,Q = map(int,input().split())\nnum = [[0 for i in range(N)] for j in range(N)]\nlr = [list(map(int,input().split())) for i in range(M)]\nfor l,r in lr:\n num[l-1][r-1] += 1\n\nfor j in range(N):\n for i in range(N-1,0,-1):\n num[i-1][j] += num[i][j]\nfor i in range(N):\n for j in range(N-1):\n num[i][j+1] += num[i][j]\npq = [list(map(int,input().split())) for i in range(Q)]\nans = []\nfor p,q in pq:\n ans.append(num[p-1][q-1])\nprint(*ans,sep='\\n')"] | ['Runtime Error', 'Accepted'] | ['s621950516', 's012153985'] | [72296.0, 75604.0] | [1159.0, 904.0] | [431, 525] |
p03283 | u608569568 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,q = map(int,input().split(" "))\nLR_2d = [[0 for i in range(n)] for i in range(n)]\nfor i in range(m):\n L,R = map(int,input().split(" "))\n LR_2d[L-1][R-1] += 1\nLR_2dsum = [[0 for i in range(n)] for i in range(n)]\nfor i in range(n):\n LR_2dsum[i][0] = LR_2d[i][0]\n for j in range(1,n):\n LR_2dsum[i][j] = LR_2dsum[i][j-1] + LR_2d[i][j]\nfor i in range(q):\n ans = 0\n p_i,q_i = map(int,input().split(" "))\n for j in range(p_i-1,q_i):\n ans_j = LR_2dsum[j][q_i-1] - LR_2dsum[j][max(0,p_i-2)]\n ans += ans_j\n print(ans)', 'n,m,q = map(int,input().split(" "))\nLR_2d = [[0 for i in range(n)] for i in range(n)]\nfor i in range(m):\n L,R = map(int,input().split(" "))\n LR_2d[L-1][R-1] += 1\nLR_2dsum = [[0 for i in range(n)] for i in range(n)]\nfor i in range(n):\n LR_2dsum[i][0] = LR_2d[i][0]\n for j in range(1,n):\n LR_2dsum[i][j] = LR_2dsum[i][j-1] + LR_2d[i][j]\nfor i in LR_2dsum:\n print(i)\nfor i in range(q):\n ans = 0\n p_i,q_i = map(int,input().split(" "))\n for j in range(p_i-1,q_i):\n ans_j = LR_2dsum[j][q_i-1] - LR_2dsum[j][max(0,p_i-2)]\n ans += ans_j\n print(ans)', 'n,m,q = map(int,input().split(" "))\nLR_2d = [[0 for i in range(n+1)] for i in range(n+1)]\nfor i in range(m):\n L,R = map(int,input().split(" "))\n LR_2d[L][R] += 1\n\nLR_2dsum = [[0 for i in range(n+1)] for i in range(n+1)]\nfor j in range(1,n):\n LR_2dsum[0][j] = LR_2dsum[0][j-1] + LR_2d[0][j]\nfor i in range(1,n+1):\n for j in range(1,n+1):\n LR_2dsum[i][j] = LR_2dsum[i-1][j] + LR_2dsum[i][j-1] - LR_2dsum[i-1][j-1] + LR_2d[i][j]\n\nfor i in range(q):\n p_i,q_i = map(int,input().split(" "))\n ans = LR_2dsum[p_i-1][p_i-1] - LR_2dsum[p_i-1][q_i] - LR_2dsum[q_i][p_i-1] + LR_2dsum[q_i][q_i]\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s284619241', 's892385949', 's582109941'] | [9204.0, 10228.0, 15472.0] | [3156.0, 3156.0, 1664.0] | [556, 588, 621] |
p03283 | u619819312 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\nn,m,q=map(int,input().split())\ns=np.zeros((n,n))\nfor i in range(m):\n l,r=map(int,input().split())\n s[n-l][r-1]+=1\ns=np.cumsum(np.cumsum(s,axis=0),axis=1)\nprint(s)\nfor i in range(q):\n d,t=map(int,input().split())\n print(int(s[n-d][t-1]))', 'import numpy as np\nn,m,q=map(int,input().split())\ns=np.zeros((n,n))\nfor i in range(m):\n l,r=map(int,input().split())\n s[n-l][r-1]+=1\ns=np.cumsum(np.cumsum(s,axis=0),axis=1)\nfor i in range(q):\n d,t=map(int,input().split())\n print(int(s[n-d][t-1]))'] | ['Wrong Answer', 'Accepted'] | ['s314830749', 's417808055'] | [18140.0, 18268.0] | [2317.0, 2334.0] | [267, 258] |
p03283 | u623601489 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,q= map(int,input().split())\ndataList = [[0 for xIndex in range(n+1)]for yIndex in range(n+1)]\n\nfor i in range(m):\n xTemp,yTemp = map(int,input().split())\n dataList[yTemp][xTemp]+=1\npqList=[list(map(lambda x:int(x),input().split()))for i in range(q)]\nprint(dataList)\nfor yIndex in range(1,n+1):\n for xIndex in range(1,n+1):\n dataList[yIndex][xIndex]+=dataList[yIndex][xIndex-1]\nfor yIndex in range(1,n+1):\n for xIndex in range(1,n+1):\n dataList[yIndex][xIndex]+=dataList[yIndex-1][xIndex]\nprint(dataList)\n\nfor pq in pqList:\n p = pq[0]-1\n q = pq[1]\n print(dataList[q][q]+dataList[p][p]-dataList[p][q]-dataList[q][p])', 'n,m,q= map(int,input().split())\nlrList=[list(map(int,input().split()))for i in range(m)]\npqList=[list(map(int,input().split()))for i in range(q)]\nfor pq in pqList:\n ans = 0\n for lr in lrList:\n ans +=(pq[0] <= lr[0] and pq[1] >= lr[1])\n print(1)', 'n,m,q= map(int,input().split())\ndataList = [[0 for xIndex in range(n+1)]for yIndex in range(n+1)]\n\nfor i in range(m):\n xTemp,yTemp = map(int,input().split())\n dataList[yTemp][xTemp]+=1\npqList=[list(map(lambda x:int(x),input().split()))for i in range(q)]\nfor yIndex in range(1,n+1):\n for xIndex in range(1,n+1):\n dataList[yIndex][xIndex]+=dataList[yIndex][xIndex-1]\nfor yIndex in range(1,n+1):\n for xIndex in range(1,n+1):\n dataList[yIndex][xIndex]+=dataList[yIndex-1][xIndex]\n\nfor pq in pqList:\n p = pq[0]-1\n q = pq[1]\n print(dataList[q][q]+dataList[p][p]-dataList[p][q]-dataList[q][p])'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s050500826', 's371099005', 's505135710'] | [41076.0, 68468.0, 34856.0] | [1295.0, 3160.0, 1250.0] | [653, 260, 621] |
p03283 | u624475441 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N,M,Q=map(int,input().split())\ndp=[[0]*-~N for _ in[0]*-~N]\nfor _ in[0]*M:\n L,R=map(int,input().split())\n for i in range(1,L+1):\n for j in range(R,N+1):\n dp[i][j] += 1\n print(i,j)\nfor _ in[0]*Q:\n p,q=map(int,input().split())\n print(dp[p][q])', "import sys\nimport numpy as np\ndef main():\n s = sys.stdin.readlines()\n N, M, _ = map(int, s[0].split())\n X = np.zeros((N, N), dtype=int)\n for L, R in (map(int, e.split()) for e in s[1:M + 1]): X[L - 1][R - 1] += 1\n S = np.cumsum(np.cumsum(X, axis=1)[::-1], axis=0)[::-1]\n print('\\n'.join(map(str, (S[p - 1][q - 1] for p, q in (map(int, e.split()) for e in s[M + 1:])))))\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s160450648', 's815333820'] | [26720.0, 43600.0] | [3156.0, 1390.0] | [282, 425] |
p03283 | u631914718 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\n\ndef LI(): return list(map(int, input().split()))\ndef LI_(): return list(map(lambda x: int(x) - 1, input().split()))\n\n\ndef cumulative_sum_ref(d1_array):\n for i in range(1, len(d1_array)):\n d1_array[i] += d1_array[i-1]\n\n\ndef cumulative_sum_val(d1_array):\n tmp = d1_array.copy()\n for i in range(1, len(tmp)):\n tmp[i] += tmp[i-1]\n return tmp\n\n\n\nif __name__ != "__main__":\n N, M, Q = LI()\n LR = np.zeros((N+1, N+1), dtype=\'uint32\')\n for i in range(M):\n l, r = LI()\n LR[l][r] += 1\n\n \n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[i][j] += LR[i][j-1]\n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[j][i] += LR[j-1][i]\n\n for _ in range(Q):\n p, q = LI()\n p -= 1\n result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]\n print(result)\n\n\nif __name__ == "__main__":\n N, M, Q = LI()\n LR = np.zeros((N+1, N+1), dtype=\'uint32\')\n for i in range(M):\n l, r = LI()\n LR[l][r] += 1\n\n \n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[i][j] += LR[i][j-1]\n LR[i][j] += LR[i-1][j]\n LR[i][j] += LR[i-1][j-1]\n\n for _ in range(Q):\n p, q = LI()\n p -= 1\n result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]\n print(result)\n', 'import numpy as np\n\n\ndef LI(): return list(map(int, input().split()))\ndef LI_(): return list(map(lambda x: int(x) - 1, input().split()))\n\n\ndef cumulative_sum_ref(d1_array):\n for i in range(1, len(d1_array)):\n d1_array[i] += d1_array[i-1]\n\n\ndef cumulative_sum_val(d1_array):\n tmp = d1_array.copy()\n for i in range(1, len(tmp)):\n tmp[i] += tmp[i-1]\n return tmp\n\n\n\nif __name__ != "__main__":\n N, M, Q = LI()\n LR = np.zeros((N+1, N+1), dtype=\'uint32\')\n for i in range(M):\n l, r = LI()\n LR[l][r] += 1\n\n \n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[i][j] += LR[i][j-1]\n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[j][i] += LR[j-1][i]\n\n for _ in range(Q):\n p, q = LI()\n p -= 1\n result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]\n print(result)\n\n\nif __name__ == "__main__":\n N, M, Q = LI()\n LR = np.zeros((N+1, N+1), dtype=\'uint32\')\n for i in range(M):\n l, r = LI()\n LR[l][r] += 1\n\n \n for i in range(1, N+1):\n for j in range(2, N+1):\n LR[i][j] += LR[i][j-1]\n LR[i][j] += LR[i-1][j]\n LR[i][j] -= LR[i-1][j-1]\n\n for _ in range(Q):\n p, q = LI()\n p -= 1\n result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]\n print(result)\n', 'from itertools import accumulate as acc\nimport sys\n\n\ndef main():\n s = sys.stdin.readlines()\n N, M, Q = map(int, s[0].split())\n LR = [[0]*N for _ in [0]*N]\n for l, r in (map(int, e.split()) for e in s[1:M + 1]):\n LR[l - 1][r - 1] += 1\n\n S = [tuple(acc(reversed(s))) for s in zip(*(acc(x) for x in LR))]\n print(\'\\n\'.join(map(str, (S[q - 1][N - p] for p, q in (map(int, e.split()) for e in s[M + 1:])))))\n\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s560397958', 's866972811', 's316175455'] | [13448.0, 13448.0, 38468.0] | [3160.0, 3160.0, 413.0] | [1446, 1446, 467] |
p03283 | u638456847 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef lunlun_num(N):\n N = str(N)\n L = len(N)\n\n dp = [[0]*10 for j in range(L)]\n for j in range(1,int(N[0])):\n dp[0][j] = 1\n\n flag = True\n for i in range(L-1):\n d = int(N[i+1])\n b = int(N[i])\n \n dp[i+1][0] += dp[i][0] + dp[i][1]\n dp[i+1][9] += dp[i][8] + dp[i][9]\n for j in range(1,9):\n dp[i+1][j] += dp[i][j-1] + dp[i][j] + dp[i][j+1]\n for j in range(1,10):\n dp[i+1][j] += 1\n\n if flag:\n if d < b - 1:\n flag = False\n elif d <= b + 1:\n for j in range(max(0, b-1),d):\n dp[i+1][j] += 1\n else:\n for j in range(max(0, b-1),b+2):\n dp[i+1][j] += 1\n flag = False\n\n return sum(dp[L-1]) + 1 if flag else sum(dp[L-1])\n\n\ndef main():\n K = int(readline())\n\n \n left = 0\n right = 10**10\n while left + 1 < right:\n x = (left + right) // 2\n\n if lunlun_num(x) >= K:\n right = x\n else:\n left = x\n \n print(right)\n\n\nif __name__ == "__main__":\n main()\n', '\nfrom itertools import accumulate\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N,M,Q,*lr = map(int, read().split())\n\n LR = [[0]*(N+1) for _ in range(N+1)]\n query = []\n for i, (l, r) in enumerate(zip(*[iter(lr)]*2)):\n if i < M:\n LR[l][r] += 1\n else:\n query.append((l, r))\n \n for i in range(1,N+1):\n LR[1][i] += LR[1][i-1]\n LR[i][1] += LR[i-1][1]\n \n for i in range(2, N+1):\n for j in range(2,N+1):\n LR[i][j] += LR[i-1][j] + LR[i][j-1] - LR[i-1][j-1]\n \n for p, q in query:\n ans = LR[q][q] - LR[p-1][q] - LR[q][p-1] + LR[p-1][p-1]\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n'] | ['Runtime Error', 'Accepted'] | ['s650312424', 's029077094'] | [3188.0, 56648.0] | [18.0, 443.0] | [1284, 793] |
p03283 | u655663334 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\n\nn,m,q = list(map(int, input().split()))\n\nlrs = [list(map(int, input().split())) for _ in range(m)]\npqs = [list(map(int, input().split())) for _ in range(q)]\n\ntrain_array = np.zeros((n,n),dtype=int)\n\nfor lr in lrs:\n train_array[lr[0]-1][lr[1]-1] +=1\n\n\n#print(train_array)\n\ntrain_array_ruisekiwa = np.zeros((n,n), dtype = int)\n\nfor index, train_vector in enumerate(train_array):\n train_array_ruisekiwa[index][0] = train_vector[0]\n\n for i in range(1, n):\n train_array_ruisekiwa[index][i] = train_array_ruisekiwa[index][i-1] + train_vector[i]\n\n#print(train_array_ruisekiwa)\n\nfor pq in pqs:\n ans = 0\n for i in range(pq[0]-1,pq[1]):\n ans += train_array_ruisekiwa[i][pq[1] - 1] - train_array_ruisekiwa[i][pq[0] - 1]\n\n print(ans)', 'import numpy as np\nimport sys\n\ninput=sys.stdin.readline\n\nn,m,q = list(map(int, input().split()))\n\nlrs = [list(map(int, input().split())) for _ in range(m)]\npqs = [list(map(int, input().split())) for _ in range(q)]\n\ntrain_array = np.zeros((n+1,n+1),dtype=int)\n\nfor lr in lrs:\n train_array[lr[0]][lr[1]] +=1\n\n\nprint(train_array)\n\ntrain_array_ruisekiwa = np.zeros((n+1,n+1), dtype = int)\n\nfor index, train_vector in enumerate(train_array):\n train_array_ruisekiwa[index][0] = train_vector[0]\n\n for i in range(1, n+1):\n train_array_ruisekiwa[index][i] = train_array_ruisekiwa[index][i-1] + train_vector[i]\n\nprint(train_array_ruisekiwa)\n\nfor pq in pqs:\n ans = 0\n for i in range(pq[0],pq[1]+1):\n ans += train_array_ruisekiwa[i][pq[1]] - train_array_ruisekiwa[i][pq[0] - 1]\n\n print(ans)', 'import numpy as np\nimport sys\n\ninput=sys.stdin.readline\n\nn,m,q = list(map(int, input().split()))\n\nlrs = [list(map(int, input().split())) for _ in range(m)]\npqs = [list(map(int, input().split())) for _ in range(q)]\n\ntrain_array = np.zeros((n+1,n+1),dtype=int)\n\nfor lr in lrs:\n train_array[lr[0]][lr[1]] +=1\n\n\n#print(train_array)\n\ntrain_array_ruisekiwa = np.zeros((n+1,n+1), dtype = int)\n\nfor i in range(1, n+1):\n for j in range(1, n+1):\n train_array_ruisekiwa[i][j] = train_array[i][j] + train_array_ruisekiwa[i][j-1] + train_array_ruisekiwa[i-1][j] - train_array_ruisekiwa[i-1][j-1]\n\n#print(train_array_ruisekiwa)\n\nfor pq in pqs:\n print(train_array_ruisekiwa[pq[1]][pq[1]] - train_array_ruisekiwa[pq[1]][pq[0]-1] - train_array_ruisekiwa[pq[0]-1][pq[1]] + train_array_ruisekiwa[pq[0]-1][pq[0]-1])\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s138218319', 's388407811', 's026395483'] | [79656.0, 79708.0, 80312.0] | [3165.0, 3166.0, 2375.0] | [773, 810, 813] |
p03283 | u659712937 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["from itertools import accumulate\nfrom operator import add, mul\nn,m,q=map(int,input().split())\n\na=[]\nb=[]\nfor i in range(n):\n a.append([0]*(n))\n b.append([0]*(n))\n\n#import numpy as np\n#b=np.array(b)\n#print(a)\n'''\nfor i in range(m):\n l,r=map(int,input().split())\n #print(a[(r-1):n,0:l])\n #a[(r-1):n,0:l]+=1\n for j in range(r-1,n):\n for k in range(l):\n a[j][k]+=1\n'''\nfor i in range(m):\n l,r=map(int,input().split())\n #print(a[(r-1):n,0:l])\n a[l-1][r-1]+=1\n\n#print(a)\n\nfor i in range(n):\n a[i]=list(accumulate(a[i]))\n\n#print(a)\n\nfor i in range(n):\n for j in range(n-i):\n a[n-i-j-2][n-i-1]+=a[n-i-j-1][n-i-1]\n #print(a)\n\nprint(a)\n\n'''\nfor l in range(n):\n for r in range(l,n):\n temp=a[r][l]\n for i in range(r,n):\n for j in range(0,l+1):\n b[i][j]+=temp\n #b[r:n,0:l+1]+=temp\n'''\n#print(a)\n#print(b)\n\nfor i in range(q):\n P,Q=map(int,input().split())\n print(a[(P-1)][(Q-1)])\n", "from itertools import accumulate\nfrom operator import add, mul\nn,m,q=map(int,input().split())\n\na=[]\nb=[]\nfor i in range(n):\n a.append([0]*(n))\n b.append([0]*(n))\n\n#import numpy as np\n#b=np.array(b)\n#print(a)\n'''\nfor i in range(m):\n l,r=map(int,input().split())\n #print(a[(r-1):n,0:l])\n #a[(r-1):n,0:l]+=1\n for j in range(r-1,n):\n for k in range(l):\n a[j][k]+=1\n'''\nfor i in range(m):\n l,r=map(int,input().split())\n #print(a[(r-1):n,0:l])\n a[l-1][r-1]+=1\n\n#print(a)\n\nfor i in range(n):\n a[i]=list(accumulate(a[i]))\n\n#print(a)\n\nfor i in range(n):\n for j in range(n-i-1):\n a[n-i-j-2][n-i-1]+=a[n-i-j-1][n-i-1]\n #print(a)\n\n#print(a)\n\n'''\nfor l in range(n):\n for r in range(l,n):\n temp=a[r][l]\n for i in range(r,n):\n for j in range(0,l+1):\n b[i][j]+=temp\n #b[r:n,0:l+1]+=temp\n'''\n#print(a)\n#print(b)\n\nfor i in range(q):\n P,Q=map(int,input().split())\n print(a[(P-1)][(Q-1)])\n"] | ['Wrong Answer', 'Accepted'] | ['s650131923', 's069467093'] | [21304.0, 19076.0] | [870.0, 858.0] | [1132, 1135] |
p03283 | u659753499 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ["N,M,Q = map(int,input().split())\nT = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor i in range(M):\n L,R = map(int, input().split())\n T[L][R] += 1\npprint(T)\nfor l in range(1,N+1):\n for r in range(1,N+1):\n T[l][r] += T[l-1][r]+T[l][r-1]-T[l-1][r-1]\nans = []\npprint(T)\nfor i in range(Q):\n p,q = map(int, input().split())\n ans.append(T[p-1][p-1]+T[q][q]-T[p-1][q]-T[q][p-1])\nprint('\\n'.join(map(str,ans)))\nquit()\n", "N,M,Q = map(int,input().split())\nT = [[0 for _ in range(N+1)] for _ in range(N+1)]\nfor i in range(M):\n L,R = map(int, input().split())\n T[L][R] += 1\nfor l in range(1,N+1):\n for r in range(1,N+1):\n T[l][r] += T[l-1][r]+T[l][r-1]-T[l-1][r-1]\nans = []\nfor i in range(Q):\n p,q = map(int, input().split())\n ans.append(T[p-1][p-1]+T[q][q]-T[p-1][q]-T[q][p-1])\nprint('\\n'.join(map(str,ans)))\n"] | ['Runtime Error', 'Accepted'] | ['s490289040', 's853945100'] | [5108.0, 23896.0] | [595.0, 1157.0] | [420, 393] |
p03283 | u672475305 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['\ndef f(h,w,a):\n da = [[0]*w for _ in range(h)]\n da[0][0] = a[0][0]\n for i in range(1, w):\n da[0][i] = da[0][i-1] + a[0][i]\n for i in range(1, h):\n cnt_w = 0\n for j in range(w):\n cnt_w += a[i][j]\n da[i][j] = da[i-1][j] + cnt_w\n return da\n\ndef Calc(p,q,x,y, da):\n if p>x or q>y:\n return 0\n if p==0 or q==0:\n return da[x][y]\n if p==0:\n return da[x][y] - da[x][q-1]\n if q==0:\n return da[x][y] - da[p-1][y]\n return da[x][y] - da[x][q-1] - da[p-1][y] + da[p-1][q-1]\n\nN,M,Q = map(int,input().split())\nt = [[0]*(N+1) for _ in range(N+1)]\nfor _ in range(M):\n l,r = map(int,input().split())\n t[l][r] += 1\n\nd = f(N,N,t)\nquery = []\nfor _ in range(Q):\n p,q = map(int,input().split())\n p -= 1\n q -= 1\n print(Calc(p,p,q,q,d))', 'def f(h,w,a):\n da = [[0]*(w+1)for _ in range(h+1)]\n da[0][0] = a[0][0]\n for i in range(1, w+1):\n da[0][i] = da[0][i-1] + a[0][i]\n for i in range(1, h+1):\n cnt_w = 0\n for j in range(w+1):\n cnt_w += a[i][j]\n da[i][j] = da[i-1][j] + cnt_w\n return da\n\ndef Calc(p,q,x,y, da):\n if p>x or q>y:\n return 0\n if p==0 or q==0:\n return da[x][y]\n if p==0:\n return da[x][y] - da[x][q-1]\n if q==0:\n return da[x][y] - da[p-1][y]\n return da[x][y] - da[x][q-1] - da[p-1][y] + da[p-1][q-1]\n\nN,M,Q = map(int,input().split())\nt = [[0]*(N+1) for _ in range(N+1)]\nfor _ in range(M):\n l,r = map(int,input().split())\n t[l][r] += 1\n\nd = f(N,N,t)\nfor _ in range(Q):\n p,q = map(int,input().split())\n print(Calc(p,p,q,q,d))'] | ['Wrong Answer', 'Accepted'] | ['s657931389', 's476080383'] | [15320.0, 17108.0] | [1561.0, 1520.0] | [830, 807] |
p03283 | u685263709 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\nLR = [list(map(int, input().split())) for i in range(M)]\nPQ = [list(map(int, input().split())) for i in range(Q)]\n\nacc = [[0 for i in range(N+1)] for i in range(N+1)] \ncoordinate = [[0 for i in range(N)] for i in range(N)]\nfor l, r in LR:\n l -= 1\n r -= 1\n coordinate[l][r] += 1\n\nfor i in range(N):\n for j in range(N):\n acc[i+1][j+1] = acc[i][j+1] + acc[i+1][j] - acc[i][j] + coordinate[i][j]\nprint(acc)\nfor p, q in PQ:\n p -= 1\n ans = acc[N][q] - acc[p][q]\n print(ans)', 'N, M, Q = map(int, input().split())\nLR = [list(map(int, input().split())) for i in range(M)]\nPQ = [list(map(int, input().split())) for i in range(Q)]\n\nacc = [[0 for i in range(N+1)] for i in range(N+1)] \ncoordinate = [[0 for i in range(N)] for i in range(N)]\nfor l, r in LR:\n l -= 1\n r -= 1\n coordinate[l][r] += 1\n\nfor i in range(N):\n for j in range(N):\n acc[i+1][j+1] = acc[i][j+1] + acc[i+1][j] - acc[i][j] + coordinate[i][j]\n\nfor p, q in PQ:\n p -= 1\n ans = acc[N][q] - acc[p][q]\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s068518068', 's961046396'] | [83496.0, 79476.0] | [1362.0, 1339.0] | [611, 601] |
p03283 | u686461495 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['# coding:utf-8\nn,m,q=map(int,input().split())\ndp = [[0 for i in range(n)] for j in range(n)]\nfor i in range(m):\n l,r=map(int,input().split())\n l-=1\n r-=1\n dp[l][r]+=1\nfor i in range(n):\n for j in range(n-1):\n dp[i][j+1]+=dp[i][j]\nfor j in range(n):\n for i in range(n-1,0,-1):\n dp[i-1][j]+=dp[i][j]\nprint(dp)\nfor i in range(n):\n p,q=map(int,input().split())\n p-=1\n q-=1\n if q==n-1:\n print(dp[p][q])\n else :\n print(dp[p][q]-dp[q][q])\n', '# coding:utf-8\nn,m,qq=map(int,input().split())\ndp = [[0 for i in range(n+5)] for j in range(n+5)]\nfor i in range(m):\n l,r=map(int,input().split())\n l-=1\n r-=1\n dp[l][r]+=1\nfor i in range(n):\n for j in range(n-1):\n dp[i][j+1]+=dp[i][j]\nfor j in range(n):\n for i in range(n-1,0,-1):\n dp[i-1][j]+=dp[i][j]\nfor i in range(qq):\n p,q=map(int,input().split())\n p-=1\n q-=1\n if q==n-1:\n print(dp[p][q])\n else :\n print(dp[p][q]-dp[q+1][q])\n'] | ['Runtime Error', 'Accepted'] | ['s478473880', 's740182112'] | [12460.0, 9460.0] | [783.0, 1678.0] | [490, 488] |
p03283 | u745514010 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,q=map(int,input().split())\nalist=[]\nfor i in range(m):\n l,r=map(int,input().split())\n alist.append([l,r])\nfor t in range(q):\n count=m\n p,q=map(int,input().split())\n for i in alist:\n if p>i[0] or p<i[1]:\n count-=1\n print(count)', 'n,m,q=map(int,input().split())\nalist=[]\nfor i in range(m):\n l,r=map(int,input().split())\n alist.append([l,r])\nalist.sort()\nfor t in range(q):\n count=0\n blist=[]\n p,q=map(int,input().split())\n print(alist)\n for j in range (len(alist)):\n if p<=alist[0][0]:\n alist.sort(key=lambda x:x[1])\n break\n blist.append(alist[0])\n alist.remove(alist[0])\n for j in range (len(alist)):\n if q>=alist[j][1]:\n count+=1\n else:\n break\n for k in blist:\n alist.append(k)\n print(count)\n alist.sort(key=lambda x:x[0])', 'n, m, Q = map(int, input().split())\nlr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]\nfor _ in range(m):\n l, r = map(int, input().split())\n lr[l][r] += 1\n\nrui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]\n \nfor _ in range(Q):\n p, q = map(int, input().split())\n p -= 1\n ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s166070998', 's368606102', 's220945661'] | [31708.0, 50048.0, 20744.0] | [3161.0, 3158.0, 963.0] | [266, 612, 501] |
p03283 | u767545760 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\ntrains = [[0] * (N + 1) for _ in range(N + 1)]\nfor _ in range(M):\n L, R = map(int, input().split())\n trains[L][R] += 1\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n trains[i][j] += trains[i - 1][j]\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n trains[i][j] += trains[i][j - 1]\nprint(trains)\nans = [0] * Q\nfor k in range(Q):\n p, q = map(int, input().split())\n ans[k] = trains[q][q] - trains[p-1][q] - trains[q][p-1] + trains[p-1][p-1]\nfor A in ans:\n print(A)', 'N, M, Q = map(int, input().split())\ntrains = [[0] * (N + 1) for _ in range(N + 1)]\nfor _ in range(M):\n L, R = map(int, input().split())\n trains[L][R] += 1\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n trains[i][j] += trains[i - 1][j]\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n trains[i][j] += trains[i][j - 1]\nans = [0] * Q\nfor k in range(Q):\n p, q = map(int, input().split())\n ans[k] = trains[q][q] - trains[p-1][q] - trains[q][p-1] + trains[p-1][p-1]\nfor A in ans:\n print(A)'] | ['Wrong Answer', 'Accepted'] | ['s743455199', 's245686483'] | [22776.0, 22352.0] | [765.0, 744.0] | [544, 530] |
p03283 | u769698512 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\nn, m, q = map(int, input().split())\nkukan = np.zeros((N+1, N+1))\nfor _ in range(m):\n l, r = map(int, input().split())\n kukan[r][l] += 1\n\n\n\nfor i in range(1, n+1):\n kukan[i] += kukan[i-1]\n\n\nfor i in range(1, n+1):\n kukan[:, i] += kukan[i-1]\n\nfor i in range(q):\n p, q = list(map(int, input().split()))\n print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))\n', 'import numpy as np\nn, m, q = map(int, input().split())\nkukan = np.zeros((n+1, n+1))\nfor _ in range(m):\n l, r = map(int, input().split())\n kukan[r][l] += 1\n\n\n\nfor i in range(1, n+1):\n kukan[i] += kukan[i-1]\n\n\nfor i in range(1, n+1):\n kukan[:, i] += kukan[i-1]\n\nfor i in range(q):\n p, q = list(map(int, input().split()))\n print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))\n', 'import numpy as np\nn, m, q = map(int, input().split())\nkukan = np.zeros((n+1, n+1))\nfor _ in range(m):\n l, r = map(int, input().split())\n kukan[r][l] += 1\n\n\n\nfor i in range(1, n+1):\n kukan[i] += kukan[i-1]\n\n\nfor i in range(1, n+1):\n kukan[:, i] += kukan[:, i-1]\n\nfor i in range(1, q+1):\n p, q = list(map(int, input().split()))\n print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s497475560', 's821176549', 's614082926'] | [12488.0, 16472.0, 15196.0] | [150.0, 2661.0, 2625.0] | [593, 593, 615] |
p03283 | u798818115 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['# coding: utf-8\n# Your code here!\nN,M,Q=map(int,input().split())\n\nstart=[0]*N\nend=[0]*N\n\nfor _ in range(M):\n p,q=map(int,input().split())\n start[p-1]+=1\n end[q-1]+=1\n\nfor i in range(len(start)-1):\n start[i+1]+=start[i]\n end[i+1]+=end[i]\nprint(start)\nprint(end)\n\n\n\n', '# coding: utf-8\n# Your code here!\nN,M,Q=map(int,input().split())\n\ndia=[[0 for i in range(N)] for j in range(N)]\n\nfor _ in range(M):\n L,R=map(int,input().split())\n dia[L-1][R-1]+=1\n\nans=[[0 for i in range(N)] for j in range(N)]\nfor i in range(N):\n for j in range(i,N):\n ans[i][j]=(ans[i][j-1] if j!=0 else 0) + dia[i][j]\n#print(ans)\n\nshin=[[0 for i in range(N)] for j in range(N)]\n\nfor j in range(N):\n temp=0\n for i in range(j+1)[::-1]:\n #print(i,j)\n temp+=ans[i][j]\n shin[i][j]=temp\n\nfor _ in range(Q):\n p,q=map(int,input().split())\n print(shin[p-1][q-1])\n#print(shin)\n"""\nfor _ in range(Q):\n p,q=map(int,input().split())\n temp=0\n for i in range(p,q+1):\n #print(i,q)\n temp+=ans[i-1][q-1]\n \n\n print(temp)\n"""'] | ['Wrong Answer', 'Accepted'] | ['s048053276', 's292165324'] | [3060.0, 15476.0] | [665.0, 1505.0] | [292, 789] |
p03283 | u816116805 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['from collections import Counter\nfrom itertools import product\nimport numpy as np\n\nn,m,q = map(int,input().split())\nrails=[tuple(map(int,input().split())) for i in range(m)]\nqs=[tuple(map(int,input().split())) for i in range(q)]\n\nxlist = np.array([[0 for j in range(n)] for i in range(n)])\nfor (l,r),i in Counter(rails).items():\n xlist[l-1,r-1]=i\n\nsumsumlist = np.cumsum(np.cumsum(xlist,axis=1),axis=0)\n\nprint(xlist)\nprint(sumsumlist)\n\nfor (p,q) in qs:\n if p>1:\n ans = sumsumlist[q-1][q-1] - sumsumlist[q-1][p-2] - sumsumlist[p-2][q-1] + sumsumlist[p-2][p-2]\n elif p==1:\n ans = sumsumlist[q-1][q-1]\n\n print(ans)\n', 'import numpy as np\n\nn,m,q = map(int,input().split())\nrails=[tuple(map(int,input().split())) for i in range(m)]\nqs=[tuple(map(int,input().split())) for i in range(q)]\n\nxlist = np.array([[0 for j in range(n)] for i in range(n)],dtype=np.int32)\nfor (l,r) in rails:\n xlist[l-1,r-1]+=1\n\nsumsumlist = np.cumsum(np.cumsum(xlist,axis=1),axis=0)\n\n\nfor (p,q) in qs:\n if p>1:\n ans = sumsumlist[q-1][q-1] - sumsumlist[q-1][p-2] - sumsumlist[p-2][q-1] + sumsumlist[p-2][p-2]\n elif p==1:\n ans = sumsumlist[q-1][q-1]\n\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s738724227', 's634874876'] | [54064.0, 47916.0] | [1835.0, 2929.0] | [638, 542] |
p03283 | u824237520 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\n\ntemp = [ [0 for _ in range(n)] for _ in range(n)]\ntables = [ [0 for _ in range(n)] for _ in range(n)]\n\nfor _ in range(m):\n l, r = map(int, input().split())\n temp[l - 1][r - 1] += 1\n\npq = [tuple(int(x) - 1 for x in input().split()) for _ in range(q)]\n\nfor i in range(m):\n hoge = 0\n for j in range(m):\n hoge += temp[i][j]\n tables[i][j] = hoge\n\nfor p, q in pq:\n ans = 0\n if p > 0:\n for i in range(p, q + 1):\n ans += tables[i][q] - tables[i][p - 1]\n else:\n for i in range(q + 1):\n ans += tables[i][q]\n print(ans)', 'n, m, q = map(int, input().split())\n\ntemp = [ [0 for _ in range(n)] for _ in range(n)]\ntables = [ [0 for _ in range(n)] for _ in range(n)]\n\nfor _ in range(m):\n l, r = map(int, input().split())\n temp[l - 1][r - 1] += 1\n\npq = [tuple(int(x) - 1 for x in input().split()) for _ in range(q)]\n\nfor i in range(m):\n hoge = 0\n for j in range(m):\n hoge += temp[i][j]\n tables[i][j] = hoge\n\nfor p, q in pq:\n ans = 0\n if p > 0:\n for i in range(p, q + 1):\n ans += tables[i][q] - tables[i][p - 1]\n else:\n for i in range(q + 1):\n ans += tables[i][q]\n print(ans)', "n, m, q = map(int, input().split())\n\ntemp = [ [0 for _ in range(n)] for _ in range(n)]\ntables = [ [0 for _ in range(n)] for _ in range(n)]\n\nif n == 1:\n print('1')\n exit()\n\nfor _ in range(m):\n l, r = map(int, input().split())\n temp[l - 1][r - 1] += 1\n\npq = [tuple(int(x) - 1 for x in input().split()) for _ in range(q)]\n\nhoge = 0\nfor j in range(n):\n hoge += temp[0][j]\n tables[0][j] = hoge\n\nfor i in range(1, n):\n hoge = 0\n for j in range(n):\n hoge += temp[i][j]\n tables[i][j] = tables[i - 1][j] + hoge\n\nfor p, q in pq:\n if p == 0:\n print(tables[q][q])\n else:\n print(tables[q][q] - tables[p - 1][q] - tables[q][p - 1] + tables[p - 1][p - 1] )"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s653157596', 's912226112', 's707953825'] | [17636.0, 17636.0, 26124.0] | [1000.0, 957.0, 1233.0] | [619, 619, 699] |
p03283 | u844789719 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = [int(_) for _ in input().split()]\nLR = [[int(_) for _ in input().split()] for _ in range(M)]\nPQ = [[int(_) for _ in input().split()] for _ in range(Q)]\n\ncumsum = [[0] * (N+2) for _ in range(N+1)]\nfor lr in LR:\n cumsum[lr[0]][lr[0]] += 1\n if lr[1] < N:\n cumsum[lr[0]][lr[1]+1] -= 1\nfor i in range(N+1):\n for j in range(i, N):\n cumsum[i][j+1] += cumsum[i][j]\n[print(_) for _ in cumsum]\nfor pq in PQ:\n print(sum([cumsum[i][i]-cumsum[i][pq[1]+1]\n for i in range(pq[0], pq[1]+1)]))', 'N, M, Q = [int(_) for _ in input().split()]\nLR = [[int(_) for _ in input().split()] for _ in range(M)]\npq = [[int(_) for _ in input().split()] for _ in range(Q)]\n\nmemo = [[0 for _ in range(N)] for _ in range(N)]\nfor l, r in LR:\n memo[l - 1][r - 1] += 1\n[print(_) for _ in memo]\nfor p, q in pq:\n print(sum([sum(memo[_][p - 1:q]) for _ in range(p - 1, q)]))', 'N, M, Q = [int(_) for _ in input().split()]\nQuery = []\nfor _ in range(M):\n Query += [[int(_) for _ in input().split()] + [0, _]]\nfor _ in range(Q):\n p, q = [int(_) for _ in input().split()]\n Query += [[p, q + 1, 1, _]]\nQuery.sort(key=lambda xs: 2 * xs[1] - xs[2])\nans = [0] * Q\n\n\nclass SegmentTree():\n def __init__(self, array, m, e, size):\n """\n Parameters\n ----------\n array : list\n to construct segment tree from\n m : func\n binary operation of the monoid\n e : \n identity element of the monoid\n size : int\n limit for array size\n """\n self.m = m\n self.e = e\n self.size = size\n self.n = n = len(array)\n self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)\n self.build()\n\n def build(self):\n dat, n, m = self.dat, self.n, self.m\n for i in range(n - 1, 0, -1):\n dat[i] = m(dat[i << 1], dat[i << 1 | 1])\n\n def modify(self, p, v):\n """\n set value at position p (0-indexed)\n """\n m, n, dat = self.m, self.n, self.dat\n p += n\n dat[p] = v\n while p > 1:\n dat[p >> 1] = m(dat[p], dat[p ^ 1])\n p >>= 1\n\n def query(self, l, r):\n """\n result on interval [l, r) (0-indexed)\n """\n m, e, n, dat = self.m, self.e, self.n, self.dat\n res = e\n l += n\n r += n\n while l < r:\n if l & 1:\n res = m(res, dat[l])\n l += 1\n if r & 1:\n r -= 1\n res = m(res, dat[r])\n l >>= 1\n r >>= 1\n return res\n\n\ne = 0\nsize = N + 2\nST = SegmentTree([0] * (N + 2), m=lambda x, y: x + y, e=e, size=size)\nfor l, r, t, i in Query:\n if t:\n ans[i] = ST.query(l, r)\n else:\n ST.modify(l, ST.query(l, l + 1) + 1)\nprint(*ans, sep=\'\\n\')\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s262555522', 's366246406', 's246424055'] | [54944.0, 51132.0, 71404.0] | [3159.0, 3159.0, 2674.0] | [526, 361, 1933] |
p03283 | u846150137 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\nn,m,q=map(int,input().split())\na=np.zeros((n+2,n+2))\nfor i in range(m):\n s,e=map(int,input().split())\n a[:s,e:]+=1\nprint(a)\nfor i in range(q):\n s,e=map(int,input().split())\n print(a[s,e])', 'from numpy import *\nI=lambda:map(int,input().split())\nF=lambda x:flipud(a.cumsum(x))\nn,m,q=I()\na=zeros((n+2,n+2))\nfor i in [0]*m:\n s,e=I()\n a[s,e]+=1\na=F(1)\na=F(0)\nfor i in [0]*q:\n s,e=I()\n print(int(a[s,e]))'] | ['Wrong Answer', 'Accepted'] | ['s838195851', 's265648968'] | [16504.0, 17940.0] | [3160.0, 2302.0] | [210, 212] |
p03283 | u846694620 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\n\ng = [[0 for j in range(n)] for i in range(n)]\n\nfor _ in range(m):\n l, r = map(int, input().split())\n g[l - 1][r - 1] = 1\n\nfor _ in range(q):\n p, q = map(int, input().split())\n ans = 1\n for i in range(p, q + 1):\n for j in range(p, q + 1):\n ans += g[i - 1][j - 1]\n print(ans)\n', 'N, M, Q = map(int, input().split())\n\nx = [[0 for j in range(N + 1)] for i in range(N + 1)]\n\nfor _ in range(M):\n L, R = map(int, input().split())\n x[L][R] += 1\n\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n x[i][j] += x[i][j - 1]\n\nfor j in range(1, N + 1):\n for i in reversed(range(1, N + 1)):\n x[i - 1][j] += x[i][j]\n\nfor _ in range(Q):\n p, q = map(int, input().split())\n print(x[p][q])\n'] | ['Wrong Answer', 'Accepted'] | ['s539940093', 's290287096'] | [7156.0, 9460.0] | [3156.0, 1518.0] | [347, 427] |
p03283 | u886747123 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['# D - AtCoder Express 2\n\nimport numpy as np\nimport sys\n\nN, M, Q = map(int, input().split())\nLRpq = np.array(sys.stdin.buffer.read().split(), np.int64)\nL = LRpq[:2*M:2]\nR = LRpq[1:2*M:2]\np = LRpq[2*M::2]\nq = LRpq[2*M+1::2]\n \ntrain = np.zeros((N+1, N+1))\nnp.add.at(train, (L,R), 1)\n\nnp.cumsum(train, axis = 0, out = train)\nnp.cumsum(train, axis = 1, out = train)\n \nans = train[q,q] - train[p-1,q] - train[q,p-1] + train[p-1,p-1]\nfor i in range(Q):\n print(int(ans[i]))', '# D - AtCoder Express 2\n\nimport numpy as np\nimport sys\n\nN, M, Q = map(int, input().split())\nL, R, = [], []\np, q = np.array([],np.int64), np.array([],np.int64)\nfor _ in range(M):\n l, r = map(int, sys.stdin.readline().split())\n L.append(l)\n R.append(r)', 'import numpy as np\n\nN, M, Q = map(int, input().split())\nL, R, = [], []\np, q = np.array([],np.int64), np.array([],np.int64)\nfor _ in range(M):\n l, r = map(int, input().split())\n L.append(l)\n R.append(r)', 'import numpy as np\n\nN, M, Q = map(int, input().split())\nL, R, = [], []\np, q = np.array([],np.int64), np.array([],np.int64)\nfor _ in range(M):\n l, r = map(int, input().split())\n L.append(l)\n R.append(r)\nfor _ in range(Q):\n tmp_p, tmp_q = map(int, input().split())\n p = np.append(p, [tmp_p])\n q = np.append(q, [tmp_q])', '# D - AtCoder Express 2\n\nimport numpy as np\nimport sys\n\nN, M, Q = map(int, input().split())\nLRpq = np.array(sys.stdin.read().split(), np.int64)\nL = LRpq[:2*M:2]\nR = LRpq[1:2*M:2]\np = LRpq[2*M::2]\nq = LRpq[2*M+1::2]', 'import numpy as np\nimport sys\nbuf = sys.stdin.buffer\n \nN, M, Q = map(int, buf.readline().split())\ncity = np.zeros((N + 1, N + 1), np.int32)\nLRpq = np.array(buf.read().split(), np.int32)\n \nL = LRpq[:2 * M:2]\nR = LRpq[1:2 * M:2]\np = LRpq[2 * M::2]\nq = LRpq[2 * M + 1::2]', '# D - AtCoder Express 2\n\nimport numpy as np\nimport sys\n\nN, M, Q = map(int, sys.stdin.buffer.readline().split())\nLRpq = np.array(sys.stdin.buffer.read().split(), np.int64)\nL = LRpq[:2*M:2]\nR = LRpq[1:2*M:2]\np = LRpq[2*M::2]\nq = LRpq[2*M+1::2]\n \ntrain = np.zeros((N+1, N+1))\nnp.add.at(train, (L,R), 1)\n\nnp.cumsum(train, axis = 0, out = train)\nnp.cumsum(train, axis = 1, out = train)\n \nans = train[q,q] - train[p-1,q] - train[q,p-1] + train[p-1,p-1]\nfor i in range(Q):\n print(int(ans[i]))'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s356314511', 's405870372', 's519093487', 's559109723', 's600744110', 's901269818', 's866293559'] | [44968.0, 21648.0, 21648.0, 23452.0, 66884.0, 45728.0, 48248.0] | [416.0, 423.0, 701.0, 3161.0, 288.0, 254.0, 414.0] | [474, 259, 210, 334, 214, 268, 494] |
p03283 | u894258749 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import numpy as np\ndef inpl(): return list(map(int,input().split()))\n\nN, M , Q = inpl()\ntrains = np.zeros((N,N),dtype=np.int)\nans = np.zeros((N,N),dtype=np.int)\n\nfor i in range(M):\n L, R = inpl()\n trains[L-1,R-1] += 1\n\nfor l in range(N):\n for r in range(l,N):\n ans[l,r] = trains[l:r+1,l:r+1].sum()\n\nfor i in range(Q):\n p, q = inpl()\n print(ans[p-1,q-1])', 'import numpy as np\ndef inpl(): return list(map(int,input().split()))\n\nN, M , Q = inpl()\n\ncumsum = np.zeros((N+1,N+1),dtype=np.int)\nans = np.zeros((N+1,N+1),dtype=np.int)\n\nfor i in range(M):\n L, R = inpl()\n cumsum[L,R] += 1\n\nfor l in range(1,N+1):\n for r in range(1,N+1):\n cumsum[l,r] += cumsum[l-1,r] + cumsum[l,r-1] - cumsum[l-1,r-1]\n\nfor l in range(1,N+1):\n for r in range(l,N+1):\n ans[l,r] = cumsum[r,r] - cumsum[l-1,r] - cumsum[r,l-1] + cumsum[l-1,l-1]\n\nfor i in range(Q):\n p, q = inpl()\n print(ans[p,q])', 'def inpl(): return list(map(int,input().split()))\n\nN, M, Q = inpl()\ncumsum = [0]*((N+1)**2)\nans = [0]*((N+1)**2)\n\nfor i in range(M):\n L, R = inpl()\n cumsum[L*(N+1)+R] += 1\n\nfor l in range(1,N+1):\n for r in range(1,N+1):\n cumsum[l*(N+1)+r] += cumsum[(l-1)*(N+1)+r] + cumsum[l*(N+1)+r-1] - cumsum[(l-1)*(N+1)+r-1]\n\nfor l in range(1,N+1):\n for r in range(l,N+1):\n ans[l*(N+1)+r] = cumsum[r*(N+1)+r] - cumsum[(l-1)*(N+1)+r] - cumsum[r*(N+1)+l-1] + cumsum[(l-1)*(N+1)+l-1]\n\nfor i in range(Q):\n p, q = inpl()\n print(ans[p*(N+1)+q])'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s355221981', 's807509626', 's300011330'] | [14660.0, 16844.0, 19028.0] | [3161.0, 3161.0, 2067.0] | [375, 582, 557] |
p03283 | u911507660 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, raw_input().split())\nfor _ in range(M):\nLR = [map(int, raw_input().split()) for _ in range(M)]\npq = [map(int, raw_input().split()) for _ in range(Q)]\n\ntable = [[0 for _i in range(N+1)] for _j in range(N+1)]\nfor line in LR:\n table[LR[0]][LR[1]] += 1\nfor question in pq:\n p = question[0]\n q = question[1]\n ans = 0\n for j in range(p, q+1):\n ans += table[p][j]\n print(ans)', 'N, M, Q = map(int, input().split())\nLR = [list(map(int, input().split())) for _ in range(M)]\npq = [list(map(int, input().split())) for _ in range(Q)]\n\ntable = [[0 for _i in range(N+1)] for _j in range(N+1)]\naccum = [[0 for _i in range(N+1)] for _j in range(N+1)]\naccum2 = [[0 for _i in range(N+1)] for _j in range(N+1)]\n\nfor line in LR:\n table[line[0]][line[1]] += 1\n\nfor i in range(1, N+1):\n for j in range(1, N+1):\n accum[i][j] = accum[i][j-1] + table[i][j]\n\nfor i in range(1, N+1):\n for j in range(1, N+1):\n accum2[i][j] = accum2[i-1][j] + accum[i][j]\n\n\n# for j in range(i, N+1):\n# ans[i][j] = sum([accum[k][j] - accum[k][i-1] for k in range(i, j+1)])\n\nfor question in pq:\n p = question[0]\n q = question[1]\n print(accum2[q][q] - accum2[p-1][q] - accum2[q][p-1] + accum2[p-1][p-1])'] | ['Runtime Error', 'Accepted'] | ['s293958680', 's172093498'] | [2940.0, 83336.0] | [17.0, 1348.0] | [412, 865] |
p03283 | u921773161 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['#%%\nimport numpy as np\n\nn, m, Q = map(int ,input().split())\nl, r, p, q = [0] * m, [0] * m, [0] * Q, [0] * Q\ncount = [[0] * n for _ in range(n)]\nfor i in range(m):\n l[i], r[i] = map(lambda x: int(x) - 1, input().split())\n count[l[i]][r[i]] += 1\nfor i in range(Q):\n p[i], q[i] = map(lambda x: int(x) - 1, input().split())\n\nprint(np.array(count))\n\nfor i in range(0, n):\n for j in range(1, n):\n count[i][j] += count[i][j-1]\n for j in range(1, n):\n if i != 0:\n count[i][j] += count[i-1][j]\n\nprint(np.array(count))\n\nfor i in range(Q):\n if 0 <= p[i]-1:\n tmp = count[q[i]][q[i]] - count[p[i]-1][q[i]]\n else:\n tmp = count[q[i]][q[i]]\n print(tmp)', '#%%\nimport numpy as np\n\nn, m, Q = map(int ,input().split())\nl, r, p, q = [0] * m, [0] * m, [0] * Q, [0] * Q\ncount = [[0] * n for _ in range(n)]\nfor i in range(m):\n l[i], r[i] = map(lambda x: int(x) - 1, input().split())\n count[l[i]][r[i]] += 1\nfor i in range(Q):\n p[i], q[i] = map(lambda x: int(x) - 1, input().split())\n\n#print(np.array(count))\n\nfor i in range(0, n):\n for j in range(1, n):\n count[i][j] += count[i][j-1]\n for j in range(0, n):\n if i != 0:\n count[i][j] += count[i-1][j]\n\n#print(np.array(count))\n\nfor i in range(Q):\n if 0 <= p[i]-1:\n tmp = count[n-1][q[i]] - count[p[i]-1][q[i]]\n else:\n tmp = count[n-1][q[i]]\n print(tmp)'] | ['Wrong Answer', 'Accepted'] | ['s364974767', 's759837703'] | [38364.0, 36588.0] | [1527.0, 1472.0] | [699, 699] |
p03283 | u932868243 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,q=map(int,input().split())\nans=[[0]*(n+1) for __ in range(n+1)]\nfor _ in range(m):\n l,r=map(int,input().split())\n ans[l][r]+=1\nfor i in range(n+1):\n for j in range(n):\n ans[i][j+1]+=ans[i][j]\nfor i in range(n):\n for j in range(n+1):\n ans[i+1][j]+=ans[i][j]\nfor qq in range(q):\n p,q=map(int,input().split())\n print(ans[q][q]-ans[p-1][q]-ans[p][q-1]+ans[p-1][p-1])', 'n,m,q=map(int,input().split())\nd=[[0]*(n+1) for _ in range(n+1)]\n\nfor mm in range(m):\n l,r=map(int,input().split())\n d[l][r]+=1\n\nfor i in range(n):\n for j in range(n+1):\n d[i+1][j]+=d[i][j]\n\nfor j in range(n+1):\n for i in range(n):\n d[j][i+1]=d[j][i]\n \nfor qq in range(q):\n x,y=map(int,input().split())\n print(d[y][y]-d[y][x-1]-d[x-1][y]+d[x-1][x-1])', 'n,m,q=map(int,input().split())\nans=[[0]*(n+1) for __ in range(n+1)]\nfor _ in range(m):\n l,r=map(int,input().split())\n ans[l][r]+=1\nfor i in range(n+1):\n for j in range(n):\n ans[i][j+1]+=ans[i][j]\nfor i in range(n):\n for j in range(n+1):\n ans[i+1][j]+=ans[i][j]\nfor qq in q:\n p,q=map(int,input().split())\n print(ans[q][q]-ans[p-1][q]-ans[p][q-1]+ans[p][p])', 'n,m,q=map(int,input().split())\nd=[[0]*(n+1) for _ in range(n+1)]\n \nfor mm in range(m):\n l,r=map(int,input().split())\n d[l][r]+=1\n\nfor i in range(n):\n for j in range(n+1):\n d[i+1][j]+=d[i][j]\n \nfor j in range(n+1):\n for i in range(n):\n d[j][i+1]+=d[j][i]\n\nfor qq in range(q):\n x,y=map(int,input().split())\n print(d[y][y]-d[y][x-1]-d[x-1][y]+d[x-1][x-1])'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s482614877', 's888846917', 's975150065', 's122442502'] | [13392.0, 8684.0, 12632.0, 14828.0] | [1560.0, 1538.0, 729.0, 1604.0] | [378, 365, 367, 364] |
p03283 | u955251526 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\ntrain = [tuple(map(int, input().split())) for _ in range(m)]\nquest = [tuple(map(int, input().split())) for _ in range(q)]\ndp = [[0 for _ in range(n)] for _ in range(n)]\nd = {}\nfor l in range(n):\n for r in range(l,n):\n d[(l,r)] = 0\nfor p, q in train:\n d[(p,q)] += 1\nfor l in range(n):\n dp[l][l] = d[(l+1,l+1)]\nfor w in range(1,n):\n for l in range(n-w):\n dp[l][l+w] = dp[l][l+w-1] + d[(l,l+w)]\nfor l, r in quest:\n print(dp[l-1][r-1])\n', 'n, m, q = map(int, input().split())\ntrain = [tuple(map(int, input().split())) for _ in range(m)]\nquest = [tuple(map(int, input().split())) for _ in range(q)]\ndp = [[0 for _ in range(n)] for _ in range(n)]\nd = {}\nfor l in range(n):\n for r in range(l,n):\n d[(l,r)] = 0\nfor p, q in train:\n else:\n d[(p,q)] += 1\nfor l in range(n):\n dp[l][l] = d[(l+1,l+1)]\nfor w in range(1,n):\n for l in range(n-w):\n dp[l][l+w] = dp[l][l+w-1] + d[(l,l+w)]\nfor l, r in quest:\n print(dp[l-1][r-1])\n', 'n, m, q = map(int, input().split())\ntrain = [tuple(map(int, input().split())) for _ in range(m)]\nquest = [tuple(map(int, input().split())) for _ in range(q)]\ndp = [[0 for _ in range(n+1)] for _ in range(n+1)]\nd = {}\nfor l in range(n):\n for r in range(l,n):\n d[(l+1,r+1)] = 0\nfor p, q in train:\n d[(p,q)] += 1\nfor l in range(1,n+1):\n dp[l][l] = d[(l,l)]\nfor w in range(1,n):\n for l in range(n-w):\n dp[l+1][l+w+1] = dp[l+1][l+w] + dp[l+2][l+w+1] - dp[l+2][l+w] + d[(l+1,l+w+1)]\nfor l, r in quest:\n print(dp[l][r])\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s058119094', 's976281769', 's443214454'] | [53044.0, 3060.0, 58484.0] | [926.0, 17.0, 1273.0] | [501, 511, 541] |
p03283 | u957084285 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n, m, q = map(int, input().split())\ncity = [[0]*(n+2) for _ in range(n+2)]\nsame = [0]*(n+1)\nfor _ in range(m):\n l, r = map(int, input().split())\n city[r][1] += 1\n city[r][l+1] -= 1\n\n city[1][r] += 1\n city[l+1][r] -= 1\n if l==r:\n same[l] += 1\n\n"""\nprint()\nfor c in city[1:n+1]:\n print(c[1:n+1])\n"""\n\nfor j in range(n+2):\n for i in range(1, n+2):\n city[j][i] += city[j][i-1]\n\nfor i in range(n+2):\n for j in range(1, n+2):\n city[j][i] += city[j-1][i]\n\n\nprint()\nfor c in city[1:n+1]:\n print(c[1:n+1])\n\n\nfor _ in range(q):\n x, y = map(int, input().split())\n if x==y:\n print(same[x])\n else:\n print(city[x][y])\n', 'n, m, q = map(int, input().split())\ncity = [[0]*(n+2) for _ in range(n+2)]\nsame = [0]*(n+1)\nfor _ in range(m):\n l, r = map(int, input().split())\n city[r][1] += 1\n city[r][l+1] -= 1\n\n city[1][r] += 1\n city[l+1][r] -= 1\n if l==r:\n same[l] += 1\n\n"""\nprint()\nfor c in city[1:n+1]:\n print(c[1:n+1])\n"""\n\nfor j in range(n+2):\n for i in range(1, n+2):\n city[j][i] += city[j][i-1]\n\nfor i in range(n+2):\n for j in range(1, n+2):\n city[j][i] += city[j-1][i]\n\n"""\nprint()\nfor c in city[1:n+1]:\n print(c[1:n+1])\n"""\n\nfor _ in range(q):\n x, y = map(int, input().split())\n if x==y:\n print(same[x])\n else:\n print(city[x][y])\n'] | ['Wrong Answer', 'Accepted'] | ['s900767716', 's112985275'] | [14704.0, 13168.0] | [1666.0, 1978.0] | [678, 684] |
p03283 | u969190727 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['n,m,q=map(int,input().split())\nL=[[0 for i in range(n)] for i in range(n)]\nLL=[[0 for i in range(n)] for i in range(n)] \nfor i in range(m):\n l,r=map(int,input().split())\n L[l-1][r-1]+=1\nfor i in range(n):\n LL[i][0]=L[i][0]\n for j in range(1,n):\n LL[i][j]=LL[i][j-1]+L[i][j]\nfor i in range(q):\n p,q=map(int,input().split())\n ans=0\n for j in range(p-1,q):\n ans+=LL[j][q-1]-LL[j][p-1]\n print(ans)', 'import sys\ninput=lambda: sys.stdin.readline().rstrip()\nn,m,q=map(int,input().split())\nT=[[0]*(n+2) for _ in range(n+2)]\nfor _ in range(m):\n l,r=map(int,input().split())\n T[l][r]+=1\nfor i in range(1,n+1)[::-1]:\n for j in range(1,n+1):\n T[i][j+1]+=T[i][j]\nfor j in range(1,n+1):\n for i in range(1,n+1)[::-1]: \n T[i-1][j]+=T[i][j]\n\nfor _ in range(q):\n p,q=map(int,input().split())\n print(T[p][q])'] | ['Wrong Answer', 'Accepted'] | ['s123960947', 's518078862'] | [9332.0, 9740.0] | [3160.0, 712.0] | [407, 405] |
p03283 | u970899068 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['import itertools\nimport numpy as np\nn,m,q=map(int, input().split()) \na=[list(map(int, input().split())) for i in range(m)]\nb=[list(map(int, input().split())) for i in range(q)]\n\nx=[[0]*(501) for i in range(501)]\nx=np.array\nfor i in range(m):\n x[a[i][0],a[i][1]]+=1\n\n\n\nfor i in range(501):\n x[i] = list(itertools.accumulate(x[i]))\n \nfor i in range(501):\n x[:,i] = list(itertools.accumulate(x[:,i]))\n\n\n\nfor i in range(q):\n print(x[b[i][1],b[i][1]]-x[b[i][1],b[i][0]-1]-x[b[i][0-1,b[i][1]]+x[b[i][0-1,b[i][0-1])\n\n\n\n \n\n\n\n\n\n', 'import sys\ninput = sys.stdin.readline\n\nn,m,q= map(int, input().split())\na= [list(map(int, input().split())) for i in range(m)]\nb= [list(map(int, input().split())) for i in range(q)]\n\n\n\nc=[[0]*(n+1) for i in range(n+1)]\nfor i,j in a:\n c[i][j]+=1\n\nfor i in range(1,n+1):\n for j in range(1,n+1):\n c[i][j] += c[i - 1][j]+c[i][j - 1]-c[i-1][j-1]\n\nfor i,j in b:\n ans=c[j][j]-c[i-1][j]-c[j][i-1]+c[i-1][i-1]\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s374633228', 's658521361'] | [3064.0, 77056.0] | [17.0, 820.0] | [533, 451] |
p03283 | u979823197 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N,M,Q=map(int,input().split())\nL,R=[],[]\nfor i in range(M):\n l,r=map(int,input().split())\n L.append(l)\n R.append(r)\nPl,Ql=[],[]\nfor i in range(Q):\n pq=list(map(int,input().split()))\n Pl.append(pq[0])\n Ql.append(pq[1])\nc=[[0 for i in range(N+1)] for i in range(N+1)]\nfor i in range(M):\n c[L[i]][R[i]]+=1\nfor i in range(1,N+1):\n for j in range(1,N+1):\n c[i][j]+=c[i][j-1]\nfor i in range(1,N+1):\n for j in range(1,N+1):\n c[i][j]+=c[i-1][j]\nfor i in range(Q):\n ans=c[R[i]][R[i]]-c[L[i]-1][R[i]]-c[R[i]][L[i]-1]+c[L[i]-1][L[i]-1]\n print(ans)', 'N,M,Q=map(int,input().split())\nL,R=[],[]\nfor i in range(M):\n l,r=map(int,input().split())\n L.append(l)\n R.append(r)\nPl,Ql=[],[]\nfor i in range(Q):\n pq=list(map(int,input().split()))\n Pl.append(pq[0])\n Ql.append(pq[1])\nc=[[0 for i in range(N+1)] for i in range(N+1)]\nfor i in range(M):\n c[L[i]][R[i]]+=1\nfor i in range(1,N+1):\n for j in range(1,N+1):\n c[i][j]+=c[i][j-1]\nfor i in range(1,N+1):\n for j in range(1,N+1):\n c[i][j]+=c[i-1][j]\nfor i in range(Q):\n ans=c[Ql[i]][Ql[i]]-c[Pl[i]-1][Ql[i]]-c[Ql[i]][Pl[i]-1]+c[Pl[i]-1][Pl[i]-1]\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s512537092', 's005389611'] | [27744.0, 27768.0] | [1245.0, 1274.0] | [553, 561] |
p03283 | u995062424 | 3,000 | 1,024,000 | In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called _AtCoder Express_ possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i). Takahashi the king is interested in the following Q matters: * The number of the trains that runs **strictly within** the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i. Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him. | ['N, M, Q = map(int, input().split())\ntrain = [[0 for _ in range(N+1)] for _ in range(N+1)]\n\nfor i in range(M):\n l, r = map(int, input().split())\n train[l][r] +=1\n \nfor i in range(N+1):\n for j in range(N):\n train[i][j+1] += train[i][j]\n \nfor i in range(N):\n for j in range(N+1):\n train[i+1][j] += train[i][j]\n \nfor i in range(Q):\n p, q = map(int, input().split())\n print(train[q][q]+train[p-1][p-1]-train[p-1][q]-train[q-1][p])', 'N, M, Q = map(int, input().split())\ntrain = [[0 for _ in range(N+1)] for _ in range(N+1)]\n\nfor i in range(M):\n l, r = map(int, input().split())\n train[l][r] +=1\n \nfor i in range(N+1):\n for j in range(N):\n train[i][j+1] += train[i][j]\n \nfor i in range(N):\n for j in range(N+1):\n train[i+1][j] += train[i][j]\n \nfor i in range(Q):\n p, q = map(int, input().split())\n print(train[q][q]+train[p-1][p-1]-train[p-1][q]-train[q][p-1])'] | ['Wrong Answer', 'Accepted'] | ['s858980540', 's992424336'] | [13396.0, 13396.0] | [1615.0, 1612.0] | [474, 474] |
p03284 | u009219947 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ["import sys\n\nN = int(input())\n\nfor i in range(26):\n for j in range(16):\n if N == i * 4 + j * 7:\n print('Yes')\n sys.exit()\nprint('No')", "N, K = list(map(int, input().split(' ')))\nprint(0 if N % K == 0 else 1)"] | ['Runtime Error', 'Accepted'] | ['s828461677', 's325942210'] | [2940.0, 2940.0] | [20.0, 17.0] | [146, 71] |
p03284 | u015993380 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['n,k = map(int,input().split())\nprint(n%k != 0)', 'n,k = map(int,input().split())\nprint(0 if n%k == 0 else 1)'] | ['Wrong Answer', 'Accepted'] | ['s218121799', 's186074882'] | [2940.0, 2940.0] | [17.0, 17.0] | [46, 58] |
p03284 | u016901717 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['n = int(input())\nprint(n if n%2==0 else n*2)', 'n,k = map(int,input().split())\nprint(0 if n%k==0 else 1)'] | ['Runtime Error', 'Accepted'] | ['s001668996', 's196961680'] | [2940.0, 2940.0] | [17.0, 17.0] | [44, 56] |
p03284 | u021548497 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['n, k = map(int, input().split())\nprint(1 if n % k == 0 else 0)', 'n, k = map(int, input().split())\nprint(0 if n % k == 0 else 1)'] | ['Wrong Answer', 'Accepted'] | ['s819024670', 's012402969'] | [3064.0, 2940.0] | [17.0, 17.0] | [62, 62] |
p03284 | u029234056 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['N,K=map(int,input().split())\nif(N%K==0):\n print(0)\n else:\n print(1)', 'N,K=map(int,input().split())\nif N%K==0:\n print(0)\nelse:\n print(1)'] | ['Runtime Error', 'Accepted'] | ['s041643350', 's518458591'] | [2940.0, 2940.0] | [17.0, 17.0] | [69, 71] |
p03284 | u031157253 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['a,b=map(int,input().split())\nprint((int)a%b==0)', 'a,b=map(int,input().split())\nprint(int(a%b!=0))'] | ['Runtime Error', 'Accepted'] | ['s737717894', 's027536491'] | [2940.0, 2940.0] | [17.0, 17.0] | [47, 47] |
p03284 | u031358594 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['N,K=(int(i) for i in input().split())\n\nres=list()\n\nfor i in range(0,K):\n res.append(0)\n\nprint(res)\nj=0\ni=0\n\nwhile N>0:\n j=0\n while j<len(res):\n if N<=0:\n break\n res[j]=res[j]+1\n N=N-1\n j+=1\n #print(str(N)+"::"+str(res))\n\n\nMinCount=min(res)\n\nMaxCount=max(res)\n\nprint(MaxCount-MinCount)\n', 'N,K=(int(i) for i in input().split())\n\nres=list()\n\nfor i in range(0,K):\n res.append(0)\n\nj=0\ni=0\n\nwhile N>0:\n j=0\n while j<len(res):\n if N<=0:\n break\n res[j]=res[j]+1\n N=N-1\n j+=1\n #print(str(N)+"::"+str(res))\n\n\nMinCount=min(res)\n\nMaxCount=max(res)\n\nprint(MaxCount-MinCount)\n\n \n'] | ['Wrong Answer', 'Accepted'] | ['s911462459', 's104593395'] | [3060.0, 3064.0] | [17.0, 17.0] | [340, 339] |
p03284 | u034369223 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ["string = input()\nN, K = string.split(' ')\nif N % K == 0:\n print(0)\nelse:\n print(1)\n", "import sys\nN = int(input())\nfor i in range(int(N/4)):\n amount = (i + 1) * 4\n for j in range(int(N/7)):\n amount += 7\n if(amount == N):\n print('Yes')\n sys.exit()\nprint('No')\n", "string = input()\narray = string.split(' ')\nN = int(array[0])\nK = int(array[1])\nif N % K == 0:\n print(0)\nelse:\n print(1)\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s263256684', 's965345371', 's001258786'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [89, 214, 126] |
p03284 | u036340997 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['n, k = map(int, input())\nif n % k == 0:\n print(0)\nelse:\n print(1)', 'n, k = map(int, input().split())\nif n % k == 0:\n print(0)\nelse:\n print(1)\n'] | ['Runtime Error', 'Accepted'] | ['s167292203', 's345875298'] | [2940.0, 2940.0] | [17.0, 17.0] | [67, 76] |
p03284 | u041111386 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['N, K = map(int, input().split())\nif N % K == :\n print(0)\nelse:\n print(1)', 'N, K = map(int, input().split())\nif N % K == 0:\n print(0)\nelse:\n print(1)'] | ['Runtime Error', 'Accepted'] | ['s275766333', 's874152607'] | [8944.0, 9004.0] | [22.0, 30.0] | [74, 75] |
p03284 | u043236471 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ['b, k = [int(i) for i in input().split()]\nprint(b%k != 0)', 'b, k = [int(i) for i in input().split()]\nprint(1) if b%k else print(0)'] | ['Wrong Answer', 'Accepted'] | ['s069708010', 's344999875'] | [2940.0, 3064.0] | [17.0, 17.0] | [56, 70] |
p03284 | u050121913 | 2,000 | 1,048,576 | Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. | ["n,k = int(input().split(' '))\ns = 1\nif n%k==0:\n\ts-=1\nprint(s)", "n = list(map(int,input().split(' ')))\ns = 1\nif n[0]%n[1]==0:\n\ts-=1\nprint(s)"] | ['Runtime Error', 'Accepted'] | ['s067367024', 's521909714'] | [2940.0, 2940.0] | [17.0, 17.0] | [61, 75] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.