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
p03295
u353797797
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(m)]\nab.sort(reverse=True)\nL=10**6\nans=0\nfor a,b in ab[::-1]:\n if not a<=L<b:\n ans+=1\n L=a\nprint(ans)', 'n,m=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(m)]\nab.sort()\nL=10**6\nans=0\nfor a,b in ab[::-1]:\n if not a<=L<b:\n ans+=1\n L=a\nprint(ans)']
['Wrong Answer', 'Accepted']
['s307207404', 's720425454']
[29280.0, 28276.0]
[494.0, 503.0]
[196, 184]
p03295
u362347649
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["N, M = map(int, input().split())\nislands = [map(int, input().split()) for _ in range(M)]\nislands.sort()\n\ncnt = 0\nlast = -float('inf')\nfor left, right in islands:\n if last <= left:\n cnt += 1\n last = right\n\nprint(cnt)\n", "import sys\nfrom operator import itemgetter\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n \ndef main():\n N, M = map(int, readline().split())\n ab = map(int, read().split())\n ab = sorted(zip(ab, ab), key=itemgetter(1))\n \n east_island = ab[0][1]\n answer = 1\n \n for i, j in ab:\n if i >= east_island:\n answer += 1\n east_island = j\n \n print(answer)\n \n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s022449743', 's092941946']
[48796.0, 29956.0]
[358.0, 159.0]
[233, 471]
p03295
u375616706
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\ncut = []\nfor _ in range(M):\n a, b = map(int, input().split())\n cut.append([a, b])\n\ncut = sorted(cut, key=lambda x: x[0])\n\nans = 1\nind = 0\n\nprint(cut)\n\ns = cut[ind][0]\ne = cut[ind][1]\nwhile ind < M:\n n_s, n_e = cut[ind]\n if n_s < e:\n e = min(e, n_e)\n else:\n s = n_s\n e = n_e\n ans += 1\n ind += 1\n\n\nprint(ans)\n', '# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\ncut = []\nfor _ in range(M):\n a, b = map(int, input().split())\n cut.append([a, b])\n\ncut = sorted(cut, key=lambda x: x[0])\n\nans = 1\nind = 0\n\n\ns = cut[ind][0]\ne = cut[ind][1]\nwhile ind < M:\n n_s, n_e = cut[ind]\n if n_s < e:\n e = min(e, n_e)\n else:\n s = n_s\n e = n_e\n ans += 1\n ind += 1\n\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s846966920', 's670104546']
[25236.0, 22124.0]
[418.0, 360.0]
[485, 474]
p03295
u379959788
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['# ABC103D\n\n\n# ex) 1-10, 2-5, 6-8\n\nN, M = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(M)]\nab.sort(key=lambda x: x[1])\nprint(ab)\nans = 1 \ntmp = ab[0][1] - 0.1 \nfor i in range(1, M):\n if ab[i][0] < tmp < ab[i][1]: \n pass\n else: \n ans += 1\n tmp = ab[i][1] - 0.1\n\nprint(ans)', 'N, M = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(M)]\nab.sort(key=lambda x: x[1])\nans = 1\ntmp = ab[0][1]\nfor i in range(1, M):\n if tmp <= ab[i][0]:\n ans += 1\n tmp = ab[i][1]\nprint(ans)']
['Wrong Answer', 'Accepted']
['s331289310', 's202844728']
[33020.0, 29084.0]
[506.0, 427.0]
[743, 237]
p03295
u389910364
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import bisect\nimport heapq\nimport itertools\nimport math\nimport os\nimport re\nimport string\nimport sys\nfrom collections import Counter, deque, defaultdict\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom fractions import gcd\nfrom functools import lru_cache, reduce\nfrom operator import itemgetter\n\nimport numpy as np\n\nif os.getenv("LOCAL"):\n sys.stdin = open("_in.txt", "r")\n\nsys.setrecursionlimit(2147483647)\nINF = float("inf")\nIINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN, M = list(map(int, sys.stdin.readline().split()))\nAB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]\n\nheap = []\n\nans = 0\nfor a, b in AB:\n if heap and a >= heap[0]:\n heap = []\n ans += 1\n heapq.heappush(heap, b)\nif heap:\n ans += 1\nprint(ans)\n', 'import os\nimport sys\n\nimport numpy as np\n\nif os.getenv("LOCAL"):\n sys.stdin = open("_in.txt", "r")\n\nsys.setrecursionlimit(10 ** 9)\nINF = float("inf")\nIINF = 10 ** 18\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nN, M = list(map(int, sys.stdin.buffer.readline().split()))\nAB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]\n\nAB.sort()\n\ncounts = np.zeros(N, dtype=int)\nstack = []\nans = 0\np = 0\nfor a, b in AB:\n a -= 1\n b -= 1\n while True:\n if counts[p] > 0:\n while stack:\n r = stack.pop()\n counts[r] -= 1\n ans += 1\n if p >= a:\n break\n p += 1\n stack.append(b)\n counts[b] += 1\n # print(a, b, p, ans)\nif stack:\n ans += 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s174676430', 's428025947']
[37312.0, 38368.0]
[374.0, 976.0]
[759, 751]
p03295
u392029857
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['def main():\n input = sys.stdin.readline\n n, m = map(int, input().split())\n a_b = [list(map(int, input().split())) for i in range(m)]\n a_b.sort(key=itemgetter(1))\n end = a_b[0][1]-2\n ans = 1 \n for i in range(m):\n if a_b[i][0]-1 > end:\n end = a_b[i][1]-2\n ans += 1\n print(ans)\nif __name__ == "__main__":\n main()', 'from operator import itemgetter\nimport sys\ndef main():\n input = sys.stdin.readline\n n, m = map(int, input().split())\n a_b = [list(map(int, input().split())) for i in range(m)]\n a_b.sort(key=itemgetter(1))\n end = a_b[0][1]-2\n ans = 1 \n for i in range(m):\n if a_b[i][0]-1 > end:\n end = a_b[i][1]-2\n ans += 1\n print(ans)\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s262646815', 's724815288']
[3064.0, 29136.0]
[17.0, 258.0]
[365, 408]
p03295
u397496203
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = [int(i) for i in input().split()]\nwars = [[int(i) for i in input().split()] for _ in range(M)]\n\nwars.sort(key=lambda x:x[1],reverse=False)\nr = set()\n\nfor war in wars:\n for i in set():\n if i <= war[1] and i >= war[0]:\n break\n else:\n r.add(war[1]-1)\n\nprint(len(r))', 'N,M = [int(i) for i in input().split()]\nwars = [[int(i) for i in input().split()] for _ in range(M)]\n\nwars.sort(key=lambda x:x[1],reverse=False)\nr = set()\nfor war in wars:\n for i in r:\n if war[0] <= i and i <= war[1]:\n break\n else:\n r.add(war[1]-1)\n \n\nprint(len(r))']
['Wrong Answer', 'Accepted']
['s654977447', 's299055883']
[26008.0, 22820.0]
[442.0, 546.0]
[299, 299]
p03295
u414920281
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['a=[""]*m\nb=[""]*m\nfor i in range(m):\n x,l=map(int,input().split())\n a[i]=x*10+5\n b[i]=l*10-5\nst=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1))\nans=0\nlast=0\nlast=-float("inf")\nfor i in range(m):\n if last<st[i][0]:\n ans+=1\n last=st[i][1]\nprint(ans)', 'from operator import itemgetter\nn,m=map(int,input().split())\na=[""]*m\nb=[""]*m\nfor i in range(m):\n x,l=map(int,input().split())\n a[i]=x*10+5\n b[i]=l*10-5\nst=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1))\nans=0\nlast=0\nlast=-float("inf")\nfor i in range(m):\n if last<st[i][0]:\n ans+=1\n last=st[i][1]\nprint(ans)']
['Runtime Error', 'Accepted']
['s683717264', 's054796387']
[3064.0, 20600.0]
[18.0, 419.0]
[284, 345]
p03295
u415905784
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\nI = [N + 1 for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n I[a - 1] = min(I[a - 1], b - 1)\ncut = 0\nfor i in range(N):\n if I[i] == i + 1:\n cut += 1\n else:\n I[i + 1] = min(I[i + 1], I[i])\nprint(cut)', 'N, M = map(int, input().split())\nI = [[N + 1] for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n I[a - 1].append(b - 1)\ncut = 0\nfor i in range(N - 1):\n if min(I[i]) == i + 1:\n cut += 1\n else:\n I[i + 1].append(min(I[i]))\nprint(cut)']
['Runtime Error', 'Accepted']
['s097464866', 's697352452']
[7164.0, 22260.0]
[487.0, 485.0]
[264, 262]
p03295
u440129511
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(m)]\nl.sort(key=lambda x:x[1])\nlb=0\nans=0\nfor a,b in l:\n if a>=lb:\n lb=b\n ans+=1\nprint(ans)', 'n,m=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(m)]\nl.sort(key=lambda x:x[1])\nlb=0\nc=0\nfor a,b in l:\n if a>=lb:\n lb=b\n c+=1\nprint(c)']
['Runtime Error', 'Accepted']
['s357373335', 's677750619']
[27380.0, 29084.0]
[330.0, 459.0]
[186, 179]
p03295
u451017206
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\ns = set(range(1,N))\nans = 1\nm = []\nfor i in range(M):\n a, b = map(int, input().split())\n m.append((a,b))\ni = 0\nwhile i < M:\n a, b = m[i]\n s = s & set(range(a,b))\n print(s)\n if len(s) == 0:\n ans += 1\n s = set(range(1,N))\n i -= 1\n i += 1\nprint(ans)\n', 'N, M = map(int, input().split())\nm = []\nfor i in range(M):\n a, b = map(int, input().split())\n m.append((a,b-1))\nans = 0\nt = None\nfor l,r in sorted(m, key=lambda x:x[1]):\n if t is None or l > t:\n t = r\n ans += 1\nprint(ans) \n']
['Wrong Answer', 'Accepted']
['s083992941', 's807436137']
[61620.0, 18972.0]
[2106.0, 382.0]
[322, 249]
p03295
u456353530
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = list(map(int, input().split()))\nD = []\nL = [0] * N\nfor i in range(M):\n D.append(list(map(int, input().split())))\nD.sort(key = lambda x: x[1])\n\nAns = 0\nRe = 0\nfor i in D:\n if Re < i[0]:\n Re = i[0]\n Ans += 1\nprint(Ans)', 'N, M = list(map(int, input().split()))\nD = []\nL = [0] * N\nfor i in range(M):\n D.append(list(map(int, input().split())))\nD.sort(key = lambda x: x[1])\n\nAns = 0\nRe = 0\nfor i in D:\n if Re < i[0]:\n Re = i[1]-1\n Ans += 1\nprint(Ans)']
['Wrong Answer', 'Accepted']
['s620532440', 's433139425']
[29844.0, 29844.0]
[455.0, 459.0]
[231, 233]
p03295
u462434199
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\ne = []\nfor i in range(m):\n e.append(list(map(int, input, split())))\n\ne.sort(key=lambda x:x[1])\nret = 0\n\nl = 0\nfor i in range(m):\n if e[i][0] < l:\n continue\n else:\n l = e[i][1]\n ret += 1\n \nprint(ret)', 'n, m = map(int, input().split())\ne = []\nfor i in range(m):\n e.append(list(map(int, input().split())))\n\ne.sort(key=lambda x:x[1])\nret = 0\n\nl = 0\nfor i in range(m):\n if e[i][0] < l:\n continue\n else:\n l = e[i][1]\n ret += 1\n \nprint(ret)']
['Runtime Error', 'Accepted']
['s243822969', 's512523933']
[3064.0, 29072.0]
[17.0, 514.0]
[246, 247]
p03295
u466917094
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nmx =[0 for i in range(0,n)]\nfor z in range(0,m):\n a,b=map(int,input().split())\n mx[b-1]=max(mx[b-1],a-1)\ncut=-1\ncn=0\nfor z in range(0,n):\n\tif cut<mx[z]:\n\t\tcut=z-1\n\t\tcn=cn+1\nprint(cn)', 'n,m=map(int,input().split())\nmx =[0 for i in range(0,n)]\nfor z in range(0,m):\n a,b=map(int,input().split())\n mx[b]=max(mx[b],a)\ncnt=0\ncn=0\nfor z in range(0,n):\n if cut<mx[z]:\n \tcut=z\n cn=cn+1\nprint(cn)', 'n,m=map(int,input().split())\nmx =[0 for i in range(0,n)]\nfor z in range(0,m):\n a,b=map(int,input().split())\n mx[b-1]=max(mx[b-1],a-1)\ncut=0\ncn=0\nfor z in range(0,n):\n if cut<mx[z]:\n \tcut=z\n cn=cn+1\nprint(cn)', 'n,m=map(int,input().split())\nmx =[-1 for i in range(0,n)]\nfor z in range(0,m):\n a,b=map(int,input().split())\n mx[b-1]=max(mx[b-1],a-1)\ncut=-1\ncn=0\nfor z in range(0,n):\n\tif cut<mx[z]:\n\t\tcut=z-1\n\t\tcn=cn+1\nprint(cn)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s338543491', 's385705499', 's462561436', 's159834236']
[6040.0, 2940.0, 2940.0, 6040.0]
[354.0, 18.0, 17.0, 351.0]
[213, 209, 215, 214]
p03295
u470936782
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = [int(str) for str in input().strip().split()]\nAB = [[int(str) for str in input().strip().split()] for _ in range(M)]\n\nA_B = [[] for i in range(N)]\nfor ab in AB:\n A_B[ab[0]].append(ab[1])\nfor a_b in A_B:\n a_b.sort()\n\nprint(A_B)\n\ni = 0\nleft = 10 ** 6\nans = 1\nfor i in range(N):\n if len(A_B[i]):\n if i > left:\n print(i, A_B[i])\n ans += 1\n left = min(left, A_B[i][0] - 1)\n i += 1\n\nprint(ans)', '#!/usr/bin/env python3\nN, M = [int(str) for str in input().strip().split()]\nab = [[int(str) for str in input().strip().split()] for _ in range(M)]\n\n\ndef solve():\n ab.sort(key=lambda x: x[1])\n ans = 0\n broken = 0\n for a, b in ab:\n if a < broken:\n continue\n broken = b\n ans += 1\n print(ans)\n\nsolve()\n']
['Wrong Answer', 'Accepted']
['s562669650', 's932969389']
[35712.0, 22840.0]
[697.0, 404.0]
[446, 345]
p03295
u474270503
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M=map(int,input().split())\n\ndata = []\ndata2=[]\nfor i in range(M):\n data.append(list(map(int, input().split())))\n data2.append(list(range(10*data[i][0]+5,10*data[i][1]+1-5,5)))\nprint(data2)\nans=set(data2[0])\nct=1\nfor i in range(1,M):\n if len(ans.intersection(set(data2[i])))>0:\n ans = ans.intersection(set(data2[i]))\n print(ans)\n else:\n ct+=1\n ans=set(data2[i])\nprint(ct)\n\n# A=list(AB[0])\n# B=list(AB[1])\n#\n# print(A)\n\n', 'N,M=map(int, input().split())\nAB=list(sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x :x[1]))\nans=1\nA=[AB[0]]\nfor i in range(1,M):\n if AB[i][0]>=A[-1][1]:\n ans+=1\n A.append(AB[i])\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s486978990', 's489628224']
[3188.0, 29848.0]
[2278.0, 452.0]
[501, 233]
p03295
u477977638
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\n\n\n\n\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\ndef II(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int,input().split()))\ndef LF(): return list(map(float,input().split()))\ndef TI(): return tuple(map(int,input().split()))\n# rstrip().decode()\n\n#import numpy as np\n\ndef main():\n\tn,m=MI()\n\tli=[LI() for _ in range(m)]\n\n\tli.sort(key=lambda x:x[1])\n\tprint(li)\n\n\tnow=0\n\tans=0\n\n\tfor a,b in li:\n\t\tif now<=a:\n\t\t\tnow=b\n\t\t\tans+=1\n\tprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == "__main__":\n\tmain()\n', 'import sys\ninput = sys.stdin.buffer.readline\n\n\n\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\ndef II(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int,input().split()))\ndef LF(): return list(map(float,input().split()))\ndef TI(): return tuple(map(int,input().split()))\n# rstrip().decode()\n\n#import numpy as np\n\ndef main():\n\tn,m=MI()\n\tli=[LI() for _ in range(m)]\n\n\tli.sort(key=lambda x:x[1])\n\t#print(li)\n\n\tnow=0\n\tans=0\n\n\tfor a,b in li:\n\t\tif now<=a:\n\t\t\tnow=b\n\t\t\tans+=1\n\tprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == "__main__":\n\tmain()\n']
['Wrong Answer', 'Accepted']
['s727903877', 's538932329']
[30952.0, 28660.0]
[335.0, 175.0]
[678, 678]
p03295
u496821919
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\n\nN,M = map(int,input().split())\n\na = []\nb = []\n\nfor i in range(M):\n ao,bo = map(int,input().split())\n a.append(ao)\n b.append(bo)\n\nab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))\n\nans = 0\nlast = 0\n\nfor i in range(N):\n if last <= ab[i][0]:\n ans += 1\n last = ab[i][1]\n\nprint(ans)\n', 'from operator import itemgetter\n\nN,M = map(int,input().split())\n\na = []\nb = []\n\nfor i in range(M):\n ao,bo = map(int,input().split())\n a.append(ao)\n b.append(bo)\n\nab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))\n\nans = 0\nlast = 0\n\nfor i in range(M):\n if last <= ab[i][0]:\n ans += 1\n last = ab[i][1]\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s644747722', 's990981866']
[20604.0, 20636.0]
[392.0, 391.0]
[353, 353]
p03295
u517910772
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["islands = []\nbridges = []\n\nN, M = map(int, input().split())\n# N, M = 10, 5\n# islands = [\n# {'a': 1, 'b': 10},\n# {'a': 2, 'b': 5},\n# {'a': 1, 'b': 9},\n# {'a': 2, 'b': 4},\n# {'a': 1, 'b': 2},\n# ]\n\nfor i in range(M):\n a, b = map(int, input().split())\n islands.append({'a': a, 'b': b})\n\nislands.sort(key=lambda x: (x['a'], x['b']))\n# print(islands)\n\nfor i in islands:\n b = [j for j in bridges if j >= i['a']]\n b = [j for j in b if j < i['b']]\n if len(b) == 0:\n bridges.append(i['b'] - 1)\n\nprint(bridges)\n", "islands = []\nbridges = []\n\nN, M = map(int, input().split())\n\nfor i in range(M):\n a, b = map(int, input().split())\n islands.append({'a': a, 'b': b})\n\nislands.sort(key=lambda x: x['b'])\n# print(islands)\n\nfor i in islands:\n b = [j for j in bridges if j >= i['a']]\n if len(b) == 0:\n bridges.append(i['b'] - 1)\n\n# print(bridges)\nprint(len(bridges))\n"]
['Wrong Answer', 'Accepted']
['s394482661', 's389014317']
[48368.0, 41612.0]
[1610.0, 1919.0]
[542, 363]
p03295
u527420996
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\nn, m = (int(i) for i in input().split())\ne = [[int(i) for i in input().split()] for i in range(m)]\ng = 1\ne.sort(key = itemgetter(1))\nprint(e)\nfor i in range(m):\n if i == 0:\n a = e[0][1] - 1\n print(a)\n else:\n if a >= e[i][0]:\n pass\n else:\n g += 1\n a = e[i][1] - 1\nprint(g)', 'from operator import itemgetter\nn, m = (int(i) for i in input().split())\ne = [[int(i) for i in input().split()] for i in range(m)]\ng = 1\ne.sort(key = itemgetter(1))\nfor i in range(m):\n if i == 0:\n a = e[0][1] - 1\n else:\n if a >= e[i][0]:\n pass\n else:\n g += 1\n a = e[i][1] - 1\nprint(g)']
['Wrong Answer', 'Accepted']
['s701412089', 's237426640']
[26768.0, 22876.0]
[461.0, 389.0]
[370, 344]
p03295
u530473641
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\nl = [list(map(int, input().split())) for i in range(M)]\nl = sorted(l, key = lambda l:(l[1]))\n\nprint(l)\n\np_num = -1\nans = 0\n\nfor i in range(M):\n\tif not l[i][0] <= p_num:\n\t\tp_num = l[i][1] - 1\n\t\tans += 1\n\nprint(ans)', 'N, M = map(int, input().split())\nl = [list(map(int, input().split())) for i in range(M)]\nl = sorted(l, key = lambda l:(l[1]))\n\np_num = -1\nans = 0\n\nfor i in range(M):\n\tif not l[i][0] <= p_num:\n\t\tp_num = l[i][1] - 1\n\t\tans += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s179069132', 's071162875']
[33016.0, 29852.0]
[496.0, 441.0]
[246, 236]
p03295
u533885955
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\nN,M=map(int,input().split())\nkyomu=[]\nfor i in range(M):\n a,b=map(int,input().split())\n kyomulen=len(kyomu)\n j=0\n flag=0\n for j in range(kyomulen):\n if a>=kyomu[j][0] and b<=kyomu[j][1]:\n del kyomu[j]\n kyomu.append([a,b])\n flag=1\n break\n if flag == 0:\n kyomu.append([a,b])\nprint(len(kyomu))', '\nN,M=map(int,input().split())\nAB=[list(map(int,input().split())) for i in range(M)]\nAB=sorted(AB, key=lambda x: x[1])\nbridges=[]\nfor i in range(M):\n if len(bridges) == 0:\n bridges.append(AB[i][1]-1)\n elif max(bridges)>=AB[i][0]:\n pass\n else:\n bridges.append(AB[i][1]-1)\nprint(len(bridges))']
['Wrong Answer', 'Accepted']
['s668603768', 's116426179']
[3692.0, 29848.0]
[2104.0, 956.0]
[375, 327]
p03295
u540761833
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\nab = []\nfor i in range(M):\n ab.append(list(map(int,input().split())))\nab.sort(key = lambda ab:ab[1])\ncount = 0\nnow = 0\nprint(ab)\nfor a,b in ab:\n if a >= now:\n count += 1\n now = b\nprint(count)', 'N,M = map(int,input().split())\nab = []\nfor i in range(M):\n ab.append(list(map(int,input().split())))\nab.sort(key = lambda ab:ab[1])\ncount = 0\nnow = 0\nfor a,b in ab:\n if a >= now:\n count += 1\n now = b\nprint(count)']
['Wrong Answer', 'Accepted']
['s009632777', 's103667019']
[33020.0, 29076.0]
[544.0, 443.0]
[242, 232]
p03295
u545368057
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\nbridges = []\nfor i in range(M):\n bridges.append(list(map(int, input().split())))\nbridges.sort(key=itemgetter(1))\nb_right = 0\ncnt = 0\nfor a,b in bridges:\n if a > b_right:\n b_right = b - 1\n cnt += 1\nprint(cnt) \n', 'N, M = map(int, input().split())\nfrom operator import itemgetter\nbridges = []\nfor i in range(M):\n bridges.append(list(map(int, input().split())))\nbridges.sort(key=itemgetter(1))\nb_right = 0\ncnt = 0\nfor a,b in bridges:\n if a > b_right:\n b_right = b - 1\n cnt += 1\nprint(cnt) \n']
['Runtime Error', 'Accepted']
['s477953930', 's387687332']
[3060.0, 29148.0]
[18.0, 451.0]
[261, 294]
p03295
u553348533
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\na = [0 for i in range(M)]\nb = [0 for i in range(M)]\nfor i in range(M):\n A,B = map(int,input().split())\n a[i] = A\n b[i] = B\n\nans = 0\nwhile 1:\n if len(a) == 0:\n break\n maxVal = max(a)\n if ans == 0:\n maxVal = maxVal // 2\n maxIdx = a.index(maxVal)\n\n for j in reversed(range(len(a))):\n if a[j] <= maxVal <= b[j] - 1:\n a.pop(j)\n b.pop(j)\n\n ans += 1\n\nprint(ans)', 'N,M = map(int,input().split())\nlistAB = [list(map(lambda x:int(x),input().split())) for i in range(M)]\n\nlistAB.sort(key=lambda x: x[1])\n\nlast = -1\nans = 0\nfor a,b in listAB:\n \n if last <= a:\n ans += 1\n \n last = b\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s791730639', 's308169060']
[13096.0, 29112.0]
[2104.0, 485.0]
[455, 390]
p03295
u562016607
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M=map(int, input().split())\nG=[list() for i in range(N)]\nfor i in range(M):\n a,b=map(int,input().split())\n a-=1\n b-=1\n G[a].append(b)\n G[b].append(a)\nans=0\nindex=-1\nfor i in range(1,N):\n for p in G[i]:\n if index<p<i:\n ans+=1\n index=i-1\nprint(ans)\nif N==5 and M==2:\n print("ans")', 'N,M=map(int, input().split())\nG=[list() for i in range(N)]\nfor i in range(M):\n a,b=map(int,input().split())\n a-=1\n b-=1\n G[a].append(b)\n G[b].append(a)\nans=0\nindex=-1\nfor i in range(1,N):\n for p in G[i]:\n if index<p<i:\n ans+=1\n index=i-1\n break\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s903566780', 's393447218']
[21424.0, 21424.0]
[444.0, 454.0]
[330, 314]
p03295
u569970656
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\nn, m = map(int, input().split())\nbridge = 0\nab = []\nfor _ in range(m):\n a, b = map(int, input().split())\n ab.append((a,b))\nab = sorted(ab, key=itemgetter(1))\ncount = 0\nfor a, b in ab:\n if not a <= bridge <= b:\n counr += 1\n bridge = b\nprint(count)\n', 'from operator import itemgetter\nn, m = map(int, input().split())\nbridge = 0\nab = []\nfor _ in range(m):\n a, b = map(int, input().split())\n ab.append((a,b))\nab = sorted(ab, key=itemgetter(1))\ncount = 0\nfor a, b in ab:\n if not a <= bridge <= b:\n count += 1\n bridge = b-1\nprint(count)\n']
['Runtime Error', 'Accepted']
['s595710272', 's985827077']
[18992.0, 18980.0]
[359.0, 378.0]
[288, 290]
p03295
u572012241
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["import heapq\nfrom sys import stdin\ninput = stdin.readline\n\n\n\n# n = int(input())\nn,m = map(int, input().split())\n# a = list(map(int,input().split()))\n\n\nab=[]\nfor i in range(m):\n a,b = map(int, input().split())\n ab.append((a,b))\nab = sorted(ab, key = lambda x: x[1])\n\n \ndef main():\n left = 0\n ans = 0\n for a,b in ab:\n print(a,b)\n if left < a:\n left = b-1\n ans +=1\n print(ans)\n\n\n \n \n\nif __name__ == '__main__':\n main()", "import heapq\nfrom sys import stdin\ninput = stdin.readline\n\n\n\n# n = int(input())\nn,m = map(int, input().split())\n# a = list(map(int,input().split()))\n\n\nab=[]\nfor i in range(m):\n a,b = map(int, input().split())\n ab.append((a,b))\nab = sorted(ab, key = lambda x: x[1])\n\n \ndef main():\n left = 0\n ans = 0\n for a,b in ab:\n\n if left < a:\n left = b-1\n ans +=1\n print(ans)\n\n\n \n \n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s252384694', 's971266471']
[19096.0, 19096.0]
[338.0, 227.0]
[539, 521]
p03295
u575431498
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['a_b = []\nfor _ in range(M):\n a, b = map(int, input().split())\n a_b.append((a, b))\na_b.sort(key=lambda x: x[0])\n\nr = a_b[0][1]\nans = 1\nfor a, b in a_b[1:]:\n if a >= r:\n r = b\n ans += 1\n continue\n if b < r:\n r = b\nprint(ans)', 'N, M = map(int, input().split())\na_b = []\nfor _ in range(M):\n a, b = map(int, input().split())\n a_b.append((a, b))\na_b.sort(key=lambda x: x[0])\n\nr = a_b[0][1]\nans = 1\nfor a, b in a_b[1:]:\n if a >= r:\n r = b\n ans += 1\n continue\n if b < r:\n r = b\nprint(ans)']
['Runtime Error', 'Accepted']
['s588886257', 's097635093']
[3064.0, 18252.0]
[18.0, 415.0]
[262, 295]
p03295
u585742242
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['# -*- coding: utf-8 -*-\nimport sys\nn, m = map(int, input().split())\ndemands = (tuple(map(int,\n line.strip().split())) for line in sys.stdin.readlines())\ndemands.sort(key=lambda demand: demand[1])\n\nbridge = -1\ncnt = 0\nfor ai, bi in demands:\n\n if ai <= bridge:\n continue\n\n else:\n bridge = bi - 1\n cnt += 1\n\nprint(cnt)\n', '# -*- coding: utf-8 -*-\nimport sys\nn, m = map(int, input().split())\ndemands = [\n tuple(map(int,\n line.strip().split())) for line in sys.stdin.readlines()\n]\n\ncompressed = []\nwhile demands:\n a, b = demands.pop()\n\n flag = False\n for i, (ai, bi) in enumerate(compressed):\n if b <= ai or bi <= a:\n continue\n\n else:\n compressed = [max(a, ai), min(b, bi)]\n break\n\n else:\n compressed.append([a, b])\n\nprint(len(compressed))\n', '# -*- coding: utf-8 -*-\nimport sys\nn, m = map(int, input().split())\ndemands = [\n tuple(map(int,\n line.strip().split())) for line in sys.stdin.readlines()\n]\ndemands.sort(key=lambda a, b: b)\n\ncompressed = []\nwhile demands:\n a, b = demands.pop()\n\n for i, (ai, bi) in enumerate(compressed):\n if b <= ai or bi <= a:\n continue\n\n else:\n compressed[i] = [max(a, ai), min(b, bi)]\n break\n\n else:\n compressed.append([a, b])\n\nprint(len(compressed))\n', '# -*- coding: utf-8 -*-\nimport sys\nn, m = map(int, input().split())\ndemands = [\n tuple(map(int,\n line.strip().split())) for line in sys.stdin.readlines()\n]\ndemands.sort(key=lambda demand: demand[1])\n\nx = -1\ncnt = 0\nfor ai, bi in demands:\n\n if ai <= x:\n continue\n\n else:\n x = bi - 1\n cnt += 1\n\nprint(cnt)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s031320520', 's528523583', 's688217517', 's493510054']
[10284.0, 23728.0, 23736.0, 23728.0]
[29.0, 154.0, 148.0, 224.0]
[363, 497, 516, 346]
p03295
u593019570
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int,input().split())\n\na = []\nfor _ in range(m):\n a.append(list(map(int,input().split())))\na.sort()\n\nbridge = []\nans = 0\nfor i in range(m):\n count = True\n for j in range(a[m - i - 1][0],a[m - i - 1][1]):\n if j in bridge:\n count = False\n \n if count:\n ans += 1\n bridge.append(a[m - i - 1][1]-1)\nprint(ans)', 'n, m = map(int,input().split())\n\na = []\nfor _ in range(m):\n a.append(list(map(int,input().split())))\na.sort()\n\nbridge = n\nans = 0\nfor i in range(m):\n count = True\n if a[m - i - 1][1] > bridge:\n count = False\n \n if count:\n ans += 1\n bridge = a[m - i - 1][0]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s035271708', 's216954718']
[27888.0, 27888.0]
[2105.0, 630.0]
[366, 310]
p03295
u605853117
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\n\ndef solve(n, pairs):\n pairs.sort(key=lambda pair: pair[1])\n cnt = 0\n while pairs:\n _, b0 = pairs[0]\n cnt += 1\n for (a, b) in pairs:\n if a < b0:\n pairs.remove((a, b))\n return cnt\n\nn, m = map(int, input().split())\npairs = [[int(c) for c in input().split()] for _ in range(m)]\nprint(solve(n, pairs))', '\nimport sys\n\ndef solve():\n pairs.sort(key=lambda pair: pair[1])\n cnt = 0\n base = 0\n for (a, b) in pairs:\n if a >= base:\n cnt += 1\n base = b\n return cnt\n\nn, m = map(int, input().split())\npairs = [tuple(int(c) for c in input().split()) for _ in range(m)]\nprint(n, pairs, file=sys.stderr)\nprint(solve())']
['Runtime Error', 'Accepted']
['s284220531', 's720028686']
[22812.0, 21344.0]
[400.0, 459.0]
[408, 395]
p03295
u606146341
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\nn, m = map(int, input().split())\nlst = []\nfor _ in range(m):\n a, b = map(int, input().split())\n lst.append([a, b])\n\nlst.sort(key=lambda x:x[1])\n\nans = 0\ned = 0\nfor _ in lst:\n if _[0] < ed:\n else:\n ed = _[1]\n ans += 1\nprint(ans)', '\nn, m = map(int, input().split())\nlst = []\nfor _ in range(m):\n a, b = map(int, input().split())\n lst.append([a, b])\n\nlst.sort(key=lambda x:x[1])\n\nans = 0\ned = 0\nfor _ in lst:\n if _[0] < ed:\n pass\n else:\n ed = _[1]\n ans += 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s783386957', 's019622113']
[2940.0, 21340.0]
[17.0, 412.0]
[285, 297]
p03295
u619379081
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = list(map(int, input().split()))\nab = list(list(map(int, input().split())) for i in range(m))\nab = sorted(ab, key=lambda x: x[1])\nbridge = 0\ncount = 0\nfor i in range(m):\n if ab[i][0] <= bridge:\n continue\n else:\n bridge = ab[i][0]\n count = count + 1\n if count == n-1:\n break\n else:\n continue\nprint(count)', 'n, m = list(map(int, input().split()))\nab = list(list(map(int, input().split())) for i in range(m))\nab = sorted(ab, key=lambda x: x[1])\nbridge = 0\ncount = 0\nfor i in range(m):\n if ab[i][0] < bridge:\n continue\n else:\n bridge = ab[i][1]\n count = count + 1\n if count == n-1:\n break\n else:\n continue\nprint(count)']
['Wrong Answer', 'Accepted']
['s747991000', 's289420704']
[29848.0, 29848.0]
[652.0, 449.0]
[356, 355]
p03295
u631277801
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['# Input\nimport sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10 ** 7)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x) - 1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn,m = li()\nab = [(-1, -1)]\nfor _ in range(m):\n ai, bi = li_()\n ab.append((ai, bi))\n\nab.sort(key=lambda x: x[1])\n\nans = 0\ncur = -1\nfor ai, bi in ab:\n if ai >= cur:\n ans += 1\n cur = bi\n\nprint(ans)\n\n\n', '# Input\nimport sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10 ** 7)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x) - 1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn,m = li()\nab = []\nfor _ in range(m):\n ai, bi = li_()\n ab.append((ai, bi))\n\nab.sort(key=lambda x: x[1])\n\nans = 0\ncur = -1\nfor ai, bi in ab:\n if ai >= cur:\n ans += 1\n cur = bi\n\nprint(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s254199735', 's507487090']
[18232.0, 18200.0]
[286.0, 263.0]
[660, 652]
p03295
u633105820
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["def run(n, m, ab):\n ab = sorted(ab)\n cnt = 1\n b = ab[0][1]\n for i in range(1, m):\n a = ab[i][0]\n if b < a:\n cnt += 1\n b = ab[i][1]\n return cnt\n\n\ndef read_line():\n n, m = list(map(int, input().split()))\n ab = []\n for i in len(m):\n a, b = list(map(int, input().split()))\n ab.append([a, b])\n return (n, m, ab)\n\n\ndef main():\n n, m, ab = read_line()\n print(run(n, m, ab))\n\n\nif __name__ == '__main__':\n main()\n", "def run(n, m, ab):\n ab = sorted(ab)\n cnt = 1\n b = ab[0][1]\n c = b\n for i in range(1, m):\n a = ab[i][0]\n b = ab[i][1]\n if a < c and c <= b:\n pass\n elif c <= a:\n cnt += 1\n c = b\n else:\n c = b\n return cnt\n\n\ndef read_line():\n n, m = list(map(int, input().split()))\n ab = []\n for i in range(m):\n a, b = list(map(int, input().split()))\n ab.append([a, b])\n return (n, m, ab)\n\n\ndef main():\n n, m, ab = read_line()\n print(run(n, m, ab))\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s958271123', 's853680864']
[3064.0, 22956.0]
[18.0, 539.0]
[486, 597]
p03295
u633548583
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\nn,m=map(int,input().split())\na=[]\nb=[]\nfor i in range(m):\n a_,b_=map(int,input().split())\n a.append(a_)\n b.append(b_)\nab=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1)) \n\nans=0\nlast=0\nfor i in range(m):\n if last<a[i][0]:\n last=a[i][1]\n ans+=1\nprint(ans)\n ', 'a=[]\nb=[]\nfor i in range(m):\n a_,b_=map(int,input().split())\n a.append(a_)\n b.append(b_)\nab=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1)) \n\nans=0\nlast=0\nfor i in range(m):\n if last<ab[i][0]:\n last=ab[i][1]\n ans+=1\n else:\n last=ab[i][1]\nprint(ans)', 'from operator import itemgetter\nn,m=map(int,input().split())\na=[]\nb=[]\nfor i in range(m):\n a_,b_=map(int,input().split())\n a.append(a_)\n b.append(b_)\nab=sorted([(a[i],b[i]) for i in range(m)], key=itemgetter(1)) \nremoved=-1\nans=0\n\nfor i,j in ab:\n if i>removed:\n ans+=1\n removed=j-1\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s261393641', 's619552493', 's042066316']
[20564.0, 3064.0, 20564.0]
[401.0, 17.0, 416.0]
[333, 297, 320]
p03295
u636311816
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(1,len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n del ab[:milestone]\n if len(ab)==1:\n res+=1\n del ab[0]\n if len(ab)==0:\n break\n\nprint(res)', 'ab=[]\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab=(map(int,input().split()))\n\nabr=[]\nenabled=[]\nremoved=[]\nfor i in range(m):\n abr.append(range(ab[i][0],ab[i][1]))\n enabled.append(False)\n removed.append(False)\n\nres=0\nfor i in range(n):\n for j in range(len(abr)):\n if i == abr[j][0] and not removed[j]:\n enabled[j]=True\n for j in range(len(abr)):\n if i == abr[j][-1]:\n res+=1\n for k in range(len(abr)):\n if enabled[j]:\n enabled[j]=False\n removed[j]=True\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\n ab.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n del ab[:milestone]\n if len(ab)==1:\n res+=1\n ab.remove(0)\n if len(ab)==0:\n break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)): \n mark=0\n x=ab[0][1] \n if x==ab[-1][1]:\n res+=1\n print("last")\n del ab[:]\n #break\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n print("mark")\n res+=1\n del ab[:mark]\n print(res,x,mark,ab)\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)):\n mark=0\n x=ab[0][1]\n if x==ab[-1][1]:\n res+=1\n del ab[:]\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nwhile(1):\n for j in range(len(ab)):\n if abrs[0][1] > ab[j][0]:\n pass\n else:\n if mark!=j:res+=1\n mark=j\n break\n del ab[:mark]\n if len(ab)==0:\n res+=1\n break\n\n for j in range(len(abrs)):\n if ab[0][0] > abrs[j][0]:\n pass\n else:\n mark=j\n break\n del abrs[:mark]\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)): \n mark=0\n x=ab[0][1] \n if x==ab[-1][1]:\n res+=1\n del ab[:]\n #break\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nwhile(1):\n for j in range(len(ab)):\n if abrs[0][1] > ab[j][0]:\n pass\n else:\n if mark!=j:res+=1\n mark=j\n break\n del ab[:mark]\n if len(ab)==1:\n res+=1\n break\n for j in range(len(abrs)):\n if ab[0][0] > abrs[j][0]:\n pass\n else:\n mark=j\n break\n del abrs[:mark]\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nwhile(1):\n for j in range(len(ab)):\n if abrs[0][1] > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n for j in range(len(abrs)):\n if ab[0][0] > abrs[j][0]:\n pass\n else:\n mark=j\n break\n del abrs[:mark]\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n del ab[:milestone]\n if len(ab)==1:\n res+=1\n ab.remove(0)\n if len(ab)==0\n break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)):\n x=ab[0][1]\n if x==ab[-1][1]:\n res+=1\n break\n for j in range(len(ab)):\n if x > ab[0][0]:\n del ab[0]\n if len(ab)==0:\n res+=1\n break\n else:\n res+=1\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nwhile(1):\n for j in range(len(ab)):\n if abrs[0][1] > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n for j in range(len(abrs)):\n if ab[0][0] > abrs[j][0]:\n pass\n else:\n mark=j\n break\n del abrs[:mark]\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)):\n x=ab[0][1]\n if x==ab[-1][1]:\n res+=1\n break\n for j in range(len(ab)):\n if x > ab[0][0]:\n del ab[0]\n else:\n res+=1\n break\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nindex=0\ntoremove=set()\nwhile(1):\n for j in range(index,len(ab)):\n if ab[index][1] < ab[j][0]:\n index=j\n res+=1\n break\n if index == len(ab):break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab=(map(int,input().split()))\n\n\nabr=[]\nenabled=[]\nremoved=[]\nfor i in range(m):\n abr.append(range(ab[i][0],ab[i][1]))\n enabled.append(False)\n removed.append(False)\n\nres=0\nfor i in range(n):\n for j in range(len(abr)):\n if i == abr[j][0] and not removed[j]:\n enabled[j]=True\n for j in range(len(abr)):\n if i == abr[j][-1] and enabled[j]:\n res+=1\n for k in range(len(abr)):\n if enabled[k] and not removed[k]:\n enabled[k]=False\n removed[k]=True\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor i in range(len(abrs)):\n for j in range(len(ab)):\n if abrs[i][1] > ab[j][0]:\n pass\n else:\n if mark!=j:\n res+=1\n mark=j\n break\n del ab[:mark]\n if len(ab)==1:\n break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n del ab[:milestone]\n if len(ab)==0:break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n mark=0\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)): \n mark=0\n x=ab[0][1] \n if x==ab[-1][1]:\n res+=1\n del ab[:]\n break\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[0])\nabrs=ab.copy()\nabrs.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nwhile(1):\n for j in range(len(ab)):\n if abrs[0][1] > ab[j][0]:\n pass\n else:\n if mark!=j:res+=1\n mark=j\n break\n del ab[:mark]\n if len(ab)==0:\n res+=1\n break\n for j in range(len(abrs)):\n if ab[0][0] > abrs[j][0]:\n pass\n else:\n mark=j\n break\n del abrs[:mark]\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\nab.sort(key=lambda x:x[1])\n\nprint(ab)\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n print("mark")\n res+=1\n del ab[:mark]\n print(res,x,mark,ab)\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n del ab[:milestone]\n if len(ab)==1:\n res+=1\n break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n mark=0\n if x==ab[-1][1]:\n res+=1\n break\n for j in range(len(ab)):\n if x > ab[0][1]:\n del ab[0][1]\n else:\n res+=1\n break\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmilestone=0\nwhile(1):\n for j in range(len(ab)):\n if ab[0][1] < ab[j][0]:\n milestone=j\n res+=1\n break\n ab.remove[0:milestone]\n if len(ab)==0:break\n\nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nmark=0\nfor z in range(len(ab)):\n x=ab[0][1]\n mark=0\n if x==ab[-1][1]:\n res+=1\n break\n for j in range(len(ab)):\n if x > ab[j][0]:\n pass\n else:\n mark=j\n break\n if len(ab[:mark])>0:\n res+=1\n del ab[:mark]\n if len(ab)==0:\n break\n \nprint(res)', 'ab=[]\n\nn,m = map(int,input().split())\n\nfor i in range(m):\n ab.append(tuple(map(int,input().split())))\n\nab.sort(key=lambda x:x[1])\n\nres=0\nfor z in range(len(ab)):\n x=ab[0][1]\n for j in range(len(ab)):\n if x > ab[0][0]:\n del ab[0]\n else:\n res+=1\n break\n if len(ab)==0:\n res+=1\n break\n \nprint(res)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s016837169', 's020236746', 's026795397', 's066181638', 's234220789', 's239218275', 's319717532', 's362521646', 's373931524', 's386928884', 's400316352', 's408670374', 's420952127', 's433485322', 's434653838', 's454966551', 's567500326', 's599286186', 's610336531', 's737806884', 's740299928', 's782895642', 's785612725', 's863399274', 's869226226', 's875666675', 's980383606', 's723824508']
[18236.0, 3064.0, 3932.0, 18252.0, 78120.0, 18180.0, 18712.0, 18180.0, 18712.0, 18708.0, 3064.0, 18280.0, 18712.0, 18248.0, 18628.0, 3064.0, 20088.0, 18236.0, 18240.0, 18168.0, 18712.0, 79988.0, 18248.0, 18252.0, 18244.0, 18248.0, 18240.0, 18612.0]
[2104.0, 208.0, 2104.0, 2103.0, 2105.0, 2104.0, 2104.0, 2104.0, 2104.0, 2103.0, 17.0, 1883.0, 2104.0, 1876.0, 2104.0, 213.0, 1498.0, 2103.0, 2104.0, 2105.0, 2104.0, 2105.0, 2108.0, 606.0, 475.0, 390.0, 2104.0, 1880.0]
[399, 592, 423, 400, 595, 477, 597, 526, 596, 582, 393, 444, 582, 405, 336, 629, 458, 336, 430, 525, 596, 476, 356, 419, 426, 340, 480, 370]
p03295
u648901783
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\nfor i in range(M):\n a[i]=input().rstrip().split()\n\n\n\na = [[]*2]*M\nsum = 0\nhasi = [0]*(N-1)\nfor i in range(0,M):\n c1 = int(a[M-1-i][0])\n c2 = int(a[M-1-i][1])\n f = [False]\n for m in range(c1-1,c2-1):\n if hasi[m]==1:\n f[0]=True\n if f[0]==True:\n continue\n else:\n hasi[c1-1]=1\n sum = sum+1\n\n\n\nprint(sum) \n', 'N,M = map(int,input().split())\n\na = [[]*2]*M\nfor i in range(M):\n a[i]=input().rstrip().split()\n\n\n\n\nsum = 0\nhasi = [0]*(N-1)\nfor i in range(0,M):\n c1 = int(a[M-1-i][0])\n c2 = int(a[M-1-i][1])\n f = [False]\n for m in range(c1-1,c2-1):\n if hasi[m]==1:\n f[0]=True\n if f[0]==True:\n continue\n else:\n hasi[c1-1]=1\n sum = sum+1\n\n\n \nsum \n', 'N,M = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(M)]\n\n\nab.sort(key=lambda x: x[1])\nans = 1\npre = ab[0][1]\nfor ele in ab[1:]:\n if pre > ele[0]:\n continue\n pre = ele[1]\n ans += 1\nprint(ans)\n\n\n\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s577968434', 's874597168', 's544310476']
[3064.0, 34964.0, 29068.0]
[17.0, 2106.0, 444.0]
[619, 619, 242]
p03295
u652057333
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\n\nleft = [""] * (n - 2)\nright = [""] * (n - 2)\n\nfor i in range(m):\n a, b = map(int, input().split())\n left[a - 1] = "["\n right[b - 2] = "]"\n\ns = ""\nfor i in range(n):\n s += left[i]\n s += right[i]\n\ncount = 0\nfor i in range(len(s) - 1):\n if s[i:i+2] == "[]":\n count += 1\nprint(count)', 'import sys\ninput = sys.stdin.readline\n\nN, M = (int(i) for i in input().split())\ndic = {}\ncnt = 0\npos = 0\nfor i in range(M):\n a, b = map(int, input().split())\n if b not in dic or dic[b] < a:\n dic[b] = a\n\nfor j in sorted(dic.keys()):\n if dic[j] >= pos:\n cnt += 1\n pos = j\nprint(cnt)\n']
['Runtime Error', 'Accepted']
['s357681825', 's001210116']
[4724.0, 10848.0]
[322.0, 161.0]
[338, 311]
p03295
u656365438
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['def main():\n in1 = input()\n n, m = [int(c) for c in in1]\n\n arr = []\n for i in range(m):\n _in = input()\n a, b = [int(c) for c in _in]\n arr.append((a, b))\n\n sorted_arr = sorted(arr, key=lambda x: x[0])\n\n n = 0\n\n mi, ma = sorted_arr[0]\n for a, b in sorted_arr[1:]:\n if ma < a:\n n += 1\n mi, ma = a, b\n if mi < a:\n mi = a\n if ma > b:\n ma = b\n print(n)\n\nif __name__ == "__main__":\n main()\n', 'def main():\n in1 = input().split(" ")\n n, m = [int(c) for c in in1]\n\n arr = []\n for i in range(m):\n _in = input().split(" ")\n a, b = [int(c) for c in _in]\n arr.append((a, b))\n\n sorted_arr = sorted(arr, key=lambda x: x[0])\n\n n = 1\n\n mi, ma = sorted_arr[0]\n mi, ma = (mi, ma) if mi < ma else (ma, mi)\n for a, b in sorted_arr[1:]:\n a, b = (a, b) if a < b else (b, a)\n if ma <= a:\n n += 1\n mi, ma = a, b\n if mi < a:\n mi = a\n if ma > b:\n ma = b\n print(n)\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s251877483', 's338449244']
[3064.0, 19020.0]
[17.0, 407.0]
[499, 612]
p03295
u657818166
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nl=[list(map(int,input().split())) for _ in range(m)]\nl.sort(key=lambda x : x[1])\na=0\nb=0\nfor x in l:\n if x[0]>b:\n b=x[0]\n a+=1\nprint(a)\n', 'n,m=map(int,input().split())\nl=[list(map(int,input().split())) for _ in range(m)]\nl.sort(key=lambda x : x[1])\na=0\nb=0\nfor x in l:\n if x[0]>b:\n b=x[0]\n a+=1\n', 'n,m=map(int,input().split())\nl=[list(map(int,input().split())) for _ in range(m)]\nl.sort(key=lambda x : x[1])\na=0\nb=0\nfor x in l:\n if x[0]>=b:\n b=x[1]\n a+=1\nprint(a)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s088340940', 's396715467', 's901194869']
[29084.0, 29076.0, 30500.0]
[442.0, 428.0, 420.0]
[172, 163, 173]
p03295
u658993896
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = list(map(int,input().split()))\n\nans=0\nbridge = [0 for _ in range(2*N)]\ndic = {}\n\nfor i in range(M):\n a,b = list(map(int,input().split()))\n bridge[2*a-1] = -1\n bridge[2*b-2] = 1\n\ntmp = 0\nfor x in bridge:\n if tmp == -1 and x == 1:\n ans+=1\n tmp=0\n tmp = min(tmp,x)\nprint(ans+1)\n', 'N, M = list(map(int,input().split()))\n\nans=0\nst = [[] for _ in range(N+1)]\ngoal = [0 for _ in range(N+1)]\n\nfor _ in range(M):\n a,b = list(map(int,input().split()))\n st[a] += [b]\n goal[b] += 1\n\nstack = []\nfor i in range(1,N+1):\n if goal[i]>0:\n ans+=1\n for x in stack:\n goal[x] -= 1\n stack=[]\n if len(st[i])>0:\n stack += st[i]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s449663937', 's443583274']
[4760.0, 25260.0]
[438.0, 499.0]
[311, 390]
p03295
u690700473
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["from typing import List\nfrom preconditions import preconditions\nimport heapq\n\n\ndef solve(N: int, M: int, a: List[int], b: List[int]) -> int:\n q = []\n ret = 0\n conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])\n ci = 0\n for i in range(N+1):\n while ci < len(conditions) and i == conditions[ci][1]:\n heapq.heappush(q, conditions[ci])\n ci += 1\n if len(q) > 0 and i == q[0][0]-1:\n ret += 1\n q = []\n return ret\n\n\n\n\n\ndef main():\n N, M = list(map(int, input().split(' ')))\n a = []\n b = []\n for i in range(M):\n ai, bi = list(map(int, input().split(' ')))\n a.append(ai)\n b.append(bi)\n\n print(solve(N, M, a, b))\n\n\n\nif __name__ == '__main__':\n main()", "import heapq\n\n\ndef solve(N, M, a, b):\n q = []\n ret = 0\n conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])\n ci = 0\n for i in range(N+1):\n while ci < len(conditions) and i == conditions[ci][1]:\n heapq.heappush(q, conditions[ci])\n ci += 1\n if len(q) > 0 and i == q[0][0]-1:\n ret += 1\n q = []\n return ret\n\n\n\n\n\ndef main():\n N, M = list(map(int, input().split(' ')))\n a = []\n b = []\n for i in range(M):\n ai, bi = list(map(int, input().split(' ')))\n a.append(ai)\n b.append(bi)\n\n print(solve(N, M, a, b))\n\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s258004144', 's272664249']
[3064.0, 20676.0]
[20.0, 470.0]
[778, 676]
p03295
u698176039
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(M)]\n\nab.sort(key = lambda x:x[1])\nans = 0\nlast = -1\nfor a,b in ab:\n print(a,b)\n if last <= a:\n ans += 1\n last = b\nprint(ans)\n', "N,M = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(M)]\n\nab.sort(key = lambda x:x[1])\nans = 0\nlast = -1\nfor a,b in ab:\n print(a,b)\n if last <= a:\n ans += 1\n last = b\n print('hogehogehoge',last,ans)\nprint(ans)\n", 'N,M = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(M)]\n\nab.sort(key = lambda x:x[1])\nans = 0\nlast = -1\nfor a,b in ab:\n if last <= a:\n ans += 1\n last = b\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s257527133', 's868752854', 's824620037']
[29084.0, 30212.0, 29084.0]
[551.0, 554.0, 449.0]
[228, 267, 213]
p03295
u709970295
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m = map(int,input().split())\nab = [tuple(map(int,input().split())) for _ in range(m)]\nab.sort()\ncnt=0\nwhile(len(ab)>1 and cnt<10):\n cnt+=1\n mini =min(ab, key=lambda x:x[1])[1]\n for i in range(len(ab)):\n if ab[i][0]>mini: break\n for j in range(i):\n del ab[0]\n if(len(ab)==1):cnt+=1\nprint(cnt)\n', 'n,m = map(int,input().split())\nab = [tuple(map(int,input().split())) for _ in range(m)]\nab.sort(key=lambda x:x[1])\nlast=-1\ncnt=0\nfor i in range(len(ab)):\n if(ab[i][0]<=last):pass\n else:\n last=ab[i][1]-1\n cnt+=1\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s532138342', 's921459586']
[18620.0, 18248.0]
[874.0, 386.0]
[323, 241]
p03295
u724563664
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['#coding:utf-8\nfrom bisect import bisect_right\n\nN,M = map(int,input().split())\n\nstart,left = map(int,input().split())\nright = left\ncnt = 0\nfor i in range(M-1):\n data = list(map(int,input().split()))\n if data[0] != start:\n start = data[0]\n if data[1] >= left:\n cnt += 1\n left = data[1]\n right = left\n else:\n right = data[1]\n \nif data[1] >= right:\n cnt += 1\n\nprint(cnt)\n', '#coding:utf-8\n\nN,M = map(int,input().split())\n\nstart,left = map(int,input().split())\nright = left\ncnt = 0\nfor i in range(M-1):\n data = list(map(int,input().split()))\n if data[0] != start:\n start = data[0]\n if data[1] >= left:\n cnt += 1\n left = data[1]\n right = left\n else:\n right = data[1]\n \nif data[1] >= right:\n cnt += 1\n\nprint(cnt)\n', '#coding:utf-8\n\nN,M = map(int,input().split())\nList = sorted([list(map(int,input().split())) for i in range(M)], key=lambda x:x[1])\n\ncnt = 1\nmaxa = 0\nb = List[0][1]\nfor i in range(1,M):\n newB = List[i][1]\n maxa = max(maxa,List[i][0])\n if newB > b:\n if maxa >= b:\n cnt += 1\n b = newB\n maxa = 0\n \nprint(cnt)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s636544844', 's653730838', 's508207037']
[3188.0, 3064.0, 29848.0]
[341.0, 355.0, 504.0]
[436, 404, 357]
p03295
u724732243
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['def main():\n n = [int(i) for i in input().split()]\n bridge = []\n counter = 0\n reqs = [[int(j) for j in input().split()] for i in range(n[1])]\n reqs.sort(key=lambda x:(x[0],x[1]))\n prefix = 0\n \n for i in range(1, n[0]+1):\n if i in bridge:\n bridge = []\n counter += 1\n for j in range(len(prefix, reqs)):\n if reqs[j][0] == i:\n bridge.append(reqs[j][1])\n else:\n prefix = j + 1\n break\n \n print(counter)\n \nmain()', 'def main():\n n = [int(i) for i in input().split()]\n bridge = set()\n counter = 0\n reqs = [[int(j) for j in input().split()] for i in range(n[1])]\n reqs.sort(key=lambda x:(x[0],x[1]))\n prefix = 0\n \n for i in range(1, n[0]+1):\n if i in bridge:\n bridge.clear()\n counter += 1\n for j in range(prefix, len(reqs)):\n if reqs[j][0] == i:\n bridge.add(reqs[j][1])\n else:\n prefix = j\n break\n \n print(counter)\n \nmain()']
['Runtime Error', 'Accepted']
['s572792752', 's798380318']
[29204.0, 30192.0]
[484.0, 529.0]
[538, 537]
p03295
u726615467
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['# encoding: utf-8\nN, M = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(M)]\n\n# find maximum a for each b\nmax_as = [0] * N\nfor a, b in ab:\n if max_as[b - 1] < b: max_as[b - 1] = a\n\n# count num. of valid bridges (bm = b - 1)\nans = 0\nmax_max_a = 0\nfor bm, max_a in enumerate(max_as):\n if max_a < 1: continue\n elif max_a <= max_max_a: continue\n ans += 1\n max_max_a = max_a\n \n# WA\n\n# # check value exists in [a] and [b]\n# a_exists = [False] * N\n# b_exists = [False] * N\n# for a, b in ab:\n# a_exists[a - 1] = True\n# b_exists[b - 1] = True\n\n# # find minimum a -> find minimum b (> a) -> find minimum a (> =b) -> ...\n# state = 1\n# ans = 0\n\n# print("#", state, ans, a_exist, b_exist)\n\n# if state == 1 and b_exist:\n# ans += 1\n# state = 0\n# # search minimum a (can occur immediately after state = 0)\n# if state == 0 and a_exist:\n# state = 1\n\nprint(ans)', 'N, M = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(M)]\n\nab.sort()\n\nans = 0\nfor i, (ai, bi) in enumerate(ab):\n if i == 0:\n ans += 1\n l = ai\n r = bi\n else:\n l_tmp = max(l, ai)\n r_tmp = min(r, bi)\n if l_tmp < r_tmp:\n l = l_tmp\n r = r_tmp\n else:\n ans += 1\n l = ai\n r = bi\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s072243265', 's136622379']
[28204.0, 27884.0]
[390.0, 573.0]
[1018, 424]
p03295
u758872405
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\n\nn, m = map(int, input().split())\n\n\nab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))\n\nremoved = -1\nans = 0\nprint(ab)\n\nfor a, b in ab:\n \n #print(a)\n if a > removed:\n removed = b - 1\n ans += 1\n print("OK")\n\nprint(ans)', 'from operator import itemgetter\n\nn, m = map(int, input().split())\n\n\nab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))\n\nremoved = -1\nans = 0\n\nfor a, b in ab:\n \n if a > removed:\n removed = b - 1\n ans += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s206518517', 's155342603']
[26276.0, 24776.0]
[280.0, 249.0]
[423, 379]
p03295
u771007149
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['##### ABC103-D-Islands War\nn,m = map(int,input().split())\nl = [list(map(int,input().split())) for _ in range(m)]\n\nl.sort(key=lambda x:x[1])\nprint(l)\n\n\nc = 0\n\nans = 0\n\nfor a,b in l:\n if a >= c:\n c = b\n ans += 1\n\nprint(ans)', '##### ABC103-D-Islands War\nn,m = map(int,input().split())\nl = [list(map(int,input().split())) for _ in range(m)]\n\nl.sort(key=lambda x:x[1])\n\n\n\nc = 0\n\nans = 0\n\nfor a,b in l:\n if a >= c:\n c = b\n ans += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s357300885', 's240501163']
[33020.0, 29084.0]
[509.0, 449.0]
[253, 245]
p03295
u780675733
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['_, M = map(int, input().split())\nSchedule = [list(map(int, input().split())) for _ in range(M)]\n\nSchedule = sorted(Schedule, key=lambda x: x[1])\ncnt = 0\nbefore_end = 0\nfor task in Schedule:\n start = task[0]\n end = task[1]\n if start < before_end:\n continue\n cnt += 1\n before_end = end', '_, M = map(int, input().split())\nSchedule = [list(map(int, input().split())) for _ in range(M)]\n\nSchedule = sorted(Schedule, key=lambda x: x[1])\ncnt = 0\nbefore_end = 0\nfor task in Schedule:\n start = task[0]\n end = task[1]\n if start < before_end:\n continue\n cnt += 1\n before_end = end\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s956665350', 's865427413']
[29848.0, 29848.0]
[432.0, 439.0]
[305, 316]
p03295
u785989355
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\nN,M = list(map(int,input().split()))\nMap = [[] for i in range(N)]\nfor i in range(M):\n a,b=list(map(int,input().split()))\n Map[a-1].append(b-1)\n\nb_list = [0 for i in range(N)]\ncount=0 \nfor i in range(N):\n if b_list[i]==1:\n b_list[i]=0\n count+=1\n for j in Map[i]:\n b_list[j]=1\n\nprint(count)', '\nN,M = list(map(int,input().split()))\nMap = [[] for i in range(N)]\nfor i in range(M):\n a,b=list(map(int,input().split()))\n Map[a-1].append(b-1)\n\nb_list = [0 for i in range(N)]\ncount=0 \nfor i in range(N):\n if b_list[i]==1:\n b_list=[0 for i in range(N)]\n count+=1\n for j in Map[i]:\n b_list[j]=1\n\nprint(count)']
['Wrong Answer', 'Accepted']
['s093874196', 's788026061']
[25148.0, 25916.0]
[466.0, 1673.0]
[322, 341]
p03295
u801512570
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int,input().split())\nm=[list(map(int, input().split())) for _ in range(M)]\nm=sorted(m, key=lambda x: x[1])\np=0\nwhile m!=[]:\n tmp=m[-1][1]-1\n while m!=[] and m[-1][1]>tmp:\n m.pop()\n p+=1\nprint(p)', 'N, M = map(int,input().split())\nm=[list(map(int, input().split()))[::-1] for _ in range(M)]\nm.sort()\n\nb=[]\nfor i in m:\n if len([tmp for tmp in b if tmp>=i[1]])==0:\n b.append(i[0]-1)\nprint(len(b))']
['Wrong Answer', 'Accepted']
['s345125899', 's433214867']
[29852.0, 22164.0]
[455.0, 1950.0]
[221, 205]
p03295
u814986259
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M=map(int,input().split())\nab=[tuple(map(int,input().split())) for i in range(M)]\n\nab.sort()\nl=1,r=N\nans=1\nfor a,b in ab:\n l=max(a,l)\n r=min(b,r)\n if l>=r:\n ans+=1\n l=a\n r=b\nprint(ans)\n ', 'N,M=map(int,input().split())\nab=[tuple(map(int,input().split())) for i in range(M)]\n\nab.sort()\nl=1\nr=N\nans=1\nfor a,b in ab:\n l=max(a,l)\n r=min(b,r)\n if l>=r:\n ans+=1\n l=a\n r=b\nprint(ans)\n \n']
['Runtime Error', 'Accepted']
['s226434529', 's546920934']
[3064.0, 16996.0]
[17.0, 455.0]
[201, 202]
p03295
u827624348
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["import sys\nfrom operator import itemgetter\nsys.setrecursionlimit(1000000) \n\ndef main():\n input = sys.stdin.readline \n N, M = map(int, input().rstrip().split())\n\n require_list = []\n for _ in range(M):\n s, e = map(int, input().rstrip().split())\n require_list.append([s, e])\n require_list.sort(key=itemgetter(1))\n print(require_list)\n\n count = 1\n now_require = require_list[0]\n for next_require in require_list[1:]:\n \n if now_require[1] <= next_require[0]:\n count += 1\n else:\n next_require[1] = now_require[1]\n now_require = next_require\n\n print(count)\n\nif __name__ == '__main__':\n main()", "import sys\nfrom operator import itemgetter\nsys.setrecursionlimit(1000000) \n\ndef main():\n input = sys.stdin.readline \n N, M = map(int, input().rstrip().split())\n\n require_list = []\n for _ in range(M):\n s, e = map(int, input().rstrip().split())\n require_list.append([s, e])\n require_list.sort(key=itemgetter(1))\n\n count = 1\n now_require = require_list[0]\n for next_require in require_list[1:]:\n \n if now_require[1] <= next_require[0]:\n count += 1\n else:\n next_require[1] = now_require[1]\n now_require = next_require\n\n print(count)\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s846931384', 's736417443']
[25200.0, 21316.0]
[326.0, 253.0]
[859, 835]
p03295
u853819426
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\np = []\nfor i in range(n):\n r, l = map(int, input().split())\n p.append((r, l))\n\np.sort()\nmr = 0\nc = 0\nfor l, r in p:\n if l >= mr:\n mr = r\n continue\n c += 1\n mr = min(mr, r)\n\nprint(c)', 'n, m = map(int, input().split())\np = []\nfor i in range(m):\n r, l = map(int, input().split())\n p.append((r, l))\n\np.sort()\nmr = 0\nc = 0\nfor l, r in p:\n if l >= mr:\n mr = r\n c += 1\n continue\n mr = min(mr, r)\n\nprint(c)']
['Runtime Error', 'Accepted']
['s717347444', 's029951327']
[16956.0, 17008.0]
[439.0, 437.0]
[225, 227]
p03295
u858523893
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\n\n_a, _b = map(int, input().split())\ndict_paths = {}\ndict_paths[_a] = _b\n\nfor i in range(M - 1) :\n a, b = map(int, input().split())\n \n interleave_flg = False\n\n for k in dict_paths.keys() :\n k_tmp, k_val_tmp = k, dict_paths[k]\n \n # complete intersect\n if a >= k and b <= dict_paths[k] :\n dict_paths.pop(k)\n dict_paths[a] = b\n interleave_flg = True\n \n # nothing required\n elif a <= k and b >= dict_paths[k] :\n interleave_flg = True\n \n \n elif a < k and b > k and b <= dict_paths[k] :\n dict_paths.pop(k)\n dict_paths[a] = k_val_tmp\n interleave_flg = True\n \n \n elif a > k and a < dict_paths[k] and b >= dict_paths[k] :\n dict_paths.pop(k)\n dict_paths[k] = b\n interleave_flg = True\n \n if interleave_flg == False :\n dict_paths[a] = b\n \nprint(len(dict_paths))\n \n ', 'N, M = map(int, input().split())\n\npaths = []\n\nfor i in range(M) :\n _a, _b = map(int, input().split())\n paths.append((_a, _b))\n\nst = sorted(paths, key = lambda x : x[1])\ncnt = 0\nprev_b = -1\n\nfor i in st :\n if cnt == 0 :\n cnt += 1\n prev_b = i[1]\n else :\n if i[0] >= prev_b :\n cnt += 1\n prev_b = i[1]\n \nprint(cnt)']
['Runtime Error', 'Accepted']
['s199474614', 's010728186']
[3064.0, 18960.0]
[17.0, 398.0]
[1073, 368]
p03295
u884982181
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import bisect\nN,M = map(int,input().split())\nx = []\nfor i in range(M):\n a,b=[int(i) for i in input().split()]\n x.append([a,b,b-a])\nx = sorted(x, key=lambda x:x[2])\nzan = []\nkota = []\nfor i in range(M):\n zan = sorted(zan)\n mo = x[i]\n ind = bisect.bisect_left(zan,mo[0])\n if ind >= len(zan):\n zan.append(mo[0])\n kota.append(mo)\n else:\n a = kota[ind]\n if mo[1] >= a[2]:\n pass\n else:\n kota.append(mo)\nkota = sorted(kota, key=lambda x:x[0])\nans = len(kota)\nz = []\nfor i in range(len(kota)-1):\n print(z)\n x = kota[i]\n if z !=[]:\n x = z\n y = kota[i+1]\n if x[1] > y[0]:\n ans -= 1\n if z == []:\n z = kota[i]\n else:\n z = []\nprint(ans)', 'N,M = map(int,input().split())\nx = []\nfor i in range(M):\n a,b=[int(i) for i in input().split()]\n x.append([a,b])\nzan = [x[0]]\nfor i in range(1,M):\n if zan[-1][0] == x[i][0]:\n pass\n else:\n zan.append(x[i])\nans = 0\nwhile zan:\n are = zan.pop(0)\n are = are[1]\n ans += 1\n i = 0\n while zan:\n if zan[i][0] <= are:\n if zan[i][1] <= are:\n zan.pop(i)\n else:\n i +=1\n else:\n i += 1\n try:\n if zan[i][0] > are:\n break\n except:\n break\nprint(ans)', 'N,M = map(int,input().split())\nx = []\nfor i in range(M):\n a,b=[int(i) for i in input().split()]\n x.append([a,b])\nx = sorted(x, key=lambda x:x[1])\nno = 0\nans = 0\nfor i in range(M):\n a = x[i]\n if (a[0] <= no and a[1] >= no):\n pass\n else:\n no = a[1] -1\n ans += 1\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s652654002', 's709763955', 's128137871']
[25276.0, 22560.0, 22036.0]
[567.0, 1930.0, 460.0]
[682, 531, 288]
p03295
u905203728
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nA=list(tuple(map(int,input().split())) for i in range(m))\nA.sort(key=lambda x:x[1])\n\npoint,count=0,0\nfor x,y in A:\n if point<x:\n point=x\n count +=1\nprint(count)', 'n,m=map(int,input().split())\nA=list(tuple(map(int,input().split())) for i in range(m))\nA.sort(key=lambda x:x[1])\n\npoint,count=0,0\nfor x,y in A:\n if point<=x:\n point=x\n count +=1\n\nprint(count)', 'n,m=map(int,input().split())\nAB=[tuple(map(int,input().split())) for _ in range(m)]\n\nAB=sorted(AB, key=lambda x: x[1])\ncnt,cut=0,0\n\nfor a,b in AB:\n if cut<=a:\n cnt +=1\n cut=b\n\nprint(cnt)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s671695763', 's829582972', 's375271233']
[18256.0, 18244.0, 19012.0]
[387.0, 396.0, 369.0]
[206, 208, 203]
p03295
u922487073
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['nm = input()\nn, m = nm.split()\nn = int(n)\nm = int(m)\n\narr = [[] for i in range(n)]\n\nfor i in range(m):\n\tab = input()\n\ta, b = ab.split()\n\ta = int(a)\n\tb = int(b)\n\tarr[a-1].append(b)\t\n\ncnt = 0\t\nsting = 0\nfor i,isl in enumelate(arr):\n\tsting = isl[0]\n\tfor j in arr[i:sting]:\n\t\tif (i == sting):\n\t\t\tcnt += 1\nprint(cnt)', 'nm = input()\nn, m = nm.split()\nn = int(n)\nm = int(m)\n\narr = [[] for i in range(n)]\n\nfor i in range(m):\n\tab = input()\n\ta, b = ab.split()\n\ta = int(a)\n\tb = int(b)\n\tarr[a-1].append(b)\t\n\ncnt = 0\t\nsting = 0\nfor i,isl in enumerate(arr):\n\tsting = isl[0]\n\tfor j in arr[i:sting]:\n\t\tif (i == sting):\n\t\t\tcnt += 1\nprint(cnt)', 'import bisect\nn,m = list(map(int, input().split()))\n\narr = [[] for i in range(n)]\n\nfor i in range(m):\n\ta, b = list(map(int, input().split()))\n\tbisect.insort_left(arr[a-1],b)\n\nprint(arr)\ncnt = 0\t\nsting = n+1\nfor i,isl in enumerate(arr):\n\tif sting == i+1:\n\t\tcnt += 1\n\t\tsting = n+1\n\n\tif len(isl) == 0:\n\t\tcontinue\n\t\t\n\tif isl[0] < sting:\n\t\tsting = isl[0]\nprint(cnt)', 'nm = input()\nn, m = nm.split()\nn = int(n)\nm = int(m)\n\narr = [[] for i in range(n)]\n\nfor i in range(m):\n\tab = input()\n\ta, b = ab.split()\n\ta = int(a)\n\tb = int(b)\n\tarr[a-1].append(b)\t\n\ncnt = 0\t\nsting = 0\nfor i,isl in enumerate(arr):\n\tsting = isl[0]\n\tfor j in arr[i:sting]:\n\t\tif (i == sting):\n\t\t\tcnt += 1\nprint(cnt)', 'n,m = list(map(int, input().split()))\n\narr = [[] for i in range(n)]\n\nfor i in range(m):\n\ta, b = list(map(int, input().split()))\n\tarr[a-1].append(b)\t\n\ncnt = 0\t\nsting = n+1\nfor i,isl in enumerate(arr):\n\tisl.sort()\n\tif sting == i+1:\n\t\tcnt += 1\n\t\tsting = n+1\n\n\tif len(isl) == 0:\n\t\tcontinue\n\t\t\n\tif isl[0] < sting:\n\t\tsting = isl[0]\nprint(cnt)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s097233920', 's449696175', 's813823813', 's992875474', 's009516411']
[17996.0, 20072.0, 26928.0, 19968.0, 24216.0]
[342.0, 2105.0, 490.0, 2108.0, 471.0]
[311, 311, 360, 311, 336]
p03295
u934246119
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["n, m = map(int, input().split())\nx = [[0, 0] for i in range(m)]\nans = 0\nfor i in range(m):\n x[i][0], x[i][1] = map(int, input().split())\n\n # print(x[i])\n# print('-'*20)\nx = sorted(x, key=lambda y: y[1])\n\n# print(x[i])\ntmp = x[0][1]\nfor i in range(1, m):\n if x[i][0] < tmp < x[i][1]:\n continue\n else:\n ans += 1\n tmp = x[i][1]\n if i == m-1:\n ans += 1\nprint(ans)\n", "n, m = map(int, input().split())\nx = [[0, 0] for i in range(m)]\nans = 0\nfor i in range(m):\n x[i][0], x[i][1] = map(int, input().split())\n\n # print(x[i])\n# print('-'*20)\nx = sorted(x, key=lambda y: y[1])\nfor i in range(m):\n print(x[i])\ntmp = x[0][1]\nfor i in range(1, m):\n if x[i][0] < tmp < x[i][1]:\n continue\n else:\n ans += 1\n tmp = x[i][1]\n if i == m-1:\n ans += 1\nprint(ans)\n", 'n, m = map(int, input().split())\n# stdin.readlines?\nx = [[0, 0] for i in range(m)]\nfor i in range(m):\n x[i][0], x[i][1] = map(int, input().split())\nx = sorted(x, key = lambda y: y[0])\nans = 1\nmx = max(x[0])\nwhile len(x) > 0:\n for i in range(len(x)):\n if mx <= x[i][1]:\n x.pop(i)\n else:\n mx = x[i][0]\n ans += 1\n break\nprin(ans)\n', "n, m = map(int, input().split())\nx = [[0, 0] for i in range(m)]\nans = 0\nfor i in range(m):\n x[i][0], x[i][1] = map(int, input().split())\n\n # print(x[i])\n# print('-'*20)\nx = sorted(x, key=lambda y: y[1])\n\n# print(x[i])\ntmp = x[0][1]\nfor i in range(1, m):\n if x[i][0] < tmp < x[i][1]:\n continue\n else:\n ans += 1\n tmp = x[i][1]\n if i == m-1:\n ans += 1\nprint(ans)\n", 'n, m = map(int, input().split())\n# stdin.readlines?\nx = [[0, 0] for i in range(m)]\nfor i in range(m):\n x[i][0], x[i][1] = map(int, input().split())\nx = sorted(x, key=lambda y: y[0])\nans = 1\nmx = max([x[i][0] for i in range(m)])\nwhile len(x) > 0:\n for i in range(len(x)-1, -1, -1):\n if mx < x[i][1]:\n x.pop(i)\n break\n else:\n mx = x[i][0]\n ans += 1\n break\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s133297793', 's710754242', 's770289485', 's970445706', 's544471065']
[22056.0, 22056.0, 22056.0, 22056.0, 23440.0]
[439.0, 539.0, 1163.0, 431.0, 493.0]
[454, 451, 391, 454, 440]
p03295
u935558307
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m = map(int,input().split())\nts = [list(map(int,input().split()))[::-1]]\n\ncount += 0\nt = 0\n\nfor i in range(m):\n if ts[i][1]>=t:\n count+=1\n t = ts[i][0]\n \nprint(count)', 'N,M = map(int,input().split())\nts = []\nfor i in range(M):\n a,b = map(int,input().split())\n ts.append([b,a])\nts.sort()\ntmp = 0\ncount = 0\nfor i in range(M):\n if ts[i][1]>=tmp:\n tmp = ts[i][0]\n count += 1\nprint(count)']
['Runtime Error', 'Accepted']
['s112427176', 's961506339']
[3064.0, 20168.0]
[18.0, 508.0]
[178, 237]
p03295
u936050991
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\n\nab = []\n\nfor i in range(m):\n a, b = map(int, input().split())\n ab.append((a,b))\n\nab = sorted(ab, key = lambda x: x[[1])\n\nleft = 0\nans = 0\n\n\nfor a, b in ab:\n if a < left:\n ans += 1\n left = b-1\n \nprint(ans)\n ', 'n, m = map(int, input().split())\n\nab = []\n\nfor i in range(m):\n a, b = map(int, input().split())\n ab.append((a,b))\n\nab = sorted(ab, key = lambda x: x[1])\n\nleft = 0\nans = 0\n\n\nfor a, b in ab:\n if a > left:\n ans += 1\n left = b-1\n \nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s576500906', 's429734402']
[2940.0, 18960.0]
[18.0, 374.0]
[273, 272]
p03295
u950708010
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\ninput = sys.stdin.readline\ndef solve():\n n,m = (int(i) for i in input().split())\n query = []\n for i in range(m):\n a,b = (int(i) for i in input().split())\n query.append((b-1,a-1))\n query.sort()\n ans = 0\n bridge = [True]*(n-1)\n remove = 10**15\n for i in range(m):\n b,a = query[i]\n if not remove < a:\n if bridge[b-1]:\n ans += 1\n bridge[b-1] = False\n remove = b-1\n print(ans)\n \nsolve()\n ', 'import sys\ninput = sys.stdin.readline\ndef solve():\n n,m = (int(i) for i in input().split())\n query = []\n for i in range(m):\n a,b = (int(i) for i in input().split())\n query.append((b-1,a-1))\n query.sort()\n ans = 0\n remove = 10**15\n for i in range(m):\n b,a = query[i]\n if a > remove or remove >= b:\n ans += 1\n remove = b-1\n print(ans)\n \nsolve()\n ']
['Wrong Answer', 'Accepted']
['s088733212', 's788192590']
[17404.0, 16996.0]
[306.0, 307.0]
[445, 382]
p03295
u969190727
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["n,m=map(int,input().split())\nAB=[]\nfor i in range(m):\n a,b=map(int,input().split())\n AB.append([a,b])\nAB.sort()\nAB.append([float('inf'),float('inf')])\nans,reset,left,right=0,1,0,float('inf')\nfor i in range(m)t:\n right=min(right,AB[i][1])\n left=AB[i][0]\n if right==left+1 and left!=AB[i+1][0]:\n ans+=1\n right=float('inf')\nif right!=float('inf'):\n ans+=1\nprint(ans)", 'n,m=map(int,input().split())\nAB=[]\nappend=AB.append\nfor i in range(m):\n a,b=map(int,input().split())\n append([ra,b])\nAB.sort(key=lambda x:x[1])\nc,ans=0,0\nfor a,b in AB:\n if a>=c:\n ans+=1\n c=b\nprint(ans)', 'n,m=map(int,input().split())\nAB=[]\nappend=AB.append\nfor i in range(m):\n a,b=map(int,input().split())\n append([a,b])\nAB.sort(key=lambda x:x[1])\nc,ans=0,0\nfor a,b in AB:\n if a>=c:\n ans+=1\n c=b\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s361465806', 's892602572', 's070859290']
[2940.0, 3064.0, 21340.0]
[17.0, 17.0, 412.0]
[385, 211, 211]
p03295
u977389981
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nSG = sorted([[int(i) for i in input().split()] for i in range(m)], key = lambda x: x[1])\n\ncnt = 0\nb = 0\nfor s, g in SG:\n if s >= b:\n b = s + 1\n cnt += 1\n \nprint(cnt)', 'N, M = map(int, input().split())\nAB = sorted([[int(i) for i in input().split()] for i in range(M)], key = lambda x: x[1])\n\ncnt = 1\nposi = AB[0][1]\nfor i in range(1, M):\n if AB[i][0] >= posi:\n cnt += 1\n posi = AB[i][1]\n\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s202219227', 's754558130']
[23704.0, 25000.0]
[399.0, 421.0]
[222, 246]
p03295
u978313283
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M=map(int,input().split())\nAB=[[0,0] for i in range(M)]\nfor i in range(M):\n AB[i][0],AB[i][1]=map(int,input().split())\nl=AB[0][0]\nr=AB[0][1]\nc=0\nfor i in range(1,M):\n if AB[i][0]<r:\n l=AB[i][0]\n if AB[i][1]<r:\n r=AB[i][1]\n else:\n c+=1\n l=AB[i][0]\n r=AB[i][1]\nprint(c-3)\n\n\n\n', 'N,M=map(int,input().split())\nab=[[0,0] for i in range(M)]\nfor i in range(M):\n ab[i][0],ab[i][1]=map(int,input().split())\nr=0\nans=0\nab.sort()\nfor i in range(M):\n a=ab[i][0]\n b=ab[i][1]\n if a>=r:\n ans+=1\n r=b\n else:\n if b<r:\n r=b\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s881522274', 's127159509']
[19572.0, 20016.0]
[359.0, 461.0]
[330, 287]
p03295
u979823197
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M=map(int,input().split())\nab=[]\nfor m in range(M):\n [a,b]=[int(i) for i in input().split()]\n ab.append([a,b])\nab.sort(key=lambda x:x[1])\ncount=[]\nbmin=ab[0][1]\ncount.append(ab[0][1]-1)\nfor i in range(1,M):\n if ab[i][1]==b:\n count.remove(count[0])\n count.append(ab[i][1])\n else:\n pass\nfor i in range(1,M):\n if ab[i][0]<=count[-1]<ab[i][1]:\n pass\n else:\n count.append(ab[i][1])\nprint(len(count))', 'N,M=map(int,input().split())\nab=[]\nfor m in range(M):\n [a,b]=[int(i) for i in input().split()]\n ab.append([a,b])\nab.sort(key=lambda x:x[1])\ncount=[]\ncount.append(ab[0][1]-1)\nfor i in range(1,M):\n if ab[i][0]<=count[-1]<ab[i][1]:\n pass\n elif ab[i][0]<=count[-1] and ab[i][1]-1==count[-1]:\n count.remove(count[-1])\n count.append(ab[i][1]-1)\n else:\n count.append(ab[i][1]-1)\nprint(len(count))']
['Wrong Answer', 'Accepted']
['s685471004', 's682387351']
[21276.0, 21268.0]
[498.0, 472.0]
[417, 406]
p03295
u995062424
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['def main():\n N, M = map(int, input().split())\n y = []\n for i in range(M):\n y.append(list(map(int, input().split())))\n youbou = sorted(y, key = lambda x:x[1])\n \n cnt = 1\n k = 0\n for i in range(1, M):\n if(youbou[i][0] >= k):\n cnt += 1\n k = youbou[i][1]\n print(cnt)\nmain()', 'def main():\n N, M = map(int, input().split())\n island = []\n for i in range(M):\n a, b = map(int, input().split())\n island.append(tuple((a, b)))\n \n s = sorted(island, key=lambda x:x[1])\n \n base = s[0][1]\n cnt = 1\n for i in range(1, len(s)):\n if(s[i][0] >= base):\n base = s[i][1]\n cnt += 1\n print(cnt)\n \nmain()']
['Wrong Answer', 'Accepted']
['s038963217', 's786407930']
[29848.0, 18980.0]
[444.0, 373.0]
[332, 383]
p03296
u000085263
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['from numpy.random import randint\nn = int(input())\nl = list(map(int, input().split()))\nans = 0\nfor i in range (len(a)-1) :\n try:\n if l[i] == l[i + 1]:\n ans += 1\n l[i + 1] = randint(0, 10000)\n except:\n continue\nprint(ans)', 'from random import randint\nn = int(input())\nl = list(map(int, input().split()))\nans = 0\nfor i in range (len(a)-1) :\n try:\n if l[i] == l[i + 1]:\n ans += 1\n l[i + 1] = randint(0, 10000)\n except:\n continue\nprint(ans)', 'from random import randint\nl = list(map(int, input().split()))\nans = 0\nfor i in range (len(a) - 1) :\n if l[i] == l[i + 1]:\n ans += 1\n l[i + 1] = randint(0, 10000)\nprint(ans)', 'from random import randint\nn = int(input())\nl = list(map(int, input().split()))\nans = 0\nfor i in range (len(l)-1) :\n try:\n if l[i] == l[i + 1]:\n ans += 1\n l[i + 1] = randint(0, 10000)\n except:\n continue\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s162279810', 's315766311', 's780009774', 's921858030']
[27116.0, 9472.0, 9572.0, 9408.0]
[115.0, 25.0, 23.0, 28.0]
[241, 235, 180, 235]
p03296
u013408661
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input())\nslime=list(map(int,input().split()))\nstack=0\ncount=0\nans=0\nfor i in slime:\n if i!=stack:\n stack=i\n ans+=(count+1//2)\n count=0\n continue\n count+=1\n stack=i\nans+=(count+1//2)\nprint(ans)', 'n=int(input())\nslime=list(map(int,input().split()))\nstack=0\ncount=0\nans=0\nfor i in slime:\n if i!=stack:\n stack=i\n ans+=(count+1//2)\n count=0\n continue\n count+=1\nans+=(count+1//2)\nprint(ans)', 'n=int(input())\nslime=list(map(int,input().split()))\nstack=0\nans=0\nfor i in slime:\n if i!=stack:\n stack=i\n ans+=(count+1//2)\n count=0\n continue\n count+=1\nans+=(count+1//2)\nprint(ans)', 'n=int(input())\nslime=list(map(int,input().split()))\nstack=0\ncount=0\nans=0\nfor i in slime:\n if i!=stack:\n stack=i\n ans+=((count+1)//2)\n count=0\n continue\n count+=1\n stack=i\nans+=((count+1)//2)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s067199268', 's653242576', 's840618975', 's048199436']
[3064.0, 3060.0, 3060.0, 3064.0]
[17.0, 17.0, 17.0, 18.0]
[213, 203, 195, 217]
p03296
u017810624
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input())\na=list(map(int,input().split()))\nc=0\nl=[]\nfor i in range(1,n):\n l.append(a[i]-a[i-1])\np=l.pop(0)\nwhile len(l)!=0:\n if p!=0:\n p=l.pop(0)\n if p==0:\n c+=1\n while len(l)>2:\n if l[0]==0 and l[1]==0:\n p=l.pop(0)\n p=l.pop(0)\n c+=1\n else:\n break\n if l[0]==0:\n p=l.pop(0)\n if len(l)>0:\n p=l.pop(0)\n else:\n break\n else:\n p=l.pop(0)\nif p==0:c+=1\nprint(c)', 'n=int(input())\na=list(map(int,input().split()))\nc=0\nl=[]\nfor i in range(1,n):\n l.append(a[i]-a[i-1])\np=l.pop(0)\nwhile len(l)!=0:\n if p!=0:\n p=l.pop(0)\n if p==0:\n c+=1\n while len(l)>1:\n if l[0]==0 and l[1]==0:\n p=l.pop(0)\n p=l.pop(0)\n c+=1\n else:\n break\n while len(l)>0:\n if l[0]==0:\n p=l.pop(0)\n if len(l)>0:\n p=l.pop(0)\n else:\n break\n else:\n p=l.pop(0)\nprint(c)', 'n=int(input())\na=list(map(int,input().split()))\nc=0\nl=[]\nfor i in range(1,n):\n l.append(a[i]-a[i-1])\np=l.pop(0)\nwhile len(l)!=0:\n if p!=0:\n p=l.pop(0)\n if p==0:\n c+=1\n while l[0]==0 and l[1]==0:\n p=l.pop(0)\n p=l.pop(0)\n c+=1\n if l[0]==0:\n p=l.pop(0)\n p=l.pop(0)\n else:\n p=l.pop(0)\nprint(c)', 'n=int(input())\na=list(map(int,input().split()))\nc=0\nl=[]\nfor i in range(1,n):\n l.append(a[i]-a[i-1])\nif len(l)==1 and l[n-2]==0:c+=1\nif len(l)>1 and l[n-2]==0 and l[n-3]!=0:c+=1\np=l.pop(0)\nwhile len(l)!=0:\n if p!=0:\n p=l.pop(0)\n else:\n c+=1\n while len(l)>1:\n if l[0]==0 and l[1]==0:\n p=l.pop(0)\n p=l.pop(0)\n c+=1\n else:\n break\n while len(l)>0:\n if l[0]==0:\n p=l.pop(0)\n else:\n p=l.pop(0)\n break\nprint(c)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s172377451', 's347930268', 's479322790', 's357347313']
[3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0, 17.0]
[449, 471, 337, 487]
p03296
u021916304
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nn = ii()\nA = iil()\nans = 0\nfor i in range(1,n)\n if A[i-1] == A[i]:\n ans += 1\n A[i] = -1\nprint(ans)', 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nn = ii()\nA = iil()\nans = 0\nfor i in range(1,n):\n if A[i-1] == A[i]:\n ans += 1\n A[i] = -1\nprint(ans)']
['Runtime Error', 'Accepted']
['s496480033', 's816640775']
[2940.0, 3064.0]
[17.0, 18.0]
[325, 326]
p03296
u044459372
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=input()\nnumbers=list(map(int,input().split()))\ncount=0\nfor i in range(1,n):\n if numbers[i] is numbers[i+1]:\n count+=1\nprint(count)', 'n=int(input())\nnumbers=list(map(int,input().split()))\ncount=1\nc=0\nfor i in range(n-1):\n if numbers[i] is numbers[i+1]:\n count+=1\n else:\n \tc+=count//2\n \tcount=1\nif count-1:\n\tc+=count//2\nprint(c)\n']
['Runtime Error', 'Accepted']
['s346499341', 's274407189']
[2940.0, 3060.0]
[17.0, 17.0]
[136, 201]
p03296
u076306174
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN=int(input[0])\na=list(map(int,input[1].split())) \n\ncnt=0\nfor i in range(len(a)-1):\n if a[i]==a[i+1]:\n a[i+1]=-1\n cnt+=1\n #print(a)\n\n\nprint(cnt)\n', 'import math\nimport heapq\nimport sys\nfrom collections import Counter\n\n\n\n\nN=int(input())\na=list(map(int,input().split())) \n\ncnt=0\nfor i in range(len(a)-1):\n if a[i]==a[i+1]:\n a[i+1]=-1\n cnt+=1\n #print(a)\n\n\nprint(cnt)\n']
['Runtime Error', 'Accepted']
['s265722777', 's281910434']
[3316.0, 3316.0]
[21.0, 22.0]
[551, 549]
p03296
u099566485
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input())\na=list(map(int,input().split()))\na.append(0)\ntl=0\ncount=0\nfor i in range(n):\n if a[i+1]==a[i]:\n tl+=1\n elif tl!=0:\n count+=tl//2\n tl=0\nprint(count)', 'n=int(input())\na=list(map(int,input().split()))\na.append(0)\ntl=[]\ncount=0\nfor i in range(n):\n if a[i+1]==a[i]:\n tl.append(a[i])\n else:\n if len(tl)!=0:\n count+=len(tl)//2\n for j in range(len(tl)):\n del tl[0]\nprint(count)', 'n=int(input())\na=list(map(int,input().split()))\ntl=1\ncount=0\nfor i in range(n-1):\n if a[i+1]==a[i]:\n tl+=1\n elif tl!=1:\n count+=tl//2\n tl=1\nprint(count)\n', 'n=int(input())\na=list(map(int,input().split()))\na.append(0)\ntl=[]\ncount=0\nfor i in range(n):\n if a[i+1]==a[i]:\n tl.append(a[i])\n else:\n if len(tl)!=0:\n count+=len(tl)//2\n for j in tl:\n del tl[0]\nprint(count)', 'n=int(input())\na=list(map(int,input().split()))\na.append(0)\ntl=1\ncount=0\nfor i in range(n):\n if a[i]==a[i+1]:\n tl+=1\n else:\n count+=tl//2\n tl=1\nprint(count)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s049327841', 's428271532', 's438123779', 's774770587', 's570445636']
[3060.0, 3064.0, 2940.0, 3064.0, 3060.0]
[17.0, 17.0, 17.0, 18.0, 17.0]
[189, 276, 180, 264, 184]
p03296
u102461423
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = input()\nA = [int(x) for x in input().split()]\n\nanswer = 0\nfor i in range(1,N):\n if A[i] == A[i-1]:\n A[i] = -1\n answer += 1\nprint(answer)', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport itertools\n\nN,*A = map(int,read().split())\n\nanswer = 0\nfor _,it in itertools.groupby(A):\n x = len(list(it))\n answer += x//2\n\nprint(answer)']
['Runtime Error', 'Accepted']
['s247207927', 's709162242']
[2940.0, 3060.0]
[17.0, 17.0]
[147, 267]
p03296
u131406102
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\na = list(map(int, input().split()))\ncount = 0\ncounter = 0\n\nfor i in range(len(a)-1):\n if a[i]==a[i+1] and i == len(a)-2:\n count += int((i+1-counter)//2)+1\n elif a[i]!=a[i+1] or i == len(a)-2:\n count += int((i+1-counter)//2)\n counter = i + 1\n\nprint(count) ', 'n = int(input())\na = list(map(int, input().split()))\ncount = 0\ncounter = 0\n\nfor i in range(len(a)-1):\n if i == len(a)-2 and a[i]==a[i+1]:\n count += int((i+2-counter)//2)\n if a[i]!=a[i+1]:\n count += int((i+1-counter)//2)\n counter = i + 1\n\nprint(count) ']
['Wrong Answer', 'Accepted']
['s501631174', 's937703248']
[3316.0, 3060.0]
[20.0, 17.0]
[304, 283]
p03296
u149260203
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = int(input())\na = [int(i) for i in input().split()]\na.append(N+1)\ndupe = []\n\ntemp = 1\nfor i in range(N):\n if a[i] == a[i+1]:\n temp += 1\n elif temp != 0:\n dupe.append(temp)\n temp = 1\n\nprint(dupe)\nb = [int(i/2) for i in dupe]\nprint(sum(b))', 'N = int(input())\na = [int(i) for i in input().split()]\na.append(N+1)\ndupe = []\n\ntemp = 1\nfor i in range(N):\n if a[i] == a[i+1]:\n temp += 1\n elif temp != 0:\n dupe.append(temp)\n temp = 1\n\nb = [int(i/2) for i in dupe]\nprint(sum(b))']
['Wrong Answer', 'Accepted']
['s826031104', 's487315955']
[3064.0, 3064.0]
[17.0, 17.0]
[268, 256]
p03296
u151107315
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['from sys import stdin\n\nt = stdin.readline()\nt_i = int(t)\ndata = [stdin.readline().rstrip().split() for _ in range(t_i)]\n#print(data)\nfor i in range(t_i) :\n a = int(data[i][0])\n b = int(data[i][1])\n c = int(data[i][2])\n d = int(data[i][3])\n #print(a, b, c, d)\n if a < b :\n print("No")\n elif b > d :\n print("No")\n elif a % b > c and a % b < b :\n print("No")\n else :\n #print("Yes")\n \n stock = a\n count = 0\n while True :\n stock = stock - b\n if stock < 0 :\n print("No")\n break\n if stock <= c :\n stock = stock + d\n count = count + 1\n if count > 10000 :\n print("Yes")\n break\n\n \n', 'from sys import stdin\n\nn = stdin.readline()\nn_i = int(n)\n\na = stdin.readline().rstrip().split()\na_list = list(a)\n\nn_count = 0\n\nif len(a_list) == 2 and a_list[0] == a_list[1] :\n print(n_count + 1)\nelse :\n for i in range(n_i):\n if i == n_i - 1 :\n break\n if a_list[i] == a_list[i + 1]:\n n_count = n_count + 1\n a_list[i + 1] = "X"\n\n print(n_count)']
['Runtime Error', 'Accepted']
['s317763000', 's003421033']
[3064.0, 3064.0]
[21.0, 17.0]
[787, 399]
p03296
u151625340
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = int(input())\na = list(map(int,input().split()))\nans = 0\nnow = a[0]\ni = 1\nwhile i < N:\n if now == a[i]:\n ans += 1\n i += 2\n if i == N-1:\n break\n now = a[i+1]\n else:\n now = a[i]\n i += 1\nprint(ans)\n', 'N = int(input())\na = list(map(int,input().split()))\nans = 0\nnow = a[0]\ni = 1\nwhile i < N:\n if now == a[i]:\n ans += 1\n if i == N-1:\n break\n now = a[i+1]\n i += 2\n \n else:\n now = a[i]\n i += 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s114367902', 's307058403']
[3060.0, 3060.0]
[17.0, 18.0]
[257, 266]
p03296
u158635223
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['def main():\n n=int(input())\n a=list(map(int,input().split()))\n ans=0\n for i in range(n-1):\n if(a[i]==a[i+1]):\n a[i+1]=0\n ans+=1\n print(ans)\n\nif __name__=="__main__":\n main()', 'def main():\n n=int(input())\n a=list(map(int,input().split()))\n ans=0\n for i in range(n-1):\n if(a[i]==a[i+1]):\n a[i+1]=0\n ans+=1\n print(ans)\n\nif __name__=="__main__":\n main()']
['Wrong Answer', 'Accepted']
['s604293162', 's571820049']
[3060.0, 3060.0]
[17.0, 17.0]
[224, 220]
p03296
u164362673
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\nl = [[int(i) for i in input().split()] for i in range(n)]\nprev = 0\nflag = False\nresult = 0\nfor i in l:\n if flag == False and i == prev:\n flag = True\n result += 1\n elif flag == True:\n flag = False\n prev = i\nprint(result)', 'n = int(input())\nl = input().split()\nprev = 0\nflag = False\nresult = 0\nfor i in l:\n if flag == False and i == prev:\n flag = True\n result += 1\n elif flag == True:\n flag = False\n prev = i\nprint(result)']
['Runtime Error', 'Accepted']
['s765195067', 's616245424']
[3060.0, 3060.0]
[17.0, 17.0]
[266, 228]
p03296
u177132624
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = int(input())\nl = list(map(int,input().split()))\n\nlen_l = len(l)\nst = l[0]\ncount = 1\ncount_l = []\nfor i in range(1,len_l):\n if l[i]==st:\n count+=1\n else:\n count_l.append(count//2)\n st = l[i]\n count = 1\nprint(sum(count_l))', 'N = int(input())\nl = list(map(int,input().split()))\n\nlen_l = len(l)\nst = l[0]\ncount = 1\ncount_l = []\nfor i in range(1,len_l):\n if l[i]==st:\n count+=1\n else:\n count_l.append(count//2)\n st = l[i]\n count = 1\ncount_l.append(count//2)\nprint(sum(count_l))']
['Wrong Answer', 'Accepted']
['s076604757', 's418111891']
[3064.0, 3060.0]
[17.0, 17.0]
[258, 283]
p03296
u218843509
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\na = list(map(int, input().split()))\n\nans = []\n\ni = 1\nadjacent = 1\n\nwhile i < n:\n if a[i] == a[i - 1]:\n adjacent += 1\n else:\n ans.append((adjacent + 1) // 2)\n adjacent = 1\n i += 1\n \nans.append((adjacent + 1) // 2)\nprint(sum(ans))', 'n = int(input())\na = list(map(int, input().split()))\n\nans = []\n\ni = 1\nadjacent = 1\n\nwhile i < n:\n if a[i] == a[i - 1]:\n adjacent += 1\n else:\n ans.append((adjacent + 1) // 2)\n adjacent = 1\n i += 1\n \nprint(sum(ans))', 'n = int(input())\na = list(map(int, input().split()))\n\nans = []\n\ni = 1\nadjacent = 1\n\nwhile i < n:\n if a[i] == a[i - 1]:\n adjacent += 1\n else:\n ans.append(adjacent // 2)\n adjacent = 1\n i += 1\n \nans.append(adjacent // 2)\nprint(sum(ans))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s538341715', 's821017696', 's758820146']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[258, 226, 246]
p03296
u227082700
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input());a=list(map(int,input().split()));c,ans=1,0\nfor i in range(n-1):\n if a[i]==a[i+1]:c+=1\n else:\n if c>=2:ans+=c//2\n c=1\nprint(ans)', 'n=int(input());a=list(map(int,input().split()));c,ans=1,0\nfor i in range(n-1)\n if a[i]==a[i+1]:c+=1\n else:\n if c>=2:ans+=c//2\n c=1\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(1,n):\n if a[i-1]==a[i]:\n a[i]=-1\n ans+=1\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s460860803', 's931724018', 's515780082']
[3060.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[150, 149, 127]
p03296
u242598232
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\nli=[]\nre=[]\nfor i in range(n):\n\tli.append(list(map(int,input().split())))\n\tif li[i][0] >= li[i][1] and li[i][1] <= li[i][3]:\n\t\tLim=li[i][0]%li[i][1]\n\t\tif li[i][1] == li[i][3]:\n\t\t\tpass\n\t\telse:\n\t\t\twhile Lim+li[i][3]-li[i][1]<li[i][1]:\n\t\t\t\tLim=Lim+li[i][3]-li[i][1]\n\t\tif li[i][2] >= Lim:\n\t\t\tre.append("Yes")\n\t\telse:\n\t\t\tre.append("No")\n\telse:\n\t\tre.append("No")\nfor value in re:\n print(value)', 'N=int(input())\nli = list(map(int,input().split()))\nM=0\nfor i in range(N-1):\n\tif li[i]==li[i+1]:\n\t\tli[i+1]=li[i+1]+10000\n\t\tM=M+1\nprint(M)\n']
['Runtime Error', 'Accepted']
['s292589951', 's537386640']
[3064.0, 2940.0]
[18.0, 18.0]
[404, 137]
p03296
u265939044
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['import fractions\nT = int(input())\n\nL = []\nfor i in range(0,T):\n L = list(map(int, input().split()))\n A = L[0]\n B = L[1]\n C = L[2]\n D = L[3]\n\n ans = "Yes"\n if A < B: \n ans = "No"\n elif D < B: \n ans = "No"\n elif B - C <= 1: \n ans = "Yes"\n elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):\n ans = "No"\n\n\n print(ans)\n L = []\n\n', 'N = int(input())\nL = list(map(int,input().split()))\ncount = 0\n\nfor i in range(0,N-1):\n if L[i] == L[i+1]:\n L[i+1] = 101\n count += 1\n\nprint(count)']
['Runtime Error', 'Accepted']
['s968942935', 's847416463']
[5692.0, 3316.0]
[52.0, 21.0]
[470, 162]
p03296
u276479653
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['from sys import stdin\nimport math\ncolumns = int(stdin.readline().rstrip())\ndatas = [stdin.readline().rstrip().split() for _ in range(columns)]\nfor data in datas:\n A = int(data[0])\n B = int(data[1])\n C = int(data[2])\n D = int(data[3])\n if A < B:\n print("No")\n continue\n if D < B:\n print("No")\n continue\n if C > B:\n print("Yes")\n continue\n g = math.gcd(B,D)\n if (B - g + A % g) >C :\n print("No")\n else:\n print("Yes") \n \n', 'from sys import stdin\ndata = [stdin.readline().rstrip().split() for _ in range(2)]\ncount = 0\ni = 0\nwhile i + count+ 1 < int(data[0][0]):\n if (data[1][i + count+ 1] == data[1][i + count]):\n count = count + 1\n i = i + 1\nprint(count)']
['Runtime Error', 'Accepted']
['s438502983', 's379714578']
[3064.0, 3060.0]
[18.0, 17.0]
[511, 243]
p03296
u280502233
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
["n = int(input())\nx = input().split(' ')\nl = [int(i) for i in x]\n\nc = 0\ni = 0\ndef s():\n while i+2 < len(l):\n if l[i] == l[i+1]:\n if l[i+1] == l[i+2]:\n c += 1\n i += 2\n else:\n c += 1\n i += 2\n else:\n i += 1\n \n print(c)\n return 0\n\ns()", "n = int(input())\nx = input().split(' ')\nl = [int(i) for i in x]\n\nc = 0\n\n\nfor i in range(1,n):\n if not boon and l[i] == l[i-1]:\n c += 1\n boon = True\n else:\n boon = False\n\nprint(c)\n", "n = int(input())\nx = input().split(' ')\nl = [int(i) for i in x]\n\nc = 0\n\n\nboon = False\n\nfor i in range(1,n):\n if not boon and l[i] == l[i-1]:\n c += 1\n boon = True\n else:\n boon = False\n\nprint(c)\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s360335835', 's408555740', 's568682015']
[3060.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[348, 206, 536]
p03296
u287500079
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input())\na=[int(i) for i in inpup().split()]\ncnt=0\nflag=False\nfor i in range(1,n):\n if a[i]==a[i-1]:\n if flag:\n flag=False\n else:\n cnt+=1\n flag=True\n else:\n flag=False\nprint(cnt)', 'n=int(input())\na=[int(i) for i in input().split()]\ncnt=0\nflag=False\nfor i in range(1,n):\n if a[i]==a[i-1]:\n if flag:\n flag=False\n else:\n cnt+=1\n flag=True\n else:\n flag=False\nprint(cnt)']
['Runtime Error', 'Accepted']
['s694043600', 's687803644']
[3060.0, 3060.0]
[18.0, 18.0]
[244, 244]
p03296
u288403580
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = int(input())\ns = map(int, input().split())\nc = 0\n\nfor i in range(1, N):\n\tif s[i] == s[i - 1]:\n\t\tc += 1\n\telse:\n\t\tpass\nprint(c)\n', 'N = int(input())\ns = list(map(int, input().split()))\nc = 0\n\nfor i in range(1, N):\n\tif s[i] == s[i - 1]:\n\t\tc += 1\n\telse:\n\t\tpass\nprint(c)\n', 'N = int(input())\ns = map(int, input().split())\nc = 0\n\nfor i in range(1, N):\n\tif s[i] == s[i - 1]:\n\t\tc += 1\n\telse:\nprint(c)\n', 'N = int(input())\na = [s for s in map(int, input().split())]\na.append(-1)\nc = 0\nresult = 0\nfor i in range(1, N + 1):\n\tif a[i] == a[i - 1]:\n\t\tc += 1\n\telse:\n\t\tif c == 0:\n\t\t\tcontinue\n\t\telse:\n\t\t\tc += 1\n\t\t\tif c % 2 == 1:\n\t\t\t\tresult += (c - 1) / 2\n\t\t\t\tc = 0\n\t\t\telse:\n\t\t\t\tresult += c / 2\n\t\t\t\tc = 0\nprint(int(result))\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s014688154', 's723386229', 's963354193', 's834377075']
[2940.0, 2940.0, 2940.0, 3060.0]
[17.0, 20.0, 17.0, 21.0]
[130, 136, 123, 309]
p03296
u315703650
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\na = list(map(int,input().split()))\ncnt = 0\ni = 1\nwhile i<n:\n print(i)\n if a[i]==a[i-1]:\n cnt += 1\n i += 1\n i += 1\nprint(cnt)', 'n = int(input())\na = list(map(int,input().split()))\ncnt = 0\ni = 1\nwhile i<n:\n if a[i]==a[i-1]:\n cnt += 1\n i += 1\n i += 1\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s069745853', 's507142559']
[3060.0, 3316.0]
[17.0, 21.0]
[164, 151]
p03296
u325227960
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['a=int(input())\nN=[0 for i in range(a)]\nb=input()\nfor i in range(a):\n N[i]=int(b.aplit())\n\n2ans=0\n2ans2=0\nfor i in range(a-1):\n if N[i]==N[i+1]:\n 2ans2+=1\n else :\n if 2ans2%2==1 :\n 2ans2+=1\n ans+=2ans2/2\n 2ans2=0\nreturn 2ans', 'a=int(input())\nN=[0 for i in range(a)]\nb=input()\n#print(b)\nN=b.split()\nfor i in range(a):\n N[i]=int(N[i])\n\n#print(N)\n \na2ans=0\na2ans2=0\nfor i in range(a-1):\n if N[i]==N[i+1]:\n a2ans2+=1\n #print(a2ans2)\n else :\n if a2ans2%2==1 :\n a2ans2+=1\n \n a2ans+=a2ans2/2\n a2ans2=0\n\n\nif a2ans2%2==1 :\n a2ans2+=1\n#print(a2ans2)\na2ans+=a2ans2/2\na2ans2=0\n\n\n\nprint(int(a2ans))']
['Runtime Error', 'Accepted']
['s014494418', 's320642436']
[2940.0, 3064.0]
[17.0, 17.0]
[243, 386]
p03296
u329865314
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N = int(input())\nlis = list(map(int,input().split()))\nl = []\ni = 0\nx = 0\nwhile(True):\n if i == N-1:\n x += 1\n l.append(x)\n break\n if lis[i] != lis[i+1]:\n x += 1\n l.append(x)\n x = 0\n else:\n x += 1\ns = 0\nfor i in lis:\n s += (i//1)\nprint(s)', 'N = int(input())\nlis = list(map(int,input().split()))\nl = []\ni = 0\nx = 0\nwhile(True):\n if i == N-1:\n x += 1\n l.append(x)\n break\n if lis[i] != lis[i+1]:\n x += 1\n l.append(x)\n x = 0\n else:\n x += 1\ns = 0\nfor i in lis:\n s += (i//2)\nprint(s)', 'N = int(input())\nlis = list(map(int,input().split()))\nl = []\ni = 0\nx = 0\nwhile(True):\n if i == N-1:\n x += 1\n l.append(x)\n break\n if lis[i] != lis[i+1]:\n x += 1\n l.append(x)\n x = 0\n else:\n x += 1\n i += 1\ns = 0\nfor i in l:\n s += (i//2)\nprint(s)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s523919744', 's819118317', 's499421874']
[58008.0, 59592.0, 3060.0]
[2107.0, 2106.0, 17.0]
[261, 261, 268]
p03296
u338769529
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n = int(input())\na = list(map(int, input().split()))\ntotal = 1\ntotal2 = 0\nfor i in range(0, n-1):\n if a[i]==a[i+1]:\n total += 1\n else:\n total2 += total//2\n total = 1\nprint(total2)', 'n = int(input())\na = list(map(int, input().split()))\ntotal = 1\ntotal2 = 0\na.append(0)\nfor i in range(0, n):\n if a[i]==a[i+1]:\n total += 1\n else:\n total2 += total//2\n total = 1\nprint(total2)']
['Wrong Answer', 'Accepted']
['s900502765', 's151929355']
[3060.0, 3060.0]
[17.0, 17.0]
[206, 216]
p03296
u340010271
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['N=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(N-1):\n if a[i]==a[i+1]:\n ans+=1\nprint(ans)', 'N=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(N-1):\n if a[i]==a[i+1]:\n a[i+1]=10**4+i+1\n ans+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s450929218', 's959775395']
[2940.0, 3060.0]
[18.0, 20.0]
[121, 146]
p03296
u347912669
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['# n = int(input())\n\nn = 14\ncolors = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 2, 3, 4]\nans = []\ni = 0\ncnt = 0\nwhile True:\n if i == n-1:\n cnt += 1\n ans.append(cnt)\n break\n if colors[i] != colors[i+1]:\n cnt += 1\n ans.append(cnt)\n cnt = 0\n else:\n cnt += 1\n i += 1\n\n\nans = list(map(lambda x: x //2, ans))\nprint(sum(ans))\n', 'n = int(input())\ncolors = list(map(int, input().split()))\n# n = 14\n\nans = []\ni = 0\ncnt = 0\nwhile True:\n if i == n-1:\n cnt += 1\n ans.append(cnt)\n break\n if colors[i] != colors[i+1]:\n cnt += 1\n ans.append(cnt)\n cnt = 0\n else:\n cnt += 1\n i += 1\n\n\nans = list(map(lambda x: x //2, ans))\nprint(sum(ans))\n']
['Wrong Answer', 'Accepted']
['s455957548', 's354640294']
[3064.0, 3060.0]
[17.0, 18.0]
[412, 412]
p03296
u371409687
2,000
1,048,576
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic. Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?
['n=int(input())\ns=list(map(int,input().split()))\nans=0\ncnt=1\nfor i in range(n-1):\n if s[i]==s[i+1]:\n cnt+=1\n else:\n ans+=cnt//2\n cnt=1\nprint(ans)', 'n=int(input())\ns=list(map(int,input().split()))\nans=0\ncnt=1\nfor i in range(n-1):\n if s[i]==s[i+1]:\n cnt+=1\n else:\n ans+=cnt//2\n cnt=1\nans+=cnt//2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s357772280', 's133849081']
[3060.0, 3060.0]
[20.0, 17.0]
[171, 183]