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
|
---|---|---|---|---|---|---|---|---|---|---|
p03403 | u185325486 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | [' N = int(input())\n A = [int(i) for i in input().split()]\n total, plus = A[0], A[1]\n for i in range(N-1):\n total += abs(A[i+1]-A[i])\n total += abs(A[N-1])\n print(total+A[1]-abs(A[1]-A[0])-A[0])\n for i in range(1,N-1): \n print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])) \n print(total+A[N-2]-abs(A[N-2]-A[N-1])-abs(A[N-1]))', 'N = int(input())\nA = [int(i) for i in input().split()]\ntotal = abs(A[0])\nfor i in range(N-1):\n total += abs(A[i+1]-A[i])\ntotal += abs(A[N-1])\nprint(total+abs(A[1])-abs(A[1]-A[0])-abs(A[0]))\nfor i in range(1,N-1): \n print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])) \nprint(total+abs(A[N-2])-abs(A[N-2]-A[N-1])-abs(A[N-1]))'] | ['Runtime Error', 'Accepted'] | ['s542161148', 's535158631'] | [2940.0, 14048.0] | [17.0, 231.0] | [385, 353] |
p03403 | u217627525 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['def main():\n n=int(input())\n a=list(map(int,input().split()))\n b=[a[0]]\n ans=abs(a[0])\n for i in range(n-1):\n b.append(a[i+1]-a[i])\n ans+=abs(a[i+1]-a[i])\n b.append(-1*a[n-1])\n ans+=abs(a[n-1])\n for i in range(n):\n if b[i]*b[i+1]>=0:\n print(ans)\n else:\n print(ans-b[i]-b[i+1]+abs(b[i]+b[i+1]))\nif __name__=="__main__":\n main()', 'def main():\n n=int(input())\n a=list(map(int,input().split()))\n b=[a[0]]\n ans=abs(a[0])\n for i in range(n-1):\n b.append(a[i+1]-a[i])\n ans+=abs(a[i+1]-a[i])\n b.append(-1*a[n-1])\n ans+=abs(a[n-1])\n for i in range(n):\n if b[i]*b[i+1]>=0:\n print(ans)\n else:\n print(ans-abs(b[i])-abs(b[i+1])+abs(b[i]+b[i+1]))\nif __name__=="__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s066329086', 's786351528'] | [14172.0, 14172.0] | [188.0, 184.0] | [403, 413] |
p03403 | u241159583 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = [0]+list(map(int, input().split()))+[0]\n\nmoney = [0]\nfor i in range(n+1):\n money.append(abs(a[i]-a[i+1]))\nprint(money)\nans = sum(money)\nfor i in range(n):\n print(ans - sum(money[i+1:i+3]) + abs(a[i]-a[i+2]))', 'import numpy as np\nn = int(input())\nA = [0] + list(map(int, input().split())) + [0]\nx = [0]\nfor i in range(len(A)-1):\n x.append(abs(A[i]-A[i+1]))\nans = sum(x)\nfor i in range(1, n+1):\n print(ans - (x[i]+x[i+1]) + abs(A[i-1]-A[i+1]))'] | ['Wrong Answer', 'Accepted'] | ['s361809393', 's282053737'] | [14048.0, 38532.0] | [236.0, 225.0] | [234, 237] |
p03403 | u252828980 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\nL = list(map(int,input().split()))\nprint(L)\nLL = sorted(L)\n\nposi = [x for x in L if x > 0]\nnega = [x for x in L if x < 0]\n\nmax_posi,max_nega,sec_posi,sec_nega = 0,0,0,0\nif len(posi) >=2:\n max_posi = LL[-1]\n sec_posi = LL[-2]\nif len(posi) == 1:\n max_posi = LL[-1]\nif len(nega) >=2:\n max_nega = LL[0]\n sec_nega = LL[1]\nif len(nega) == 1:\n max_nega = LL[0]\n\nif max_posi and max_nega: \n sum1 = max_posi*2 + abs(max_nega)*2\nelif max_posi and not max_nega:\n sum1 = max_posi*2\nelif not max_posi and max_nega:\n sum1 = abs(max_nega)*2\n\nprint(max_posi,sec_posi,max_nega,sec_nega,sum1) \n\nfor i in range(n):\n if max_posi and max_nega:\n if L[i] != max_posi and L[i] != max_nega:\n print(sum1)\n elif L[i] == max_posi:\n if sec_posi:\n print(sec_posi*2 + abs(max_nega)*2)\n else:\n print(abs(max_nega)*2)\n elif L[i] == max_nega:\n if sec_nega:\n print(abs(sec_nega)*2 + max_posi*2)\n else:\n print(max_posi*2)\n else:\n if max_posi:\n if L[i] == max_posi:\n if sec_posi:\n print(sec_posi*2)\n else:\n print(abs(max_posi)*2)\n else:\n print(sum1)\n elif max_nega:\n if L[i] == max_nega:\n if sec_nega:\n print(abs(sec_nega)*2)\n else:\n print(abs(max_nega)*2)\n \n\n \n ', 'n = int(input())\nL = list(map(int,input().split()))\nprint(L)\nLL = sorted(L)\n\nposi = [x for x in L if x > 0]\nnega = [x for x in L if x < 0]\n\nmax_posi,max_nega,sec_posi,sec_nega = 0,0,0,0\nif len(posi) >=2:\n max_posi = LL[-1]\n sec_posi = LL[-2]\nif len(posi) == 1:\n max_posi = LL[-1]\nif len(nega) >=2:\n max_nega = LL[0]\n sec_nega = LL[1]\nif len(nega) == 1:\n max_nega = LL[0]\n\nif max_posi and max_nega: \n sum1 = max_posi*2 + abs(max_nega)*2\nelif max_posi and not max_nega:\n sum1 = max_posi*2\nelif not max_posi and max_nega:\n sum1 = abs(max_nega)*2\n\nprint(max_posi,sec_posi,max_nega,sec_nega,sum1) \n\nfor i in range(n):\n if max_posi and max_nega:\n if L[i] != max_posi and L[i] != max_nega:\n print(sum1)\n elif L[i] == max_posi:\n if sec_posi:\n print(sec_posi*2 + abs(max_nega)*2)\n else:\n print(abs(max_nega)*2)\n elif L[i] == max_nega:\n if sec_nega:\n print(abs(sec_nega)*2 + max_posi*2)\n else:\n print(max_posi*2)\n else:\n if max_posi:\n if L[i] == max_posi:\n if sec_posi:\n print(sec_posi*2)\n else:\n print(abs(max_posi)*2)\n else:\n print(sum1)\n elif max_nega:\n if L[i] == max_nega:\n if sec_nega:\n print(abs(sec_nega)*2)\n else:\n print(abs(max_nega)*2)\n \n\n \n ', 'n = int(input())\nL = list(map(int,input().split()))\nL = [0] + L + [0]\n\ndiff1 = []\ndiff2 = []\nsum1 = 0\nfor i in range(n+1):\n sum1 += abs(L[i+1]-L[i])\n diff1.append(abs(L[i+1]-L[i]))\n\nfor i in range(n):\n diff2.append(abs(L[i+2]-L[i]))\n\nfor i in range(n):\n ans = sum1-(diff1[i]+diff1[i+1]) + diff2[i]\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s928936678', 's929063898', 's952067688'] | [20600.0, 20576.0, 20520.0] | [126.0, 129.0, 176.0] | [1557, 1557, 324] |
p03403 | u257541375 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['import copy\n\nn = int(input())\nnatural = [int(i) for i in input().split()]\nsortedlist = natural.sorted()\n\nsum = 0\n\nfor i in range(n):\n removed = copy.deepcopy(sortedlist).remove(natural[i])\n for j in range(n-1):\n if j == 0:\n sum += abs(removed[j])\n else:\n sum += abs(removed[j]-removed[j-1])\n print(sum)', 'n = int(input())\nsortedlist = [int(i) for i in input().split()]\nanslist = []\n\nlongest = 0\nans = 0\n\nfor i in range(n+1):\n if i==0:\n longest += abs(sortedlist[0]-0)\n elif i==n:\n longest += abs(0-sortedlist[n-1])\n else:\n longest += abs(sortedlist[i]-sortedlist[i-1])\n\n \nfor i in range(n):\n if i==0:\n ans = longest - abs(sortedlist[0]) - abs(sortedlist[1]-sortedlist[0]) + abs(sortedlist[1])\n elif i==n-1:\n ans = longest - abs(sortedlist[n-1]) - abs(sortedlist[n-1]-sortedlist[n-2]) + abs(sortedlist[n-2])\n else:\n ans = longest - abs(sortedlist[i]-sortedlist[i-1])-abs(sortedlist[i+1]-sortedlist[i]) + abs(sortedlist[i+1]-sortedlist[i-1])\n print(ans)\n '] | ['Runtime Error', 'Accepted'] | ['s968721077', 's145318101'] | [14560.0, 13792.0] | [50.0, 257.0] | [321, 677] |
p03403 | u278356323 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ["# ARC093c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n from collections import Counter\n\n n = int(input())\n a = [0]\n a.extend(list(map(int, input().split())))\n a.append(0)\n print(a)\n\n total = 0\n for i in range(1, n+2):\n total += abs(a[i]-a[i-1])\n # print(total)\n\n for j in range(1, n+1):\n if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:\n print(total)\n continue\n print(total-abs(a[j]-a[j-1])-abs(a[j+1]-a[j])+abs(a[j+1]-a[j-1]))\n\n\nif __name__ == '__main__':\n main()\n", "# ARC093c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n from collections import Counter\n\n n = int(input())\n a = [0]\n a.extend(list(map(int, input().split())))\n a.append(0)\n # print(a)\n\n total = 0\n for i in range(1, n+2):\n total += abs(a[i]-a[i-1])\n # print(total)\n\n for j in range(1, n+1):\n if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:\n print(total)\n continue\n print(total-abs(a[j]-a[j-1])-abs(a[j+1]-a[j])+abs(a[j+1]-a[j-1]))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s071385770', 's752839464'] | [14304.0, 14300.0] | [202.0, 193.0] | [596, 598] |
p03403 | u318427318 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n \ndef main():\n plan=[0]\n n = int(input())\n plan+=list(map(int,input().split()))\n plan.append(0)\n pay_sum = 0\n for i in range(1,n+2):\n pay_sum += abs(plan[i] - plan[i-1])\n \n for i in range(1,n+1):\n result = abs(plan[i-1] - plan[i+1])\n result -= abs(plan[i-1] - plan[i])\n result -= abs(plan[i+1] - plan[i])\n print(pay_sum - result)\n\nif __name__=="__main__":\n main()', '#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n \ndef main():\n plan=[0]\n n = int(input())\n plan+=list(map(int,input().split()))\n plan.append(0)\n pay_sum = 0\n for i in range(1,n+2):\n pay_sum += abs(plan[i] - plan[i-1])\n \n for i in range(1,n+1):\n result = abs(plan[i-1] - plan[i+1])\n result -= abs(plan[i-1] - plan[i])\n result -= abs(plan[i+1] - plan[i])\n print(pay_sum + result)\n\nif __name__=="__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s456386627', 's089806161'] | [19944.0, 19844.0] | [144.0, 139.0] | [488, 488] |
p03403 | u329865314 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\nlis = list(map(int, input().split()))\ndef abs(m):\n if m>0:\n return m\n return(-m)\ndef mysum(data):\n ans = 0\n data = [0] + data+[0]\n for j in range(len(data)-1):\n ans += abs(data[j] - data[j+1])\nfor i in range(len(lis)):\n tmp = lis[:i-1] + lis[i:]\n print(mysum(tmp))', 'n = int(input())\nlis = [0] + list(map(int, input().split())) + [0]\ntmp = []\nfor j in range(len(lis)-1):\n tmp.append(lis[j+1] - lis[j])\nlis = list(map(abs,tmp))\npreans = sum(lis)\nfor i in range(len(tmp)-1):\n print(preans - lis[i] - lis[i+1] + abs(tmp[i] + tmp[i+1]))\n'] | ['Wrong Answer', 'Accepted'] | ['s796227286', 's168852614'] | [14288.0, 14272.0] | [2104.0, 191.0] | [294, 272] |
p03403 | u362829196 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ["#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\nN = int(sys.stdin.readline())\n\nA = map(lambda x: int(x), sys.stdin.readline().split(' '))\n\ntotal = 0\nA.insert(0, 0)\nA.append(0)\n\nfor i in range(N + 1):\n\ttotal += abs(A[i] - A[i+1])\n\nfor i in range(1, N + 1):\n\tprint(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))\n", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\nN = int(sys.stdin.readline())\n\nA = sys.stdin.readline().split(' ')\n\n\nfor rem in range(len(A)):\n\tpay = 0\n\tB = A.copy()\n\tdel(B[rem])\n\n\tfor i in range(len(B)):\n\n\t\ta = B[i]\n\t\ts = B[i - 1] if i > 0 else 0\n\n\t\tl = a - s\n\t\tpay += l if l > 0 else -l\n\n\tlastPoint = B[len(B) - 1]\n\tpay += lastPoint if lastPoint > 0 else -lastPoint\n\n\tprint(pay)", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\nN = int(sys.stdin.readline())\n\nA = sys.stdin.readline().split(' ')\n\nA = [int(x) for x in A]\n\nA.insert(0, 0)\nA.append(0)\n\ntotal = 0\n\nfor i in range(N + 1):\n\ttotal += abs(A[i] - A[i+1])\n\nfor i in range(1, N + 1):\n\tprint(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s542767318', 's837657536', 's431839362'] | [9960.0, 10236.0, 14052.0] | [26.0, 27.0, 235.0] | [358, 391, 361] |
p03403 | u397531548 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['A=int(input())\nB=list(map(int,input().split()))\na=0\nS=0\nfor i in range(len(B)):\n S+=abs(B[i]-a)\n a=B[i]\nS+=abs(B[-1])\nfor j in range(len(B)):\n if j=0:\n if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:\n print(S)\n elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:\n print(S-abs(B[0]))\n else:\n print(S-abs(B[1]-B[0]))\n elif j=len(B)-1:\n if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:\n print(S)\n elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:\n print(S-abs(B[-1]))\n else:\n print(S-abs(B[-1]-B[-2]))\n else:\n if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:\n print(S)\n elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:\n print(S-abs(B[j-1]-B[j]))\n else:\n print(S-abs(B[j+1]-B[j]))', 'A=int(input())\nB=list(map(int,input().split()))\na=0\nS=0\nfor i in range(len(B)):\n S+=abs(B[i]-a)\n a=B[i]\nS+=abs(B[-1])\nfor j in range(len(B)):\n if j==0:\n if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:\n print(S)\n elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:\n print(S-2*abs(B[0]))\n else:\n print(S-2*abs(B[1]-B[0]))\n elif j==len(B)-1:\n if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:\n print(S)\n elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:\n print(S-2*abs(B[-1]))\n else:\n print(S-2*abs(B[-1]-B[-2]))\n else:\n if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:\n print(S)\n elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:\n print(S-2*abs(B[j-1]-B[j]))\n else:\n print(S-2*abs(B[j+1]-B[j]))\n'] | ['Runtime Error', 'Accepted'] | ['s062367773', 's269991675'] | [2940.0, 13928.0] | [17.0, 264.0] | [808, 823] |
p03403 | u410118019 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = list(map(int,input().split()))\nal = [0] * n\nfor i in range(n):\n al[i] = abs(a[i+1] - a[i])\ns = sum(al)\nfor i in range(n):\n print(s-al[i-1]-al[i]+abs(a[i+1]-a[i-1]))', 'n = int(input())\nai = list(map(int,input().split()))\na = [0]\nfor i in ai:\n a.append(i)\nal = [0] * (n+1)\nfor i in range(n+1):\n al[i] = abs(a[(i+1)%(n+1)] - a[i])\ns = sum(al)\nfor i in range(1,n+1):\n print(s-al[i-1]-al[i]+abs(a[(i+1)%(n+1)]-a[i-1]))'] | ['Runtime Error', 'Accepted'] | ['s212242458', 's023103733'] | [13920.0, 14176.0] | [70.0, 220.0] | [187, 249] |
p03403 | u473291366 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\nA = [0] + list(map(int,input().split())) + [0]\nprint(A)\n\nF = [0]\nfor i in range(1, N+1):\n F.append(abs(A[i] - A[i-1]) + F[i-1])\n\nB = [0]\nfor i in range(1, N+1):\n B.append(abs(A[N+1-i] - A[N+2-i]) + B[i-1])\nB.reverse()\n\nfor i in range(1, N+1):\n print(abs(A[i+1]-A[i-1]) + F[i-1] + B[i])', 'N = int(input())\nA = [0] + list(map(int,input().split())) + [0]\n\nF = [0]\nfor i in range(1, N+1):\n F.append(abs(A[i] - A[i-1]) + F[i-1])\n\nB = [0]\nfor i in range(1, N+1):\n B.append(abs(A[N+1-i] - A[N+2-i]) + B[i-1])\nB.reverse()\n\nfor i in range(1, N+1):\n print(abs(A[i+1]-A[i-1]) + F[i-1] + B[i])'] | ['Wrong Answer', 'Accepted'] | ['s898980948', 's431381623'] | [17668.0, 17044.0] | [264.0, 254.0] | [311, 302] |
p03403 | u496727432 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = list(map(int,input().split))\nans = [0] * n\nfor i in range(n):\n ac = a\n del ac[i]\n for j in range(0, n):\n if j == 0:\n ans[i] += abs(ac[0])\n else:\n ans[i] += abs(ac[j]-ac[j - 1])\n\nfor k in ans:\n print(str(k))', 'import copy\n\nn = int(input())\na = list(map(int,input().split()))\nans = [0] * n\nprint(ans)\nfor i in range(n):\n ac = copy.copy(a)\n del ac[i]\n for j in range(n):\n if j == 0:\n ans[i] += abs(ac[0])\n elif j == n - 1:\n ans[i] += abs(ac[n - 2])\n else:\n ans[i] += abs(ac[j]-ac[j - 1])\n\nfor k in ans:\n print(str(k))', 'n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nans = 0\nanslist = [0] * n\nfor j in range(n + 1):\n if j == 0:\n ans += abs(a[0])\n elif j == n:\n ans += abs(a[n - 1])\n else:\n ans += abs(a[j]-a[j - 1])\n\nfor i in range(1, n + 1):\n anslist[i - 1] = ans - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])\n \nfor k in anslist:\n print(k)\n', 'n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nans = 0\nanslist = [0] * n\nfor j in range(1, n + 2):\n if j == 1:\n ans += abs(a[j])\n elif j == n + 1:\n ans += abs(a[n])\n else:\n ans += abs(a[j]-a[j - 1])\n\nfor i in range(1, n + 1):\n anslist[i - 1] = ans - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])\n \nfor k in anslist:\n print(k)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s294791384', 's313167052', 's854268174', 's732355404'] | [10076.0, 20836.0, 20584.0, 20496.0] | [26.0, 2206.0, 180.0, 182.0] | [275, 371, 412, 414] |
p03403 | u536034761 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['from itertools import accumulate\nN = int(input())\nA = tuple([0,] + list(map(int, input().split())) + [0,])\nD = []\nsum = 0\nfor i, a in enumarate(A[1:-1]):\n i += 1\n pre = A[i - 1]\n tem = A[i]\n nex = A[i + 1]\n x = abs(pre - tem) + abs(tem - nex)\n sum += x\n D.append(abs(pre - nex) - x)\nfor d in D:\n print(sum + d)', 'from itertools import accumulate\nN = int(input())\nA = tuple([0,] + list(map(int, input().split())) + [0,])\nD = []\nsum = 0\nfor i, a in enumerate(A[1:-1]):\n i += 1\n pre = A[i - 1]\n tem = A[i]\n nex = A[i + 1]\n x = abs(pre - tem)\n y = abs(tem - nex)\n sum += x\n D.append(abs(pre - nex) - x - y)\nsum += y\nfor d in D:\n print(sum + d)'] | ['Runtime Error', 'Accepted'] | ['s686354144', 's655553996'] | [20372.0, 20464.0] | [53.0, 165.0] | [318, 335] |
p03403 | u557437077 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ["if __name__ == '__main__':\n n = int(input())\n a = list(map(int, input().split()))\n A = list([0])\n A.append(a)\n A.append(0)\n \n sum = 0\n for i in range(n):\n root = list(A[:])\n del root[i+1]\n for j in range(1, n+1):\n sum += abs(root[j]-root[j-1])\n print(sum)\n sum = 0\n", "if __name__ == '__main__':\n n = int(input())\n a = list(map(int, input().split()))\n A = list([0])\n A.append(a)\n A.append(0)\n \n sum = 0\n for i in range(n):\n root = list(A[:])\n del root[i+1]\n for j in range(1, n+1):\n sum += abs(root[j]-root[j-1])\n print(sum)\n sum = 0\n", "if __name__ == '__main__':\n n = int(input())\n a = list(map(int, input().split()))\n A = list([0])\n A.extend(a)\n A.append(0)\n\n sum = 0\n for i in range(1, n+2):\n sum += abs(A[i]-A[i-1])\n for i in range(1, n+1):\n print(sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s406074186', 's865587185', 's131916930'] | [14048.0, 14048.0, 14044.0] | [41.0, 41.0, 221.0] | [335, 335, 311] |
p03403 | u593567568 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['import itertools\n\nN = int(input())\nA = list(map(int,input().split()))\n\nacc = []\nprev = 0\nfor a in A:\n t = abs(a - prev)\n acc.append(t)\n prev = a\n \n\nans = []\nfor i in range(N):\n t = 0\n if 0 < i:\n t += acc[i-1]\n \n if i < N-1:\n t += acc[N-1] - acc[i]\n \n ans.append(t)\n \nprint("\\n".join(map(str,ans)))', 'import itertools\n\nN = int(input())\nA = [0] + list(map(int,input().split())) + [0]\n\nacc = []\nprev = 0\nt = 0\nfor i in range(N+2):\n if i == 0:\n continue\n a = A[i]\n t += abs(a - prev)\n acc.append(t)\n prev = a\n \nans = []\nfor i in range(N+1):\n if i == 0:\n continue\n t = 0\n\n if 1 < i:\n t += acc[i-2]\n if i < N:\n t += acc[N] - acc[i]\n t += abs(A[i+1] - A[i-1])\n \n ans.append(t)\n \nprint("\\n".join(map(str,ans)))\n'] | ['Wrong Answer', 'Accepted'] | ['s564924753', 's242464027'] | [21948.0, 23148.0] | [151.0, 218.0] | [316, 431] |
p03403 | u600896094 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ["def main():\n N = int(input())\n A = [0] + list(map(int, input().split())) + [0]\n\n sum = 0\n for i in range(1, N+2): sum += abs(A[i] - A[i-1])\n\n for i in range(1, N+1):\n if (A[i-1] <= A[i] <= A[i+1]): print(sum)\n elif (A[i-1] >= A[i] >= A[i+1]): print(sum)\n else: print(sum - abs(A[i] - A[i-1]) * 2)\n\nif __name__ == '__main__':\n main()\n", "def main():\n N = int(input())\n A = [0] + list(map(int, input().split())) + [0]\n\n sum = 0\n for i in range(1, N+2): sum += abs(A[i] - A[i-1])\n\n for i in range(1, N+1):\n if A[i-1] <= A[i] <= A[i+1]: print(sum)\n elif A[i-1] >= A[i] >= A[i+1]: print(sum)\n elif A[i-1] < A[i+1] < A[i] or A[i-1] > A[i+1] > A[i]: print(sum - abs(A[i+1] - A[i]) * 2)\n else: print(sum - abs(A[i] - A[i-1]) * 2)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s697480800', 's219819918'] | [14048.0, 14048.0] | [174.0, 201.0] | [372, 468] |
p03403 | u657611449 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\ndd = list(map(int, input().split()))\nd = [0]\nd.extend(dd)\nd.append(0)\n\ndiff = [abs(d[i + 1] - d[i]) for i in range(N + 1)]\n\ndd = []\nfor i in range(N):\n if (d[i + 1] - d[i]) * (d[i + 2] - d[i]) < 0:\n dd.append(2 * abs(d[i + 1] - d[i]))\n else:\n dd.append(0)\n\ns = sum(diff)\nfor i in range(N):\n print(s - dd[i])', 'N = int(input())\ndd = list(map(int, input().split()))\nd = [0]\nd.extend(dd)\nd.append(0)\n\ndiff = [abs(d[i + 1] - d[i]) for i in range(N + 1)]\ndd = []\nfor i in range(N):\n temp = abs(d[i + 1] - d[i]) + abs(d[i + 2] - d[i + 1])\n temp_2 = abs(d[i + 2] - d[i])\n if temp > temp_2:\n dd.append(temp - temp_2)\n else:\n dd.append(0)\ns = sum(diff)\nfor i in range(N):\n print(s - dd[i])'] | ['Wrong Answer', 'Accepted'] | ['s425255295', 's422563790'] | [13920.0, 14980.0] | [201.0, 242.0] | [347, 399] |
p03403 | u778814286 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\nA = [0] + list(map(int, input().split())) + [0]\ndiff = [abs(A[i]-A[i+1]) for i in range(n+1)]\n\n\nsum = 0\nfor i,(a, dif) in enumerate(zip(A, diff)):\n if i == n+1: break \n sum += abs(a - dif) #a:A[i]\n \n\nfor i in range(1, n+1, 1): \n nowsum = sum\n nowsum -= abs(A[i-1]-A[i])\n nowsum -= abs(A[i]-A[i+1])\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n', 'n = int(input\nA = [0] + list(map(int, input().split())) + [0]\n\n\nsum = 0\nfor i, a in enumerate(A):\n if i == n+1: break \n sum += abs(a - A[i+1]) #a:A[i]\n \n\nfor i in range(1, n+1, 1): \n nowsum = sum\n nowsum -= abs(A[i-1]-A[i])\n nowsum -= abs(A[i]-A[i+1])\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n', 'n = int(input)\nA = [0] + list(map(int, input().split())) + [0]\n\n\nsum = 0\nfor i, a in enumerate(A):\n if i == n+1: break \n sum += abs(a - A[i+1]) #a:A[i]\n \n\nfor i in range(1, n+1, 1): \n nowsum = sum\n nowsum -= abs(A[i-1]-A[i])\n nowsum -= abs(A[i]-A[i+1])\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n', 'n = int(input())\nA = [0] + list(map(int, input().split())) + [0]\ndiff = [abs(A[i]-A[i+1]) for i in range(n+1)]\n\n\nsum = sum(diff)\n \n\nfor i in range(1, n+1, 1): \n nowsum = sum\n nowsum -= diff[i-1]\n nowsum -= diff[i]\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s135564859', 's162357197', 's701027311', 's491456785'] | [14172.0, 2940.0, 3064.0, 14176.0] | [273.0, 17.0, 17.0, 202.0] | [476, 413, 414, 330] |
p03403 | u781262926 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n, *A = map(int, open(0).input().split())\nA = [0] + A + [0]\nB = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]\ns = sum(B)\nfor i in range(1, n+1):\n print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])', 'n, *A = map(int, open(0).read().split())\nA = [0] + A + [0]\nB = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]\ns = sum(B)\nfor i in range(1, n+1):\n print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])'] | ['Runtime Error', 'Accepted'] | ['s530279042', 's588535240'] | [3060.0, 13932.0] | [17.0, 178.0] | [189, 188] |
p03403 | u813098295 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = [ int(x) for x in input().split() ]\n\nans = abs(a[0] )\n\nfor i in range(1, len(a)):\n ans += abs(a[i] - a[i-1])\n\nans += abs(a[-1] - 0)\n\nfor i, v in enumerate(a):\n if i == 0:\n if 0 <= v <= a[i+1] or a[i+1] <= v <= 0:\n print(ans)\n elif 0 <= a[i+1] <= v or v <= a[i+1] <= 0:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= 0 <= a[i+1] or a[i+1] <= 0 <= v:\n print(ans-abs(v)*2)\n\n\n if 0 <= v <= a[i+1] or a[i+1] <= v <= 0:\n print(ans)\n else:\n print(ans-2*abs(v))\n elif i == n-1:\n if a[i-1] <= v <= 0 or 0 <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= 0 <= v or v <= 0 <= a[i-1]:\n print(ans-abs(v)*2)\n elif v <= a[i-1] <= 0 or 0 <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n else:\n if a[i-1] <= v <= a[i+1] or a[i+1] <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= a[i+1] <= v or v <= a[i+1] <= a[i-1]:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n\n', 'n = int(input())\na = [ int(x) for x in input().split() ]\n\nans = abs(a[0] )\n\nfor i in range(1, len(a)):\n ans += abs(a[i] - a[i-1])\n\nans += abs(a[-1] - 0)\n\nfor i, v in enumerate(a):\n if i == 0:\n if 0 <= v <= a[i+1] or a[i+1] <= v <= 0:\n print(ans)\n elif 0 <= a[i+1] <= v or v <= a[i+1] <= 0:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= 0 <= a[i+1] or a[i+1] <= 0 <= v:\n print(ans-abs(v)*2)\n\n elif i == n-1:\n if a[i-1] <= v <= 0 or 0 <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= 0 <= v or v <= 0 <= a[i-1]:\n print(ans-abs(v)*2)\n elif v <= a[i-1] <= 0 or 0 <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n else:\n if a[i-1] <= v <= a[i+1] or a[i+1] <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= a[i+1] <= v or v <= a[i+1] <= a[i-1]:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s258351581', 's355402159'] | [13800.0, 13800.0] | [254.0, 262.0] | [1122, 1003] |
p03403 | u814781830 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\nA = [0] * (N + 2)\nfor i, v in enumerate(input().split()):\n A[i+1] = int(v)\nnum = sum([abs(A[i] - A[i+1]) for i in range(N+1)])\nfor i in range(N):\n ret = num + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))\n print(ret)', 'N = int(input())\nA = [0] * (N + 2)\nfor i, v in enumerate(input().split()):\n A[i+1] = int(v)\nnum = sum([abs(A[i] - A[i+1]) for i in range(N+1)])\nfor i in range(1,N+1):\n ret = num + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))\n print(ret)'] | ['Wrong Answer', 'Accepted'] | ['s437350901', 's829997375'] | [14000.0, 14000.0] | [239.0, 235.0] | [261, 265] |
p03403 | u860002137 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = np.array([0] + list(map(int, input().split())) + [0])\n\nwhole = np.abs((np.diff(a))).sum()\n\nfor i in range(n):\n print(whole - abs(a[i + 1] - a[i]) -\n abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))', 'import numpy as np\n\nN = int(input())\nA = np.array([0] + list(map(int, input().split())) + [0])\n\ndiff = np.diff(A)\n\nrev = [x < 0 for x in diff]\n\nis_true = []\nfor i in range(len(rev) - 1):\n is_true.append(rev[i] & rev[i + 1])\n\nwhole = np.abs(diff).sum()\n\nresult = []\nfor i in range(N):\n if is_true[i]:\n result.append(whole)\n else:\n result.append(whole - np.abs(diff)[i] * 2)\n\nprint(*result, sep="\\n")', 'import numpy as np\nn = int(input())\na = np.array([0] + list(map(int, input().split())) + [0])\n\nwhole = np.abs((np.diff(a))).sum()\n\nfor i in range(n):\n print(whole - abs(a[i + 1] - a[i]) -\n abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s451140858', 's574626151', 's126776927'] | [3060.0, 22852.0, 32008.0] | [17.0, 2109.0, 1115.0] | [230, 421, 249] |
p03403 | u861141787 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = list(map(int, input().split()))\n\nb = [0] + a + [0]\nc = []\nfor i in range(n+1):\n c.append(abs(b[i] - b[i+1]))\n\nfor i in range(n):\n ans = l - c[i] - c[i+1]\n ans += abs(b[i] - b[i+2])\n print(ans)\n', 'n = int(input())\na = list(map(int, input().split()))\n\nb = [0] + a + [0]\nc = []\nfor i in range(n+1):\n c.append(abs(b[i] - b[i+1]))\n\nl = sum(c)\n\nfor i in range(n):\n ans = l - c[i] - c[i+1]\n ans += abs(b[i] - b[i+2])\n print(ans)\n\n'] | ['Runtime Error', 'Accepted'] | ['s604324627', 's642759220'] | [14048.0, 14040.0] | [74.0, 197.0] | [226, 239] |
p03403 | u896741788 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n=input()\nl=[0]+list(map(int,input().split()))+[0]\nans=0\npre=0\nfor i in l:ans+=abs(pre-i);pre=i\nfor i in range(1,int(n)+1):\n dif=-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1])\n if l[i]in(l[i-1],l[i+1]):print(ans)\n elif l[i]<l[i-1]:\n print(ans if l[i+1]<l[i] else ans+dif)\n else:print(ansans if l[i+1]>l[i] else ans+dif)', 'n=input()\nl=[0]+list(map(int,input().split()))+[0]\nans=0\npre=0\nfor i in l:ans+=abs(pre-i);pre=i\nfor i in range(1,int(n)+1):\n dif=-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1])\n if l[i]in(l[i-1],l[i+1]):print(ans)\n elif l[i]<l[i-1]:\n print(ans if l[i+1]<l[i] else ans+dif)\n else:print(ans if l[i+1]>l[i] else ans+dif)'] | ['Runtime Error', 'Accepted'] | ['s986749238', 's001604152'] | [20672.0, 20620.0] | [73.0, 207.0] | [333, 330] |
p03403 | u931462344 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\nA = [0]\nA = A + list(map(int, input().split()))\nA.append(0)\nprint(A)\nsumOfRoute = 0\ntmp = 0\nfor a in A:\n sumOfRoute += abs(tmp-a)\n tmp = a\n\nprev = 0\nfor i in range(1, N+1):\n nexti = A[i+1]\n print(sumOfRoute + abs(prev - nexti) - abs(A[i] - nexti) - abs(prev - A[i]))\n prev = A[i]\n', 'N = int(input())\nA = [0]\nA = A + list(map(int, input().split()))\nA.append(0)\nsumOfRoute = 0\ntmp = 0\nfor a in A:\n sumOfRoute += abs(tmp-a)\n tmp = a\n\nprev = 0\nfor i in range(1, N+1):\n nexti = A[i+1]\n print(sumOfRoute + abs(prev - nexti) - abs(A[i] - nexti) - abs(prev - A[i]))\n prev = A[i]\n'] | ['Wrong Answer', 'Accepted'] | ['s238225955', 's930074396'] | [13920.0, 13920.0] | [216.0, 201.0] | [312, 303] |
p03403 | u955125992 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.insert(0, 0)\ndis = [0] * (n+1)\nfor i in range(1, n+2):\n dis[i-1] = abs(a[i] - a[i-1])\n\nS = sum(dis)\nprint(S)\nfor i in range(1, n+1):\n A = a[i-1]\n B = a[i]\n C = a[i+1]\n if A > C:\n A, C = C, A\n if A<=B<=C:\n print(S)\n else:\n print(S-2*min(abs(A-B), abs(C-B)))', 'n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.insert(0, 0)\ndis = [0] * (n+1)\nfor i in range(1, n+2):\n dis[i-1] = abs(a[i] - a[i-1])\n\nS = sum(dis)\nfor i in range(1, n+1):\n A = a[i-1]\n B = a[i]\n C = a[i+1]\n if A > C:\n A, C = C, A\n if A<=B<=C:\n print(S)\n else:\n print(S-2*min(abs(A-B), abs(C-B)))'] | ['Wrong Answer', 'Accepted'] | ['s900577859', 's683761884'] | [14172.0, 14048.0] | [239.0, 242.0] | [365, 356] |
p03403 | u981931040 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\nA = list(map(int, input().split()))\nA.append(0)\nsum_val = 0\nnow = 0\nfor i in range(N + 1):\n sum_val += abs(A[i] - now)\n now = A[i]\n\nfor i in range(1 , N + 1):\n if A[i - 1] >= 0:\n if A[i - 1] > A[i]:\n print(sum_val - abs(A[i - 1] - A[i - 2]) * 2)\n else:\n print(sum_val)\n elif A[i - 1] < 0:\n if A[i - 1] < A[i]:\n print(sum_val - abs(A[i - 1] - A[i - 2]) * 2)\n else:\n print(sum_val)\n', 'N = int(input())\nA = list(map(int, input().split()))\nA.append(0)\nA.insert(0, 0)\nsum_val = 0\nnow = 0\nfor i in range(N + 1):\n sum_val += abs(A[i] - A[i + 1])\n\nfor i in range(1 , N + 1):\n print(sum_val - (abs(A[i-1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]))\n'] | ['Wrong Answer', 'Accepted'] | ['s726142145', 's972994171'] | [14048.0, 14040.0] | [195.0, 219.0] | [481, 279] |
p03403 | u993435350 | 2,000 | 262,144 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | ['N = int(input())\nA = list(map(int,input().split()))\n \nfor i in range(N):\n now = 0\n ans = 0\n for j in range(N):\n if i != j:\n next = A[j]\n ans += abs(next - now)\n now = next\n ans += abs(A[-1])\n print(ans)', 'N = int(input())\nA = list(map(int,input().split()))\n\nfor i in range(N):\n now = 0\n ans = 0\n B = [A[j] for j in range(N) if j != i]\n for next in A:\n ans += abs(next - now)\n now = next\n ans += abs(B[-1])\n print(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\n\nfor i in range(N):\n now = 0\n ans = 0\n for j in range(N):\n if i != j:\n next = A[j]\n ans += abs(next - now)\n now = next\n ans += abs(B[-1])\n print(ans)\n', 'N = int(input())\nA = [0]\nA = A + list(map(int,input().split()))\nA = A + [0]\n\nD = 0\n\nfor i in range(N + 1):\n D += abs(A[i + 1] - A[i])\n \nfor i in range(1,N + 1):\n ans = D + abs(A[i + 1] - A[i - 1]) - (abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]))\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s033465802', 's384708932', 's513133867', 's827345640'] | [14048.0, 13920.0, 14048.0, 13920.0] | [2104.0, 2108.0, 79.0, 226.0] | [225, 225, 225, 260] |
p03411 | u077291787 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['# ARC092C - 2D Plane 2N Points (ABC091C)\n# greedy algorithm\ndef main():\n N = int(input())\n A = sorted(\n [tuple(map(int, input().split())) for _ in range(N)],\n key=lambda x: x[1],\n reverse=1,\n )\n B = sorted([tuple(map(int, input().split())) for _ in range(N)])\n ans, memo = 0, set()\n for bx, by in B:\n for i, (ax, ay) in enumerate(A):\n if i not in memo and ax < bx and ay < by:\n ans += 1\n memo |= {i}\n print(ans)\n\n\nif __name__ == "__main__":\n main()', '# ABC091C - 2D Plane 2N Points (ARC092C)\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n N = int(input())\n A = sorted(\n [tuple(map(int, input().split())) for _ in range(N)],\n key=lambda x: x[1],\n reverse=1,\n )\n B = sorted([tuple(map(int, input().split())) for _ in range(N)])\n ans, memo = 0, set()\n for bx, by in B:\n for i, (ax, ay) in enumerate(A):\n if i not in memo and ax < bx and ay < by:\n ans += 1\n memo |= {i}\n break\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s206201328', 's266890740'] | [3064.0, 3064.0] | [19.0, 18.0] | [541, 584] |
p03411 | u098240946 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['n = int(input())\n\nred = []\nblue = []\ned = []\nfor i in range(n):\n red.append(list(map(int,input().split())))\nfor i in range(n):\n blue.append(list(map(int,input().split())))\n\n\nnode = n*2\n \nfor i in range(n):\n for j in range(n):\n if red[i][0]<blue[j][0] and red[i][1]<blue[j][1]:\n ed.append([i,j+n])\n \nimport random\nimport numpy as np\n\nnode = n\n\nedge = ed\n\ndef tutte():\n tut = np.zeros((node,node))\n for e in edge:\n x = random.random()\n tut[e[0]][e[1]]=x\n tut[e[1]][e[0]]=-x\n return tut\n\n\n\ntimes = 11\nrank = []\nfor i in range(times):\n rank.append(np.linalg.matrix_rank(tutte()))\nrank.sort()\nans = rank[times//2]//2\n\nprint(ans)', 'n = int(input())\n\nred = []\nblue = []\ned = []\nfor i in range(n):\n red.append(list(map(int,input().split())))\nfor i in range(n):\n blue.append(list(map(int,input().split())))\n\ninf = 10**30\n\nnode = n*2+2\n\nfor i in range(1,n+1):\n ed.append([0,i,0])\n ed.append([n+i,2*n+1,0])\n \nfor i in range(n):\n for j in range(n):\n if red[i][0]<blue[j][0] and red[i][1]<blue[j][1]:\n ed.append([i+1,j+1,1])\n \n\n\nedge = len(ed)\nstart = 0\ngoal = 2*n+1\n\n\n\nlimit = [[] for i in range(node)]\nfor i in ed:\n limit[i[0]].append([i[1],i[2]])\n limit[i[1]].append([i[0],0])\n\nans = 0\nwhile True:\n used = [False for i in range(node)]\n used[start] = True\n stack = [start]\n pre = [False for i in range(node)] \n pcos = [inf for i in range(node)] \n flg = False\n while stack:\n # print(stack)\n pos = stack.pop()\n for e in limit[pos]:\n if e[1] != 0 and (not used[e[0]]):\n pre[e[0]]=pos\n pcos[e[0]]=e[1]\n stack.append(e[0])\n used[e[0]]=True\n if e[0]==goal:\n stack = []\n flg = True\n if flg==False:\n print(ans)\n break\n pos = goal\n root = []\n minicost = inf\n while pos != start:\n root.append(pos)\n minicost = min(minicost,pcos[pos])\n pos = pre[pos]\n root.append(start)\n root.reverse()\n ans += minicost\n for i in range(len(root)-1):\n for j in range(len(limit[root[i]])):\n if limit[root[i]][j][0]==root[i+1]:\n limit[root[i]][j] = [root[i+1],limit[root[i]][j][1]-minicost]\n for j in range(len(limit[root[i+1]])):\n if limit[root[i+1]][j][0] == root[i]:\n limit[root[i+1]][j] = [root[i],limit[root[i+1]][j][1]+minicost]\n ', 'n = int(input())\n\nred = []\nblue = []\ned = []\nfor i in range(n):\n red.append(list(map(int,input().split())))\nfor i in range(n):\n blue.append(list(map(int,input().split())))\n\n\nnode = n*2\n \nfor i in range(n):\n for j in range(n):\n if red[i][0]<blue[j][0] and red[i][1]<blue[j][1]:\n ed.append([i,j+n])\n \nimport random\nimport numpy as np\n\n\nedge = ed\n\ndef tutte():\n tut = np.zeros((node,node))\n for e in edge:\n x = random.random()\n tut[e[0]][e[1]]=x\n tut[e[1]][e[0]]=-x\n return tut\n\n\n\ntimes = 11\nrank = []\nfor i in range(times):\n rank.append(np.linalg.matrix_rank(tutte()))\nrank.sort()\nans = rank[times//2]//2\n\nprint(ans)\n '] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s030007005', 's592570132', 's502521583'] | [22948.0, 3948.0, 18152.0] | [360.0, 24.0, 335.0] | [697, 1950, 691] |
p03411 | u126232616 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['n = int(input())\nR = [list(map(int, input().split())) for i in range(n)]\nB = [list(map(int, input().split())) for i in range(n)]\nB.sort(key = lambda x:x[0])\nR.sort(key = lambda x:x[1], reverse = True)\n\nprint(R)\nans = 0\nfor bx,by in B:\n print(bx,by)\n for i in range(len(R)):\n if R[i][0] < bx and R[i][1] < by:\n print(R[i],"とマッチ")\n del R[i]\n ans += 1\n break\nprint(ans)\n\n', 'n = int(input())\nR = [list(map(int, input().split())) for i in range(n)]\nB = [list(map(int, input().split())) for i in range(n)]\nB.sort(key = lambda x:x[0])\nR.sort(key = lambda x:x[1], reverse = True)\n\n#print(R)\nans = 0\nfor bx,by in B:\n # print(bx,by)\n for i in range(len(R)):\n if R[i][0] < bx and R[i][1] < by:\n \n del R[i]\n ans += 1\n break\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s672062090', 's828333668'] | [3064.0, 3064.0] | [20.0, 19.0] | [433, 436] |
p03411 | u493813116 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N = int(input())\nR = [tuple(map(int, input().split())) for _ in range(N)]\nB = [tuple(map(int, input().split())) for _ in range(N)]\n\n\ndef solve(i, p):\n if i == N:\n print(p)\n return len(p)\n\n s = []\n a, b = R[i]\n for c, d in B:\n if (c, d) in p:\n continue\n if a < c and b < d:\n \n s.append(solve(i+1, p + [(c, d)]))\n \n s.append(solve(i+1, p))\n return max(s)\n\n\nprint(solve(0, []))\n', 'N = int(input())\nR = [tuple(map(int, input().split())) for _ in range(N)]\nB = [tuple(map(int, input().split())) for _ in range(N)]\n\n\nR.sort(reverse=True, key=lambda k: k[1])\nB.sort()\n\np = []\nq = []\nfor c, d in B:\n for a, b in R:\n if (a, b) in p:\n continue\n if a < c and b < d:\n p.append((a, b))\n q.append((c, d))\n break\n\nprint(len(p))\n'] | ['Wrong Answer', 'Accepted'] | ['s478045189', 's635739286'] | [35444.0, 3064.0] | [2104.0, 23.0] | [506, 396] |
p03411 | u500297289 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N = int(input())\nr = [list(map(int, input().split())) for _ in range(N)]\nb = [list(map(int, input().split())) for _ in range(N)]\n\nr.sort(key=lambda val:val[1], reverse=True)\nb.sort()\n\nans = 0\n\nfor bb in b:\n for i in range(N):\n if bb[0] > r[i][0]:\n ans += 1\n N -= 1\n r.pop(i)\n break\n\nprint(ans)\nprint(r)\nprint(b)\n', 'N = int(input())\nr = [list(map(int, input().split())) for _ in range(N)]\nb = [list(map(int, input().split())) for _ in range(N)]\n\nr.sort(key=lambda val:val[1], reverse=True)\nb.sort(reverse=True)\n\nans = 0\n\nfor bb in b:\n for i in range(N):\n if bb[1] > r[i][1]:\n ans += 1\n N -= 1\n r.pop(i)\n break\n\nprint(ans)\n', 'N = int(input())\nr = [list(map(int, input().split())) for _ in range(N)]\nb = [list(map(int, input().split())) for _ in range(N)]\n\nr.sort(key=lambda val:val[1], reverse=True)\nb.sort()\n\nans = 0\n\nfor bb in b:\n for i in range(N):\n if bb[0] > r[i][0] and bb[1] > r[i][1]:\n ans += 1\n N -= 1\n r.pop(i)\n break\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s314504350', 's858441664', 's506690677'] | [3064.0, 3064.0, 3064.0] | [19.0, 18.0, 19.0] | [366, 360, 368] |
p03411 | u509368316 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N=int(input())\nR=sorted([list(map(int,input().split())) for i in range(N)])\nB=sorted([list(map(int,input().split())) for i in range(N)])\nans=0\nfor i in range(N-1,-1,-1):\n a=[-1,-1]\n x=-1\n for j in range(len(R)):\n if B[i][0]>R[j][0] and B[i][1]>R[j][1]:\n if a[1]<R[j][1]:\n a=R[j]\n x=j\n if x>=0:\n print(i,x)\n del R[x]\n ans+=1\nprint(ans)', 'N=int(input())\nR=sorted([list(map(int,input().split())) for i in range(N)])\nB=sorted([list(map(int,input().split())) for i in range(N)])\nans=0\nfor i in range(N):\n a=[-1,-1]\n x=-1\n for j in range(len(R)):\n if B[i][0]>R[j][0] and B[i][1]>R[j][1]:\n if a[1]<R[j][1]:\n a=R[j]\n x=j\n if x>=0:\n del R[x]\n ans+=1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s934290501', 's837220731'] | [3064.0, 3064.0] | [20.0, 19.0] | [415, 388] |
p03411 | u607075479 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['import sys\nimport math\nfrom collections import deque\nimport bisect\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\n\ndef make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]\n\n\ndef main():\n\tN = NI()\n\tR = [NLI() for _ in range(N)]\n\tB = {}\n\tfor i in range(N):\n\t\tc, d = NMI()\n\t\tB[c] = d\n\tR.sort(key=lambda x: x[0], reverse=True)\n\tans = 0\n\tfor r in R:\n\t\tprint(r)\n\t\tBX = sorted(list(B.keys()))\n\t\tidx = bisect.bisect_left(BX, r[0])\n\n\t\ttmp_by = 300\n\t\ttmp_bx = -1\n\t\tfor bx in BX[idx:]:\n\t\t\tif B[bx] < tmp_by:\n\t\t\t\ttmp_by = B[bx]\n\t\t\t\ttmp_bx = bx\n\t\tif tmp_bx != -1:\n\t\t\tprint(tmp_bx, B[tmp_bx])\n\t\t\tdel B[tmp_bx]\n\t\t\tans += 1\n\n\tprint(ans)\n\n\n\n\n\nif __name__ == "__main__":\n\tmain()', 'import sys\nimport math\nfrom collections import defaultdict\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nINF = 10 ** 20\ninput = lambda: sys.stdin.readline().strip()\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\n\nclass Dinic:\n \n\n\n def __init__(self, n):\n self.n = n\n self.links = [[] for _ in range(n)]\n self.depth = None\n self.progress = None\n\n def add_link(self, _from, to, cap):\n self.links[_from].append([cap, to, len(self.links[to])])\n self.links[to].append([0, _from, len(self.links[_from]) - 1])\n\n def bfs(self, s):\n from collections import deque\n\n depth = [-1] * self.n\n depth[s] = 0\n q = deque([s])\n while q:\n v = q.popleft()\n for cap, to, rev in self.links[v]:\n if cap > 0 and depth[to] < 0:\n depth[to] = depth[v] + 1\n q.append(to)\n self.depth = depth\n\n def dfs(self, v, t, flow):\n if v == t:\n return flow\n links_v = self.links[v]\n for i in range(self.progress[v], len(links_v)):\n self.progress[v] = i\n cap, to, rev = link = links_v[i]\n if cap == 0 or self.depth[v] >= self.depth[to]:\n continue\n d = self.dfs(to, t, min(flow, cap))\n if d == 0:\n continue\n link[0] -= d\n self.links[to][rev][0] += d\n return d\n return 0\n\n def max_flow(self, s, t):\n flow = 0\n while True:\n self.bfs(s)\n if self.depth[t] < 0:\n return flow\n self.progress = [0] * self.n\n current_flow = self.dfs(s, t, INF)\n while current_flow > 0:\n flow += current_flow\n current_flow = self.dfs(s, t, INF)\n\n\ndef main():\n N = NI()\n R = [NLI() for _ in range(N)]\n B = [NLI() for _ in range(N)]\n din = Dinic(2*N+2)\n for a, b in R:\n for c, d in B:\n if a >= c or b >= d: continue\n din.add_link(a, c, 1)\n for a, b in R:\n din.add_link(2*N, a, 1)\n for c, d in B:\n din.add_link(c, 2*N+1, 1)\n print(din.max_flow(2*N, 2*N+1))\n\n\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s670264453', 's765186894'] | [3424.0, 9772.0] | [22.0, 36.0] | [833, 2365] |
p03411 | u663710122 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ["from collections import namedtuple\n\nPoint = namedtuple('Point', ['x', 'y'])\n\nN = int(input())\n\nR = []\nfor _ in range(N):\n x, y = map(int, input().split())\n R.append(Point(x, y))\n\nB = []\nfor _ in range(N):\n x, y = map(int, input().split())\n B.append(Point(x, y))\n\nE = [[] for _ in range(N)]\nfor i, r in enumerate(R):\n for j, b in enumerate(B):\n if r.x < b.x and r.y < b.y:\n E[i].append(j)\n\n\nclass BipartiteMatching:\n def __init__(self, max_u: int, max_v: int, edges):\n self.max_u = max_u\n self.max_v = max_v\n self.edges = edges \n self.__match = None\n\n def dfs(self, v: int, visited: set) -> bool:\n for u in self.edges[v]:\n if u in visited:\n continue\n visited.add(u)\n\n if self.__match[u] == -1 or self.dfs(self.__match[u], visited):\n self.__match[u] = v\n return True\n return False\n\n def execute(self):\n self.__match = [-1 for _ in range(self.max_u)]\n return sum(self.dfs(u, set()) for u in range(self.max_u))\n\n\nprint(BipartiteMatching(N, E).execute())\n", "from collections import namedtuple\n\nPoint = namedtuple('Point', ['x', 'y'])\n\nN = int(input())\n\nR = []\nfor _ in range(N):\n x, y = map(int, input().split())\n R.append(Point(x, y))\n\nB = []\nfor _ in range(N):\n x, y = map(int, input().split())\n B.append(Point(x, y))\n\nE = [[] for _ in range(N)]\nfor i, r in enumerate(R):\n for j, b in enumerate(B):\n if r.x < b.x and r.y < b.y:\n E[i].append(j)\n\n\nclass BipartiteMatching:\n def __init__(self, max_u: int, edges):\n self.max_u = max_u\n self.edges = edges \n self.__match = None\n\n def dfs(self, v: int, visited: set) -> bool:\n for u in self.edges[v]:\n if u in visited:\n continue\n visited.add(u)\n\n if self.__match[u] == -1 or self.dfs(self.__match[u], visited):\n self.__match[u] = v\n return True\n return False\n\n def execute(self):\n self.__match = [-1 for _ in range(self.max_u)]\n return sum(self.dfs(u, set()) for u in range(self.max_u))\n\n\nprint(BipartiteMatching(N, E).execute())\n"] | ['Runtime Error', 'Accepted'] | ['s472702646', 's742370190'] | [3444.0, 3444.0] | [25.0, 30.0] | [1148, 1109] |
p03411 | u814986259 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N = int(input())\nab = [[0, 0] for i in range(N)]\nb = [0]*N\ncd = [[0, 0] for i in range(N)]\nd = [0]*N\n\nfor i in range(N):\n ab[i] = list(map(int, input().split()))\nfor i in range(N):\n cd[i] = list(map(int, input().split()))\n\npoints2 = [[] for i in range(N)]\nab.sort(key=lambda x: x[0])\nab.sort(key=lambda x: x[1])\n\nfor i in range(N):\n for j in range(N):\n if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:\n points2[j].append(i)\n\npoints2.sort(key=lambda x: len(x))\nans = 0\n\nfor i in range(N):\n if len(points[i]) == 0:\n continue\n for j in range(i+1, N):\n if points[i][0] in points[j]:\n points[j].pop(points[j].index(points[i][0]))\n ans += 1\nprint(ans)', 'N = int(input())\nab = [[0, 0] for i in range(N)]\nb = [0]*N\ncd = [[0, 0] for i in range(N)]\nd = [0]*N\n\nfor i in range(N):\n ab[i] = list(map(int, input().split()))\nfor i in range(N):\n cd[i] = list(map(int, input().split()))\n\npoints = [[] for i in range(N)]\npoints2 = [[] for i in range(N)]\ncd.sort(key=lambda x: x[0])\nab.sort(key=lambda x: x[1], reverse=True)\n\npoints.sort(key=lambda x: len(x))\nans = 0\n\nfor i in range(N):\n for j in range(N):\n if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:\n ans += 1\n cd[j][0] = -1\n break\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s463842843', 's529772647'] | [3064.0, 3064.0] | [21.0, 20.0] | [705, 582] |
p03411 | u859897687 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['n=int(input())\na=[list(map(int,input().split()))for i in range(n)]\nb=[list(map(int,input().split()))for i in range(n)]\na.sort(key=lambda x:x[0])\nb.sort(key=lambda x:x[1],reverse=1)\nans=0\ni,j=0,0\nwhile i<n and j<n:\n if a[i][0]>b[j][0]:\n j+=1\n continue\n elif a[i][1]>b[j][1]:\n i+=1\n else:\n ans+=1\nprint(ans)', 'n=int(input())\na=[list(map(int,input().split()))for i in range(n)]\nb=[list(map(int,input().split()))for i in range(n)]\na.sort(key=lambda x:x[1],reverse=1)\nb.sort(key=lambda x:x[0])\nans=0\nfor i in a:\n for j in b:\n if i[0]<j[0] and i[1]<j[1]:\n b.remove(j)\n ans+=1\n break\nprint(ans)'] | ['Time Limit Exceeded', 'Accepted'] | ['s934475560', 's642004223'] | [3064.0, 3064.0] | [2104.0, 19.0] | [320, 298] |
p03411 | u859968552 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N=int(input())\n\nred=[]\nblue=[]\n\nfor i in range(N):\n a,b=map(int,input().split())\n red.append((a,b))\n\nfor i in range(N):\n c,d=map(int,input().split())\n blue.append((c,d))\n\nred=sorted(red,key=lambda x:-x[1])\nblue=sorted(blue,key=lambda x:x[0])\n\nanswer=0\nfor i,b in enumerate(blue):\n for j,r in enumerate(red):\n if red[0]<blue[0] and red[1]<blue[1]:\n answer+=1\n red.pop(j)\n break\n\nprint(answer)', 'N=int(input())\n\nred=[]\nblue=[]\n\nfor i in range(N):\n a,b=map(int,input().split())\n red.append((a,b))\n\nfor i in range(N):\n c,d=map(int,input().split())\n blue.append((c,d))\n\nred=sorted(red,key=lambda x:-x[1])\nblue=sorted(blue,key=lambda x:x[0])\n\nanswer=0\nfor i,b in enumerate(b):\n for j,r in enumerate(r):\n if red[0]<blue[0] and red[1]<blue[1]:\n answer+=1\n red.pop(j)\n break\n\nprint(answer)', 'N=int(input())\n\nred=[]\nblue=[]\n\nfor i in range(N):\n a,b=map(int,input().split())\n red.append((a,b))\n\nfor i in range(N):\n c,d=map(int,input().split())\n blue.append((c,d))\n\nred=sorted(red,key=lambda x:-x[1])\nblue=sorted(blue,key=lambda x:x[0])\n\nanswer=0\nfor i,b in enumerate(blue):\n for j,r in enumerate(red):\n if r[0]<b[0] and r[1]<b[1]:\n answer+=1\n red.pop(j)\n break\n\nprint(answer)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s648837701', 's866113583', 's487773447'] | [3064.0, 3064.0, 3064.0] | [20.0, 18.0, 20.0] | [446, 441, 436] |
p03411 | u923270446 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['s=input()\nk=int(input())\nl=list(s)\nfor i in range(len(s)):\n if 26-(ord(s[i])-ord("a"))<=k:k-=26-(ord(s[i])-ord("a"));l[i]="a"\nprint("".join(l[:-1]+list(chr((ord(l[-1])-97+k)%26+97))))', 'n = int(input())\nab = [list(map(int, input().split())) for i in range(n)]\ncd = [list(map(int, input().split())) for i in range(n)]\nab.sort()\ncd.sort()\nans = 0\nfor i in cd:\n c, d = i\n flag = False\n cur = 0\n difference = float("inf")\n for i in range(n):\n a, b = ab[i]\n if a < c and b < d:\n if difference > d - b:\n difference = min(difference, d - b)\n flag = True\n cur = i\n if flag:\n ab[cur] = [float("inf"), float("inf")]\n ans += 1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s308706905', 's935278440'] | [9092.0, 9144.0] | [26.0, 32.0] | [183, 542] |
p03411 | u957084285 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | ['N = int(input())\nA = list(map(int, input().split()))\n\nsum_even = sum(map(lambda i: A[i] if A[i] > 0 else 0, range(1, N, 2)))\nsum_odd = sum(map(lambda i: A[i] if A[i] > 0 else 0, range(0, N, 2)))\n\nif sum_even == 0 and sum_odd == 0:\n max_ = max(A)\n print(max_)\n index = A.index(max_)\n print(len(A)-1)\n for _ in range(index):\n print(1)\n for j in range(N-index-1):\n print(N - index - j)\n exit()\n\nprint(max(sum_even, sum_odd))\nEVEN = sum_even >= sum_odd\nans = []\n\nif EVEN:\n A = A[1:]\n ans.append(1)\nif len(A)%2 == 0:\n ans.append(len(A))\n A = A[:-1]\n\nwhile len(A) > 1:\n if A[0] <= 0:\n ans.append(1)\n ans.append(1)\n A = A[2:]\n else:\n if A[2] <= 0:\n ans.append(3)\n A.pop(2)\n if len(A) == 2:\n ans.append(2)\n A.pop(1)\n else:\n ans.append(3)\n A.pop(2)\n else:\n ans.append(2)\n A.pop(1)\n A[0] += A.pop(1)\nprint(len(ans))\nfor a in ans:\n print(a)', 'N = int(input())\n\nred = []\nblue = []\ncount = 0\n\ndellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]\n\nfor n in range(2*N):\n v = list(map(int, input().split()))\n if n < N:\n red.append(v)\n else:\n blue.append(v)\n\n\nfor x in range(2*N):\n\n for k in range(2):\n r_remove_list = []\n b_remove_list = []\n\n for i, b in enumerate(blue):\n if b[k] == x:\n cand = -1\n max_ = -1\n max_j = -1\n for j, r in enumerate(red):\n if r[k] < x:\n if r[1-k] < b[1-k] and max_ < r[1-k]:\n cand = j\n max_ = r[1-k]\n max_j = j\n if cand >= 0:\n r_remove_list.append(max_j)\n b_remove_list.append(i)\n\n blue = dellist(blue,b_remove_list)\n red = dellist(red,r_remove_list)\n count += len(b_remove_list)\n\n\nprint(count)'] | ['Runtime Error', 'Accepted'] | ['s469973780', 's148933202'] | [3184.0, 3064.0] | [18.0, 30.0] | [1058, 1036] |
p03411 | u974944183 | 2,000 | 262,144 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | [" N = int(input())\n ab = [tuple(map(int,input().split())) for i in range(N)]\n cd = [tuple(map(int,input().split())) for i in range(N)]\n result = []\n for i in range(N):\n xr , yr = ab[i]\n xb, yb = cd[i]\n if xr < xb or yr < yb:\n print(xr, yr, xb, yb)\n result.append('BINGO!!!')\n print(len(result))", ' N = int(input())\n ab = sorted([ tuple(map(int, input().split())) for x in range(N)], key=lambda x:x[1], reverse=True)\n cd = sorted([ tuple(map(int, input().split())) for x in range(N)])\n resultx = []\n resulty = []\n for xb, yb in list(cd):\n for xr, yr in list(ab):\n if (xr, yr) in resultx:\n continue\n if xr < xb and yr < yb:\n resultx.append((xr,yr))\n resulty.append((xb,yb))\n break\n\n print(len(resultx))', " N = int(input())\n ab = [tuple(map(int,input().split())) for i in range(N)]\n cd = [tuple(map(int,input().split())) for i in range(N)]\n result = []\n for i in range(N):\n xr , yr = ab[i]\n xb, yb = cd[i]\n if xr < xb or yr < yb:\n print(xr, yr, xb, yb)\n result.append('BINGO!!!')\n print(len(result))\n", " N = int(input())\n ab = [tuple(map(int,input().split())) for i in range(N)]\n cd = [tuple(map(int,input().split())) for i in range(N)]\n result = []\n for i in range(N):\n xr , yr = ab[i]\n xb, yb = cd[i]\n if xr < xb and yr < yb:\n result.append('BINGO!!!')\n print(len(result))", "N = int(input())\nab = [tuple(map(int,input().split())) for i in range(N)]\ncd = [tuple(map(int,input().split())) for i in range(N)]\nresult = []\nfor i in range(N):\n xr , yr = ab[i]\n xb, yb = cd[i]\n if xr < xb or yr < yb:\n result.append('BINGO!!!')\nprint(len(result))", 'N = int(input())\nab = sorted([ tuple(map(int, input().split())) for x in range(N)], key=lambda x:x[1],reverse=True)\ncd = sorted([ tuple(map(int, input().split())) for x in range(N)])\nresultx = []\nresulty = []\nfor xb, yb in list(cd):\n for xr, yr in list(ab):\n if (xr, yr) in resultx:\n continue\n if xr < xb and yr < yb:\n resultx.append((xr,yr))\n resulty.append((xb,yb))\n break\n\nprint(len(resultx))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s188044638', 's447861231', 's529644969', 's921283320', 's968534041', 's066413621'] | [2940.0, 2940.0, 2940.0, 2940.0, 3064.0, 3064.0] | [17.0, 17.0, 17.0, 17.0, 18.0, 23.0] | [321, 471, 320, 291, 280, 456] |
p03419 | u020962106 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m=map(int,input().split())\nif n==1 and m==1:\n print(1)\nelif n==1 or M==1:\n print(n*m-2)\nelse:\n print((m-2)*(n-2))\n', 'n,m=map(int,input().split())\nif n==1 and m==1:\n print(1)\nelif n==1 or m==1:\n print(n*m-2)\nelse:\n print((m-2)*(n-2))\n'] | ['Runtime Error', 'Accepted'] | ['s259808286', 's473103384'] | [2940.0, 2940.0] | [17.0, 17.0] | [125, 125] |
p03419 | u028973125 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['if N > 1 and M > 1:\n four = 4\n six = (N - 2) * 2 + (M - 2) * 2\n nine = N * M - four - six\n print(nine)\nelse:\n two = 2\n three = N * M - two\n print(three)', 'import sys\n\nN, M = map(int, sys.stdin.readline().split())\n\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n two = 2\n three = N * M - two\n print(three)\nelse:\n four = 4\n six = (N - 2) * 2 + (M - 2) * 2\n nine = N * M - four - six\n print(nine)'] | ['Runtime Error', 'Accepted'] | ['s572624544', 's569456151'] | [8988.0, 9056.0] | [24.0, 25.0] | [173, 270] |
p03419 | u046158516 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,M=map(int,input().split())\nif N==1:\n if M==1:\n print(1)\n else:\n print(M-2)\nelif M==1:\n print(N-2)\nelse:\n print(N*M-max(0,N-2)-max(0,M-2))', 'N,M=map(int,input().split())\nif N==1:\n if M==1:\n print(1)\n else:\n print(M-2)\nelif M==1:\n print(N-2)\nelse:\n print(N*M-2*max(0,N-1)-2*max(0,M-1))'] | ['Wrong Answer', 'Accepted'] | ['s660974608', 's322916648'] | [3060.0, 3064.0] | [17.0, 18.0] | [149, 153] |
p03419 | u047668580 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,N = list(map(int,input().split()))\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n print(max([N,M]) -2)\nelse:\n print( N * M + 4 - 2*(N+M))\n', 'N,M = list(map(int,input().split()))\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n print(max([N,M]) -2)\nelse:\n print( N * M + 4 - 2*(N+M))\n'] | ['Runtime Error', 'Accepted'] | ['s948034662', 's590945762'] | [2940.0, 2940.0] | [17.0, 17.0] | [158, 158] |
p03419 | u106778233 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m=map(int,input())\nn,m=min(n,m),max(n,m)\nif n==1:\n print(max(0,m-2))\n exit()\nelse:\n print(max(0,(n-2)*(m-2)))', 'n,m=map(int,input().split())\nn,m=min(n,m),max(n,m)\nif n==1:\n if m==1:\n print(1)\n else:\n print(max(0,m-2))\n exit()\nelse:\n print(max(0,(n-2)*(m-2)))'] | ['Runtime Error', 'Accepted'] | ['s353011008', 's237346551'] | [2940.0, 3060.0] | [17.0, 17.0] | [120, 176] |
p03419 | u132350318 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['def main():\n n = int(input())\n res = 0\n\n for (a, k) in [[int(x) for x in input().split()] for _ in range(n)]:\n while a >= k:\n m, u, v = a // k, (a - k * m), (m + 1)\n if a % k == 0 or u % v == 0:\n res ^= m\n break\n x = (u // v)\n a -= (x + 1) * v\n\n print(\'Takahashi\' if res != 0 else \'Aoki\')\n\n\nif __name__ == "__main__":\n main()\n', 'def main():\n n, m = map(int, input().split())\n print(compute(min(n, m), max(n, m)))\n\n\ndef compute(n, m):\n if n == 1 and m == 1:\n return 1\n if n == 1:\n return max(0, m - 2)\n return (n - 2) * (m - 2)\n\n\nif __name__ == "__main__":\n main()\n'] | ['Runtime Error', 'Accepted'] | ['s427394604', 's632929446'] | [3060.0, 3060.0] | [17.0, 17.0] | [422, 267] |
p03419 | u225053756 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | [' H, W =[int(i) for i in input().split()]\n if H==1 and W!=1:\n print(max(0, W-2))\n elif W==1 and H!=1:\n print(max(0, H-2))\n else:\n print(max(H-2, 0)*max(W-2, 0))', 'H, W =[int(i) for i in input().split()]\nif H*W=1:\n print(1)\nelif H==1 and W!=1:\n print(max(0, W-2))\nelif W==1 and H!=1:\n print(max(0, H-2))\nelse:\n print(max(H-2, 0)*max(W-2, 0))', 'H,W =[int(i) for i in input().split()]\nif H*W=1:\n print(1)\nelif H==1 and W!=1:\n print(max(0, W-2))\nelif W==1 and H!=1:\n print(max(0, H-2))\nelse:\n print(max(H-2, 0)*max(W-2, 0))\n', 'H,W =[int(i) for i in input().split()]\nif H*W==1:\n print(1)\nelif H==1 and W!=1:\n print(max(0, W-2))\nelif W==1 and H!=1:\n print(max(0, H-2))\nelse:\n print(max(H-2, 0)*max(W-2, 0))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s125926927', 's212602174', 's869534965', 's008201638'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [186, 193, 189, 190] |
p03419 | u247554097 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['\n\nn, m = map(int, input().split())\n\nif n == 1 or m == 1: \n print(f"kasu")\n print(1 / 0)\n', '\nn, m = map(int, input().split())\nif n == m == 1:\n print(1)\nelif n == 1 or m == 1:\n print(max(n, m) - 2)\nelse:\n print(n * m - (n * 2 + (m - 2) * 2))\n'] | ['Runtime Error', 'Accepted'] | ['s326810530', 's263138344'] | [9080.0, 9012.0] | [29.0, 24.0] | [215, 368] |
p03419 | u314057689 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['print(-1)', 'def solve():\n N, M = map(int, input().split())\n\n if N == 1 and M == 1:\n print(1)\n return\n\n if N == 1:\n print(M-2)\n return\n\n if M == 1:\n print(N-2)\n return\n\n print((N-2) * (M-2))\n\n\nif __name__ == "__main__":\n solve()\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s115121556', 's878496332'] | [2940.0, 2940.0] | [17.0, 17.0] | [9, 278] |
p03419 | u314188085 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m = map(int,input().split())\n\nprint(max(n-2,1)*max(m-2,1))', 'n,m = map(int,input().split())\n\nif n>1:\n uraN=n-2\nelse:\n uraN=1\n \nif m>1:\n uraM=m-2\nelse:\n uraM=1\n \nprint(uraN*uraM)'] | ['Wrong Answer', 'Accepted'] | ['s459738777', 's560738020'] | [9048.0, 9068.0] | [30.0, 24.0] | [60, 134] |
p03419 | u357751375 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m = map(int,input().split())\nprint((max(1,n-2))*(max(1,m-2)))', 'n,m = map(int,input().split())\nif n == m == 1:\n print(1)\nelif n == 1 or m == 1:\n print((max(1,n-2))*(max(1,m-2)))\nelse:\n print((n-2)*(m-2))\n'] | ['Wrong Answer', 'Accepted'] | ['s911399907', 's120173428'] | [9168.0, 9048.0] | [29.0, 27.0] | [63, 149] |
p03419 | u362563655 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,M = map(int, input().split())\nif N==M==1:\n print(1)\nelif n == 1 or m == 1:\n print(max(N,M)-2)\nelse:\n print((N-2) * (M-2))', 'N,M = map(int, input().split())\nif N==M==1:\n print(1)\nelif N == 1 or M == 1:\n print(max(N,M)-2)\nelse:\n print((N-2) * (M-2))\n'] | ['Runtime Error', 'Accepted'] | ['s605512999', 's975887482'] | [3060.0, 2940.0] | [24.0, 17.0] | [132, 133] |
p03419 | u452269253 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m = [int(i) for i in input().split()]\nif 2 < n and 2 < m:\n print((n-2)*(m-2))\nelif 2 < n:\n print((n-2)*m)\nelif 2 < m:\n print(n*(m-2))\nelse:\n print(n*m)', 'n,m = [int(i) for i in input().split()]\n\nif 2 <= n and 2 <= m:\n print((n-2)*(m-2))\nelif 2 <= n:\n print((n-2)*m)\nelif 2 <= m:\n print(n*(m-2))\nelse:\n print(1)'] | ['Wrong Answer', 'Accepted'] | ['s989833146', 's058381022'] | [9060.0, 9076.0] | [32.0, 27.0] | [165, 168] |
p03419 | u455638863 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['def flip(B, m, n, M, N):\n# print(m,n)\n for mm in range(m-1,m+2):\n for nn in range(n-1,n+2):\n print("mm=", mm, "nn=", nn)\n if 0<=mm and mm<M and 0<=nn and nn<N:\n if B[mm][nn] == 0:\n B[mm][nn] = 1\n else:\n B[mm][nn] = 0\n#print(input().split())\nMN=list(map(int, input().split()))\nB = [[0 for i in range(MN[0])] for j in range(MN[1])]\nfor m in range(0,MN[0]):\n for n in range(0,MN[1]):\n flip(B, m, n, MN[0], MN[1])\nc = 0\nfor m in range(0,MN[0]):\n for n in range(0,MN[1]):\n c += B[m][n]\n\nprint(c)', 'MN=list(map(int, input().split()))\nM = MN[0]\nN = MN[1]\nif N == 1:\n N = MN[0]\n M = MN[1]\nif M == 1:\n if N == 1:\n c = 1\n elif N == 2:\n c = 0\n else:\n c = N - 2\nelse:\n c = (M - 2)*(N - 2)\nprint(c)'] | ['Runtime Error', 'Accepted'] | ['s534195191', 's492871791'] | [533400.0, 3060.0] | [2129.0, 17.0] | [554, 207] |
p03419 | u503111914 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,M = map(int, input().split())\nif n == 1:\n if m == 1:\n print(1)\n else:\n print(m - 2)\nelif m == 1:\n print(n - 2)\nelse: \n print((N-2)*(M-2))\n', 'N,M = map(int, input().split())\nif N == 1: print(1) if M == 1 else print(M - 2)\nelif M == 1: print(N - 2)\nelse: print(N * M - (N + M - 2) * 2)\n'] | ['Runtime Error', 'Accepted'] | ['s743595252', 's598008387'] | [9092.0, 9080.0] | [22.0, 25.0] | [158, 143] |
p03419 | u536034761 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N, M = map(int, input().split())\nprint(2 * N + 2 * M - 4)', 'N, M = map(int, input().split())\nif N == 1 and M == 1:\n print(1)\nelif N == 1:\n print(M - 2)\nelif M == 1:\n print(N - 2)\nelse:\n print(N * M - (N * 2 + M * 2 - 4))'] | ['Wrong Answer', 'Accepted'] | ['s767657843', 's458585955'] | [8792.0, 9116.0] | [30.0, 29.0] | [57, 164] |
p03419 | u536659057 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ["# coding: utf-8\n# Your code here!\n\n\nfrom collections import deque\nlines = input().split(' ')\nm = int(lines[0])\nn = int(lines[1])\n\nm = 314\nn = 1592\n\nif m > 1 and n > 1:\n ans = (m-2)*(n-2)\nelif m == 1 and n == 1:\n ans = 1\nelse:\n ans = abs(m-n) - 1\nprint(ans)", "\nfrom collections import deque\nlines = input().split(' ')\nm = int(lines[0])\nn = int(lines[1])\n\nif m > 1 and n > 1:\n ans = (m-2)*(n-2)\nelif m == 1 and n == 1:\n ans = 1\nelse:\n ans = abs(m-n) - 1\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s029744126', 's536875464'] | [3316.0, 3316.0] | [21.0, 20.0] | [265, 212] |
p03419 | u655048024 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m = map(int,input().split())\nelif(n==1)or(m==1):\n if(n==1)and(m==1):\n print(1)\n else:\n print(max(0,max(n,m)-2))\nelse:\n print((n-2)*(m-2))\n', 'n,m = map(int,input().split())\nif(n==1)or(m==1):\n if(n==1)and(m==1):\n print(1)\n else:\n print(max(0,max(n,m)-2))\nelse:\n print((n-2)*(m-2))\n'] | ['Runtime Error', 'Accepted'] | ['s014256015', 's676823472'] | [8948.0, 9032.0] | [23.0, 26.0] | [149, 147] |
p03419 | u694649864 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N, M = map(int, input().split())\nif(N == 1 and M == 1):\n print(0)\nelif(N == 1):\n if(M == 2):\n print(2)\n else:\n print(1 * M-2)\nelif(M == 1):\n if(N == 2):\n print(2)\n else:\n print(1 * N-2)\nelif(N == 2 and M == 2):\n print(4)\nelse:\n print((N - 2) * (M - 2))', 'N, M = map(int, input().split())\nif(N == 1 and M == 1):\n print(1)\nelif(N == 1):\n if(M == 2):\n print(0)\n else:\n print(1 * M-2)\nelif(M == 1):\n if(N == 2):\n print(0)\n else:\n print(1 * N-2)\nelse:\n print((N - 2) * (M - 2))'] | ['Wrong Answer', 'Accepted'] | ['s461375462', 's438212975'] | [3064.0, 3064.0] | [17.0, 17.0] | [301, 263] |
p03419 | u750651325 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef s(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float("inf")\n\nS = s()\nif len(S)==26:\n print(-1)\n sys.exit()\n\nalpha=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]\n\nfor i in alpha:\n if i not in S:\n print(S+ans)\n sys.exit()\n', 'import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef s(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float("inf")\n\nN, M = map(int,input().split())\n\nif N == 1 or M == 1:\n if N + M == 2:\n print(1)\n else:\n print(N*M-2)\nelse:\n print((N-2)*(M-2))\n'] | ['Runtime Error', 'Accepted'] | ['s191019605', 's047700878'] | [10264.0, 10436.0] | [36.0, 41.0] | [772, 681] |
p03419 | u759590494 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,M = map(int, input().split())\n if M==1 and N==1:\n print(1)\n elif M==1:\n print(N-2)\n elif N==1:\n print(M-2)\n else:\n print((N-2)*(M-2))\n', 'N,M = map(int, input().split())\n if M==1 and N==1:\n return 1\n elif M==1:\n return N-2\n elif N==1:\n return M-2\n else:\n return (N-2)*(M-2)', 'N,M = map(int, input().split())\nif M==1 and N==1:\n return 1\nelif M==1:\n return N-2\nelif N==1:\n return M-2\nelse:\n return (N-2)*(M-2)\n', 'N,M = map(int, input().split())\n if M==1 and N==1:\n return 1\n elif M==1:\n return N-2\n elif N==1:\n return M-2\n else:\n return (N-2)*(M-2)', 'N,M = map(int, input().split())\nif M==1 and N==1:\n print(1)\nelif M==1:\n print(N-2)\nelif N==1:\n print(M-2)\nelse:\n print((N-2)*(M-2))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s055289900', 's397179274', 's595580143', 's658626936', 's820175078'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0, 17.0] | [176, 175, 144, 175, 144] |
p03419 | u761320129 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N,M = map(int,input().split())\nprint(max(1,(N-2)) * max(1,(M-2)))\n', 'N,M = map(int,input().split())\nif N == 1 and M == 1:\n print(1)\nelif N == 2 or M == 2:\n print(0)\nelif N == 1:\n print(M-2)\nelif M == 1:\n print(N-2)\nelse:\n print((N-2) * (M-2))\n'] | ['Wrong Answer', 'Accepted'] | ['s520000227', 's452743244'] | [2940.0, 2940.0] | [17.0, 17.0] | [66, 189] |
p03419 | u777028980 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['a,b=int(input())\n\nif(a==1):\n print(max(0,b-2))\nelif(b==1):\n print(max(0,a-2))\nelse:\n print((a-2)*(b-2))', 'a,b=map(int,input().split())\n\nif(a==1 and b==1):\n print(1)\nelif(a==1):\n print(max(0,b-2))\nelif(b==1):\n print(max(0,a-2))\nelse:\n print((a-2)*(b-2))'] | ['Runtime Error', 'Accepted'] | ['s210561628', 's511953490'] | [3060.0, 3060.0] | [17.0, 17.0] | [106, 150] |
p03419 | u807772568 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['b = list(map(int,input().split()))\n\nif b[0] == 1 and b[1] == 1:\n\tprint(1)\nelif b[0] == 1:\n\tprint(b[1]-2)\nelif b[1] == 1:\n\tprint(b[0] -2)\n\nelse:\n\tprint(b[0]*b[1] - 2(b[0] + b[1] - 2))', 'b = list(map(int,input().split()))\n\nif b[0] == 1 and b[1] == 1:\n\tprint(1)\nelif b[0] == 1:\n\tprint(b[1]-2)\nelif b[1] == 1:\n\tprint(b[0] -2)\n\nelse:\n\tprint(b[0]*b[1] - 2*(b[0] + b[1] - 2))'] | ['Runtime Error', 'Accepted'] | ['s604986860', 's466841028'] | [3060.0, 3060.0] | [17.0, 17.0] | [182, 183] |
p03419 | u842230338 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['N = int(input())\na,b,c,d = [0]*N,[0]*N,[0]*N,[0]*N\nfor i in range(N):\n a[i],b[i] = map(int,input().split())\nfor i in range(N):\n c[i],d[i] = map(int,input().split())\n\nans=0\nfor k in range(N):\n for i in range(N):\n if a[i] == k or b[i] == k:\n ans += 1\n a.pop(i)\n b.pop(i)\n break\n elif c[i] == k or d[i] == k:\n c.pop(i)\n d.pop(i)\n\nprint(ans)\n ', 'N = int(input())\na,b,c,d = [0]*N,[0]*N,[0]*N,[0]*N\nfor i in range(N):\n a[i],b[i] = map(int,input().split())\nfor i in range(N):\n c[i],d[i] = map(int,input().split())\n\ne = [(0,"")]*2*N\nfor i in range(N):\n e[a[i]] = (b[i],"R")\n e[c[i]] = (d[i],"B")\n\nans,p = 0,0\nfor i in range(2*N):\n n,c = e[i]\n if c == "R":\n p += 1\n if p > 0:\n ans += 1\n else:\n p -= 1\n\nprint(ans)', 'N,M = map(int, input().split())\nif N==1 and M==1:\n print(1)\nelif N<3 and M<3:\n print(0)\nelif N==1 or M==1:\n print(max(N-2,M-2))\nelif N==2 or M==2:\n print(0)\nelse:\n print(max(N-2,1)*max(M-2,1))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s188455972', 's821137169', 's501290992'] | [3064.0, 3064.0, 3064.0] | [17.0, 18.0, 17.0] | [439, 414, 207] |
p03419 | u854685063 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['import sys\nimport math\ndef I():return int(sys.stdin.readline().replace("\\n",""))\ndef I2():return map(int,sys.stdin.readline().replace("\\n","").split())\ndef S():return str(sys.stdin.readline().replace("\\n",""))\ndef L():return list(sys.stdin.readline().replace("\\n",""))\ndef Intl():return [int(k) for k in sys.stdin.readline().replace("\\n","").split()]\ndef Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\\n","").split()))\n\nif __name__ == "__main__":\n n ,m = I2()\n print(max(1, n - 2)*max(1, m - 2))', 'import sys\nimport math\ndef I():return int(sys.stdin.readline().replace("\\n",""))\ndef I2():return map(int,sys.stdin.readline().replace("\\n","").split())\ndef S():return str(sys.stdin.readline().replace("\\n",""))\ndef L():return list(sys.stdin.readline().replace("\\n",""))\ndef Intl():return [int(k) for k in sys.stdin.readline().replace("\\n","").split()]\ndef Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\\n","").split()))\n\nif __name__ == "__main__":\n n ,m = I2()\n if n == 2 or m == 2:\n print(0)\n else:\n print(max(1, n - 2)*max(1, m - 2))'] | ['Wrong Answer', 'Accepted'] | ['s346977530', 's341041897'] | [9184.0, 9092.0] | [26.0, 28.0] | [526, 582] |
p03419 | u859897687 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelse:\n print(a+a+b+b-4)', 'a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelse:\n print((a-2)*(b-2))'] | ['Wrong Answer', 'Accepted'] | ['s963533987', 's183185278'] | [2940.0, 2940.0] | [18.0, 18.0] | [121, 123] |
p03419 | u941438707 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['a,b=map(int,input().split())\nprint(max(1,a-2)*max(1,b-2))', 'a,b=map(int,input().split())\nprint(0 if a==2 or b==2 else max(1,a-2)*max(1,b-2))'] | ['Wrong Answer', 'Accepted'] | ['s281152179', 's661546586'] | [2940.0, 2940.0] | [17.0, 17.0] | [57, 80] |
p03419 | u999503965 | 2,000 | 262,144 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations. | ['n,m=int(input())\n\nif n>=3 and m>=3:\n a=n*m\n b=n*2+m*2-4\nelif n==1 or m==1:\n a=n*m\n b=2\nelif n==2 or m==2:\n a=0\n b=0\n \nprint(a-b)', 'n,m=map(int,input().split())\n\nif n>=3 and m>=3:\n a=n*m\n b=n*2+m*2-\n ans=a-b\nelif n==1 and b==1:\n ans=1\nelif n==1 or m==1:\n a=n*m\n b=2\n ans=a-b\nelif n==2 or m==2:\n ans=0\n \nprint(ans)\n', 'n,m=map(int,input().split())\n\nif n>=3 and m>=3:\n a=n*m\n b=n*2+m*2-4\n ans=a-b\nelif n==1 and m==1:\n ans=1\nelif n==1 or m==1:\n a=n*m\n b=2\n ans=a-b\nelif n==2 or m==2:\n ans=0\n \nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s322397299', 's438679565', 's307141064'] | [9184.0, 8828.0, 9052.0] | [25.0, 25.0, 26.0] | [135, 191, 192] |
p03420 | u102461423 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['# a%b >= K iff xb+K <= a < (x+1)b\n\n\nN,K = map(int,input().split())\nans = 0\n\nfor b in range(K+1,N+1):\n cnt = 0\n x_max = N//b\n # 0 <= x < x_max\n \n cnt += x_max * (b-K)\n # x = x_max\n lower = min(x_max*b+K,N)\n upper = min((x_max+1)*b-1,N)\n cnt += upper - lower + 1\n ans += cnt\n \nprint(ans)', '# a%b >= K iff xb+K <= a < (x+1)b\n\n\nN,K = map(int,input().split())\nans = 0\n\nfor b in range(K+1,N+1):\n cnt = 0\n x_max = N//b\n # 0 <= x < x_max\n \n cnt += x_max * (b-K)\n # x = x_max\n lower = x_max*b+K\n if lower <= N:\n\tupper = min((x_max+1)*b-1,N)\n cnt += upper - lower + 1\n ans += cnt\n \nprint(ans)', '# a%b >= K iff xb+K <= a < (x+1)b\n\n\nN,K = map(int,input().split())\nans = 0\n\nfor b in range(K+1,N+1):\n cnt = 0\n x_max = N//b\n # 0 <= x < x_max\n \n cnt += x_max * (b-K)\n # x = x_max\n lower = x_max*b+K\n if lower <= N:\n upper = min((x_max+1)*b-1,N)\n cnt += upper - lower + 1\n ans += cnt\n\n\nif K == 0:\n ans -= N\n \nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s530986772', 's886687113', 's461554412'] | [3064.0, 2940.0, 3064.0] | [133.0, 18.0, 124.0] | [353, 364, 402] |
p03420 | u106778233 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['def main():\n n,k=map(int,input().split())\n ans=n**2\n ans-=n*k\n for i in range(k+1,n+1):\n temp=n//i\n temp*=k\n temp+=min(temp%i,k-1)\n ans-=temp \n print(ans)\n\nmain()', 'def main():\n n,k=map(int,input().split())\n ans=0\n for i in range(1,1+n):\n for j in range(1,n+1):\n if i%j==k:\n ans+=1\n print(ans)\n\nmain()', 'N,K=map(int,input().split())\nans=0\nfor b in range(K+1,N+1):\n ans+=(N//b*(b-K))+max(N%b+1-K,0)-(K<1)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s388998683', 's647998267', 's672527438'] | [2940.0, 2940.0, 3060.0] | [54.0, 2104.0, 85.0] | [205, 181, 113] |
p03420 | u192154323 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['import sys\nn,k = map(int,input().split())\nans = 0\nif k == 0:\n print(n**2)\n sys.exit()\nfor b in range(k+1,n+1):\n ans_per_loop = b - k\n loop, r = divmod(n,b)\n new = ans_per_loop*loop\n if r >= k:\n new += r-k+1\n print(new)\n ans += new\nprint(ans)\n', 'import sys\nn,k = map(int,input().split())\nans = 0\nif k == 0:\n print(n**2)\n sys.exit()\nfor b in range(k+1,n+1):\n ans_per_loop = b - k\n loop, r = divmod(n,b)\n new = ans_per_loop*loop\n if r >= k:\n new += r-k+1\n ans += new\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s657556523', 's745160543'] | [9212.0, 9112.0] | [105.0, 80.0] | [273, 258] |
p03420 | u197457087 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N,K = map(int,input().split())\nans = 0\nif K == 0:\n print(N**2)\n exit()\nfor b in range(K+1,N+1): \n amari = b-K\n loop = N//b\n nokori = max(N%b+1-K,0)\n temp = loop*amari + nokori\n print(b,amari,loop,nokori,temp)\n ans += temp\nprint(ans)', 'N,K = map(int,input().split())\nans = 0\nif K == 0:\n print(N**2)\n exit()\nfor b in range(K+1,N+1): \n amari = b-K\n loop = N//b\n nokori = max(N%b+1-K,0)\n temp = loop*amari + nokori\n \n ans += temp\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s152874679', 's085296262'] | [9324.0, 9172.0] | [187.0, 80.0] | [285, 286] |
p03420 | u345966487 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N,K=map(int,input().split());print(sum(N//b*(b-K)+max(N%b+1-K,0)-(K<1)for b in range(N+1)))', 'N,K=map(int,input().split());print(sum(N//b*(b-K)+max(N%b+1-K,0)-(K<1)for b in range(K+1,N+1)))'] | ['Runtime Error', 'Accepted'] | ['s836222092', 's688221175'] | [2940.0, 2940.0] | [18.0, 75.0] | [91, 95] |
p03420 | u375616706 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\n\nans = 0\nfor b in range(K+1, N+1):\n ans = 0\n ans += (N//b)*(b-K)\n r = N % b\n if r != 0:\n ans += max(0, r-K+1)\nprint(ans)\n', '# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\n\nans = 0\nif K == 0:\n ans = N*N\nelse:\n for b in range(K+1, N+1):\n ans += (N//b)*(b-K)\n r = N % b\n ans += max(0, r-K+1)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s779023482', 's371763996'] | [2940.0, 3060.0] | [93.0, 90.0] | [272, 288] |
p03420 | u411858517 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N, K = map(int, input().split())\n\nres = 0\n \nfor b in range(1, N + 1):\n res += max(b - K, 0) * (N // b)\n res += max(N % b - K + 1, 0)\n \nif k == 0:\n res -= 10\nprint(res)', 'N, K = map(int, input().split())\n\nres = 0\n \nfor b in range(1, N + 1):\n res += max(b - K, 0) * (N // b)\n res += max(N % b - K + 1, 0)\n \nif K == 0:\n res -= N\nprint(res)'] | ['Runtime Error', 'Accepted'] | ['s536567946', 's154468376'] | [3060.0, 2940.0] | [102.0, 100.0] | [180, 179] |
p03420 | u413165887 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ["def main():\n n, k = map(int, input().split(' '))\n result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]\n if k == 0:\n result -= n\n print(result)\nmain()", "def main():\n n, k = map(int, input().split(' '))\n result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]\n if k == 0:\n print(sum(result)-n)\n else:\n print(result)\nmain()", "def main():\n n, k = map(int, input().split(' '))\n result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]\n if k != 0:\n print(sum(result))\n else: \n print(sum(result)-n)\nmain()"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s076447115', 's669999724', 's785548310'] | [9056.0, 9056.0, 7012.0] | [88.0, 83.0, 77.0] | [183, 206, 214] |
p03420 | u463775490 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n, k = map(int, input().split())\nans = 0\nfor i in range(1,n+1):\n ans += max(0, (i-k) * (n // i)) + max(0, (n-(n//i)*i-1)-k+1)\nprint(ans)', 'n, k = map(int, input().split())\nif k == 0:\n ans = -n\nelse:\n ans = 0\nfor i in range(1,n+1):\n ans += max(0, (i-k) * (n // i)) + max(0, (n-(n//i)*i)-k+1)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s893325968', 's918986475'] | [2940.0, 3060.0] | [109.0, 106.0] | [139, 171] |
p03420 | u511899838 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['import math\nn, k = map(int,input().split())\n\ncount = 0\nfor b in range(max(k,1),n+1):\n if n % b != 0:\n t = math.ceil(n/b)\n else:\n t = int(n/b) + 1\n if n % b >= k:\n count += (b-k)*t - ((t*b-1)-n)\n else:\n count += (b-k)*(t-1)\n print(b,count)\n\n\nif k ==0:\n count -= (n-k)\n\n\nprint(count)', 'import math\nn, k = map(int,input().split())\n\ncount = 0\nfor b in range(max(k,1),n+1):\n if n % b != 0:\n t = math.ceil(n/b)\n else:\n t = int(n/b) + 1\n if n % b >= k:\n count += (b-k)*t - ((t*b-1)-n)\n else:\n count += (b-k)*(t-1)\n\n\nif k ==0:\n count -= (n-k)\n\n\nprint(count)\n'] | ['Wrong Answer', 'Accepted'] | ['s417002177', 's536420097'] | [4904.0, 3060.0] | [243.0, 103.0] | [359, 341] |
p03420 | u538632589 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n, k = map(int, input().split())\n\nres = 0\nif k == 0:\n print(n*n)\n exit()\n\nfor i in range(k+1, n+1):\n print("i={}".format(i))\n cnt = (i-1)-k+1\n add = n // i * cnt\n if n % i >= k:\n add += (n % i) - k + 1\n res += add\n\nprint(res)\n', 'n, k = map(int, input().split())\n\nres = 0\nif k == 0:\n print(n*n)\n exit()\n\nfor i in range(k+1, n+1):\n cnt = (i-1)-k+1\n add = n // i * cnt\n if n % i >= k:\n add += (n % i) - k + 1\n res += add\n\nprint(res)\n'] | ['Wrong Answer', 'Accepted'] | ['s182918587', 's005898697'] | [4004.0, 2940.0] | [199.0, 92.0] | [254, 226] |
p03420 | u572142121 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | [',K=map(int,input().split())\ndef f(b):\n d=max(b-K,0)*(N//b)+max(N%b-K+1,0)\n return d\nans=0\nif K==0:\n print(N**2)\n exit()\n \nfor i in range(1,N+1):\n ans+=(f(i))\nprint(ans)', 'N,K=map(int,input().split())\ndef f(b):\n d=max(b-K,0)*(N//b)+max(N%b-K+1,0)\n return d\nans=0\nif K==0:\n print(N**2)\n exit()\n \nfor i in range(1,N+1):\n ans+=(f(i))\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s002973934', 's379218035'] | [2940.0, 3060.0] | [17.0, 93.0] | [174, 175] |
p03420 | u572144347 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N,K=map(int,input().split())\nans=(N-K)*(N-K+1)//2\nfor b in range(K+1, N):\n n=(N-b+1)//b\n ans+=n*(b-K)\n if N%b>=K:\n ans+=N%b-K+1\nprint(ans)', 'N,K=map(int,input().split())\nans=(N-K)*(N-K+1)//2\nfor b in range(K+1, N):\n n=(N-b+1)//b\n ans+=(n-1)*(b-K)\n if N%b>=K:\n ans+=N%b-K+1\nprint(ans)', 'N,K=map(int,input().split())\nif K==0: print(N**2);exit(0)\nans=(N-K)*(N-K+1)//2\nfor b in range(K+1, N):\n n=(N-b+1)//b\n ans+=(n)*(b-K)\n if n*b+b-1!=N:\n if N%b>=K:\n ans+=N%b-K+1\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s235931940', 's982059986', 's908435808'] | [3060.0, 2940.0, 3060.0] | [89.0, 91.0, 104.0] | [144, 148, 197] |
p03420 | u759590494 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N,K = map(int, input().split())\nres = 0\nif K==0:\n print(N*N)\n return\nfor i in range(N):\n i += 1\n if i-K<=0:\n continue\n amari = N % i\n amari = amari - K + 1\n re = N//i\n if amari<=0:\n amari = 0\n res += re*(i-K) + amari\n print(res)', 'import sys\n\nN,K = map(int, input().split())\nres = 0\nif K==0:\n print(N*N)\n sys.exit(0)\nfor i in range(N):\n i += 1\n if i-K<=0:\n continue\n amari = N % i\n amari = amari - K + 1\n re = N // i\n if amari <= 0:\n amari = 0\n res += re*(i-K) + amari\n print(res)', 'import sys\n\nN,K = map(int, input().split())\nres = 0\nif K==0:\n print(N*N)\n sys.exit(0)\nfor i in range(N):\n i += 1\n if i-K<=0:\n continue\n amari = N % i\n amari = amari - K + 1\n re = N//i\n if amari<=0:\n amari = 0\n res += re*(i-K) + amari\n print(res)', 'import sys\n\nN,K = map(int, input().split())\nres = 0\nif K==0:\n print(N*N)\n sys.exit(0)\nfor i in range(N):\n i += 1\n if i-K<=0:\n continue\n amari = N % i\n amari = amari - K + 1\n re = N // i\n if amari <= 0:\n amari = 0\n res += re*(i-K) + amari\nprint(res)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s155193794', 's265408183', 's538468160', 's015015127'] | [2940.0, 3064.0, 3064.0, 3064.0] | [17.0, 17.0, 17.0, 95.0] | [269, 290, 286, 289] |
p03420 | u814663076 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n, k = map(int,input().split())\na=0\nfor i in range(1,n):\n a+=max(0,i-k)*(n//i)+max(0,n%i-k+1)\nif k==0:\n a-=n\nprint(a)\n', 'n, k = map(int,input().split())\nfor i in range(1,n):\n a=max(0,i-k)*(n//b)+max(0,n%i-k+1)\nif k==0:\n a-=n\nprint(a)', 'n, k = map(int,input().split())\na=0\nfor i in range(1,n+1):\n a+=max(0,i-k)*(n//i)+max(0,n%i-k+1)\nif k==0:\n a-=n\nprint(a)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s676174646', 's939581809', 's941294111'] | [2940.0, 2940.0, 2940.0] | [100.0, 18.0, 94.0] | [120, 114, 122] |
p03420 | u858670323 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n,k=map(int,input().split())\nans=0\nfor b in range(1,N+1):\n p = N//b\n r = N%b\n ans+=p*max(0,b-K)\n ans+=max(0,r-K+1)\nprint(ans)\n', 'n,k=map(int,input().split())\nans=0\nfor q in range(k,n):\n for b in range(k+1,n+1):\n\t ans+=(n-q)//b+1\nprint(ans)', 'N,K=map(int,input().split())\nans=0\nfor b in range(1,N+1):\n p = N//b\n r = N%b\n ans+=p*max(0,b-K)\n ans+=max(0,r-K+1)\nif(K==0):\n ans-=N\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s308866846', 's328985372', 's583456423'] | [2940.0, 2940.0, 2940.0] | [17.0, 2104.0, 110.0] | [130, 112, 149] |
p03420 | u942033906 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['N,K = map(int,input().split())\nans = 0\nfor b in range(K+1, N+1):\n\t# a=K, K+b, K+2b, ...\n\tn = N // b\n\tr = N % b\n\tc = b - K\n\tans += n * c\n\tprint(b, n*c, r-K+1)\n\tif r >= K:\n\t\tif K > 0:\n\t\t\tans += r - K + 1\n\t\telse:\n\t\t\tans += r - K\nprint(ans)', 'N,K = map(int,input().split())\nans = 0\nfor b in range(K+1, N+1):\n\t# a=K, K+b, K+2b, ...\n\tn = N // b\n\tr = N % b\n\tc = b - K\n\tans += n * c\n\tif r >= K:\n\t\tif K > 0:\n\t\t\tans += r - K + 1\n\t\telse:\n\t\t\tans += r - K\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s762953527', 's494675679'] | [5076.0, 2940.0] | [260.0, 85.0] | [236, 214] |
p03420 | u969190727 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n,k=map(int,input().split())\nans=0\nfor i in range(k+1,n+1):\n ans+=(n//i)*(i-k)+max(n%i-k+1,0)\nprint(n**2 if k== else ans)', 'n,k=map(int,input().split())\nans=0\nfor i in range(k+1,n+1):\n ans+=(n//i)*(i-k)+max(n%i-k+1,0)\nprint(n**2 if k==0 else ans)\n'] | ['Runtime Error', 'Accepted'] | ['s940619725', 's876236044'] | [3064.0, 2940.0] | [17.0, 77.0] | [122, 124] |
p03420 | u987164499 | 2,000 | 262,144 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | ['n,k = map(int,input().split())\npoint = 0\nfor b in range(1,n+1):\n kaisu = n//b\n kosuu = max(0,b-k)\n point += kaisu*kosuu\n point += max(0,n%b+1-k)\nif k == 0:\n point -= n', 'n,k = map(int,input().split())\npoint = 0\nfor b in range(1,n+1):\n kaisu = n//b\n kosuu = max(0,b-k)\n point += kaisu*kosuu\n point += max(0,n%b+1-k)\nif k == 0:\n point -= n\nprint(point)'] | ['Wrong Answer', 'Accepted'] | ['s063021595', 's504897920'] | [2940.0, 3060.0] | [108.0, 120.0] | [182, 195] |
p03422 | u132350318 | 2,000 | 262,144 | Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i. Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation: * Choose a pile. If the i-th pile is selected and there are X stones left in the pile, remove some number of stones between 1 and floor(X/K_i) (inclusive) from the pile. The player who first becomes unable to perform the operation loses the game. Assuming that both players play optimally, determine the winner of the game. Here, floor(x) represents the largest integer not greater than x. | ['def main():\n n = int(input())\n res = 0\n\n for (a, k) in [[int(x) for x in input().split()] for _ in range(n)]:\n while a >= k:\n m, u = a // k, (a - k * m)\n if a % k == 0 or (a % k) % (m + 1) == 0:\n res ^= m\n break\n x = u // (m + 1)\n a -= (x + 1) * (m + 1)\n\n print(\'Takahashi\' if res != 0 else \'Aoki\')\n\n\nif __name__ == "__main__":\n main()\n', "def main():\n n = int(input())\n res = 0\n for (a, k) in [map(int, input().split()) for _ in range(n)]:\n while a > k and a % k != 0:\n m = a // k\n x = (a - k * m - 1) // (m + 1)\n a -= max(1, x) * (m + 1)\n res ^= a // k\n print('Takahashi' if res != 0 else 'Aoki')\n\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s445343393', 's034633469'] | [3064.0, 3188.0] | [19.0, 1905.0] | [432, 357] |
p03423 | u003018968 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['n = input()\nprint(n / 3)', 'n = input()\nprint(n // 3)', 'n = int(input())\nprint(int(n / 3))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s604444450', 's614607503', 's312217243'] | [2940.0, 2940.0, 2940.0] | [18.0, 19.0, 18.0] | [24, 25, 35] |
p03423 | u005388620 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['a = int(input())\nb = a/3\nprint(b)\n', 'n = int(input())\na = int(n/3)\nprint(a)'] | ['Wrong Answer', 'Accepted'] | ['s819628673', 's544750043'] | [2940.0, 2940.0] | [17.0, 17.0] | [34, 38] |
p03423 | u007808656 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['h,w,d=map(int,input().split())\n\nboard=[0 for _ in range(h*w)]\n\nfor i in range(h):\n for j,a in enumerate(input().split()):\n board[i*w+j]=int(a)\n\nq=int(input())\n\n\ndistances=[0 for _ in range(h*w)]\n\nfor i in range(d,h*w):\n a=h*w-i\n tmp=board.index(a)\n i=tmp//w\n j=tmp%w\n tmp=board.index(a+d)\n x=tmp//w\n y=tmp%w\n distances[a-1]=distances[a+d-1]+abs(i-x)+abs(j-y)\n\nfor _ in range(q):\n l,r=map(int,input().split())\n print(distances[l-1]-distances[r-1])', 'n=int(input())\nprint(n//3)'] | ['Runtime Error', 'Accepted'] | ['s852351822', 's096503302'] | [3064.0, 3316.0] | [17.0, 19.0] | [486, 26] |
p03423 | u013756322 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['n = int() n = int(input())\n print((n - n % 3)//3)', ' n = int(input())\n print((n - n % 3)//3)', ' n = int(input())\n print(n//3)', 'n = int(input())\nprint(n//3)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s303083736', 's738773923', 's799734094', 's857575458'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0, 17.0] | [52, 43, 32, 28] |
p03423 | u019578976 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['print(input()//3)', 'print(int(input())//3)'] | ['Runtime Error', 'Accepted'] | ['s817292694', 's261779038'] | [2940.0, 2940.0] | [17.0, 17.0] | [17, 22] |
p03423 | u019584841 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['n=int(input())\nn//3', 'n=int(input())\nprint(n//3)'] | ['Wrong Answer', 'Accepted'] | ['s240986340', 's243203013'] | [2940.0, 2940.0] | [17.0, 17.0] | [19, 26] |
p03423 | u023107557 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['print(int(input()/3))', 'print(int(int(input())/3))'] | ['Runtime Error', 'Accepted'] | ['s579689164', 's148798756'] | [2940.0, 2940.0] | [17.0, 17.0] | [21, 26] |
p03423 | u027622859 | 2,000 | 262,144 | There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible. Divide the students so that the number of groups consisting of three or more students is maximized. | ['n = int(input())\nl = input().split()\nl = set(l)\nlength = len(l)\n\nif length == 4:\n print("Four")\nelse:\n print("Three")', 'print(int(input())//3)'] | ['Runtime Error', 'Accepted'] | ['s917142954', 's074672059'] | [2940.0, 2940.0] | [17.0, 17.0] | [123, 22] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.