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
|
---|---|---|---|---|---|---|---|---|---|---|
p02676 | u949237528 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['K=int(input())\nS=input()\nprint(S if len(S)<=K else S[0:K]+"."*(len(S)-K)) ', 'K=int(input())\nS=input()\nprint(S if len(S)<=K else S[0:K]+"."*3) '] | ['Wrong Answer', 'Accepted'] | ['s594581961', 's089047684'] | [9076.0, 9104.0] | [23.0, 24.0] | [74, 65] |
p02676 | u956318161 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k=int(input())\ns=list(input())\nss=("").join(s)\nS=len(s)\nif S<=k:\n print(ss)\nelse:\n print(ss+("..."))', 'k=int(input())\ns=list(input())\nss=("").join(s)\nS=len(s)\nsss=("").join(s[0:k])\nif S<=k:\n print(ss)\nelse:\n print(sss+("..."))'] | ['Wrong Answer', 'Accepted'] | ['s950931219', 's717235684'] | [9144.0, 9100.0] | [27.0, 26.0] | [102, 125] |
p02676 | u957872856 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k = int(input())\nS = input()\nif len(S) > K:\n print(S[:K]+"...")\nelse:\n print(S)\n', 'k = int(input())\nS = input()\nif len(S) > K:\n print(S[:K])\nelse:\n print(S)', 'K = int(input())\nS = input()\nif len(S) > K:\n print(S[:K])\nelse:\n print(S)\n', 'K = int(input())\nS = input()\nif len(S) > K:\n print(S[:K]+"...")\nelse:\n print(S)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s093053375', 's471184548', 's708936743', 's239570756'] | [9024.0, 9156.0, 9140.0, 9160.0] | [25.0, 23.0, 26.0, 23.0] | [82, 75, 76, 82] |
p02676 | u963747475 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["s=input()\nk=int(input())\nif len(s)> k:\n print(s[:k]+'...')\nif len(s)<=k:\n print(s)", "k=int(input())\ns=input()\nif len(s)> k:\n print(s[:k]+'...')\nif len(s)<=k:\n print(s)\n"] | ['Runtime Error', 'Accepted'] | ['s026566443', 's841721974'] | [9160.0, 9156.0] | [22.0, 22.0] | [84, 85] |
p02676 | u967359881 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k=int(input())\ns=input()\nif len(s)==k:\n print(s)\nelse:\n print(s[:k+1]+"...")\n ', 'k=int(input())\ns=input()\nif len(s)<=k:\n print(s)\nelse:\n print(s[:k]+"...")\n'] | ['Wrong Answer', 'Accepted'] | ['s241490627', 's548573180'] | [9156.0, 9156.0] | [24.0, 23.0] | [81, 77] |
p02676 | u967484343 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['K = int(input())\nS = input()\nans = ""\nif K >= len(S):\n print(S)\nelse:\n for i in range(K):\n ans += S[i]\n print(ans + "…")', 'K = int(input())\nS = input()\nans = ""\nif K >= len(S):\n print(S)\nelse:\n for i in range(K):\n ans += S[i]\n print(ans + "...")'] | ['Wrong Answer', 'Accepted'] | ['s719897997', 's267110105'] | [9128.0, 9064.0] | [24.0, 30.0] | [138, 138] |
p02676 | u969483761 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['S=input()\nK=int(input())\n\nif len(S) <= K:\n print(S)\nelse :\n print(S[0:K]+"...")', 'K=int(input())\nS=input()\n\nif len(S) <= K:\n print(S)\nelse :\n print(S[0:K]+"...")'] | ['Runtime Error', 'Accepted'] | ['s848312652', 's066768295'] | [9172.0, 9192.0] | [21.0, 20.0] | [85, 85] |
p02676 | u973972117 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["S = input()\nif len(S) <= K:\n print(S)\nelse:\n print(S[0:K]+'...')", "K = int(input())\nS = input()\nif len(S) <= K:\n print(S)\nelse:\n print(S[0:K]+'...')"] | ['Runtime Error', 'Accepted'] | ['s429710140', 's297552331'] | [9032.0, 9160.0] | [19.0, 22.0] | [70, 87] |
p02676 | u974485376 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k = int(input())\ns = input()\nif len(s) <= k:\n print(s)\nelse:\n print(s[:k])\n', 'm = int(input())\nk = input()\nif len(k) <= m:\n print(k)\nelse:\n print(k[:m])\n', "k = int(input())\ns = input()\nif len(s) <= k:\n print(s)\nelse:\n print(s[:k]+'...')\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s222213902', 's700302067', 's332285058'] | [8996.0, 9128.0, 9092.0] | [33.0, 26.0, 25.0] | [81, 81, 87] |
p02676 | u974918235 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['K, S = int(input()), input()\nif len(S) <= K:\n print(S)\nelse:\n print(S[:K] + ...)', 'K, S = int(input()), input()\nif len(S) <= K:\n print(S)\nelse:\n print(S[:K] + "...")'] | ['Runtime Error', 'Accepted'] | ['s737938733', 's878984110'] | [9168.0, 8836.0] | [29.0, 29.0] | [82, 84] |
p02676 | u977650778 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["a = int(input())\nb = input()\nif len(b) < a:\n print(b[:a]+'...')\nelse:\n print(b)", "a = int(input())\nb = input()\nif len(a) < b:\n print(b[:a]+'...')\nelse:\n print(b)", "a = int(input())\nb = input()\nif len(b) > a:\n print(b[:a]+'...')\nelse:\n print(b)"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s564403397', 's914447144', 's347595403'] | [9168.0, 9164.0, 9168.0] | [21.0, 21.0, 23.0] | [85, 85, 85] |
p02676 | u982591663 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['K = int(input())\nS = input()\nlen_S = len(S)\n\nif len_S <= K:\n print(S)\nelse:\n ans = S[:K+1]\n print(ans+"...")\n', 'K = int(input())\nS = input()\nlen_S = len(S)\n\nif len_S <= K:\n print(S)\nelse:\n ans = S[:K]\n print(ans+"...")\n'] | ['Wrong Answer', 'Accepted'] | ['s870843982', 's795473001'] | [9160.0, 9160.0] | [21.0, 24.0] | [118, 116] |
p02676 | u983967747 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k = int(input())\ns = input()\nans = ""\nif(k<len(s)):\n ans += s[0:k]\n ans += ans.ljust(len(s),\'.\')\nelse:\n ans+=s[0:k]\n\nprint(ans)\n', 'k = int(input())\ns = input()\nans = ""\nif(k<len(s)):\n ans += s[0:k]\n ans.ljust(len(s)-k,\'.\')\nelse:\n ans+=s[0:k]\n\nprint(ans)\n', 'k = int(input())\ns = input()\nans = ""\nif(k<len(s)):\n ans += s[0:k]\n ans += \'...\'\nelse:\n ans+=s[0:k]\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s377535227', 's534542385', 's461314586'] | [9180.0, 9176.0, 9172.0] | [21.0, 22.0, 22.0] | [137, 132, 121] |
p02676 | u987549444 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["from sys import stdin\nimport math\na=int(stdin.readline())\nb=stdin.readline()\n\nif len(b)<=a:\n print(b)\nelse:\n for k in range(0,a):\n print(b[k],end='')\n print('...',end='')", "from sys import stdin\n\na=int(stdin.readline())\nb=stdin.readline()\n\nif len(b)-1<=a:\n print(b)\nelse:\n b=b[:a]\n b=b+'...'\n print(b)"] | ['Wrong Answer', 'Accepted'] | ['s493347166', 's445093932'] | [9180.0, 9168.0] | [21.0, 21.0] | [186, 140] |
p02676 | u987637902 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['K = int(input())\nS = input()\na = len(S)\nif a <= K:\n print(S)\nelse:\n print(str(S[0:K]))\n', "# ABC168\n# B (Triple Dots)\nK = int(input())\nS = input()\na = len(S)\nif a <= K:\n print(S)\nelse:\n print(str(S[0:K])+'...')\n"] | ['Wrong Answer', 'Accepted'] | ['s906588125', 's153986101'] | [9060.0, 9156.0] | [26.0, 26.0] | [93, 126] |
p02676 | u996996256 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["k = int(input())\nn = input()\nif len(n)>k:\n print(n+'...')\nelse:\n print(n)", "k = int(input())\nn = input()\nif len(n)>k:\n print(n[:k]+'...')\nelse:\n print(n)"] | ['Wrong Answer', 'Accepted'] | ['s546074371', 's414123089'] | [9160.0, 9164.0] | [22.0, 22.0] | [79, 83] |
p02676 | u997036872 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["n = int(input())\na = input()\nif len(a) > n:\n print(a[0:n+1]+'...')\nelse:\n print(a )", "n = int(input())\na = input()\nif len(a) > n:\n print(a[0:n+1])\nelse:\n print(a +'...')", 'n = int(input())\na = input()\nif len(a) > n:\n print(a[0:n+1])\nelse:\n print(a)', "n = int(input())\na = input()\nif len(a) > n:\n print(a[0:n]+'...')\nelse:\n print(a )"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s123876477', 's606562058', 's971218982', 's000646644'] | [9072.0, 9160.0, 9180.0, 9148.0] | [22.0, 22.0, 21.0, 23.0] | [85, 85, 78, 83] |
p02676 | u999799597 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ['k = int(input())\ns = input()\nif len(s) > k:\n print (s[: k + 1] + "...")\nelse:\n print(s)\n', 'k = int(input())\ns = input()\nif len(s) > k:\n print (s[: k] + "...")\nelse:\n print(s)'] | ['Wrong Answer', 'Accepted'] | ['s781641041', 's913084326'] | [9064.0, 9160.0] | [27.0, 27.0] | [94, 89] |
p02676 | u999983491 | 2,000 | 1,048,576 | We have a string S consisting of lowercase English letters. If the length of S is at most K, print S without change. If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result. | ["K = int(input())\nS = input()\nif len(S) > K:\n print(S[:-K+1] + '...')\nelse:\n print(S)", "K = int(input())\nS = input()\nif len(S) > K:\n print(S[:K] + '...')\nelse:\n print(S)\n"] | ['Wrong Answer', 'Accepted'] | ['s210896679', 's904685964'] | [9160.0, 9160.0] | [22.0, 22.0] | [90, 88] |
p02677 | u026862065 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ["import math\n\na, b, h, m = map(int, input().split())\nl = m * 6\ns = m * 0.5 + h * 30\nth = abs(l - s)\nif th == 0:\n print(abs(a - b))\n #print('{:.20f}'.format(abs(a - b)))\n exit()\nelif th == 180:\n print(a + b)\n #print('{:.20f}'.format(a + b))\n exit()\nif th >= 180:\n th -= 180\ncos = math.cos(math.radians(th))\nans = a**2 + b**2 - 2 * a * b * cos\nprint(ans**0.5)\n#print('{:.20f}'.format(math.sqrt(ans)))", "import math\n\na, b, h, m = map(int, input().split())\nl = m * 6\ns = m * 0.5 + h * 30\nth = abs(l - s)\nprint(th)\nif th == 0:\n print('{:.20f}'.format(abs(a - b)))\n exit()\nelif th == 180:\n print('{:.20f}'.format(a + b))\n exit()\nif th >= 180:\n th = 360 - th\ncos = math.cos(math.radians(th))\nans = a**2 + b**2 - 2 * a * b * cos\nprint('{:.20f}'.format(math.sqrt(ans)))", "import math\n\na, b, h, m = map(int, input().split())\nl = m * 6\ns = m * 0.5 + h * 30\nth = abs(l - s)\nif th == 0:\n print('{:.20f}'.format(abs(a - b)))\n exit()\nelif th == 180:\n print('{:.20f}'.format(a + b))\n exit()\nif th >= 180:\n th = 360 - th\ncos = math.cos(math.radians(th))\nans = a**2 + b**2 - 2 * a * b * cos\nprint('{:.20f}'.format(math.sqrt(ans)))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s027026235', 's256938239', 's942149631'] | [9520.0, 9464.0, 9352.0] | [23.0, 24.0, 26.0] | [418, 374, 364] |
p02677 | u146967091 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ["import sys\nimport math\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(4100000)\n\n\ndef main():\n A, B, H, M = map(int, input().rstrip().split())\n theta_m = 2 * math.pi * M / 60\n theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)\n theta = (theta_h - theta_m) % math.pi\n ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))\n print(theta_m)\n print(theta_h)\n print(theta)\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(4100000)\n\n\ndef main():\n A, B, H, M = map(int, input().rstrip().split())\n theta_m = 2 * math.pi * M / 60\n theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)\n theta = (theta_h - theta_m) % math.pi\n ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))\n \n \n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(4100000)\n\n\ndef main():\n A, B, H, M = map(int, input().rstrip().split())\n theta_m = 2 * math.pi * M / 60\n theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)\n if theta_h > theta_m:\n theta = (theta_h - theta_m) % math.pi\n else:\n theta = (theta_m - theta_h) % math.pi\n ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))\n \n \n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(4100000)\n\n\ndef main():\n A, B, H, M = map(int, input().rstrip().split())\n theta_m = 2 * math.pi * M / 60\n theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)\n theta = abs(theta_m - theta_h)\n if theta > math.pi:\n theta = 2 * math.pi - theta\n ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))\n \n \n \n print('{:.20f}'.format(ans))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s039514293', 's254420108', 's780191803', 's952411053'] | [9492.0, 9424.0, 9468.0, 9476.0] | [22.0, 26.0, 24.0, 24.0] | [455, 461, 547, 532] |
p02677 | u197868423 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ["import sys\nimport math\n\ndef resolve():\nA, B, H, M = map(int, sys.stdin.readline().split())\ntheta = (H * 30 + M * 0.5) - (M * 6)\nans = math.sqrt((A**2 + B**2) - (2 * A * B) * math.cos(math.radians(theta)))\nprint('{:.20f}'.format(ans))", "import sys\nimport math\n\nA, B, H, M = map(int, sys.stdin.readline().split())\ntheta = (H * 30 + M * 0.5) - (M * 6)\nans = math.sqrt((A**2 + B**2) - (2 * A * B) * math.cos(math.radians(theta)))\nprint('{:.20f}'.format(ans))"] | ['Runtime Error', 'Accepted'] | ['s450754719', 's587762491'] | [8940.0, 9428.0] | [25.0, 24.0] | [234, 219] |
p02677 | u210882514 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\n\nInp = input()\nList = Inp.split(" ")\nA = int(List[0])\nB = int(List[1])\nH = int(List[2])\nM = int(List[3])\n\nDegA = int(H*30 + M*0.5)\nDegB = int(M*6)\n\n \n\nDeg =abs(DegA - DegB)\n\nC = (A**2 + B**2 - 2*B*A*math.cos(math.radians(Deg)))**0.5\n\nprint(format(C,\'.10f\'))', 'import math\n\nInp = input()\nList = Inp.split(" ")\nA = int(List[0])\nB = int(List[1])\nH = int(List[2])\nM = int(List[3])\n\nDegA = int(H*30 + M*0.5)\nDegB = int(M*6)\n\n\nif abs(DegA - DegB) <= 180:\n Deg = DegA - DegB\n\nelse:\n\n if DegA > DegB:\n Deg = 360 - DegA + DegB\n\n else:\n Deg = 360 - DegB + DegA\n \nC = (A**2 + B**2 - 2*B*A*math.cos(math.radians(Deg)))**0.5\n\nprint(format(C,\'.10f\'))', 'import math\n\nInp = input()\nList = Inp.split(" ")\nA = int(List[0])\nB = int(List[1])\nH = int(List[2])\nM = int(List[3])\n\n \n\nDeg = math.radians(abs(0.5 * (60 * H + M) - 6 * M))\n\nC = math.sqrt((A**2 + B**2 - 2*A*B*math.cos(Deg)))\n\nprint(format(C,\'.20f\'))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s585426320', 's949580452', 's534495785'] | [9484.0, 9556.0, 9524.0] | [23.0, 25.0, 22.0] | [430, 402, 452] |
p02677 | u218757284 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\na, b, h, m = map(int, input().split())\n\nangle_m = 6 * m\nangle_h = 30 * h + 0.5 * m\nangle = abs(angle_m - angle_h)\nif angle >= 180:\n angle -= 180\n\nans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))\nprint(ans)', 'import math\na, b, h, m = map(int, input().split())\n\nangle_m = 6 * m\nangle_h = 30 * h + 0.5 * m\nangle = abs(angle_m - angle_h)\nif angle > 180:\n angle -= 180\n\nans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))\nprint(ans)', "import math\na, b, h, m = map(int, input().split())\n\nangle_m = 6 * m\nangle_h = 30 * h + 0.5 * m\nangle = abs(angle_m - angle_h)\nif angle > 180:\n angle = 360 - angle\n\nans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))\nprint('{:.20f}'.format(ans))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s162386037', 's892574537', 's756461920'] | [9388.0, 9504.0, 9516.0] | [23.0, 21.0, 23.0] | [234, 233, 258] |
p02677 | u307615746 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\n\ndef main() :\n A, B, H, M = list(map(int, input().split()))\n\n theta = abs((H+ M/ 60)* 30- M* 6)\n print(theta)\n \n result = B**2 + A**2 - 2* B* A* math.cos(math.radians(theta))\n result = math.sqrt(result)\n\n print(\'{:.020f}\'.format(result))\n\nif __name__ == "__main__":\n main()', 'import math\n\ndef main() :\n A, B, H, M = list(map(int, input().split()))\n\n theta = abs((H+ M/ 60)* 30- M* 6)\n \n \n result = B**2 + A**2 - 2* B* A* math.cos(math.radians(theta))\n result = math.sqrt(result)\n\n print(\'{:.020f}\'.format(result))\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s136177472', 's135517645'] | [9444.0, 9500.0] | [23.0, 24.0] | [309, 310] |
p02677 | u425068548 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\n\nnums = list(map(lambda x:int(x), input().split()))\na, b, h, m = nums[0], nums[1], nums[2], nums[3]\n\nwa = 0.5\nwb = 6\n\ntm = 60 * h + m\n\nda = tm * wa\ndb = (tm % 60) * wb\ndiff = abs(da - db)\nprint(tm, da, db, diff)\ncsq = a*a + b*b - (2 * a * b * math.cos(diff * math.pi / 180))\nprint("{:.20f}".format(math.sqrt(csq)))', 'import math\n\nnums = list(map(lambda x:int(x), input().split()))\na, b, h, m = nums[0], nums[1], nums[2], nums[3]\n\nwa = 0.5\nwb = 6\n\ntm = 60 * h + m\n\nda = tm * wa * math.pi / 180\ndb = (tm % 60) * wb * math.pi / 180\ndiff = abs(da - db)\ncsq = a*a + b*b - (2 * a * b * math.cos(diff))\nprint("{:.20f}".format(math.sqrt(csq)))'] | ['Wrong Answer', 'Accepted'] | ['s980504658', 's378757329'] | [9468.0, 9456.0] | [23.0, 23.0] | [326, 318] |
p02677 | u511501183 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\n\nA, B, H, M = [int(a) for a in input().split()]\nh_d = -2*math.pi/12\nm_d = -2*math.pi/60\n\nh_s = h_d*(H+M/60) + math.pi/2\nm_s = m_d*M + math.pi/2\n\nh_y = A*math.sin(h_s)\nh_x = A*math.cos(h_s)\nm_y = B*math.sin(m_s)\nm_x = B*math.cos(m_s)\n\nx = h_x - m_x\ny = h_y - m_y\n\nprint(A, h_x, h_y, math.sqrt(h_x**2+h_y**2))\nprint(B, m_x, m_y, math.sqrt(m_x**2+m_y**2))\n\nans = math.sqrt(pow(x,2)+pow(y,2))\nprint("{:.20f}".format(ans))\n', 'import math\n\nA, B, H, M = [int(a) for a in input().split()]\nh_d = -2*math.pi/12\nm_d = -2*math.pi/60\n\nh_s = h_d*(H+M/60) + math.pi/2\nm_s = m_d*M + math.pi/2\n\nh_y = A*math.sin(h_s)\nh_x = A*math.cos(h_s)\nm_y = B*math.sin(m_s)\nm_x = B*math.cos(m_s)\n\nx = h_x - m_x\ny = h_y - m_y\n\nans = math.sqrt(pow(x,2)+pow(y,2))\nprint("{:.20f}".format(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s142237881', 's156011380'] | [9576.0, 9576.0] | [23.0, 24.0] | [430, 339] |
p02677 | u565448206 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\nfrom math import cos\n\n\ndef time():\n A, B, H, M = map(int, input().split())\n minuteAngel = (float(M) * 360) / 60\n hourAngel = (float(H) % 12) * 30 + (float(M) * 30) / 60\n angel = abs(hourAngel - minuteAngel)\n a = cos((angel % 180)/180 * math.pi)\n diatance = math.sqrt(A * A + B * B - 2 * A * B * a)\n print("%.20f" % diatance)\n\n', 'import math\nimport cmath\nif __name__ == \'__main__\':\n ABHM = list(map(int, input().split(" ")))\n A, B, H, M = ABHM[0], ABHM[1], ABHM[2], ABHM[3]\n mintime = (float)(60 * H + M)\n M=(float)(mintime%60/360)\n H=(float)(mintime%720/60)\n angle=abs(H-M)\n re=cmath.sqrt(A*A+B*B-2*A*B*math.cos(angle*math.pi))\n print("%.20f",re)', 'import math\nfrom math import cos\n\n\ndef time():\n A, B, H, M = map(int, input().split())\n minuteAngel = (float(M) * 360) / 60\n hourAngel = (float(H) % 12) * 30 + (float(M) * 30) / 60\n angel = abs(hourAngel - minuteAngel)\n a = cos(angel / 180 * math.pi)\n a = float(\'%.30f\' % a)\n diatance = math.sqrt(A * A + B * B - 2 * A * B * a)\n print("%.20f" % diatance)\n\n', 'import math\nfrom math import cos\n\n\ndef time():\n A, B, H, M = map(int, input().split())\n minuteAngel = M * 360.0 / 60.0\n hourAngel = H * 30.0 + M * 30.0 / 60.0\n angel = abs(hourAngel - minuteAngel)\n a = cos(angel / 180 * math.pi)\n a = float(\'%.20f\' % a)\n distance = math.sqrt(A * A + B * B - 2 * A * B * a)\n print("%.20f" % distance)\n\n\nif __name__=="__main__":\n time()\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s298761519', 's607251984', 's776820364', 's051947006'] | [9056.0, 9624.0, 9120.0, 9476.0] | [21.0, 24.0, 22.0, 25.0] | [359, 341, 380, 395] |
p02677 | u587518324 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['#!/usr/bin/env python\n\n\n__author__ = \'bugttle <[email protected]>\'\n\nimport math\n\ndef normalize_angle(angle):\n angle = 360 - angle\n angle = angle + 90\n if (360 <= angle):\n angle -= 360\n return angle\n\n\ndef main():\n A, B, H, M = list(map(int, input().split()))\n\n # X * 12 = 360\n # X * 60 = 30\n angle = normalize_angle((H * 30 + M * 0.5))\n print(angle)\n x1 = A * math.cos(math.radians(angle))\n y1 = A * math.sin(math.radians(angle))\n\n # X * 60 = 360\n angle = normalize_angle((M * 6))\n print(angle)\n x2 = B * math.cos(math.radians(angle))\n y2 = B * math.sin(math.radians(angle))\n\n print("{},{}".format(x1, y1))\n print("{},{}".format(x2, y2))\n\n print(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2))\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python\n\n\n__author__ = \'bugttle <[email protected]>\'\n\nimport math\n\ndef normalize_angle(angle):\n angle = 360 - angle\n angle = angle + 90\n if (360 <= angle):\n angle -= 360\n return angle\n\n\ndef main():\n A, B, H, M = list(map(int, input().split()))\n\n # X * 12 = 360\n # X * 60 = 30\n angle = normalize_angle((H * 30 + M * 0.5))\n print(angle)\n x1 = A * math.cos(math.radians(angle))\n y1 = A * math.sin(math.radians(angle))\n\n # X * 60 = 360\n angle = normalize_angle((M * 6))\n print(angle)\n x2 = B * math.cos(math.radians(angle))\n y2 = B * math.sin(math.radians(angle))\n\n print("{},{}".format(x1, y1))\n print("{},{}".format(x2, y2))\n\n print("{:.20f}".format(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2)))\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python\n\n\n__author__ = \'bugttle <[email protected]>\'\n\nimport math\n\ndef normalize_angle(angle):\n angle = 360 - angle\n angle = angle + 90\n if (360 <= angle):\n angle -= 360\n return angle\n\n\ndef main():\n A, B, H, M = list(map(int, input().split()))\n\n # X * 12 = 360\n # X * 60 = 30\n angle = normalize_angle((H * 30 + M * 0.5))\n x1 = A * math.cos(math.radians(angle))\n y1 = A * math.sin(math.radians(angle))\n\n # X * 60 = 360\n angle = normalize_angle((M * 6))\n x2 = B * math.cos(math.radians(angle))\n y2 = B * math.sin(math.radians(angle))\n\n print("{:.20f}".format(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2)))\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s412557966', 's477686620', 's115443744'] | [9556.0, 9572.0, 9524.0] | [24.0, 23.0, 23.0] | [878, 896, 793] |
p02677 | u744695362 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\n\n\na,b,h,m=map(int, input().split())\n\n\nd = 30*(h+m/60)-6*m\ne = 360-d\nf = int(min(d,e))\ny = math.cos(math.radians(f))\n\n\nx = a**2+b**2-2*a*b*y\nprint(math.sqrt(x))\n', 'import math\n \n \na,b,h,m=map(int, input().split())\n \n \nd = 30*(h+m/60)-6*m\ne = 360-d\nf = min(d,e)\ny = math.cos(math.radians(f))\n \n \nx = a**2+b**2-2*a*b*y\nz = float(math.sqrt(x))\nprint("{0:.20f}".format(z))'] | ['Wrong Answer', 'Accepted'] | ['s665502781', 's522771336'] | [9504.0, 9520.0] | [23.0, 25.0] | [172, 204] |
p02677 | u750651325 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\nimport sys\nsys.stdin.readline\n\ndef yogen(x):\n ans = 0\n ans = (A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(x)))**(1/2)\n print(ans)\n\nA, B, H, M = map(int, input().split())\n\nji = int(H)*30 + int(M)/2\nhun = int(M)*6\n\nif ji == hun:\n print(0)\nelif ji - hun < 180:\n yogen(ji - hun)\nelse:\n yogen(hun-ji)\n', 'import math\nimport sys\nsys.stdin.readline\n\ndef yogen(x):\n ans = (A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(x)))**(1/2)\n print("{:.20f}".format(ans))\n\nA, B, H, M = map(int, input().split())\n\nji = int(H)*30 + int(M)/2\nhun = int(M)*6\n\nif ji == hun:\n aaa = abs(A-B)\n print("{:.20f}".format(aaa))\nelif ji - hun < 180:\n yogen(ji-hun)\nelse:\n yogen(hun-ji)\n'] | ['Wrong Answer', 'Accepted'] | ['s678839192', 's992410863'] | [9512.0, 9524.0] | [23.0, 22.0] | [328, 371] |
p02677 | u754046530 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ["# C\nimport math\n\nA,B,H,M = map(int,input().split(' '))\n\nrad = math.radians(abs(H*30-M*6))\n\nprint('{:.15f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))", "# C\nimport math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nrad = abs(H*30-M*6)\nrad = math.radians(min(rad,360-rad))\nprint('{:.15f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\nprint(edge)\nif edge%180 == 0:\n print('{:.15f}'.format(A+B))\nelse:\n print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))", "# C\nimport math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nrad = abs(H/6*math.pi-M/30*math.pi)\nrad = min(rad,360-rad)\nprint('{:.15f}'.format(A*A + B*B - 2*A*B*math.cos(rad))**0.5)", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\nprint(edge)\nif edge%180 == 0:\n print('{:.15f}'.format(A+B))\nelse:\n print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\nprint(edge)\nif edge%180 == 0:\n print('{:.20f}'.format(A+B))\nelse:\n print('{:.20f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\n\nif edge%180 == 0:\n print('{:.15f}'.format(A+B))\nelse:\n print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\n\nif edge%180 == 0:\n print('{:.15f}'.format(A+B))\nelse:\n print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(edge))))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nrad = abs(H/6*math.pi-M/30*math.pi)\n \nprint('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(rad))))", "import math\n\nA,B,H,M = map(int,input().split(' '))\n\n\nif H >= 6:\n edge = abs(M*6+(12-H)*5*6)\nelse:\n edge = abs(M*6-H*5*6)\n\nif edge > 180:\n edge = 360 - edge\n\nif edge%180 == 0:\n print('{:.15f}'.format(A+B))\nelse:\n print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))", "# C\nimport math\n\nA,B,H,M = map(int,input().split(' '))\nrad = abs((H*30+M/2)-M*6)\nrad = math.radians(min(rad,360-rad))\nprint('{:.20f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s028543614', 's185310088', 's204574247', 's264877751', 's380111652', 's382972017', 's523370662', 's563856303', 's897654072', 's985144563', 's497546433'] | [9432.0, 9512.0, 9616.0, 9596.0, 9528.0, 9320.0, 9588.0, 9404.0, 9496.0, 9476.0, 9572.0] | [21.0, 22.0, 24.0, 24.0, 26.0, 23.0, 22.0, 23.0, 22.0, 24.0, 21.0] | [210, 256, 423, 254, 319, 423, 412, 398, 238, 412, 237] |
p02677 | u759510609 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ["import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*40\na=abs(sita1-sita2)\nx1 = B*math.cos(math.radians(sita1))\ny1 = B*math.sin(math.radians(sita1))\nx2 = A*math.cos(math.radians(sita2))\ny2 = A*math.sin(math.radians(sita2))\n\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint('{:.20f}'.format(d))\n", 'import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*40\na=abs(sita1-sita2)\nx1 = B*math.cos(math.radians(sita1))\ny1 = B*math.sin(math.radians(sita1))\nx2 = A*math.cos(math.radians(sita2))\ny2 = A*math.sin(math.radians(sita2))\n\nprint(A,B,a)\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint(d)', "import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*M\n\na=abs(sita1-sita2)\nif a > 180:\n a = 360 - a\nprint(A,B,a)\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint('{:.20f}'.format(d))\n", "import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*40\n\na=abs(sita1-sita2)\n\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint('{:.20f}'.format(d))\n", 'import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=(360-M*360/60+90)%360\nsita2=(360-H*360/12+90)%360\nx1 = B*math.cos(math.radians(sita1))\ny1 = B*math.sin(math.radians(sita1))\nx2 = A*math.cos(math.radians(sita2))\ny2 = A*math.sin(math.radians(sita2))\n\nd = math.sqrt((x2-x1)**2 +(y2-y1)**2)\n\nprint(d)\n', 'import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*40\na=abs(sita1-sita2)\nx1 = B*math.cos(math.radians(sita1))\ny1 = B*math.sin(math.radians(sita1))\nx2 = A*math.cos(math.radians(sita2))\ny2 = A*math.sin(math.radians(sita2))\n\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint(d)', "import math\n\nA,B,H,M = map(int,input().split())\n\nsita1=M*360/60\nsita2=H*360/12+0.5*M\n\na=abs(sita1-sita2)\nif a > 180:\n a = 360 - a\nd = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))\n\nprint('{:.20f}'.format(d))\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s248580148', 's253231834', 's352605955', 's611150023', 's714364348', 's742975854', 's757401442'] | [9524.0, 9524.0, 9572.0, 9452.0, 9488.0, 9520.0, 9508.0] | [22.0, 23.0, 23.0, 25.0, 24.0, 23.0, 23.0] | [337, 331, 229, 190, 302, 318, 216] |
p02677 | u805392425 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\nfrom decimal import *\nimport sympy\na, b, h, m = map(int, input().split())\n\nbig = max(30*h, 6*m)\nsmall = min(30*h, 6*m)\ngap = min(big - small, 360 - (big - small)) + (m*0.5)\n\n\nprint(format(Decimal(a**2 + b**2 - 2*a*b*sympy.cos(sympy.radians(gap)))**Decimal("0.5"), ".20f"))\n', 'import math\na, b, h, m = map(int, input().split())\n\nbig = max(30*h, 6*m)\nsmall = min(30*h, 6*m)\ngap = min(big - small, 360 - (big - small))\n\nprint(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))))', 'import math\na, b, h, m = map(int, input().split())\n\nbig = max(30*h, 6*m)\nsmall = min(30*h, 6*m)\ngap = min(big - small, 360 - (big - small)) + (m*0.5)\n\n\nprint(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))))', 'import math\na, b, h, m = map(int, input().split())\n\nbig = max(30*h + (m*0.5), 6*m)\nsmall = min(30*h + (m*0.5), 6*m)\ngap = min(big - small, 360 - (big - small))\n\nprint(format(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))), ".20f"))'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s140375885', 's880351823', 's903709287', 's130826620'] | [9872.0, 9392.0, 9516.0, 9516.0] | [28.0, 22.0, 23.0, 23.0] | [285, 206, 217, 242] |
p02677 | u832806457 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import sys\nimport numpy as np\n\n##i = list(map(int, input().split()))\n##a = i[0]\n##b = i[1]\n##h = i[2]\n##m = i[3]\na,b,h,m = 3,4,10,40\ntime = h*60+m\nths = np.pi/2-(np.pi * time/(60*12))\nthl = np.pi/2-(np.pi * m/30.0)\n#ths = np.deg2rad(90-h*30.0)\n#thl = np.deg2rad(90-m*6.0)\nx1 = a*np.cos(ths)\ny1 = a*np.sin(ths)\nx2 = b*np.cos(thl)\ny2 = b*np.sin(thl)\nprint(np.sqrt((x1-x2)**2+(y1-y2)**2))', 'import sys\nimport numpy as np\n\ni = list(map(int, input().split()))\na = i[0]\nb = i[1]\nh = i[2]\nm = i[3]\nths = np.pi/2-(np.pi * h/6)\nthl = np.pi/2-(np.pi * m/30)\nx1 = a*np.cos(ths)\ny1 = a*np.sin(ths)\nx2 = b*np.cos(thl)\ny2 = b*np.sin(thl)\nprint(np.linalg.norm(np.array([x1,y1])-np.array([x2,y2])))', "import numpy as np\nimport math\n\na,b,h,m = map(int,input().split())\ntime = h*60.0+m\n#angle = np.abs(((time-24*m)/60*12))%180\nangle = np.abs(time/2-60*m)%360\nangle = min(angle, 360-angle)\nprint(angle)\nprint('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))\n", "import sys\nimport numpy as np\n\n\n\ni = list(map(float, input().split()))\na = i[0]\nb = i[1]\nh = i[2]\nm = i[3]\n\ntime = float(h*60.0+m)\nth = np.abs(np.pi*(time-24.0*m)/(60.0*12)).astype('float64')\nprint('{:.20f}'.format(np.sqrt(a**2+b**2-2*np.cos(th)*a*b)))", "import numpy as np\nimport math\n\na,b,h,m = map(int,input().split())\ntime = h*60.0+m\n#angle = np.abs(((time-24*m)/60*12))%180\nangle = np.abs(time/2-60*m)\nprint(angle)\nprint('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))\n", 'import sys\nimport numpy as np\n\ni = list(map(int, input().split()))\na = i[0]\nb = i[1]\nh = i[2]\nm = i[3]\ntime = h*60+m\nths = np.pi/2-(np.pi * time/(60*12))\nthl = np.pi/2-(np.pi * m/30.0)\n#ths = np.deg2rad(90-h*30.0)\n#thl = np.deg2rad(90-m*6.0)\nx1 = a*np.cos(ths)\ny1 = a*np.sin(ths)\nx2 = b*np.cos(thl)\ny2 = b*np.sin(thl)\nprint(np.sqrt((x1-x2)**2+(y1-y2)**2))\n', "import numpy as np\nimport math\n\na,b,h,m = map(int,input().split())\ntime = h*60.0+m\n#angle = np.abs(((time-24*m)/60*12))%180\nangle = np.abs(time/2-60*m)%360\nangle = min(angle, 360-angle)\nprint(angle)\nprint('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))\n", "import sys\nimport numpy as np\nimport math\n\na,b,h,m = map(int,input().split())\ntime = h+m/60.0\n#angle = np.abs(((time-24*m)/60*12))%180\n#angle = np.abs(time/12-m/60)*360\nangle = np.abs(30*time-m*6)%360\nangle = min(angle, 360-angle)\nprint('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s159529236', 's277106320', 's400773841', 's529167427', 's662490474', 's744251713', 's764305779', 's451466737'] | [27172.0, 27208.0, 27224.0, 27232.0, 27220.0, 27208.0, 27232.0, 27212.0] | [100.0, 110.0, 113.0, 103.0, 100.0, 105.0, 105.0, 105.0] | [385, 294, 279, 252, 245, 356, 279, 311] |
p02677 | u833382483 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\ndef:\n\tA B H M=map(int,input().split(" "))\n\tif H>M/5:\n\t\tangle=(H/12-M/60)*360\n\telse:\n\t\tangle=(M/60-H/12)*360\n t=cos(angle)\n d=(A^2+B^2-2AB*t)^0.5\n print(d)\n ', 'import math\ndef:\n\tA B H M=map(int,input().split(" "))\n\tif H>M/5:\n\t\tangle=(H/12-M/60)\n\telse:\n\t\tangle=(M/60-H/12)\n t=math.cos(math.pi*angle)\n d=(A^2+B^2-2AB*t)^0.5\n print(d)\n ', 'import math\n\n\ndef cal():\n string = input()\n a, b, h, m = string.split(" ")\n a = int(a)\n b = int(b)\n h = int(h)\n m = int(m)\n minuteAngel = (float(m) * 360) / 60\n hourAngel = (float(h) % 12) * 30 + (float(m) * 30) / 60\n angel = abs(hourAngel - minuteAngel)\n angel=angel/180\n cosine = math.cos(math.pi*angel)\n ans = math.sqrt(a*a + b*b - 2*a*b*cosine)\n print(format(ans, \'.20f\'))\n # print(angle1)\n # print(angle2)\n # print(angle)\n # print(cosine)\n\ncal()'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s265239745', 's265468852', 's641723269'] | [9012.0, 9036.0, 9460.0] | [21.0, 21.0, 22.0] | [180, 185, 501] |
p02677 | u945157177 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['import math\ndef readInt():\n return list(map(int, input().split()))\na,b,h,m = readInt()\n# print(a)\narg_h = 30*h + 30*(m/60)\narg_m = 6*m\nif abs(arg_h-arg_m) <= 180:\n arg = math.radians(abs(arg_h-arg_m))\nelse:\n arg = math.radians(abs(arg_h-arg_m)-180) \n# print(arg_h, arg_m, arg)\n# print(math.cos(arg))\nans = math.sqrt(a**2+b**2-2*a*b*math.cos(arg))\nprint(ans)', "import math\ndef readInt():\n return list(map(int, input().split()))\na,b,h,m = readInt()\n# print(a)\narg_h = 30*h + 30*(m/60)\narg_m = 6*m\nif abs(arg_h-arg_m) < 180:\n arg = math.radians(abs(arg_h-arg_m))\n ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)\nelif abs(arg_h-arg_m) == 180:\n ans = a+b\nelse:\n arg = math.radians(360-abs(arg_h-arg_m)) \n ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)\n# print(arg_h, arg_m, arg)\n# print(math.cos(arg))\n\nprint('{:.20f}'.format(ans))"] | ['Wrong Answer', 'Accepted'] | ['s709449926', 's597596331'] | [9448.0, 9540.0] | [25.0, 21.0] | [366, 479] |
p02677 | u952656646 | 2,000 | 1,048,576 | Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands? | ['A, B, H, M = map(int, input().split())\nw_a = 2*pi/(12*60.0)\nw_b = 2*pi/(60.0)\ntheta_a = w_a*(H*60+M)\ntheta_b = w_b*M\nans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))\nprint("{:.20f}".format(ans))', 'from math import pi, cos, sqrt\nA, B, H, M = map(int, input().split())\nw_a = 2*pi/(12*60.0)\nw_b = 2*pi/(60.0)\ntheta_a = w_a*(H*60+M)\ntheta_b = w_b*M\nans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))\nprint("{:.20f}".format(ans))'] | ['Runtime Error', 'Accepted'] | ['s374416868', 's465568143'] | [9212.0, 9496.0] | [21.0, 30.0] | [194, 226] |
p02679 | u021916304 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nfrom fractions import Fraction\n\nmod = int(1e9+7)\nn = ii()\ncnd = {}\nazero = 0\nbzero = 0\nallzero = 0\nfor _ in range(n):\n a,b = iim()\n if a*b == 0:\n if a == 0 and b != 0:\n azero += 1\n elif a != 0 and b == 0:\n bzero += 1\n else:\n allzero += 1\n else:\n ratio = Fraction(a,b)\n before = cnd.get(ratio,False)\n check = cnd.get(-1*Fraction(1,ratio),False)\n if before:\n cnd[ratio] = [before[0]+1,before[1]]\n elif check:\n cnd[-1*Fraction(1,ratio)] = [check[0],check[1]+1]\n else:\n cnd[ratio] = [1,0]\n\ncnd[0] = [azero,bzero]\nnoreg = 0\nans = 1\n#print(cnd)\nfor item in cnd.values():\n if item[0] == 0 or item[1] == 0:\n noreg += max(item[0],item[1])\n else:\n ans *= (2**item[0]%mod+2**item[1]%mod-1)%mod\n ans %= mod\nprint('hoge')\nprint(int((ans*((2**noreg)%mod)-1+allzero)%mod))", 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\n#from math import gcd\nfrom fractions import Fraction as Fc\n\nmod = int(1e9+7)\nn = ii()\ncnd = {}\nazero = 0\nbzero = 0\nallzero = 0\nfor _ in range(n):\n a,b = iim()\n if a == 0:\n if b != 0:\n azero += 1\n else:\n allzero += 1\n elif b == 0:\n bzero += 1 \n else:\n f = Fc(a,b)\n cnd[f] = cnd.get(f,0)+1\n\n\nnoreg = 0\nif azero == 0 or bzero == 0:\n noreg += max(azero,bzero)\n ans = 1\nelse:\n ans = (2**azero%mod + 2**bzero%mod - 1)%mod\n\nfor k,item in cnd.items():\n if k>0:\n m = cnd.get(-f,False)\n if m:\n ans *= (2**item%mod+2**m%mod-1)%mod\n else:\n noreg += item\n else:\n m = cnd.get(-f,False)\n if not m:\n noreg += item\nprint(int((ans*((2**noreg)%mod)-1+allzero)%mod))', "def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\n#from fractions import Fraction\nfrom math import gcd\n\nmod = int(1e9+7)\nn = ii()\ncnd = {}\nazero = 0\nbzero = 0\nallzero = 0\nfor _ in range(n):\n a,b = iim()\n if a == 0:\n if b != 0:\n azero += 1\n else:\n allzero += 1\n elif b == 0:\n bzero += 1 \n else:\n \n g = gcd(a,b)\n a //= g\n b //= g\n if a < 0:\n a *= -1\n b *= -1\n cnd[(a,b)] += cnd.get((a,b),0)\n\n\nnoreg = 0\nif azero == 0 or bzero == 0:\n noreg += max(azero,bzero)\nelse:\n ans = (2**azero%mod + 2**bzero%mod - 1)%mod\n\nfor k,item in cnd:\n a,b = k\n if b>0:\n m = cnd.get((-b,a),False)\n if m:\n ans *= (2**item%mod+2**m%mod-1)%mod\n else:\n noreg += item\n else:\n m = cnd.get((-b,a),False)\n if not m:\n noreg += item\n#print('hoge')\nprint(int((ans*((2**noreg)%mod)-1+allzero)%mod))", 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nfrom math import gcd\n\nmod = int(1e9+7)\nn = ii()\ncnd = {}\nazero = 0\nbzero = 0\nallzero = 0\nfor _ in range(n):\n a,b = iim()\n if a*b == 0:\n if a == 0 and b != 0:\n azero += 1\n elif a != 0 and b == 0:\n bzero += 1\n else:\n allzero += 1\n else:\n g = gcd(a,b)\n a //= g\n b //= g\n if a<0:\n a *= -1\n b *= -1\n before = cnd.get((a,b),False)\n if b > 0:\n check = cnd.get((b,-a),False)\n else:\n check = cnd.get((-b,a),False)\n if before:\n cnd[(a,b)] = [before[0]+1,before[1]]\n elif check:\n if b > 0:\n cnd[(b,-a)] = [check[0],check[1]+1]\n else:\n cnd[(-b,a)] = [check[0],check[1]+1]\n else:\n cnd[(a,b)] = [1,0]\n\ncnd[0] = [azero,bzero]\nnoreg = 0\nans = 1\n#print(cnd)\nfor item in cnd.values():\n if item[0] == 0 or item[1] == 0:\n noreg += max(item[0],item[1])\n else:\n ans *= (2**item[0]+2**item[1]-1)\n ans %= mod\nprint((ans*((2**noreg)%mod)-1+allzero)%mod)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s097565008', 's851738950', 's967379916', 's449726086'] | [37484.0, 19048.0, 9256.0, 63844.0] | [2206.0, 2206.0, 352.0, 940.0] | [1133, 1019, 1511, 1317] |
p02679 | u036340997 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["from math import gcd\nmod = 10**9+7\nn = int(input())\ndicn = {}\ndicp = {}\ndicz = {'a': 0, 'b': 0, 'z': 0}\nfor i in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n dicz['z'] += 1\n else:\n g = gcd(a,b)\n a //= g\n b //= g\n if a < 0:\n a *= -1\n b *= -1\n elif a == 0 and b < 0:\n b *= -1\n if a * b > 0:\n if a in dicp:\n if b in dicp[a]:\n dicp[a][b] += 1\n else:\n dicp[a][b] = 1\n else:\n dicp[a] = {b: 1}\n elif a * b < 0:\n if b in dicn:\n if a in dicn[b]:\n dicn[b][a] += 1\n else:\n dicn[b][a] = 1\n else:\n dicn[b] = {a: 1}\n else:\n if a == 0:\n dicz['a'] += 1\n else:\n dicz['b'] += 1\n\nans = 1\n\nfor a in dicp:\n for b in dicp[a]:\n if -a in dicn:\n if b in dicn[-a]:\n ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)\n dicn[-a][b] = 0\n else:\n ans *= pow(2, dicp[a][b], mod)\n else:\n ans *= pow(2, dicp[a][b], mod)\n ans %= mod\n\nfor b in dicn:\n for a in dicn[b]:\n ans *= pow(2, dicn[b][a], mod)\n ans %= mod\n \nif dicz['a'] > 0 and dicz['b'] > 0:\n ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1\nelif dicz['a'] > 0:\n ans *= pow(2,dicz['a'],mod)\nelif dicz['b'] > 0:\n ans *= pow(2,dicz['b'],mod)\n \nans += pow(2,dicz['z'],mod)\nprint((ans-1)%mod)\n", "from math import gcd\nmod = 10**9+7\nn = int(input())\ndicn = {}\ndicp = {}\ndicz = {'a': 0, 'b': 0, 'z': 0}\nfor i in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n dicz['z'] += 1\n else:\n g = gcd(a,b)\n a //= g\n b //= g\n if a < 0:\n a *= -1\n b *= -1\n elif a == 0 and b < 0:\n b *= -1\n if a * b > 0:\n if a in dicp:\n if b in dicp[a]:\n dicp[a][b] += 1\n else:\n dicp[a][b] = 1\n else:\n dicp[a] = {b: 1}\n elif a * b < 0:\n if b in dicn:\n if a in dicn[b]:\n dicn[b][a] += 1\n else:\n dicn[b][a] = 1\n else:\n dicn[b] = {a: 1}\n else:\n if a == 0:\n dicz['a'] += 1\n else:\n dicz['b'] += 1\n\nans = 1\n\nfor a in dicp:\n for b in dicp[a]:\n if -a in dicn:\n if b in dicn[-a]:\n ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)\n dicn[-a][b] = 0\n else:\n ans *= pow(2, dicp[a][b], mod)\n else:\n ans *= pow(2, dicp[a][b], mod)\n ans %= mod\n\nfor b in dicn:\n for a in dicn[b]:\n ans *= pow(2, dicn[b][a], mod)\n ans %= mod\n \nif dicz['a'] > 0 and dicz['b'] > 0:\n ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1\nelif dicz['a'] > 0:\n ans *= pow(2,dicz['a'],mod)\nelif dicz['b'] > 0:\n ans *= pow(2,dicz['b'],mod)\n \nans += dicz['z']\nprint((ans-1)%mod)\n"] | ['Wrong Answer', 'Accepted'] | ['s091915076', 's173319387'] | [82876.0, 82552.0] | [992.0, 1004.0] | [1381, 1370] |
p02679 | u038021590 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import fractions\nfrom collections import Counter\nN = int(input())\nA_B = []\nmod = 1000000007\nfor _ in range(N):\n A, B = map(int, input().split())\n if A < 0:\n A = -A\n B = -B\n C = fractions.gcd(abs(A), abs(B))\n A_B.append((A//C, B//C))\nA_B_C = Counter(A_B)\n\n\nhate_couple = 0\nans = 1\nDone = set([])\nfor key, value in A_B_C.items():\n if key in Done:\n continue\n keya, keyb = key\n a = 0\n if keyb < 0:\n keya = -keya\n keyb = -keyb\n if (keyb, -keya) not in A_B_C:\n a = pow(2, value, mod)\n else:\n a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1\n Done.add((keyb, -keya))\n ans *= a\n Done.add(key)\n\nprint(ans - 1)', 'import math\nfrom collections import Counter\n\nN = int(input())\nA_B = []\nmod = 1000000007\nfor _ in range(N):\n A, B = map(int, input().split())\n if (A == 0) and (B == 0):\n A_B.append((A, B))\n elif A == 0:\n A_B.append((0, -1))\n elif B == 0:\n A_B.append((1, 0))\n else:\n if A < 0:\n A = -A\n B = -B\n C = math.gcd(abs(A), abs(B))\n A_B.append((A // C, B // C))\n\nA_B_C = Counter(A_B)\n\n\nans = 1\nDone = set([])\nDone.add((0, 0))\nfor key, value in A_B_C.items():\n if key in Done:\n continue\n keya, keyb = key\n a = 0\n if keya == 0 and keyb == 0:\n a = value + 1\n Done.add((0, 0))\n else:\n if keyb < 0:\n keya = -keya\n keyb = -keyb\n if (keyb, -keya) not in A_B_C:\n a = pow(2, value, mod)\n else:\n a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1\n Done.add((keyb, -keya))\n ans *= a\n ans %= mod\n Done.add(key)\nans -= 1\nans += A_B_C[(0, 0)]\n\nprint(ans % mod)\n'] | ['Runtime Error', 'Accepted'] | ['s679462882', 's190299998'] | [62724.0, 61140.0] | [1769.0, 961.0] | [718, 1060] |
p02679 | u047816928 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['N = int(input())\nD = {}\n\ndef gcd(x,y):\n if x>y: x,y=y,x\n while x:\n x,y=y%x,x\n return y\n\nprint(gcd(12,5))\nprint(gcd(12,16))\n\nfor _ in range(N):\n A, B = map(int, input().split())\n if A==0 and B==0: key=(0,0)\n elif A==0: key=(0,1)\n elif B==0: key=(1,0)\n else:\n if A<0:\n A=-A\n B=-B\n g = gcd(A,abs(B))\n key = (A//g, B//g)\n\n if key not in D: D[key]=0\n D[key]+=1\n\nmod = 10**9+7\n\nans = 1\nn00 = 0\nfor k1, v1 in D.items():\n if k1==(0,0):\n n00+=v1\n continue\n if v1==0: continue\n \n k2 = (k1[1], -k1[0]) if k1[1]>0 else (-k1[1], k1[0])\n if k2 not in D:\n ans = ans * pow(2, v1, mod) % mod\n else:\n v2 = D[k2]\n m = (pow(2, v1, mod) + pow(2, v2, mod) - 1) % mod\n ans = ans * m % mod\n D[k2]=0\n \nprint((ans+n00-1)%mod)\n', 'N = int(input())\nD = {}\n\ndef gcd(x,y):\n if x>y: x,y=y,x\n while x:\n x,y=y%x,x\n return y\n\nfor _ in range(N):\n A, B = map(int, input().split())\n if A==0 and B==0: key=(0,0)\n elif A==0: key=(0,1)\n elif B==0: key=(1,0)\n else:\n if A<0:\n A=-A\n B=-B\n g = gcd(A,abs(B))\n key = (A//g, B//g)\n\n if key not in D: D[key]=0\n D[key]+=1\n\nmod = 10**9+7\n\nans = 1\nn00 = 0\nfor k1, v1 in D.items():\n if k1==(0,0):\n n00+=v1\n continue\n if v1==0: continue\n \n k2 = (k1[1], -k1[0]) if k1[1]>0 else (-k1[1], k1[0])\n if k2 not in D:\n ans = ans * pow(2, v1, mod) % mod\n else:\n v2 = D[k2]\n m = (pow(2, v1, mod) + pow(2, v2, mod) - 1) % mod\n ans = ans * m % mod\n D[k2]=0\n \nprint((ans+n00-1)%mod)\n'] | ['Wrong Answer', 'Accepted'] | ['s571531244', 's084892211'] | [46408.0, 46244.0] | [1365.0, 1389.0] | [860, 824] |
p02679 | u153302617 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nn = int(input())\np = 10**9 + 7\niwashi = {}\nbad = 0\nans = 1\nfor i in range(n):\n x, y = map(int, input().split())\n if(x == 0 and y == 0):\n bad += 1\n continue\n elif(x == 0):\n\t\ttry:\n \tiwashi[(0, -1)] += 1\n\t\texcept KeyError:\n iwashi[(0, -1)] = 1\n continue\n elif(y == 0):\n try:\n \tiwashi[(-1, 0)] += 1\n\t\texcept KeyError:\n iwashi[(-1, 0)] = 1\n continue\n else:\n g = gcd(x, y)\n x, y = x // g, y // g\n if x < 0:\n x, y = -x, -y\n try:\n \tiwashi[(x, y)] += 1\n except KeyError:\n iwashi[(x, y)] = 1\n \nfor x, y in iwashi:\n a = iwashi[(x, y)]\n if y > 0:\n \trx,ry = y, -x\n else:\n \trx,ry = y, -x\n try:\n b = iwashi[(rx,ry)]\n iwashi[(rx,ry)] = 0\n except KeyError:\n \tb = 0\n ans *= pow(2, a, p) + pow(2, b, p) - 1\n ans %= p\n iwashi[(x, y)] = 0\nprint((ans + bad - 1) % p)\n', 'from math import gcd\nn = int(input())\np = 10**9 + 7\niwashi = {}\nbad = 0\nans = 1\nfor i in range(n):\n x, y = map(int, input().split())\n if(x == 0 and y == 0):\n bad += 1\n continue\n elif(x == 0):\n try:\n \tiwashi[(0, 1)] += 1\n except KeyError:\n iwashi[(0, 1)] = 1\n continue\n elif(y == 0):\n try:\n \tiwashi[(1, 0)] += 1\n except KeyError:\n iwashi[(1, 0)] = 1\n continue\n else:\n g = gcd(x, y)\n x, y = x // g, y // g\n if x < 0:\n x, y = -x, -y\n try:\n \tiwashi[(x, y)] += 1\n except KeyError:\n iwashi[(x, y)] = 1\n \nfor x, y in iwashi:\n a = iwashi[(x, y)]\n if y > 0:\n \trx,ry = y, -x\n else:\n \trx,ry = -y, x\n try:\n b = iwashi[(rx,ry)]\n iwashi[(rx,ry)] = 0\n except KeyError:\n \tb = 0\n ans *= pow(2, a, p) + pow(2, b, p) - 1\n ans %= p\n iwashi[(x, y)] = 0\nprint((ans + bad - 1) % p)\n'] | ['Runtime Error', 'Accepted'] | ['s651505510', 's636735105'] | [9036.0, 46316.0] | [24.0, 1073.0] | [974, 992] |
p02679 | u157020659 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["import math\nimport collections\n\nn = int(input())\nmod = 10 * 6 + 7\nc = []\nd = []\n\ntan = []\natan = []\n\nfor _ in range(n):\n a, b = map(int, input().split())\n if b == 0: tan.append(float('inf'))\n else: tan.append(a / b)\n if a == 0: atan.append(float('inf'))\n else: atan.append(- b / a)\n\ntan = collections.Counter(tan)\natan = collections.Counter(atan)\n\nfor key, value in tan.items():\n print(key)\n if abs(key) > 1: continue\n if atan[key] > 0:\n c.append(value)\n d.append(value)\n\n# print(c, d)\n\nans = pow(2, n - sum(c) - sum(d), mod)\nfor i, j in zip(c, d):\n ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod\nans -= 1\n\nprint(ans)", "import collections\nimport math\n\nn = int(input())\nm = 0\nmod = 10 ** 9 + 7\nc = []\nd = []\nfrac = []\n\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n n -= 1\n m += 1\n continue\n if a == 0:\n frac.append('0/1')\n elif b == 0:\n frac.append(('1/0'))\n else:\n gcd = abs(math.gcd(a, b))\n sign = 1 if a * b > 0 else -1\n a = sign * abs(a) // gcd\n b = abs(b) // gcd\n frac.append('{}/{}'.format(a, b))\n\nfrac = collections.Counter(frac)\nprint(frac)\n\ndef inverse(key):\n if key == '0/1':\n return '1/0'\n elif key == '1/0':\n return '0/1'\n elif key[0] != '-':\n a, b = key.split('/')\n return '-{}/{}'.format(b, a)\n else:\n a, b = key[1:].split('/')\n return '{}/{}'.format(b, a)\n\nfor key, value in frac.items():\n if key[0] == '-' or key[0] == '0': continue\n if frac[inverse(key)] > 0:\n c.append(value)\n d.append(frac[inverse(key)])\n\nans = pow(2, n - sum(c) - sum(d), mod)\nfor i, j in zip(c, d):\n tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)\n ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod\nans = (ans - 1 + m) % mod\n\nprint(ans)\n", "import collections\nimport math\n\nn = int(input())\nm = 0\nmod = 10 ** 9 + 7\nc = []\nd = []\nfrac = []\n\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n n -= 1\n m += 1\n continue\n if a == 0:\n frac.append('0/1')\n elif b == 0:\n frac.append(('1/0'))\n else:\n gcd = abs(math.gcd(a, b))\n sign = 1 if a * b > 0 else -1\n a = sign * abs(a) // gcd\n b = abs(b) // gcd\n frac.append('{}/{}'.format(a, b))\n\nfrac = collections.Counter(frac)\nprint(frac)\n\ndef inverse(key):\n if key == '0/1':\n return '1/0'\n elif key == '1/0':\n return '0/1'\n elif key[0] != '-':\n a, b = key.split('/')\n return '-{}/{}'.format(b, a)\n else:\n a, b = key[1:].split('/')\n return '{}/{}'.format(b, a)\n\nfor key, value in frac.items():\n if key[0] == '-' or key[0] == '0': continue\n if frac[inverse(key)] > 0:\n c.append(value)\n d.append(frac[inverse(key)])\n\nans = pow(2, n - sum(c) - sum(d), mod)\nfor i, j in zip(c, d):\n tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod\n ans = ans * tmp % mod\nans = (ans - 1 + m) % mod\n\nprint(ans)\n", "import collections\nimport fractions\n\nn = int(input())\nmod = 10 ** 6 + 7\nc = []\nd = []\n\ntan = []\natan = []\n\nfor _ in range(n):\n a, b = map(int, input().split())\n if b == 0: tan.append(float('inf'))\n else: tan.append(fractions.Fraction(a, b))\n if a == 0: atan.append(float('inf'))\n else: atan.append(fractions.Fraction(-1 * b, a))\n\nprint('yes')", "import collections\nimport math\n\nn = int(input())\nm = 0\nmod = 10 ** 9 + 7\nc = []\nd = []\nfrac = []\n\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n n -= 1\n m += 1\n continue\n if a == 0:\n frac.append('0/1')\n elif b == 0:\n frac.append(('1/0'))\n else:\n gcd = abs(math.gcd(a, b))\n sign = 1 if a * b > 0 else -1\n a = sign * abs(a) // gcd\n b = abs(b) // gcd\n frac.append('{}/{}'.format(a, b))\n\nfrac = collections.Counter(frac)\n\ndef inverse(key):\n if key == '0/1':\n return '1/0'\n elif key == '1/0':\n return '0/1'\n elif key[0] != '-':\n a, b = key.split('/')\n return '-{}/{}'.format(b, a)\n else:\n a, b = key[1:].split('/')\n return '{}/{}'.format(b, a)\n\nfor key, value in frac.items():\n if key[0] == '-' or key[0] == '0': continue\n if frac[inverse(key)] > 0:\n c.append(value)\n d.append(frac[inverse(key)])\n\nans = pow(2, n - sum(c) - sum(d), mod)\nfor i, j in zip(c, d):\n tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod\n ans = ans * tmp % mod\nans = (ans - 1 + m) % mod\n\nprint(ans)"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s315399622', 's337712768', 's907589571', 's997769772', 's686591534'] | [53984.0, 73140.0, 73328.0, 57600.0, 44988.0] | [826.0, 942.0, 985.0, 1250.0, 847.0] | [669, 1204, 1174, 357, 1161] |
p02679 | u163783894 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\n\n\ndef main():\n\n mod = 1000000007\n N = int(input())\n\n A = [0]\n B = [0]\n\n for n in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\n calc = dict()\n\n for i in range(1, N + 1):\n r = math.gcd(A[i], B[i])\n m = 1\n if A[i] * B[i] < 0:\n m = -1\n\n k1 = (m * abs(A[i] // r), abs(B[i] // r))\n k2 = (-m * abs(B[i] // r), abs(A[i] // r))\n if calc.get(k1):\n calc[k1][0] += 1\n elif not calc.get(k2):\n calc[k1] = [1, 0]\n\n for i in range(1, N + 1):\n r = math.gcd(A[i], B[i])\n m = 1\n if A[i] * B[i] < 0:\n m = -1\n\n k2 = (-m * abs(B[i] // r), abs(A[i] // r))\n if calc.get(k2):\n calc[k2][1] += 1\n\n count = 0\n for k, v in calc.items():\n if not v[0] * v[1] == 0:\n count += v[0] + v[1]\n\n ans = pow(2, N - count, mod)\n for k, v in calc.items():\n if not v[0] * v[1] == 0:\n comb = (pow(2, v[0]) + pow(2, v[1]) - 1)\n ans = (ans * comb) % mod\n\n for k, v in calc.items():\n print("{} {}".format(k, v))\n print(ans - 1)\n\n\nif __name__ == \'__main__\':\n main()\n', "import math\n\n\ndef main():\n\n mod = 1000000007\n N = int(input())\n\n A = [0]\n B = [0]\n\n for n in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\n calc = dict()\n non_count = 0\n\n for i in range(1, N + 1):\n\n if A[i] == 0 and B[i] == 0:\n non_count += 1\n elif A[i] == 0:\n k = (0, 1)\n if calc.get(k):\n calc[k][0] += 1\n else:\n calc[k] = [1, 0]\n elif B[i] == 0:\n k = (0, 1)\n if calc.get(k):\n calc[k][1] += 1\n else:\n calc[k] = [0, 1]\n else:\n r = math.gcd(A[i], B[i])\n m = 1\n if A[i] * B[i] < 0:\n m = -1\n k1 = (m * abs(A[i] // r), abs(B[i] // r))\n k2 = (-m * abs(B[i] // r), abs(A[i] // r))\n if calc.get(k1):\n calc[k1][0] += 1\n elif not calc.get(k2):\n calc[k1] = [1, 0]\n else:\n calc[k2][1] += 1\n\n N = N - non_count\n\n count = 0\n for k, v in calc.items():\n if not v[0] * v[1] == 0:\n count += v[0] + v[1]\n\n ans = pow(2, N - count, mod)\n for k, v in calc.items():\n if not v[0] * v[1] == 0:\n comb = (pow(2, v[0]) + pow(2, v[1]) - 1)\n ans = (ans * comb) % mod\n\n print((ans - 1 + non_count) % mod)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s241158121', 's828572654'] | [83140.0, 79356.0] | [1374.0, 915.0] | [1215, 1463] |
p02679 | u169350228 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nimport numpy as np\nimport queue\nfrom collections import deque\nimport heapq\nmod = 10**9+7\nans = 1\n\ndef twoxxn(t,mod):\n ni = t\n an = 1\n n2 = 2\n while ni > 0:\n if ni%2 == 1:\n an = (an*n2)%mod\n n2 = (n2**2)%mod\n ni //= 2\n return an\n\nn = int(input())\nd = dict()\nfor i in range(n):\n a,b = map(int,input().split())\n if a < 0 and (b < 0 or abs(a) > abs(b)):\n a = -a\n b = -b\n g = math.gcd(abs(a),abs(b))\n if a == 0 and b == 0:\n continue\n elif a == -b:\n if "1 -1" in d:\n d["1 -1"] += 1\n else:\n d["1 -1"] = 1\n elif a == b:\n if "1 1" in d:\n d["1 1"] += 1\n else:\n d["1 1"] = 1\n else:\n p1 = str(a//g)+" "+str(b//g)\n p2 = str(b//g)+" "+str(a//g)\n if p1 in d:\n d[p1] += 1\n d[p2] += 1\n else:\n d[p1] = 1\n d[p2] = 1\nprint(d)\n\nfor i in d.keys():\n i0, i1 = map(int,i.split())\n if abs(i0) < abs(i1):\n continue\n elif str(i0)+" "+str(-i1) in d:\n if d[i] == 0:\n continue\n aaa = (twoxxn(d[str(i0)+" "+str(-i1)],mod)+twoxxn(d[i],mod)-1)%mod\n print(i,aaa)\n ans = (ans*aaa)%mod\n d[str(i0)+" "+str(-i1)] = 0\n else:\n ans = (ans*twoxxn(d[i],mod))%mod\nans = (ans-1)%mod\n\nprint(max(1,ans))\n', 'import math\nimport numpy as np\nimport queue\nfrom collections import deque\nimport heapq\nmod = 10**9+7\nans = 1\n\ndef twoxxn(t,mod):\n ni = t\n an = 1\n n2 = 2\n while ni > 0:\n if ni%2 == 1:\n an = (an*n2)%mod\n n2 = (n2**2)%mod\n ni //= 2\n return an\n\nn = int(input())\nd = dict()\nfor i in range(n):\n a,b = map(int,input().split())\n if a < 0 :\n a = -a\n b = -b\n g = math.gcd(abs(a),abs(b))\n if a == 0 and b == 0:\n continue\n else:\n if a == 0:\n b = 1\n g = 1\n elif b == 0:\n a = 1\n g = 1\n p1 = str(a//g)+" "+str(b//g)\n if p1 in d:\n d[p1] += 1\n else:\n d[p1] = 1\n\nfor i in d.keys():\n i0, i1 = map(int,i.split())\n if str(i1)+" "+str(-i0) in d:\n if d[i] == 0:\n continue\n aaa = (twoxxn(d[str(i1)+" "+str(-i0)],mod)+twoxxn(d[i],mod)-1)%mod\n ans = (ans*aaa)%mod\n d[str(i1)+" "+str(-i0)] = 0\n elif str(-i1)+" "+str(i0) in d:\n if d[i] == 0:\n continue\n aaa = (twoxxn(d[str(-i1)+" "+str(i0)],mod)+twoxxn(d[i],mod)-1)%mod\n ans = (ans*aaa)%mod\n d[str(-i1)+" "+str(i0)] = 0\n else:\n ans = (ans*twoxxn(d[i],mod))%mod\n\nif ans == 1:\n print(1)\n exit()\nans = (ans-1)%mod\nprint(ans)\n', 'import math\nimport numpy as np\nimport queue\nfrom collections import deque\nimport heapq\nmod = 10**9+7\nans = 1\niw0 = 0\n\ndef twoxxn(t,mod):\n ni = t\n an = 1\n n2 = 2\n while ni > 0:\n if ni%2 == 1:\n an = (an*n2)%mod\n n2 = (n2**2)%mod\n ni >>= 1\n return an\n\nn = int(input())\nd = dict()\nfor i in range(n):\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n iw0 += 1\n continue\n if a == 0:\n b = 1\n g = 1\n elif b == 0:\n a = 1\n g = 1\n else:\n g = math.gcd(abs(a),abs(b))\n if a < 0 :\n a = -a\n b = -b\n p1 = a//g, b//g\n if p1 in d:\n d[p1] += 1\n else:\n d[p1] = 1\n\nfor (i0, i1) in d.keys():\n din = d[(i0,i1)]\n if din == -1:\n continue\n if i1 < 0:\n i00 = -i0\n i10 = -i1\n else:\n i00 = i0\n i10 = i1\n if (i10,-i00) in d.keys():\n aaa = (twoxxn(d[(i10,-i00)],mod)+twoxxn(din,mod)-1)%mod\n print(aaa)\n ans = (ans*aaa)%mod\n d[(i10,-i00)] = -1\n else:\n ans = (ans*twoxxn(din,mod))%mod\n\nif len(d.keys()) == 0:\n print(iw0)\n exit()\n\nans = (i0+ans-1)%mod\nprint(ans)\n', 'import math\nimport numpy as np\nimport queue\nfrom collections import deque\nimport heapq\nmod = 10**9+7\nans = 1\ni0 = 0\n\ndef twoxxn(t,mod):\n ni = t\n an = 1\n n2 = 2\n while ni > 0:\n if ni%2 == 1:\n an = (an*n2)%mod\n n2 = (n2**2)%mod\n ni >>= 1\n return an\n\nn = int(input())\nd = dict()\nfor i in range(n):\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n i0 += 1\n continue\n if a == 0:\n b = 1\n g = 1\n elif b == 0:\n a = 1\n g = 1\n else:\n g = math.gcd(abs(a),abs(b))\n if a < 0 :\n a = -a\n b = -b\n p1 = a//g, b//g\n if p1 in d:\n d[p1] += 1\n else:\n d[p1] = 1\n\nfor (i0, i1) in d.keys():\n din = d[(i0,i1)]\n if din == -1:\n continue\n if i1 < 0:\n i00 = -i0\n i10 = -i1\n else:\n i00 = i0\n i10 = i1\n if (i10,-i00) in d.keys():\n aaa = (twoxxn(d[(i10,-i00)],mod)+twoxxn(din,mod)-1)%mod\n print(aaa)\n ans = (ans*aaa)%mod\n d[(i10,-i00)] = -1\n else:\n ans = (ans*twoxxn(din,mod))%mod\n\nif len(d.keys()) == 0:\n print(i0)\n exit()\n\nans = (ans-1)%mod\nprint(ans)\n', 'import math\nimport numpy as np\nimport queue\nfrom collections import deque\nimport heapq\nmod = 10**9+7\nans = 1\niw0 = 0\n\ndef twoxxn(t,mod):\n ni = t\n an = 1\n n2 = 2\n while ni > 0:\n if ni%2 == 1:\n an = (an*n2)%mod\n n2 = (n2**2)%mod\n ni >>= 1\n return an\n\nn = int(input())\nd = dict()\nfor i in range(n):\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n iw0 += 1\n continue\n if a == 0:\n b = 1\n g = 1\n elif b == 0:\n a = 1\n g = 1\n else:\n g = math.gcd(abs(a),abs(b))\n if a < 0 :\n a = -a\n b = -b\n p1 = a//g, b//g\n if p1 in d:\n d[p1] += 1\n else:\n d[p1] = 1\ndone = []\nfor (i0,i1), din in d.items():\n if d.get((-i1,i0),1) == 0 or d.get((i1,-i0),1) == 0:\n continue\n w = d.get((i1,-i0),0) + d.get((-i1,i0),0)\n aaa = (twoxxn(w,mod)+twoxxn(din,mod)-1)%mod\n ans = (ans*aaa)%mod\n d[(i0,i1)] = 0\n\nif len(d.keys()) == 0:\n print(iw0)\n exit()\n\nans = (iw0+ans+mod-1)%mod\nprint(ans)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s068557681', 's411401616', 's932030191', 's933226766', 's455488549'] | [132576.0, 58800.0, 64192.0, 64324.0, 64128.0] | [1839.0, 1260.0, 999.0, 996.0, 1067.0] | [1373, 1336, 1180, 1174, 1040] |
p02679 | u191680842 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\n\nmod = 10**9 +7\nN = int(input())\ndic = {}\n\nzero = 0\nfor _ in range(N):\n a,b = map(int, input().split())\n if a ==0 and b == 0:\n zero += 1\n continue\n elif a == 0:\n key = (0,1)\n elif b == 0:\n key = (1,0)\n else:\n if a<0:\n a=-a \n b=-b\n g = gcd(a,abs(b))\n key = (a//g,b//g)\n \n if key not in dic:\n dic[key]=0\n\n dic[key] +=1\n\nans = 1\nfor k1, v1 in dic.items():\n if v1 ==0:\n continue\n\n if k1[1] >0:\n k2 = (k1[1],-k1[0])\n else:\n k2 = (-k1[1],k1[0])\n\n if k2 not in dic:\n ans *= 2**v1\n ans %= mod\n else:\n ans *= ((2**v1-1)) %mod) + ((2**dic[k2]-1)) %mod) +1\n ans %= mod\n dic[k2]=0\n\nans = (ans + zero -1 )%mod\nprint(ans)', 'from math import gcd\n\nmod = 10**9 +7\nN = int(input())\ndic = {}\n\nzero = 0\nfor _ in range(N):\n a,b = map(int, input().split())\n if a ==0 and b == 0:\n zero += 1\n continue\n elif a == 0:\n key = (0,1)\n elif b == 0:\n key = (1,0)\n else:\n if a<0:\n a=-a \n b=-b\n g = gcd(a,abs(b))\n key = (a//g,b//g)\n \n if key not in dic:\n dic[key]=0\n\n dic[key] +=1\n\nans = 1\nfor k1, v1 in dic.items():\n if v1 ==0:\n continue\n\n if k1[1] >0:\n k2 = (k1[1],-k1[0])\n else:\n k2 = (-k1[1],k1[0])\n\n if k2 not in dic:\n ans *= 2**v1\n ans %= mod\n else:\n ans *= ((2**v1-1) %mod) + ((2**dic[k2]-1) %mod) +1\n ans %= mod\n dic[k2]=0\n\nans = (ans + zero -1 )%mod\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s561754670', 's263189491'] | [9016.0, 46144.0] | [23.0, 820.0] | [802, 800] |
p02679 | u201387466 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nimport numpy as np\nINF = float("inf")\n\n\n#N = int(input())\n#A = list(map(int,input().split()))\n#S = list(input())\n#S.remove("\\n")\n#N,M = map(int,input().split())\n#S,T = map(str,input().split())\n#A = [int(input()) for _ in range(N)]\n#S = [input() for _ in range(N)]\n#A = [list(map(int,input().split())) for _ in range(N)]\nN = int(input())\nMOD = 10**9+7\nAB = []\nx = 0\ny = 0\nd = defaultdict(int)\nch = defaultdict(int)\nflag = 0\nfor _ in range(N):\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n flag = 1\n continue\n elif a == 0:\n x += 1\n continue\n elif b == 0:\n y += 1\n continue\n else:\n d = math.gcd(abs(a),abs(b))\n a /= d\n b /= d\n c = a / b\n d[c] += 1\n AB.append(c)\nn = len(AB)\nans = 1\nfor i in range(n):\n cc = AB[i]\n if ch[cc] != 0:\n continue\n m = d[cc]\n ccc = (-1)/cc\n l = d[ccc]\n ans *= (pow(2,m,MOD)+pow(2,l,MOD)-1)\n print(ans)\n ch[cc] = 1\n ch[ccc] = 1\nans *= (pow(2,x,MOD)+pow(2,y,MOD)-1)\nif flag == 0:\n ans -= 1\nans = ans % MOD\nprint(ans)', 'import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nimport numpy as np\nINF = float("inf")\n\n\n#N = int(input())\n#A = list(map(int,input().split()))\n#S = list(input())\n#S.remove("\\n")\n#N,M = map(int,input().split())\n#S,T = map(str,input().split())\n#A = [int(input()) for _ in range(N)]\n#S = [input() for _ in range(N)]\n#A = [list(map(int,input().split())) for _ in range(N)]\nN = int(input())\nMOD = 10**9+7\nAB = []\nx = 0\ny = 0\nd = defaultdict(int)\nch = defaultdict(int)\nflag = 0\nfor _ in range(N):\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n flag += 1\n elif a == 0:\n d[(0,1)] += 1\n AB.append([0,1])\n elif b == 0:\n d[(1,0)] += 1\n AB.append([1,0])\n else:\n dd = math.gcd(abs(a),abs(b))\n a //= dd\n b //= dd\n if a < 0:\n a *= -1\n b *= -1\n d[(a,b)] += 1\n AB.append([a,b])\nn = len(AB)\nans = 1\nif n > 0:\n for i in range(n):\n a,b = AB[i]\n if ch[(a,b)] == 1:\n continue\n m = d[(a,b)]\n if b > 0:\n l = d[(b,(-1)*a)]\n ch[(a,b)] = 1\n ch[(b,(-1)*a)] = 1\n elif a == 0 or b == 0:\n l = d[(b,a)]\n ch[(a,b)] = 1\n ch[(b,a)] = 1\n else:\n l = d[((-1)*b,a)]\n ch[(a,b)] = 1\n ch[((-1)*b,a)] = 1\n ans *= (pow(2,m,MOD)+pow(2,l,MOD)-1)\n ans = ans % MOD\nans = ans % MOD\nans = ans -1 + flag\nans = ans % MOD\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s689565537', 's933833804'] | [27272.0, 184604.0] | [225.0, 1399.0] | [1594, 1896] |
p02679 | u204616996 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['N=int(input())\nfrom collections import defaultdict\nimport math\nd = defaultdict(int)\nMOD=10**9+7\nM=0\nfor i in range(N):\n a,b=map(int,input().split())\n x=math.gcd(abs(a),abs(b))\n if x==0:\n if a>b:\n k=(1,0)\n elif b>a:\n k=(0,1)\n else:\n k=(0,0)\n else:\n if a<0:\n a,b=-a,-b\n if b<0:\n a,b=a//x,-((-b)//x)\n else:\n a,b=a//x,b//x\n k=(a,b)\n d[k]+=1\n M=max(M,d[k])\nans=0\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n#N = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range( 2, M + 1 ):\n g1.append( ( g1[-1] * i ) % MOD )\n inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )\n g2.append( (g2[-1] * inverse[-1]) % MOD )\n\ndef C(x):\n _=0\n for i in range(1,x+1):\n _+=cmb(x,i,MOD)\n return _\n\nif d[(0,0)]>0:\n ans+=d[(0,0)]\nind=defaultdict(int)\nindex=1\n_ans=[1]\nfor a,b in list(d.keys()):\n if b<0:\n _k=(-b,a)\n else:\n _k=(b,-a)\n if d[_k]==0:\n _ans.append(C(d[(a,b)])+1)\n index+=1\n else:\n if ind[_k]==0:\n _ans.append(C(d[(a,b)]))\n ind[(a,b)]=index\n index+=1\n else:\n _ans[ind[_k]]+=C(d[(a,b)])+1\n_=1\nfor a in _ans:\n _*=a\nprint((ans+_-1)%MOD)\n\n', 'N=int(input())\nfrom collections import defaultdict\nimport math\nd = defaultdict(int)\nMOD=10**9+7\nM=0\nfor i in range(N):\n a,b=map(int,input().split())\n x=math.gcd(a,b)\n if x==0:\n if a>b:\n k=(1,0)\n elif b>a:\n k=(0,1)\n else:\n k=(0,0)\n else:\n a,b=a//x,b//x\n if a<0:\n a,b=-a,-b\n k=(a,b)\n d[k]+=1\n M=max(M,d[k])\nans=0\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n#N = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range( 2, M + 1 ):\n g1.append( ( g1[-1] * i ) % MOD )\n inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )\n g2.append( (g2[-1] * inverse[-1]) % MOD )\n\ndef C(x):\n _=0\n for i in range(1,x+1):\n _+=cmb(x,i,MOD)\n return _%MOD\n\nif d[(0,0)]>0:\n ans+=d[(0,0)]\nind=defaultdict(int)\nindex=1\n_ans=[1]\nfor a,b in list(d.keys()):\n if b<0:\n _k=(-b,a)\n else:\n _k=(b,-a)\n if d[_k]==0:\n _ans.append(C(d[(a,b)])+1)\n index+=1\n else:\n if ind[_k]==0:\n _ans.append(C(d[(a,b)]))\n ind[(a,b)]=index\n index+=1\n else:\n _ans[ind[_k]]+=C(d[(a,b)])+1\n_=1\nfor a in _ans:\n _*=a\nprint((ans+_-1)%MOD)', 'N=int(input())\nfrom collections import defaultdict\nimport math\nd = defaultdict(int)\nMOD=10**9+7\nM=0\nfor i in range(N):\n a,b=map(int,input().split())\n x=math.gcd(a,b)\n if x==0:\n if a>b:\n k=(1,0)\n elif b>a:\n k=(0,1)\n else:\n k=(0,0)\n else:\n a,b=a//x,b//x\n if a<0:\n a,b=-a,-b\n k=(a,b)\n d[k]+=1\n M=max(M,d[k])\nans=0\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n#N = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range( 2, M + 1 ):\n g1.append( ( g1[-1] * i ) % MOD )\n inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )\n g2.append( (g2[-1] * inverse[-1]) % MOD )\n\ndef C(x):\n _=0\n for i in range(1,x+1):\n _+=cmb(x,i,MOD)\n return _%MOD\n\nif d[(0,0)]>0:\n x=d[(0,0)]\n for i in range(1,x+1):\n ans+=cmb(x,i,MOD)\nind=defaultdict(int)\nindex=1\n_ans=[1]\nfor a,b in list(d.keys()):\n if b<0:\n _k=(-b,a)\n else:\n _k=(b,-a)\n if d[_k]==0:\n _ans.append(C(d[(a,b)])+1)\n index+=1\n else:\n if ind[_k]==0:\n _ans.append(C(d[(a,b)]))\n ind[(a,b)]=index\n index+=1\n else:\n _ans[ind[_k]]+=C(d[(a,b)])+1\n_=1\nfor a in _ans:\n _*=a\nprint((ans+_-1)%MOD)', 'N=int(input())\nfrom collections import defaultdict\nimport math\nd = defaultdict(int)\nMOD=10**9+7\nM=0\nfor i in range(N):\n a,b=map(int,input().split())\n x=math.gcd(abs(a),abs(b))\n if x==0:\n if a>b:\n k=(1,0)\n elif b>a:\n k=(0,1)\n else:\n k=(0,0)\n else:\n a,b=a//x,b//x\n if a<0:\n a,b=-a,-b\n k=(a,b)\n d[k]+=1\n M=max(M,d[k])\nans=0\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n#N = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\nfor i in range( 2, M + 1 ):\n g1.append( ( g1[-1] * i ) % MOD )\n inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )\n g2.append( (g2[-1] * inverse[-1]) % MOD )\n\ndef C(x):\n _=0\n for i in range(1,x+1):\n _+=cmb(x,i,MOD)\n return _%MOD\n\nif d[(0,0)]>0:\n ans+=d[(0,0)]\nind=defaultdict(int)\nindex=1\n_ans=[1]\nfor a,b in list(d.keys()):\n if b<0:\n _k=(-b,a)\n else:\n _k=(b,-a)\n if d[_k]==0:\n _ans.append(C(d[(a,b)])+1)\n index+=1\n else:\n if ind[_k]==0:\n _ans.append(C(d[(a,b)]))\n ind[(a,b)]=index\n index+=1\n else:\n _ans[ind[_k]]+=C(d[(a,b)])+1\n_=1\nfor a in _ans:\n _*=a\nprint((ans+_-1)%MOD)', 'N=int(input())\nfrom collections import defaultdict\nimport math\nd = defaultdict(int)\nMOD=10**9+7\nfor i in range(N):\n a,b=map(int,input().split())\n x=math.gcd(abs(a),abs(b))\n if a==0:\n if b==0:\n k=(0,0)\n else:\n k=(0,1)\n elif b==0:\n k=(1,0)\n else:\n if a<0:\n a,b=-a,-b\n if b<0:\n a,b=a//x,-((-b)//x)\n else:\n a,b=a//x,b//x\n k=(a,b)\n d[k]+=1\n\nind=defaultdict(int)\nindex=1\n_ans=[1]\nfor a,b in list(d.keys()):\n if a==b==0:\n continue\n if b<=0:\n _k=(-b,a)\n else:\n _k=(b,-a)\n if d[_k]==0:\n _ans[0]*=pow(2,d[(a,b)])\n else:\n if ind[_k]==0:\n _ans.append(pow(2,d[(a,b)],MOD))\n ind[(a,b)]=index\n index+=1\n else:\n _ans[ind[_k]]+=pow(2,d[(a,b)],MOD)-1\nans=1\nfor a in _ans:\n ans=ans*a%MOD\nprint((d[(0,0)]+ans-1+MOD)%MOD)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s128419583', 's133021482', 's281036484', 's632832786', 's768386200'] | [82600.0, 82600.0, 82580.0, 82776.0, 81112.0] | [1691.0, 1684.0, 1667.0, 1703.0, 1520.0] | [1289, 1402, 1446, 1412, 796] |
p02679 | u216928054 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from collections import defaultdict\nimport sys\nfrom fractions import Fraction\n\ncount = defaultdict(int)\nif 1:\n N = int(sys.stdin.readline())\n\n edges = defaultdict(list)\n for i in range(N):\n A, B = [int(x) for x in sys.stdin.readline().split()]\n if B == 0:\n angle = "I"\n else:\n angle = Fraction(A, B)\n count[angle] += 1\n\npairs = {}\nsolos = []\nfor k1 in count:\n if k1 in pairs:\n continue\n for k2 in count:\n if k1 * k2 == -1:\n pairs[k2] = k1\n break\n else:\n solos.append(k1)\nprint(pairs, solos)\n\n\ndef power(n):\n 1000000007\n\n\nresult = 1\nfor p in pairs:\n print("pair", p, count[p], pairs[p], count[pairs[p]])\n n = count[p]\n m = count[pairs[p]]\n result *= (2 ** n - 1) + (2 ** m - 1) + 1\nfor k in solos:\n print("solo", k, count[k])\n result *= 2 ** count[k]\n\nprint(result - 1)\n', 'from collections import defaultdict\nimport sys\nfrom math import gcd\ncount = defaultdict(int)\nN = int(sys.stdin.readline())\n\nzeros = 0\nfor i in range(N):\n A, B = [int(x) for x in input().split()]\n if A == B == 0:\n zeros += 1\n continue\n if A == 0:\n angle = (0, 1)\n elif B == 0:\n angle = (1, 0)\n else:\n sgn = A // abs(A)\n g = gcd(A, B)\n angle = (A // sgn // g, B // sgn // g)\n\n count[angle] += 1\n# print(count)\n\npairs = {}\nsolos = []\nfor k1 in count:\n if k1 in pairs:\n continue\n if k1 == (0, 1):\n if (1, 0) in count:\n pairs[(1, 0)] = k1\n else:\n solos.append(k1)\n continue\n\n A, B = k1\n if B:\n sgn = -B // abs(B)\n k2 = (-B // sgn, A // sgn)\n else:\n k2 = (0, 1)\n if k2 in count:\n pairs[k2] = k1\n else:\n solos.append(k1)\n\n\nP = 1000000007\n\n\ndef pow2(n):\n # if n < 30:\n # return 2 ** n\n\n \n \n # if n % 2 == 1:\n # return (2 * pp) % P\n # else:\n # return pp\n return pow(2, n, P)\n\n\nresult = 1\nfor p in pairs:\n \n n = count[p]\n m = count[pairs[p]]\n result = result * ((pow2(n) - 1) + (pow2(m) - 1) + 1) % P\nfor k in solos:\n # print("solo", k, count[k])\n result = result * pow2(count[k]) % P\n\nprint((result + zeros - 1) % P)\n'] | ['Runtime Error', 'Accepted'] | ['s368624638', 's345266849'] | [15552.0, 46780.0] | [2206.0, 1109.0] | [901, 1449] |
p02679 | u221061152 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nmod=1000000007\n\nn=int(input())\nzeros = 0\nvec = {}\nfor _ in range(n):\n a,b=map(int,input().split())\n if a==0 and b==0:\n zeros+=1\n continue\n elif a==0:\n vec[(0,1)]=vec.get((0,1),0)+1\n elif b==0:\n vec[(1,0)]=vec.get((1,0),0)+1\n else:\n g = gcd(a,b)\n a,b= a//g,b//g\n vec[(a,b)]=vec.get((a,b),0)+1\ndone = set()\ntotal=1\nfor (a,b),v in vec.items():\n if (-b,a) in done or (b,-a) in done: continue\n done.add((a,b))\n w=vec[(-b,a)]+vec[(b,-a)]\n total *= (pow(2,v,mod)+pow(2,w,mod)-1)\n total %= mod\nprint((total+zeros-1+mod)%mod)\n', 'from math import gcd\nn=int(input())\nmod = 1000000007\nz=0\nd={}\nfor _ in range(n):\n a,b=map(int,input().split())\n if not any((a,b)):\n z+=1\n continue\n if a==0:\n d[(0,1)]=d.get((0,1),0)+1\n continue\n if b==0:\n d[(1,0)]=d.get((1,0),0)+1\n continue\n g = gcd(a,b)\n s = a//abs(a)\n a,b = (a//g)*s, (b//g)*s\n d[(a,b)]=d.get((a,b),0)+1\n\ndone = set()\nans = 1\nfor (a,b), v in d.items():\n if (a,b) in done:continue\n done.add((a,b))\n done.add((-b,a))\n done.add((b,-a))\n w = d.get((-b,a),0)+d.get((b,-a),0)\n ans *= (pow(2,v,mod)+pow(2,w,mod)-1)\n ans %= mod\nans = (ans + z - 1 + mod)%mod\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s200466257', 's630582610'] | [46524.0, 124756.0] | [659.0, 1458.0] | [569, 613] |
p02679 | u239528020 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['#!/usr/bin/env python3\nimport math\n\nn = int(input())\n\nmod = 10**9+7\n\ndata = {}\nzero_zero = 0\n\nfor i in range(n):\n a, b = list(map(int, input().split()))\n # # print(a, b)\n gcd = math.gcd(a, b)\n a, b = a//gcd, b//gcd\n\n if a == 0 and b == 0:\n zero_zero += 1\n continue\n if a < 0:\n a, b = -a, -b\n\n if a == 0: # (0, 1)\n a, b = 0, 1\n\n elif b == 0: # (1, 0)\n a, b = 1, 0\n\n # print(a, b)\n # print()\n\n if b <= 0: # (+, -) or (1, 0)\n if (-b, a) in data:\n data[(-b, a)][1] += 1\n else:\n data[(-b, a)] = [0, 1]\n elif b > 0: # (+, +) or (1, 0)\n if (a, b) in data:\n data[(a, b)][0] += 1\n else:\n data[(a, b)] = [1, 0]\n\nprint(data)\n\n\npower_2 = [1]\nfor i in range(1, 2*10**5+100):\n power_2.append(power_2[i-1]*2 % mod)\n\nans = 1\n# print(ans)\n# print()\nfor (a, b), (l, m) in data.items():\n ans *= power_2[l]+power_2[m]-1\n ans %= mod\n # print(power_2[l]+power_2[m]-1)\n # print(ans)\n # print()\n\nans = ans - 1 # removed not selected\n\nprint(ans)\n\n# count_pm = 0\n# ans = 0\n# while(1):\n\n\n\n# print("pp_tmp", pp_tmp)\n# print("pm_tmp", pm_tmp)\n\n# if pp_tmp[0]*pm_tmp[0] + pp_tmp[1]*pm_tmp[1] == 0:\n# pp_mag, pm_mag = 1, 1 # magnitude\n# while(1):\n\n\n\n\n# else:\n# break\n# else:\n# break\n# while(1):\n\n\n\n# count_pm += 1\n# else:\n# break\n# else:\n# break\n# ans += pp_mag*pm_mag\n\n# elif pp_tmp[2]*pm_tmp[2] > -1:\n\n\n# elif pp_tmp[2]*pm_tmp[2] < -1:\n# count_pm += 1\n\n\n# break\n\n# break\n# print(1)\n\n\n\n# count = ((n % mod) * ((n-1) % mod))//2\n\n\n# print(count % mod)\n', '#!/usr/bin/env python3\nimport math\n\nn = int(input())\n\nmod = 10**9+7\n\ndata = {}\nzero_zero = 0\n\nfor i in range(n):\n a, b = list(map(int, input().split()))\n # # print(a, b)\n gcd = math.gcd(a, b)\n a, b = a//gcd, b//gcd\n\n if a == 0 and b == 0:\n zero_zero += 1\n continue\n if a < 0:\n a, b = -a, -b\n\n if a == 0: # (0, 1)\n a, b = 0, 1\n\n elif b == 0: # (1, 0)\n a, b = 1, 0\n\n # print(a, b)\n # print()\n\n if b <= 0: # (+, -) or (1, 0)\n if (-b, a) in data:\n data[(-b, a)][1] += 1\n else:\n data[(-b, a)] = [0, 1]\n elif b > 0: # (+, +) or (1, 0)\n if (a, b) in data:\n data[(a, b)][0] += 1\n else:\n data[(a, b)] = [1, 0]\n\nprint(data)\n\n\npower_2 = [1]\nfor i in range(1, 2*10**5+100):\n power_2.append(power_2[i-1]*2 % mod)\n\nans = 1\n# print(ans)\n# print()\nfor (a, b), (l, m) in data.items():\n ans *= (power_2[l]+power_2[m]-1) % mod\n # print(power_2[l]+power_2[m]-1)\n # print(ans)\n # print()\n\nans = ans - 1 # removed not selected\n\nprint(ans)\n\n# count_pm = 0\n# ans = 0\n# while(1):\n\n\n\n# print("pp_tmp", pp_tmp)\n# print("pm_tmp", pm_tmp)\n\n# if pp_tmp[0]*pm_tmp[0] + pp_tmp[1]*pm_tmp[1] == 0:\n# pp_mag, pm_mag = 1, 1 # magnitude\n# while(1):\n\n\n\n\n# else:\n# break\n# else:\n# break\n# while(1):\n\n\n\n# count_pm += 1\n# else:\n# break\n# else:\n# break\n# ans += pp_mag*pm_mag\n\n# elif pp_tmp[2]*pm_tmp[2] > -1:\n\n\n# elif pp_tmp[2]*pm_tmp[2] < -1:\n# count_pm += 1\n\n\n# break\n\n# break\n# print(1)\n\n\n\n# count = ((n % mod) * ((n-1) % mod))//2\n\n\n# print(count % mod)\n', '#!/usr/bin/env python3\nimport math\n\nn = int(input())\n\nmod = 10**9+7\n\ndata = {}\nzero_zero = 0\n\nfor i in range(n):\n a, b = list(map(int, input().split()))\n # # print(a, b)\n gcd = math.gcd(a, b)\n a, b = a//gcd, b//gcd\n\n if a == 0 and b == 0:\n zero_zero += 1\n continue\n if a < 0:\n a, b = -a, -b\n\n if a == 0: # (0, 1)\n a, b = 0, 1\n\n elif b == 0: # (1, 0)\n a, b = 1, 0\n\n # print(a, b)\n # print()\n\n if b <= 0: # (+, -) or (1, 0)\n if (-b, a) in data:\n data[(-b, a)][1] += 1\n else:\n data[(-b, a)] = [0, 1]\n elif b > 0: # (+, +) or (1, 0)\n if (a, b) in data:\n data[(a, b)][0] += 1\n else:\n data[(a, b)] = [1, 0]\n\nprint(data)\n\n\npower_2 = [1]\nfor i in range(1, 2*10**5+100):\n power_2.append(power_2[i-1]*2 % mod)\n\nans = 1\n# print(ans)\n# print()\nfor (a, b), (l, m) in data.items():\n ans *= power_2[l]+power_2[m]-1\n # print(power_2[l]+power_2[m]-1)\n # print(ans)\n # print()\n\nans = ans - 1 # removed not selected\n\nprint(ans)\n\n# count_pm = 0\n# ans = 0\n# while(1):\n\n\n\n# print("pp_tmp", pp_tmp)\n# print("pm_tmp", pm_tmp)\n\n# if pp_tmp[0]*pm_tmp[0] + pp_tmp[1]*pm_tmp[1] == 0:\n# pp_mag, pm_mag = 1, 1 # magnitude\n# while(1):\n\n\n\n\n# else:\n# break\n# else:\n# break\n# while(1):\n\n\n\n# count_pm += 1\n# else:\n# break\n# else:\n# break\n# ans += pp_mag*pm_mag\n\n# elif pp_tmp[2]*pm_tmp[2] > -1:\n\n\n# elif pp_tmp[2]*pm_tmp[2] < -1:\n# count_pm += 1\n\n\n# break\n\n# break\n# print(1)\n\n\n\n# count = ((n % mod) * ((n-1) % mod))//2\n\n\n# print(count % mod)\n', '#!/usr/bin/env python3\nimport math\n\nn = int(input())\n\nmod = 10**9+7\n\ndata = {}\nzero_zero = 0\n\nfor i in range(n):\n a, b = list(map(int, input().split()))\n # # print(a, b)\n if a == 0 and b == 0:\n zero_zero += 1\n continue\n gcd = math.gcd(a, b)\n a, b = a//gcd, b//gcd\n if a < 0:\n a, b = -a, -b\n\n if a == 0: # (0, 1)\n a, b = 0, 1\n\n elif b == 0: # (1, 0)\n a, b = 1, 0\n\n # print(a, b)\n # print()\n\n if b <= 0: # (+, -) or (1, 0)\n if (-b, a) in data:\n data[(-b, a)][1] += 1\n else:\n data[(-b, a)] = [0, 1]\n elif b > 0: # (+, +) or (1, 0)\n if (a, b) in data:\n data[(a, b)][0] += 1\n else:\n data[(a, b)] = [1, 0]\n\n# print(data)\n\n\npower_2 = [1]\nfor i in range(1, 2*10**5+100):\n power_2.append(power_2[i-1]*2 % mod)\n\nans = 1\n# print(ans)\n# print()\nfor (a, b), (l, m) in data.items():\n ans *= (power_2[l]+power_2[m]-1) % mod\n # print(power_2[l]+power_2[m]-1)\n # print(ans)\n # print()\n\nans = ans - 1 # removed not selected\nans += zero_zero\nprint(ans % mod)\n\n# count_pm = 0\n# ans = 0\n# while(1):\n\n\n\n# print("pp_tmp", pp_tmp)\n# print("pm_tmp", pm_tmp)\n\n# if pp_tmp[0]*pm_tmp[0] + pp_tmp[1]*pm_tmp[1] == 0:\n# pp_mag, pm_mag = 1, 1 # magnitude\n# while(1):\n\n\n\n\n# else:\n# break\n# else:\n# break\n# while(1):\n\n\n\n# count_pm += 1\n# else:\n# break\n# else:\n# break\n# ans += pp_mag*pm_mag\n\n# elif pp_tmp[2]*pm_tmp[2] > -1:\n\n\n# elif pp_tmp[2]*pm_tmp[2] < -1:\n# count_pm += 1\n\n\n# break\n\n# break\n# print(1)\n\n\n\n# count = ((n % mod) * ((n-1) % mod))//2\n\n\n# print(count % mod)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s266653927', 's390397018', 's451607452', 's408198196'] | [88108.0, 88092.0, 88076.0, 68212.0] | [1106.0, 1668.0, 1654.0, 1471.0] | [2406, 2399, 2391, 2422] |
p02679 | u249218427 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['# -*- coding: utf-8 -*-\nfrom fractions import Fraction\n\nN = int(input())\n\ndict_F = {}\ncount_0 = 0\n\ndef insert(A,B,s): # A>=0, B>0, s=0or1\n if Fraction(A,B) not in dict_F.keys():\n dict_F[Fraction(A,B)] = [0,0]\n dict_F[Fraction(A,B)][s] += 1\n\ndef power2(A):\n result = 1\n for _ in range(A):\n result = (2*result)%mod\n return result\n\nfor _ in range(N):\n A,B = map(int, input().split())\n if A==0 and B==0:\n count_0 += 1\n elif A>=0 and B>0:\n insert(A,B,0)\n elif A>0 and B<=0:\n insert(-B,A,1)\n elif A<=0 and B<0:\n insert(-A,-B,0)\n elif A<0 and B>=0:\n insert(B,-A,1)\n\nmod = 1000000007\nanswer = 1\n\n\nanswer = (answer+count_0-1)%mod\nprint(answer)', '# -*- coding: utf-8 -*-\nimport sys\nfrom math import gcd\n\nN, *AB = map(int, sys.stdin.buffer.read().split())\n\ndict_F = {}\ncount_0 = 0\n\ndef insert(A,B,s): # A>=0, B>0, s=0or1\n if (A,B) not in dict_F.keys():\n dict_F[(A,B)] = [0,0]\n dict_F[(A,B)][s] += 1\n\ndef make_power2(N):\n result = 1\n list_result = [1]\n for _ in range(N):\n result = (2*result)%mod\n list_result.append(result)\n return list_result\n\nfor i in range(N):\n A,B = AB[2*i:2*i+2]\n if A==0 and B==0:\n count_0 += 1\n continue\n g = gcd(A,B)\n A //= g\n B //= g\n if A>=0 and B>0:\n insert(A,B,0)\n elif A>0 and B<=0:\n insert(-B,A,1)\n elif A<=0 and B<0:\n insert(-A,-B,0)\n elif A<0 and B>=0:\n insert(B,-A,1)\n\nmod = 1000000007\npower2 = make_power2(N)\nanswer = 1\n\nfor A,B in dict_F.values():\n answer = (answer*(power2[A]+power2[B]-1))%mod\nanswer = (answer+count_0-1)%mod\n\nprint(answer)'] | ['Wrong Answer', 'Accepted'] | ['s353981849', 's465838285'] | [17804.0, 92996.0] | [2206.0, 775.0] | [742, 872] |
p02679 | u316464887 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\ndef main():\n N = int(input())\n d = {}\n zb = 0\n za = 0\n zab = 0\n r = 0\n mod = 10**9 + 7\n for i in range(N):\n a, b = map(int, input().split())\n if a== 0 and b == 0:\n zab += 1\n elif b == 0:\n zb += 1\n elif a == 0:\n za += 1\n else:\n if a < 0:\n a = -a\n b = -b\n x = math.gcd(abs(a), abs(b))\n if (a//x, b//x) in d:\n d[(a//x, b//x)] += 1\n else:\n d[(a//x, b//x)] = 1\n used = set()\n l = []\n for x in d:\n if x in used:\n continue\n a, b = x[0], x[1]\n used.add(x)\n if a * b > 0:\n t = (abs(b), -abs(a))\n if t in d:\n used.add(t)\n l.append((d[x], d[t]))\n else:\n l.append((1, 0))\n else:\n t = (abs(b), abs(a))\n if t in d:\n used.add(t)\n l.append((d[x], d[t]))\n else:\n l.append((1, 0))\n r = zab + pow(2, za) + pow(2, zb) - 2\n for i in l:\n r *= (pow(2, i[0]) + pow(2, i[1]) - 1)\n r %= mod\n return r % mod - 1\nprint(main())\n', 'import math\ndef main():\n N = int(input())\n d = {}\n za = zb = zab = r = 0\n mod = 10**9 + 7\n for i in range(N):\n a, b = map(int, input().split())\n if a== 0 and b == 0:\n zab += 1\n elif b == 0:\n zb += 1\n elif a == 0:\n za += 1\n else:\n if a < 0:\n a, b = -a, -b\n x = math.gcd(abs(a), abs(b))\n d[(a//x, b//x)] = d.get((a//x, b//x), 0) + 1\n used = set()\n l = []\n for x in d:\n if x in used:\n continue\n a, b = x[0], x[1]\n used.add(x)\n if a * b > 0:\n t = (abs(b), -abs(a))\n else:\n t = (abs(b), abs(a))\n used.add(t)\n l.append((d[x], d.get(t, 0)))\n r = pow(2, za) + pow(2, zb) - 1\n for i in l:\n r *= (pow(2, i[0]) + pow(2, i[1]) - 1)\n r %= mod\n return (r - 1 + zab) % mod\nprint(main())\n'] | ['Wrong Answer', 'Accepted'] | ['s507663916', 's256828319'] | [59412.0, 100640.0] | [874.0, 1050.0] | [1241, 917] |
p02679 | u318127926 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['n = int(input())\nab = []\nfor _ in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndi = {}\ndef gcd(a, b):\n while b!=0:\n a, b = b, a%b\n return a\nfor a, b in ab:\n if a*b!=0:\n g = gcd(abs(a), abs(b))\n a, b = a//g, b//g\n if a*b>0:\n ind = (abs(a), abs(b))\n elif a*b<0:\n ind = (abs(b), abs(a))\n else:\n ind = 0\n if ind in di:\n x, y = di[ind]\n else:\n x = y = 0\n if a*b==0:\n if b!=0:\n di[ind] = (x+1, y)\n elif a!=0:\n di[ind] = (x, y+1)\n else:\n if a*b>0:\n di[ind] = (x+1, y)\n else:\n di[ind] = (x, y+1)\nprint(di)\nmod = 10**9+7\nans = 1\nfor i, j in di.values():\n ans *= (pow(2, i, mod)+pow(2, j, mod)-1)\n ans %= mod\nprint((ans-1)%mod)', 'n = int(input())\nab = []\nfor _ in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndi = {}\nz = 0\ndef gcd(a, b):\n while b!=0:\n a, b = b, a%b\n return a\nfor a, b in ab:\n if a*b!=0:\n g = gcd(abs(a), abs(b))\n a, b = a//g, b//g\n if a*b>0:\n ind = (abs(a), abs(b))\n elif a*b<0:\n ind = (abs(b), abs(a))\n else:\n ind = 0\n if ind in di:\n x, y = di[ind]\n else:\n x = y = 0\n if a*b==0:\n if b!=0:\n di[ind] = (x+1, y)\n elif a!=0:\n di[ind] = (x, y+1)\n else:\n z += 1\n else:\n if a*b>0:\n di[ind] = (x+1, y)\n else:\n di[ind] = (x, y+1)\nmod = 10**9+7\nans = 1\nfor i, j in di.values():\n ans *= (pow(2, i, mod)+pow(2, j, mod)-1)\n ans %= mod\nprint((ans+z-1)%mod)'] | ['Wrong Answer', 'Accepted'] | ['s223088166', 's963732415'] | [111868.0, 84596.0] | [1739.0, 1544.0] | [805, 836] |
p02679 | u318233626 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nfrom sys import setrecursionlimit\nsetrecursionlimit(4100000)\nmod = 10 ** 9 + 7\nn = int(input())\n\nzeros = 0\nd = {}\nfor i in range(n):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zeros += 1\n else:\n g = gcd(x, y)\n x, y = x / g, y / g\n if (y < 0) or (y == 0 and x < 0): \n x, y = -x, -y\n else: \n pass\n if x <= 0:\n sq = True #second quadrant\n x, y = y, -x\n else:\n sq = False\n if sq == True:\n if (x, y) in d:\n d[(x, y)][1] += 1\n else:\n d[(x, y)] = [0, 1]\n else:\n if (x, y) in d:\n d[(x, y)][0] += 1\n else:\n d[(x, y)] =[1, 0] \n\n\ndef mod_pow(a:int, b:int, mod:int)->int:\n if b == 0:\n return 1 % mod\n elif b % 2 == 0:\n return (mod_pow(a, b//2, mod) ** 2) % mod\n elif b == 1:\n return a % mod\n else:\n return ((mod_pow(a, b//2, mod) ** 2) * a) % mod\n#print(d)\n\nans = 1\nfor (i, j) in tuple(d.values()):\n now = 1\n now = (now + mod_pow(2, i, mod) - 1) % mod\n now = (mow + mod_pow(2, j, mod) - 1) % mod\n ans = (ans * now) % mod\n \nans -= 1\nans += zeros % mod\nans = ans % mod\nprint(ans)', 'from math import gcd\nfrom sys import setrecursionlimit\nsetrecursionlimit(4100000)\nmod = 10 ** 9 + 7\nn = int(input())\n\nzeros = 0\nd = {}\nfor i in range(n):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zeros += 1\n else:\n g = gcd(x, y)\n x, y = x // g, y // g\n if (y < 0) or (y == 0 and x < 0): \n x, y = -x, -y\n else: \n pass\n if x <= 0:\n sq = True #second quadrant\n x, y = y, -x\n else:\n sq = False\n if sq == True:\n if (x, y) in d:\n d[(x, y)][1] += 1\n else:\n d[(x, y)] = [0, 1]\n else:\n if (x, y) in d:\n d[(x, y)][0] += 1\n else:\n d[(x, y)] =[1, 0] \n\n\ndef mod_pow(a:int, b:int, mod:int)->int:\n if b == 0:\n return 1 % mod\n elif b % 2 == 0:\n return (mod_pow(a, b//2, mod) ** 2) % mod\n elif b == 1:\n return a % mod\n else:\n return ((mod_pow(a, b//2, mod) ** 2) * a) % mod\n#print(d)\n\nans = 1\nfor (a, b), (k, l) in d.items():\n now = 1\n now = (now + mod_pow(2, k, mod) - 1) % mod\n now = (now + mod_pow(2, l, mod) - 1) % mod\n ans = (ans * now) % mod\n \nans -= 1\nzeros = zeros % mod\nans = (ans + zeros) % mod\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s478671377', 's307599297'] | [61716.0, 60384.0] | [852.0, 959.0] | [1310, 1323] |
p02679 | u324090406 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nfrom numpy import sign\nmod = 1000000007\nN = int(input())\n\nif N == 1:\n print(1)\n \nd = {}\n\nfor _ in range(N):\n a, b = list(map(int, input().split()))\n if a == b == 0:\n if (0, 0) not in d:\n d[(0, 0)] = 1\n else:\n d[(0, 0)] += 1\n else:\n g = gcd(a, b)\n\n a, b = a / g, b /g\n if b < 0:\n a, b = -a, -b\n if b == 0:\n a, b = 1, 0\n if (a, b) not in d:\n d[(a, b)] =1\n else:\n d[(a, b)] +=1\n\nanswer = 1\n\nprint(d)\n\ndone_list = []\n\nfor k in list(d.keys()):\n if k not in done_list:\n pair_k = (sign(k[0]) * (-1) * k[1], abs(k[0]))\n if pair_k not in d:\n answer *= 2 ** d[k]\n answer = answer % mod\n done_list += [k]\n else:\n answer *= (2 ** d[k]) + (2 ** d[pair_k]) - 1\n answer = answer % mod\n done_list += [k, pair_k]\n\nif (0, 0) in d:\n answer += d[(0, 0)]\n \nprint((answer - 1) % mod)', 'from math import gcd\nfrom numpy import sign\nmod = 1000000007\nN = int(input())\n\nif N == 1:\n print(1)\n \nd = {}\n\nsearch_list = []\n\nfor _ in range(N):\n a, b = list(map(int, input().split()))\n if a == b == 0:\n if (0, 0) not in d:\n d[(0, 0)] = 1\n else:\n d[(0, 0)] += 1\n else:\n g = gcd(a, b)\n\n a, b = a / g, b /g\n if b < 0:\n a, b = -a, -b\n if b == 0:\n a, b = 1, 0\n if (a, b) not in d:\n d[(a, b)] =1\n else:\n d[(a, b)] +=1\n\nanswer = 1\n\n\n\nfor k in list(d.keys()):\n if k not in done_list and k != (0, 0):\n pair_k = (sign(k[0]) * (-1) * k[1], abs(k[0]))\n if pair_k not in d:\n answer *= (2 ** d[k]) % mod\n answer = answer % mod\n done_list += [k]\n else:\n answer *= ((2 ** d[k]) + (2 ** d[pair_k]) - 1) % mod\n answer = answer % mod\n done_list += [k, pair_k]\n\nif (0, 0) in d:\n answer += d[(0, 0)]\n \nprint((answer - 1) % mod)', 'from math import gcd\nfrom numpy import sign\nmod = 1000000007\nN = int(input())\n\nif N == 1:\n print(1)\n \nd = {}\ncounter = 0\n\nf = 0\nl = 0\n\nfor _ in range(N):\n a, b = list(map(int, input().split()))\n if a == b == 0:\n counter += 1\n elif a==0:\n f += 1\n elif b==0:\n l += 1\n else:\n g = gcd(a, b)\n a, b = a // g, b //g\n if b < 0:\n a, b = -a, -b\n if (a, b) not in d:\n d[(a, b)] =1\n else:\n d[(a, b)] +=1\n\nanswer = 1\n\n\ngroup = set()\nfor (p, q), v in d.items():\n invp,invq=-q,p\n if invq<0:\n invp,invq=-invp,-invq\n if not (invp,invq) in group:\n group.add((p,q))\n\nfor (p, q), v in group:\n invp, invq = (sign(p) * (-1) * q, abs(p))\n if (invp, invq) not in d:\n answer *= (2 ** d[(p, q)]) % mod\n answer = answer % mod\n else:\n answer *= ((2 ** d[(p, q)]) + (2 ** d[(invp, invq)]) - 1) % mod\n answer = answer % mod\n \nanswer *= 2**f + 2**l - 1\n \nprint((answer + counter - 1) % mod)', 'from math import gcd\nfrom numpy import sign\nmod = 1000000007\nN = int(input())\n\nif N == 1:\n print(1)\n \nd = {}\ncounter = 0\n\nf = 0\nl = 0\n\nfor _ in range(N):\n a, b = list(map(int, input().split()))\n if a == b == 0:\n counter += 1\n elif a==0:\n f += 1\n elif b==0:\n l += 1\n else:\n g = gcd(a, b)\n a, b = a // g, b //g\n if b < 0:\n a, b = -a, -b\n if (a, b) not in d:\n d[(a, b)] =1\n else:\n d[(a, b)] +=1\n\nanswer = 1\n\ngroup = set()\nfor (p, q), v in d.items():\n invp,invq=-q,p\n if invq<0:\n invp,invq=-invp,-invq\n if not (invp,invq) in group:\n group.add((p,q))\n\nfor (p, q) in group:\n invp,invq=-q,p\n if invq<0:\n invp,invq=-invp,-invq\n if (invp, invq) not in d:\n answer *= (2 ** (d[(p, q)]-1)) % mod\n answer = answer % mod\n else:\n answer *= ((2 ** (d[(p, q)]-1)) + (2 ** (d[(invp, invq)]-1)) - 1) % mod\n answer = answer % mod\n \nanswer *= 2**f + 2**l - 1\n \nprint((answer + counter - 1) % mod)', 'from math import gcd\nfrom numpy import sign\nmod = 1000000007\nN = int(input())\n\nd = {}\ncounter = 0\n\nf = 0\nl = 0\n\nfor _ in range(N):\n a, b = list(map(int, input().split()))\n if a == b == 0:\n counter += 1\n elif a==0:\n f += 1\n elif b==0:\n l += 1\n else:\n g = gcd(a, b)\n a, b = a // g, b //g\n if b < 0:\n a, b = -a, -b\n if (a, b) not in d:\n d[(a, b)] =1\n else:\n d[(a, b)] +=1\n\nanswer = 1\n\ngroup = set()\nfor (p, q), v in d.items():\n invp,invq=-q,p\n if invq<0:\n invp,invq=-invp,-invq\n if not (invp,invq) in group:\n group.add((p,q))\n\nfor (p, q) in group:\n invp,invq=-q,p\n if invq<0:\n invp,invq=-invp,-invq\n if (invp, invq) not in d:\n answer *= (2 ** d[(p, q)])\n else:\n answer *= ((2 ** d[(p, q)]) + (2 ** d[(invp, invq)]) - 1)\n \nanswer *= 2**f + 2**l - 1\n \nprint((answer + counter - 1) % mod)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s080958489', 's295153901', 's545843721', 's609973448', 's970907530'] | [86840.0, 64268.0, 90008.0, 89916.0, 90168.0] | [2218.0, 834.0, 967.0, 1163.0, 1775.0] | [1017, 1043, 1040, 1066, 953] |
p02679 | u347600233 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from collections import defaultdict\nfrom math import gcd\nMOD = 10**9 + 7\nn = int(input())\nzero = 0\ncnt = dict()\nfor i in range(n):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zero += 1\n continue\n g = gcd(x, y)\n x //= g\n y //= g\n if y < 0 or (y == 0 and x < 0):\n x *= -1\n y *= -1\n rot_90 = 1 if x <= 0 else 0\n if rot_90:\n x, y = y, -x\n cnt[(x, y)][rot_90] += 1\n\nans = 1\nfor s, t in cnt.values():\n now = 1\n now += (pow(2, s, MOD) - 1) % MOD\n now += (pow(2, t, MOD) - 1) % MOD\n ans *= now\nans -= 1\nans += zero\nprint(ans % MOD)', 'from math import gcd\nMOD = 10**9 + 7\nn = int(input())\nzero = 0\ncnt = defaultdict()\nfor i in range(n):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zero += 1\n continue\n g = gcd(x, y)\n x //= g\n y //= g\n if y < 0 or (y == 0 and x < 0):\n x *= -1\n y *= -1\n rot_90 = 1 if x <= 0 else 0\n if rot_90:\n x, y = y, -x\n cnt[(x, y)][rot_90] += 1\n\nans = 1\nfor s, t in cnt.values():\n now = 1\n now += (pow(2, s, MOD) - 1) % MOD\n now += (pow(2, t, MOD) - 1) % MOD\n ans *= now\nans -= 1\nans += zero\nprint(ans % MOD)', 'from math import gcd\nMOD = 10**9 + 7\nn = int(input())\nzero = 0\ncnt = dict()\nfor i in range(n):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zero += 1\n continue\n g = gcd(x, y)\n x //= g\n y //= g\n if y < 0 or (y == 0 and x < 0):\n x *= -1\n y *= -1\n rot_90 = 1 if x <= 0 else 0\n if rot_90:\n x, y = y, -x\n try:\n cnt[(x, y)][rot_90] += 1\n except KeyError:\n cnt[(x, y)] = [int(not rot_90), rot_90]\n\nans = 1\nfor s, t in cnt.values():\n now = 1\n now += (pow(2, s, MOD) - 1) % MOD\n now += (pow(2, t, MOD) - 1) % MOD\n ans *= now\nans -= 1\nans += zero\nprint(ans % MOD)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s355144113', 's638649856', 's671821646'] | [9444.0, 9196.0, 62788.0] | [345.0, 21.0, 1619.0] | [615, 586, 657] |
p02679 | u347640436 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\n\nN = int(input())\nAB = [map(int, input().split()) for _ in range(N)]\n\nab = set()\nd = {}\nd[0] = {}\nd[0][0] = 0\nfor a, b in AB:\n i = gcd(a, b)\n if i != 0:\n a //= i\n b //= i\n if b < 0:\n a, b = -a, -b\n ab.add((a, b))\n d.setdefault(a, {})\n d[a].setdefault(b, 0)\n d[a][b] += 1\nif (0, 0) in ab:\n ab.remove((0, 0))\n\nresult = 1\nused = set()\nfor a, b in ab:\n if (a, b) in used:\n continue\n i = d[a][b]\n j = 0\n if -b in d and a in d[-b]:\n j = d[-b][a]\n used.add((-b, a))\n result *= pow(2, i, 1000000007) + pow(2, j, 1000000007) - 1\n result %= 1000000007\nresult += d[0][0] - 1\nresult %= 1000000007\nprint(result)\n', 'from math import gcd\n\nN = int(input())\nAB = [map(int, input().split()) for _ in range(N)]\n\nt = []\nd = {}\nd[0][0] = 0\nfor a, b in AB:\n i = gcd(a, b)\n if i != 0:\n a //= i\n b //= i\n t.append((a, b))\n d.setdefault(a, {})\n d[a].setdefault(b, 0)\n d[a][b] += 1\n\nused = set()\nresult = 1\nfor a, b in t:\n if (a, b) in used:\n continue\n used.add((a, b))\n if a == 0 and b == 0:\n continue\n i = d[a][b]\n j, k, l = 0, 0, 0\n if -a in d and -b in d[-a]:\n j = d[-a][-b]\n used.add((-a, -b))\n if -b in d and a in d[-b]:\n k = d[-b][a]\n used.add((-b, a))\n if b in d and -a in d[b]:\n l = d[b][-a]\n used.add((b, -a))\n result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1\n result %= 1000000007\nprint(result + d[0][0] - 1)\n', 'from math import gcd\n\nN = int(input())\nAB = [map(int, input().split()) for _ in range(N)]\n\nab = set()\nd = {}\nd[0] = {}\nd[0][0] = 0\nfor a, b in AB:\n i = gcd(a, b)\n if i != 0:\n a //= i\n b //= i\n if b < 0:\n a, b = -a, -b\n ab.add((a, b))\n d.setdefault(a, {})\n d[a].setdefault(b, 0)\n d[a][b] += 1\nif (0, 0) in ab:\n ab.remove((0, 0))\n\nresult = 1\nfor a, b in ab:\n if a == 0 and b == 0:\n continue\n i = d[a][b]\n j, k, l = 0, 0, 0\n if -a in d and -b in d[-a]:\n j = d[-a][-b]\n result *= pow(2, i, 1000000007) + pow(2, j, 1000000007) - 1\n result %= 1000000007\nresult += d[0][0] - 1\nresult %= 1000000007\nprint(result)\n', 'from math import gcd\n\nN = int(input())\nAB = [map(int, input().split()) for _ in range(N)]\n\nm = 1000000007\n\nt = []\nd = {}\nd[0] = {}\nd[0][0] = 0\nfor a, b in AB:\n i = gcd(a, b)\n if i != 0:\n a //= i\n b //= i\n t.append((a, b))\n d.setdefault(a, {})\n d[a].setdefault(b, 0)\n d[a][b] += 1\n\nused = set()\nresult = 1\nfor a, b in t:\n if (a, b) in used:\n continue\n used.add((a, b))\n if a == 0 and b == 0:\n continue\n i = d[a][b]\n j, k, l = 0, 0, 0\n if -a in d and -b in d[-a]:\n j = d[-a][-b]\n used.add((-a, -b))\n if -b in d and a in d[-b]:\n k = d[-b][a]\n used.add((-b, a))\n if b in d and -a in d[b]:\n l = d[b][-a]\n used.add((b, -a))\n result *= pow(2, i + j, m) + pow(2, k + l, m) - 1\n result %= m\nresult += d[0][0] - 1\nresult %= m\nprint(result)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s083908143', 's158028667', 's289958766', 's780719256'] | [134308.0, 102868.0, 134316.0, 151468.0] | [1552.0, 624.0, 1564.0, 1355.0] | [704, 829, 682, 848] |
p02679 | u391589398 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nmod = 10**9+7\nN = int(input())\n\niwashi01 = 0\niwashi10 = 0\niwashi00 = 0\niwashi = dict()\nfor i in range(N):\n a, b = map(int, input().split())\n g = math.gcd(abs(a), abs(b))\n a //= g; b //= g\n if a == 0 and b == 0:\n iwashi00 += 1\n elif a == 0:\n iwashi01 += 1\n elif b == 0:\n iwashi10 += 1 \n else:\n if a*b > 0:\n if a < 0 and b < 0:\n a *= -1\n b *= -1\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][0] += 1\n if a*b < 0:\n if a < 0 and b > 0:\n a *= -1\n b *= -1\n a, b = -b, a\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][1] += 1\n\nr = 2**iwashi01 % mod - 1 + 2**iwashi10 % mod - 1 + 1\nfor s, t in iwashi.values():\n r *= 2**s % mod -1 + 2**t % mod -1 + 1\n r %= mod\n print(r + iwashi00 - 1)', 'import math\nmod = 10**9+7\nN = int(input())\n \niwashi01 = 0\niwashi10 = 0\niwashi00 = 0\niwashi = dict()\nfor i in range(N):\n a, b = map(int, input().split())\n g = math.gcd(abs(a), abs(b))\n a //= g; b //= g\n if a == 0 and b == 0:\n iwashi00 += 1\n elif a == 0:\n iwashi01 += 1\n elif b == 0:\n iwashi10 += 1 \n else:\n if a*b > 0:\n if a < 0 and b < 0:\n a *= -1\n b *= -1\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][0] += 1\n if a*b < 0:\n if a < 0 and b > 0:\n a *= -1\n b *= -1\n a, b = -b, a\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][1] += 1\n \nr = 2**iwashi01 % mod - 1 + 2**iwashi10 % mod - 1 + 1\nfor s, t in iwashi.values():\n r *= 2**s % mod -1 + 2**t % mod -1 + 1\n r %= mod\n print(r + iwashi00 - 1)', 'import math\nmod = 10**9+7\nN = int(input())\n\niwashi01 = 0\niwashi10 = 0\niwashi00 = 0\niwashi = dict()\nfor i in range(N):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n iwashi00 += 1\n elif a == 0:\n iwashi01 += 1\n elif b == 0:\n iwashi10 += 1 \n else:\n g = math.gcd(abs(a), abs(b))\n a //= g; b //= g\n if a*b > 0:\n if a < 0 and b < 0:\n a *= -1\n b *= -1\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][0] += 1\n if a*b < 0:\n if a < 0 and b > 0:\n a *= -1\n b *= -1\n a, b = -b, a\n iwashi.setdefault((a, b), [0, 0])\n iwashi[(a, b)][1] += 1\n\nr = 2**iwashi01 % mod - 1 + 2**iwashi10 % mod - 1 + 1\nfor s, t in iwashi.values():\n r *= 2**s % mod -1 + 2**t % mod -1 + 1\n r %= mod\nprint((r + iwashi00 - 1) % mod)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s753873083', 's829191406', 's379770145'] | [9032.0, 63132.0, 62824.0] | [24.0, 1051.0, 977.0] | [915, 913, 923] |
p02679 | u425177436 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nmod = 10**9 + 7\nn = int(input())\nd = {}\nd0 = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n g = math.gcd(a, b)\n if g == 0:\n d0 += 1\n else:\n a //= g\n b //= g\n if a < 0:\n a = -a\n b = -b\n elif a == 0 and b < 0:\n b = -b\n if (a,b) in d:\n d[(a,b)] += 1\n else:\n d[(a,b)] = 1\nans = 1\nprint(d)\nfor (a,b) in d.keys():\n if d[(a,b)] > 0:\n t = 2**d[(a,b)]\n if b < 0:\n a = -a\n b = -b\n if (b,-a) in d:\n t += 2**d[(b,-a)] - 1\n d[(b,-a)] = 0\n ans *= t\n ans %= mod\nprint((ans+d0-1)%mod)', 'import math\nmod = 10**9 + 7\nn = int(input())\nd = {}\nd0 = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n g = math.gcd(a, b)\n if g == 0:\n d0 += 1\n else:\n a //= g\n b //= g\n if a < 0:\n a = -a\n b = -b\n elif a == 0 and b < 0:\n b = -b\n if (a,b) in d:\n d[(a,b)] += 1\n else:\n d[(a,b)] = 1\nans = 1\nfor (a,b) in d.keys():\n if d[(a,b)] > 0:\n t = 2**d[(a,b)]\n if b <= 0:\n a = -a\n b = -b\n if (b,-a) in d:\n t += 2**d[(b,-a)] - 1\n d[(b,-a)] = 0\n ans *= t\n ans %= mod\nprint((ans+d0-1)%mod)'] | ['Wrong Answer', 'Accepted'] | ['s962937225', 's878693555'] | [69464.0, 46208.0] | [968.0, 884.0] | [687, 679] |
p02679 | u434846982 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['_, *e = [[*map(int, t.split())] for t in open(0)]\nans = 1\nmod = 10 ** 9 + 7\nslope_dict = {}\nzeros = 0\nvect_x = 0\nfor x, y in e:\n if x == y == 0:\n zeros += 1\n elif y == 0:\n vect_x += 1\n else:\n slope_dict[x/y] = slope_dict.get(x/y, 0) + 1\nans = ans * (pow(2, vect_x, mod) + pow(2, slope_dict.get(0, 0), mod) - 1) % mod\nslope_dict.pop(0)\nfor k in slope_dict:\n if -1/k in slope_dict:\n if k >= 1:\n ans = ans * (pow(2, slope_dict[k], mod) +\n pow(2, slope_dict[-1/k], mod) - 1) % mod\n else:\n ans = ans * (pow(2, slope_dict[k], mod)) % mod\nprint(ans + zeros - 1 % mod)\n', '_, *e = [[*map(int, t.split())] for t in open(0)]\nans = 1\nmod = 10 ** 9 + 7\nslope_dict = {}\nzeros = 0\nvect_x = 0\nfor x, y in e:\n if x == y == 0:\n zeros += 1\n elif y == 0:\n vect_x += 1\n else:\n slope_dict[x/y] = slope_dict.get(x/y, 0) + 1\nans = ans * (pow(2, vect_x, mod) + pow(2, slope_dict.get(0, 0), mod) - 1) % mod\nslope_dict.pop(0, True)\nfor k in slope_dict:\n if -1/k in slope_dict:\n if k >= 1:\n ans = ans * (pow(2, slope_dict[k], mod) +\n pow(2, slope_dict[-1/k], mod) - 1) % mod\n else:\n ans = ans * (pow(2, slope_dict[k], mod)) % mod\nprint(ans + zeros - 1 % mod)\n', '_, *e = [[*map(int, t.split())] for t in open(0)]\nans = 1\nmod = 10 ** 9 + 7\nslope_dict = {}\nzeros = 0\nvect_x = 0\nfor x, y in e:\n if x == y == 0:\n zeros += 1\n elif y == 0:\n vect_x += 1\n else:\n slope_dict[x/y] = slope_dict.get(x/y, 0) + 1\nans = ans * (pow(2, vect_x, mod) + pow(2, slope_dict.get(0, 0), mod) - 1) % mod\nslope_dict.popitem(0)\nfor k in slope_dict:\n if -1/k in slope_dict:\n if k >= 1:\n ans = ans * (pow(2, slope_dict[k], mod) +\n pow(2, slope_dict[-1/k], mod) - 1) % mod\n else:\n ans = ans * (pow(2, slope_dict[k], mod)) % mod\nprint(ans + zeros - 1 % mod)\n', 'from math import gcd\n_, *e = [[*map(int, t.split())] for t in open(0)]\nans = 1\nmod = 10 ** 9 + 7\nslope_dict = {}\nzeros = 0\nfor x, y in e:\n if x == y == 0:\n zeros += 1\n else:\n d = gcd(x, y)\n x //= d\n y //= d\n if x < 0 or x == 0 < y:\n x, y = -x, -y\n s = 0\n if y < 0:\n x, y, s = -y, x, 1\n if (x, y) not in slope_dict:\n slope_dict[(x, y)] = [0, 0]\n slope_dict[(x, y)][s] += 1\n\nfor k in slope_dict:\n ans = ans * (pow(2, slope_dict[k][0], mod) +\n pow(2, slope_dict[k][1], mod) - 1) % mod\nprint((ans + zeros - 1) % mod)\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s549586158', 's992516031', 's998725158', 's472956643'] | [68660.0, 68536.0, 68780.0, 99168.0] | [419.0, 652.0, 447.0, 966.0] | [646, 652, 650, 634] |
p02679 | u460375306 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nmod_val = 1000000007\ndef simplify(A, B):\n a = A//gcd(A,B)\n b = B//gcd(A,B)\n if b<0:\n return (-a, -b)\n return (a, b)\nn = int(input())\ncount_simple_fish = dict()\nbad_fish = 0\nfor _ in range(n):\n A, B = map(int, input().split())\n if A == B == 0:\n bad_fish = (bad_fish + 1)%mod_val\n continue\n if B == 0:\n if (1, 0) in count_simple_fish:\n count_simple_fish[(1, 0)][1] += 1\n else:\n count_simple_fish[(1, 0)] = [0, 1]\n elif A == 0:\n if (1, 0) in count_simple_fish:\n count_simple_fish[(1, 0)][0] += 1\n else:\n count_simple_fish[(1, 0)] = [1, 0]\n else:\n a, b = simplify(A, B)\n if a>0:\n if (a, b) in count_simple_fish:\n count_simple_fish[(a, b)][1] += 1\n else:\n count_simple_fish[(a, b)] = [0, 1]\n else:\n if (b, -a) in count_simple_fish:\n count_simple_fish[(b, -a)][0] += 1\n else:\n count_simple_fish[(b, -a)] = [1, 0]\nbig_total = 1\nfor simple_fish, count_leftright in count_simple_fish.items():\n group_pair_combos = 1\n group_pair_combos = (group_pair_combos + pow(2, count_leftright[1], mod_val) - 1)%mod_val\n group_pair_combos = (group_pair_combos + pow(2, count_leftright[0], mod_val) - 1)%mod_val\n big_total = (big_total * group_pair_combos)%mod_val\nprint(count_simple_fish)\nbig_total = (big_total + bad_fish - 1)%mod_val\nprint(big_total)', 'from math import gcd\nmod_val = 1000000007\ndef simplify(A, B):\n a = A//gcd(A,B)\n b = B//gcd(A,B)\n if b<0:\n return (-a, -b)\n return (a, b)\nn = int(input())\ncount_simple_fish = dict()\nbad_fish = 0\nfor _ in range(n):\n A, B = map(int, input().split())\n if A == B == 0:\n bad_fish = (bad_fish + 1)%mod_val\n continue\n if B == 0:\n if (1, 0) in count_simple_fish:\n count_simple_fish[(1, 0)][1] += 1\n else:\n count_simple_fish[(1, 0)] = [0, 1]\n elif A == 0:\n if (1, 0) in count_simple_fish:\n count_simple_fish[(1, 0)][0] += 1\n else:\n count_simple_fish[(1, 0)] = [1, 0]\n else:\n a, b = simplify(A, B)\n if a>0:\n if (a, b) in count_simple_fish:\n count_simple_fish[(a, b)][1] += 1\n else:\n count_simple_fish[(a, b)] = [0, 1]\n else:\n if (b, -a) in count_simple_fish:\n count_simple_fish[(b, -a)][0] += 1\n else:\n count_simple_fish[(b, -a)] = [1, 0]\nbig_total = 1\nfor simple_fish, count_leftright in count_simple_fish.items():\n group_pair_combos = 1\n group_pair_combos = (group_pair_combos + pow(2, count_leftright[1], mod_val) - 1)%mod_val\n group_pair_combos = (group_pair_combos + pow(2, count_leftright[0], mod_val) - 1)%mod_val\n big_total = (big_total * group_pair_combos)%mod_val\nbig_total = (big_total + bad_fish - 1)%mod_val\nprint(big_total)'] | ['Wrong Answer', 'Accepted'] | ['s608149336', 's401666140'] | [88116.0, 60480.0] | [1364.0, 1140.0] | [1362, 1337] |
p02679 | u479719434 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\n\nmod = 1000000007\n\nn = int(input())\ncounter = {}\nzeros = 0\nfor i in range(n):\n a, b = map(int, input().split())\n if (a == 0 and b == 0):\n zeros += 1\n continue\n g = gcd(a, b)\n a //= g\n b //= g\n if (b < 0):\n a = -a\n b = -b\n if (b == 0 and a < 0):\n a = -a\n counter[(a, b)] = counter.get((a, b), 0)+1\n\n# print(counter)\ncounted = set()\nans = 1\nfor s, s_count in counter.items():\n if s not in counted:\n if s[0] >= 0 and s[1] >= 0:\n t = (-s[1], s[0])\n else:\n t = (s[1], -s[0])\n t_count = counter.get(t, 0)\n now = pow(2, s_count, mod)-1\n now += pow(2, t_count, mod)-1\n now += 1\n ans *= now\n print(now)\n counted.add(s)\n counted.add(t)\nprint(ans - 1 + zeros)\n', 'from math import gcd\n\nmod = 1000000007\n\nn = int(input())\ncounter = {}\nzeros = 0\nfor i in range(n):\n a, b = map(int, input().split())\n if (a == 0 and b == 0):\n zeros += 1\n continue\n g = gcd(a, b)\n a //= g\n b //= g\n if (b < 0):\n a = -a\n b = -b\n if (b == 0 and a < 0):\n a = -a\n rot90 = a <= 0\n if rot90:\n a, b = b, -a\n count = counter.get((a, b), [0, 0])\n if rot90:\n count[0] += 1\n else:\n count[1] += 1\n counter[(a, b)] = count\n\nans = 1\nfor k, pairs in counter.items():\n s_count = pairs[0]\n t_count = pairs[1]\n now = pow(2, s_count, mod)-1\n now += pow(2, t_count, mod)-1\n now += 1\n ans *= now\n ans %= mod\nprint((ans - 1 + zeros) % mod)\n'] | ['Wrong Answer', 'Accepted'] | ['s685636685', 's855524042'] | [90832.0, 60576.0] | [1856.0, 1073.0] | [824, 749] |
p02679 | u493520238 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nMOD = 10**9 + 7\n\n\ndef pow_k(x, n):\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n x%=MOD\n return K * x\n\n\nn = int(input())\n\na_b_d = {}\n# b_a_d = {}\n\nzero_cnt = 0\n\nfor i in range(n):\n a, b = map(int, input().split()) \n if a==0 or b==0:\n zero_cnt += 1\n else:\n gcd_ab = math.gcd(a,b)\n a = a//gcd_ab\n b = b//gcd_ab\n if a > 0 and b < 0:\n a *= -1\n b *= -1\n elif a < 0 and b < 0:\n a *= -1\n b *=-1\n a_b_d.setdefault((a,b),0)\n a_b_d[(a,b)] += 1\n\n\ndone_list = set()\npair_cnt = []\nuniq_cnt = 0\nfor k,v in a_b_d.items():\n comp_pair1 = (-k[1], k[0])\n comp_pair2 = (k[1], -k[0])\n if k in done_list:\n continue\n if comp_pair1 in a_b_d:\n \n done_list.add(comp_pair1)\n pair_cnt.append((v,a_b_d[comp_pair1]))\n elif comp_pair2 in a_b_d:\n \n done_list.add(comp_pair2)\n pair_cnt.append((v,a_b_d[comp_pair2]))\n else:\n uniq_cnt += 1\n\n\nans = pow_k(2,uniq_cnt) % MOD\nfor pair in pair_cnt:\n ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )\n ans%=MOD\n\nans *= (zero_cnt+1)\n# ans -= 1\nprint(ans%MOD)', 'import math\nMOD =1000000007\n\n\ndef pow_k(x, n):\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n x%=MOD\n return K * x\n\n\nn = int(input())\n\na_b_d = {}\n\na_zero_cnt = 0\nb_zero_cnt = 0\nab_zero_cnt = 0\n\nfor i in range(n):\n a, b = map(int, input().split()) \n if a==0 and b!=0:\n a_zero_cnt += 1\n elif a!=0 and b==0:\n b_zero_cnt += 1\n elif a == 0 and b == 0:\n ab_zero_cnt += 1\n else:\n gcd_ab = math.gcd(a,b)\n a = a//gcd_ab\n b = b//gcd_ab\n if a > 0 and b < 0:\n a *= -1\n b *= -1\n elif a < 0 and b < 0:\n a *= -1\n b *=-1\n a_b_d.setdefault((a,b),0)\n a_b_d[(a,b)] += 1\n\n\ndone_list = set()\npair_cnt = []\nuniq_cnt = 0\nfor k,v in a_b_d.items():\n comp_pair1 = (-k[1], k[0])\n comp_pair2 = (k[1], -k[0])\n if k in done_list:\n continue\n if comp_pair1 in a_b_d:\n done_list.add(comp_pair1)\n pair_cnt.append((v,a_b_d[comp_pair1]))\n elif comp_pair2 in a_b_d:\n done_list.add(comp_pair2)\n pair_cnt.append((v,a_b_d[comp_pair2]))\n else:\n uniq_cnt += 1\n\n\nans = pow_k(2,uniq_cnt) % MOD\nfor pair in pair_cnt:\n ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )\n ans%=MOD\n\nzero_m = max(pow_k(2,a_zero_cnt) + pow_k(2,b_zero_cnt) + ab_zero_cnt, 1)\nans *= zero_m\nans -= 1\nprint(ans%MOD)', 'import math\nMOD =1000000007\n\n\ndef pow_k(x, n):\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n x%=MOD\n return K * x\n\n\nn = int(input())\n\na_b_d = {}\n\na_zero_cnt = 0\nb_zero_cnt = 0\nab_zero_cnt = 0\n\nfor i in range(n):\n a, b = map(int, input().split()) \n if a==0 and b!=0:\n a_zero_cnt += 1\n elif a!=0 and b==0:\n b_zero_cnt += 1\n elif a == 0 and b == 0:\n ab_zero_cnt += 1\n else:\n gcd_ab = math.gcd(a,b)\n a = a//gcd_ab\n b = b//gcd_ab\n if a > 0 and b < 0:\n a *= -1\n b *= -1\n elif a < 0 and b < 0:\n a *= -1\n b *=-1\n a_b_d.setdefault((a,b),0)\n a_b_d[(a,b)] += 1\n\n\ndone_list = set()\npair_cnt = []\nuniq_cnt = 0\nfor k,v in a_b_d.items():\n comp_pair1 = (-k[1], k[0])\n comp_pair2 = (k[1], -k[0])\n if k in done_list:\n continue\n if comp_pair1 in a_b_d:\n done_list.add(comp_pair1)\n pair_cnt.append((v,a_b_d[comp_pair1]))\n elif comp_pair2 in a_b_d:\n done_list.add(comp_pair2)\n pair_cnt.append((v,a_b_d[comp_pair2]))\n else:\n uniq_cnt += v\n\nprint(a_b_d)\n\nans = pow_k(2,uniq_cnt) % MOD\nfor pair in pair_cnt:\n ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )\n ans%=MOD\n\nzero_m = max(pow_k(2,a_zero_cnt) + pow_k(2,b_zero_cnt) -1, 1)\nans *= zero_m\nans -= 1\nprint(ans%MOD)', 'import math\nMOD =1000000007\n\n\ndef pow_k(x, n):\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n x%=MOD\n return K * x\n\n\nn = int(input())\n\na_b_d = {}\n# b_a_d = {}\n\na_zero_cnt = 0\nb_zero_cnt = 0\nab_zero_cnt = 0\n\nfor i in range(n):\n a, b = map(int, input().split()) \n if a==0 and b!=0:\n a_zero_cnt += 1\n elif a!=0 and b==0:\n b_zero_cnt += 1\n elif a == 0 and b == 0:\n ab_zero_cnt += 1\n else:\n gcd_ab = math.gcd(a,b)\n a = a//gcd_ab\n b = b//gcd_ab\n if a > 0 and b < 0:\n a *= -1\n b *= -1\n elif a < 0 and b < 0:\n a *= -1\n b *=-1\n a_b_d.setdefault((a,b),0)\n a_b_d[(a,b)] += 1\n\n\ndone_list = set()\npair_cnt = []\nuniq_cnt = 0\nfor k,v in a_b_d.items():\n comp_pair1 = (-k[1], k[0])\n comp_pair2 = (k[1], -k[0])\n if k in done_list:\n continue\n if comp_pair1 in a_b_d:\n \n done_list.add(comp_pair1)\n pair_cnt.append((v,a_b_d[comp_pair1]))\n elif comp_pair2 in a_b_d:\n \n done_list.add(comp_pair2)\n pair_cnt.append((v,a_b_d[comp_pair2]))\n else:\n uniq_cnt += 1\n\n\nans = pow_k(2,uniq_cnt) % MOD\nfor pair in pair_cnt:\n ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )\n ans%=MOD\n\nzero_m = max(pow_k(2,a_zero_cnt) + pow_k(2,b_zero_cnt) -1, 1)\nprint(ans)\nans *= zero_m\n# ans *= (zero_cnt+1)\nans -= 1\nprint(ans%MOD)', 'import math\nMOD =1000000007\n\n\ndef pow_k(x, n):\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n x%=MOD\n return K * x\n\n\nn = int(input())\n\na_b_d = {}\n\na_zero_cnt = 0\nb_zero_cnt = 0\nab_zero_cnt = 0\n\nfor i in range(n):\n a, b = map(int, input().split()) \n if a==0 and b!=0:\n a_zero_cnt += 1\n elif a!=0 and b==0:\n b_zero_cnt += 1\n elif a == 0 and b == 0:\n ab_zero_cnt += 1\n else:\n gcd_ab = math.gcd(a,b)\n a = a//gcd_ab\n b = b//gcd_ab\n if a > 0 and b < 0:\n a *= -1\n b *= -1\n elif a < 0 and b < 0:\n a *= -1\n b *=-1\n a_b_d.setdefault((a,b),0)\n a_b_d[(a,b)] += 1\n\n\ndone_list = set()\npair_cnt = []\nuniq_cnt = 0\nfor k,v in a_b_d.items():\n comp_pair1 = (-k[1], k[0])\n comp_pair2 = (k[1], -k[0])\n if k in done_list:\n continue\n if comp_pair1 in a_b_d:\n done_list.add(comp_pair1)\n pair_cnt.append((v,a_b_d[comp_pair1]))\n elif comp_pair2 in a_b_d:\n done_list.add(comp_pair2)\n pair_cnt.append((v,a_b_d[comp_pair2]))\n else:\n uniq_cnt += v\n\n# print(a_b_d)\n\nans = pow_k(2,uniq_cnt) % MOD\nfor pair in pair_cnt:\n ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )\n ans%=MOD\n\nzero_m = max(pow_k(2,a_zero_cnt) + pow_k(2,b_zero_cnt) -1, 1)\nans *= zero_m\nans += ab_zero_cnt\nans -= 1\nprint(ans%MOD)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s026557161', 's804772827', 's823538762', 's865173290', 's170545640'] | [49016.0, 49236.0, 72828.0, 49292.0, 49172.0] | [865.0, 852.0, 959.0, 862.0, 869.0] | [1327, 1457, 1459, 1552, 1480] |
p02679 | u503228842 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['\n\nfrom collections import defaultdict\nfrom math import gcd\nN = int(input())\nMOD = 10**9 + 7\nd = defaultdict(lambda: [0, 0])\nzeros = 0\nfor _ in range(N):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zeros += 1\n elif x == 0:\n d[(0, 0)][0] += 1\n elif y == 0:\n d[(0, 0)][1] += 1\n else:\n if y < 0:\n x = -x\n y = -y\n g = gcd(abs(x), abs(y))\n x //= g\n y //= g\n if x < 0:\n d[(y, -x)][0] += 1\n else:\n d[(x, y)][1] += 1\nans = 1\nprint(d)\nfor k, v in d.items():\n ans *= pow(2, v[0], MOD)+pow(2, v[1], MOD)-1\n ans %= MOD\nans = (ans + zeros - 1) % MOD \nprint(ans)\n', '\n\nfrom collections import defaultdict\nfrom math import gcd\nN = int(input())\nMOD = 10**9 + 7\nd = defaultdict(lambda: [0, 0])\nzeros = 0\nfor _ in range(N):\n x, y = map(int, input().split())\n if x == 0 and y == 0:\n zeros += 1\n elif x == 0:\n d[(0, 0)][0] += 1\n elif y == 0:\n d[(0, 0)][1] += 1\n else:\n if y < 0:\n x = -x\n y = -y\n g = gcd(abs(x), abs(y))\n x //= g\n y //= g\n if x < 0:\n d[(y, -x)][0] += 1\n else:\n d[(x, y)][1] += 1\nans = 1\nfor k, v in d.items():\n ans *= pow(2, v[0], MOD)+pow(2, v[1], MOD)-1\n ans %= MOD\nans = (ans + zeros - 1) % MOD \nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s348847297', 's117229229'] | [84444.0, 60760.0] | [1138.0, 964.0] | [869, 860] |
p02679 | u515740713 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\nimport math\nmod = 1000000007\n \nn = int(sys.stdin.readline().rstrip())\nab = {}\nfor i in range(n):\n a,b = map(int,sys.stdin.readline().rstrip().split())\n if a == 0 and b == 0:\n pass\n elif a == 0:\n b = 1\n else:\n gcd = math.gcd(a,b)\n a //= gcd\n b //= gcd\n if a < 0:\n a = -a\n b = -b\n ab.setdefault((a,b),0)\n ab[(a,b)]+=1\nans = 0\npairs=[]\ns = list(set(ab.keys()))\nfor i in ab.keys():\n a = i[0];b = i[1]\n if a == 0 and b == 0:\n ans = ab[(0,0)]\n n -= ans\n else:\n if (-b, a) in s:\n pairs.append([ab[(a,b)],ab[(-b,a)]])\nselect = 1\nfor pair in pairs:\n select*= (pow(2,pair[0],mod) + pow(2,pair[1],mod) -1)\n n -= (pair[0]+pair[1])\n select %= mod \nselect *= pow(2,n,mod) + ans -1\nall_ans = select + ans -1\nall_ans %= mod\nprint(all_ans)', 'import sys\nimport math\nmod = 1000000007\n \nn = int(sys.stdin.readline().rstrip())\nab = {}\nfor i in range(n):\n a,b = map(int,sys.stdin.readline().rstrip().split())\n if a == 0 and b == 0:\n pass\n elif a == 0:\n b = 1\n else:\n gcd = math.gcd(a,b)\n a //= gcd\n b //= gcd\n if a < 0:\n a = -a\n b = -b\n ab.setdefault((a,b),0)\n ab[(a,b)]+=1\nans = 0\npairs=[]\ns = set(ab.keys())\nfor i in ab.keys():\n a = i[0];b = i[1]\n if a == 0 and b == 0:\n ans = ab[(0,0)]\n n -= ans\n else:\n if (-b, a) in s:\n pairs.append([ab[(a,b)],ab[(-b,a)]])\nselect = 1\nfor pair in pairs:\n select*= (pow(2,pair[0],mod) + pow(2,pair[1],mod) -1)\n n -= (pair[0]+pair[1])\nall_ans = (pow(2,n,mod) * select) % mod + ans -1\nall_ans %= mod\nprint(all_ans)'] | ['Wrong Answer', 'Accepted'] | ['s281986143', 's558819137'] | [59308.0, 59356.0] | [2207.0, 629.0] | [887, 831] |
p02679 | u559196406 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd \nn=int(input())\nmod = 10**9+7\ncount = {}\n\nfor _ in range(n):\n a,b = map(int,input().split())\n if a==0 and b==0:\n continue\n if a*b != 0:\n g=gcd(a,b)*b//abs(b)\n elif a != 0:\n g=a\n else:\n g=b\n \n x=a//g,b//g\n count[x]=count.get(x,0)+1\n \nmem=set()\nans=1\nfor (x,y),z in count.items():\n if (-1*x//abs(x)*y,abs(x)) in mem:\n continue\n mem.add((x,y))\n ans*=pow(2,z)+pow(2,count.get((-1*x//abs(x)*y,abs(x))),0)-1\n ans%=mod\n\nprint((ans-1)%mod)', 'from math import gcd \nn=int(input())\nmod = 10**9+7\ncount = {}\n\nfor _ in range(n):\n a,b = map(int,input().split())\n if a==0 and b==0:\n continue\n if a*b != 0:\n g=gcd(a,b)*b//abs(b)\n elif a != 0:\n g=a\n else:\n g=b\n \n x=a//g,b//g\n count[x]=count.get(x,0)+1\n \nmem=set()\nans=1\nfor (x,y),z in count.items():\n if (-1*x//abs(x)*y,abs(x)) in mem:\n continue\n mem.add((x,y))\n ans*=pow(2,z)+pow(2,count.get((-1*x//abs(x)*y,abs(x)),0)-1\n ans%=mod\n\nprint((ans-1)%mod)', 'from math import gcd \nn=int(input())\nmod = 10**9+7\ncount = {}\n\nnum=0\nfor _ in range(n):\n a,b = map(int,input().split())\n if a==0 and b==0:\n num+=1\n continue\n if a*b != 0:\n g=gcd(a,b)*(b//abs(b))\n elif a != 0:\n g=a\n else:\n g=b\n \n l=a//g,b//g\n count[l]=count.get(l,0)+1\n \nmem=set()\nans=1\nfor (x,y),z in count.items():\n if x*y==0:\n k=(y,x)\n else:\n k=(-1*x//abs(x)*y,abs(x))\n if k in mem:\n continue\n mem.add((x,y))\n ans*=(pow(2,z)+pow(2,count.get(k,0))-1)\n ans%=mod\n\nprint((ans+num-1)%mod)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s186363451', 's833761889', 's011352031'] | [46604.0, 9096.0, 72080.0] | [686.0, 24.0, 1075.0] | [534, 533, 594] |
p02679 | u588341295 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["import sys\nfrom collections import Counter\nfrom math import gcd\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN = INT()\nC = Counter()\nfor i in range(N):\n a, b = MAP()\n g = gcd(a, b)\n ga, gb = a // g, b // g\n C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1\n\nans = 1\nfor k, v in C.items():\n if v == 0:\n continue\n op, a, b = k\n ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1\n if (1-op, b, a) in C:\n C[(1-op, b, a)] = 0\nprint(ans)\n", "import sys\nfrom collections import Counter\nfrom math import gcd\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN = INT()\nC = Counter()\nzero = 0\nfor i in range(N):\n a, b = MAP()\n if a == b == 0:\n zero += 1\n elif a == 0:\n C[(0, 1, 0)] += 1\n elif b == 0:\n C[(1, 0, 1)] += 1\n else:\n g = gcd(a, b)\n ga, gb = a // g, b // g\n C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1\n\nans = 1\nfor k, v in C.items():\n if v == 0:\n continue\n op, a, b = k\n ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1\n ans %= MOD\n if (1-op, b, a) in C:\n C[(1-op, b, a)] = 0\nprint((zero+ans-1)%MOD)\n"] | ['Runtime Error', 'Accepted'] | ['s010036282', 's866460717'] | [46716.0, 46880.0] | [1514.0, 949.0] | [1080, 1263] |
p02679 | u588794534 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['n=int(input())\n\nmod=10**9+7\n\n\nfrom collections import defaultdict\npp = defaultdict(lambda: 0) \npm = defaultdict(lambda: 0) \n\nfrom math import gcd\nzero=0\nfor _ in range(n):\n a,b=map(int,input().split())\n\n if a==0 and b==0:\n zero+=1\n elif a*b>0:\n tmp=gcd(a,b)\n a=a//tmp\n b=b//tmp\n pp[(a,b)]+=1\n elif a==0:\n pp[(1,0)]+=1\n elif n==0:\n pm[(0,1)]+=1\n else:\n tmp=gcd(abs(a),abs(b))\n a=abs(a//tmp)\n b=abs(b//tmp)\n pm[(b,a)]+=1\n \n \nresult=1\nfor key in pp.keys():\n pp_v=pp[key]\n pm_v=pm[key]\n result*=(pow(2,pm_v,mod)+pow(2,pp_v,mod)-1)\n result%=mod\n\nprint((result-1+zero)%mod)\n\n\n \n\n ', 'n=int(input())\n\nmod=10**9+7\n\n\nfrom collections import defaultdict\npp = defaultdict(lambda: 0) \npm = defaultdict(lambda: 0) \n\ndef seiki(x,y):\n tmp=gcd(x,y)\n return (x//tmp,y//tmp)\n\nfrom math import gcd\nzero=0\nfor _ in range(n):\n a,b=map(int,input().split())\n\n if a==0 and b==0:\n zero+=1\n elif a*b>0:\n tmp=seiki(abs(a),abs(b))\n pp[tmp]+=1\n elif a==0:\n pp[(1,0)]+=1\n elif b==0:\n pm[(1,0)]+=1\n pp[(1,0)]+=0\n else:\n tmp=seiki(abs(b),abs(a))\n pm[tmp]+=1\n pp[tmp]+=0\n#print(pm)\n#print(pp)\nresult=1\nfor key in pp.keys():\n pp_v=pp[key]\n pm_v=pm[key]\n result*=(pow(2,pm_v,mod)+pow(2,pp_v,mod)-1)\n result%=mod\n\nprint((result-1+zero)%mod)\n\n\n \n\n '] | ['Wrong Answer', 'Accepted'] | ['s973419824', 's522555058'] | [54916.0, 62724.0] | [883.0, 1030.0] | [732, 761] |
p02679 | u619819312 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from fractions import gcd\nfrom collections import defaultdict as d\nn=int(input())\nm=10**9+7\ns=d(lambda:[0,0])\np=-1\nfor i in range(n):\n a,b=map(int,input().split())\n if a==b==0:p+=1\n else:\n g=gcd(a,b)\n a=a//g\n b=b//g\n if a<0 or a==0<b:\n a,b=-a,-b\n if b<0:s[(a,-b)][1]+=1\n else:s[(a,b)][0]+=1\nq=1\nfor i in s:\n k,l=s[i]\n q=q*(pow(k,2,m)+pow(l,2,m)-1)%m\nprint((q+p)%m)', 'from math import gcd\nfrom collections import defaultdict as d\nn=int(input())\nm=10**9+7\ns=d(lambda:[0,0])\np=-1\nfor i in range(n):\n a,b=map(int,input().split())\n if a==b==0:p+=1\n else:\n g=gcd(a,b)\n a=a//g\n b=b//g\n if a<0 or a==0<b:a,b=-a,-b\n if b<0:s[(-b,a)][1]+=1\n else:s[(a,b)][0]+=1\nq=1\nfor i in s:\n k,l=s[i]\n q=q*(pow(2,k,m)+pow(2,l,m)-1)%m\nprint((q+p)%m)'] | ['Wrong Answer', 'Accepted'] | ['s415559537', 's741827825'] | [36036.0, 60588.0] | [991.0, 1016.0] | [440, 414] |
p02679 | u627600101 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from collections import defaultdict\nfrom math import gcd\nN = int(input())\nMOD = 10**9 + 7\nL = defaultdict(lambda: [0,0])\nzero = 0\nfor _ in range(N):\n A, B = map(int, input().split())\n if A==0: d=B\n elif B==0: d=A\n else: d=gcd(A,B)\n if d != 0:\n A, B = A//d, B//d\n if A<0: A, B = -A, -B\n if B>0: L[(A,B)][0] += 1\n else: L[(-B,A)][1] += 1\n else: zero += 1\nprint(L)\nres = 1\n\nfor x,y in L.values():\n res *= pow(2,x,MOD) + pow(2,y,MOD) -1\n res %= MOD\nprint((res+zero-1)%MOD)\n\n', 'N = int(input())\nmod = 10 **9 + 7\n\ndef equal(item0, item1, delta = 10 ** (-24)):\n if abs(item0 - item1) < delta:\n return True\n else:\n return False\ndef bigger(item0, item1, delta = 10** (-24)):\n if item0 -item1 > delta:\n return True\n else:\n return False\n\nab = []\nba = []\nzero = 0\nfrom bisect import insort\nfor _ in range(N):\n A, B = map(int, input().split())\n if A*B == 0:\n if A == 0 and B == 0:\n zero += 1\n elif A == 0 and B != 0:\n ab = [0] + ab\n else:\n ba = [0] + ba\n elif A*B > 0:\n insort(ab, A/B)\n else:\n insort(ba, -B/A)\ndef make_count(list):\n k = 0\n lis = []\n while k < len(list):\n cnt = 1\n while k+1 < len(list):\n if equal(list[k],list[k+1]):\n cnt += 1\n k += 1\n continue\n else:\n break\n lis.append([list[k], cnt])\n k += 1\n return lis\n\nab = make_count(ab)\nba = make_count(ba)\nfrom collections import deque\nab = deque(ab)\nba = deque(ba)\nans = 1 #all pattern\nflag = True\npair = []\nif len(ab) == 0:\n print(pow(2, N-zero, mod)+zero-1)\n exit()\nif len(ba) == 0:\n print(pow(2, N-zero, mod)+ zero -1)\n exit()\n\n\nwhile True:\n if flag:\n a = ab.popleft()\n b = ba.popleft()\n flag = False\n if equal(a[0], b[0]):\n pair.append([a[1], b[1]])\n if ab:\n a = ab.popleft()\n else:\n a = [-1, 0]\n if ba:\n b = ba.popleft()\n else:\n b = [-1, 0]\n if a[0] == b[0] == -1:\n break\n elif bigger(a[0], b[0]):\n if ba:\n pair.append([0,b[1]])\n b = ba.popleft()\n continue\n elif ab:\n pair.append([a[1],0])\n a = ab.popleft()\n b = [-1, 0]\n continue\n else:\n if a[0] != -1:\n pair.append([a[1], 0])\n if b[0]!= -1:\n pair.append([0, b[1]])\n break\n else:\n if ab:\n pair.append([a[1], 0])\n a = ab.popleft()\n continue\n elif ba:\n pair.append([0, b[1]])\n b = ba.popleft()\n a = [-1, 0]\n else:\n if a[0] != -1:\n pair.append([a[1], 0])\n if b[0]!= -1:\n pair.append([0, b[1]])\n break\nans = 1\nprint(pair)\nfor item in pair:\n ans *= pow(2, item[0], mod) + pow(2, item[1], mod) -1\n ans %= mod\nans += zero-1\nans %= mod\nprint(ans)\n\n\n', 'from collections import defaultdict\nfrom math import gcd\nN = int(input())\nMOD = 10**9 + 7\nL = defaultdict(lambda: [0,0])\nzero = 0\nfor _ in range(N):\n A, B = map(int, input().split())\n if A==0: d=B\n elif B==0: d=A\n else: d=gcd(A,B)\n if d != 0:\n A, B = A//d, B//d\n if A<0: A, B = -A, -B\n if B>0: L[(A,B)][0] += 1\n else: L[(-B,A)][1] += 1\n else: zero += 1\n\nres = 1\n\nfor x,y in L.values():\n res *= pow(2,x,MOD) + pow(2,y,MOD) -1\n res %= MOD\nprint((res+zero-1)%MOD)\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s332492684', 's608297791', 's378111658'] | [84432.0, 17996.0, 60604.0] | [1101.0, 2206.0, 970.0] | [522, 2569, 514] |
p02679 | u638456847 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from fractions import Fraction\nfrom collections import Counter\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\nMOD = 10**9+7\n\ndef main():\n N,*ab = map(int, read().split())\n\n ab_zero = 0\n a_zero = 0\n b_zero = 0\n ratio = []\n for a, b in zip(*[iter(ab)]*2):\n if a == 0 and b == 0:\n ab_zero += 1\n elif a == 0:\n a_zero += 1\n elif b == 0:\n b_zero += 1\n else:\n ratio.append(Fraction(a, b))\n \n s = Counter(ratio)\n\n bad = pow(2, a_zero, MOD) * pow(2, b_zero, MOD) - 1\n bad %= MOD\n for k, v in s.items():\n if - 1 / k in s:\n if s[k] != 0:\n bad *= (pow(2, v, MOD) + pow(2, s[-1/k], MOD) -1) % MOD\n bad %= MOD\n s[- 1 / k] = 0\n else:\n bad *= pow(2, v, MOD)\n bad %= MOD\n\n ans = bad - 1 + ab_zero\n print(ans)\n \n\nif __name__ == "__main__":\n main()\n', 'from math import gcd\nfrom collections import Counter\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\nMOD = 10**9+7\n\ndef main():\n N,*ab = map(int, read().split())\n\n ab_zero = 0\n ratio = []\n for a, b in zip(*[iter(ab)]*2):\n if a == 0 and b == 0:\n ab_zero += 1\n else:\n if b < 0:\n a, b = -a, -b\n if b == 0:\n a = 1\n g = gcd(a, b)\n a //= g\n b //= g\n ratio.append((a, b))\n \n s = Counter(ratio)\n\n bad = 1\n no_pair = 0\n for k, v in s.items():\n a, b = k\n if a > 0:\n if (-b, a) in s:\n bad *= pow(2, v, MOD) + pow(2, s[(-b, a)], MOD) -1\n bad %= MOD\n else:\n no_pair += v\n \n elif (b, -a) not in s:\n no_pair += v\n\n bad *= pow(2, no_pair, MOD)\n bad %= MOD\n\n ans = (bad + ab_zero -1) % MOD\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s483654112', 's105318732'] | [61468.0, 72596.0] | [2207.0, 409.0] | [988, 1043] |
p02679 | u667084803 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math \n\nMOD = 10**9 + 7\nN = int(input())\nABC = []\nfor i in range(N):\n a, b = map(int, input().split())\n if a * b >=0 and a > 0:\n ABC.append([ math.atan2(abs(b),abs(a)), abs(a), abs(b),1])\n else:\n ABC.append([math.atan2(abs(a),abs(b)), abs(b), abs(a), -1])\nABC.sort()\nprint(ABC)\ncurrent_arg = ABC[-1][0]\ngroup = []\ndaiich = 0\ndaini = 0\nwhile ABC:\n current = ABC.pop()\n if current[0] == current_arg:\n if current[3]==1:\n daiich += 1\n else:\n daini += 1\n else:\n group += [[daiich, daini]]\n daiich = 0\n daini = 0\n if current[3]==1:\n daiich += 1\n else:\n daini += 1\n if ABC:\n current_arg = ABC[-1][0]\nelse:\n group += [[daiich, daini]]\n daiich = 0\n daini = 0\n\nans = -1\nfor u, v in group:\n ans *= (2**u + 2**v -1)\n ans %= MOD\nprint(ans)', 'from math import gcd \nfrom collections import defaultdict\n\ndef to_irreducible(a, b):\n if a == 0:\n return [0, 1]\n GCD = gcd(a, b)\n return [a//GCD, b//GCD]\n\nMOD = 10**9 + 7\nN = int(input())\ndaiichi_dict = defaultdict(int)\ndaini_dict = defaultdict(int)\nzero_cases = 0\n\nfor i in range(N):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n zero_cases += 1\n elif a * b >=0 and b != 0:\n a, b = to_irreducible(abs(a), abs(b))\n daiichi_dict[(a,b)] += 1\n else:\n a, b = to_irreducible(abs(b), abs(a))\n daini_dict[(a,b)] += 1\n daiichi_dict[(a,b)] += 0\n\n\nans = 1 \nfor key, value_daiichi in daiichi_dict.items():\n value_daini = daini_dict[key]\n ans *= (2**value_daiichi + 2**value_daini -1)\n ans %= MOD\nprint((ans+zero_cases-1) % MOD)'] | ['Wrong Answer', 'Accepted'] | ['s061634882', 's384916435'] | [82628.0, 69080.0] | [1352.0, 956.0] | [890, 807] |
p02679 | u674959776 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import functools\nMOD=10**9+7\n\ndef euclid(a, b):\n if b == 0:\n return a\n else:\n return euclid(b, a%b)\n\ndef gcd(nums):\n return functools.reduce(euclid, nums)\n\nn=int(input())\nt=[]\nfor i in range(n):\n a,b=map(int,input().split())\n t.append((a,b))\nz=0\ny={}\nfor i in range(n):\n if t[i][0]==0 and t[i][1]==0:\n z+=1\n else:\n g=abs(gcd([t[i][0],t[i][1]]))\n if t[i][1]==0:\n a=(1,0)\n elif t[i][1]>0:\n a=(t[i][0]//g , t[i][1]//g)\n else:\n a=(-t[i][0]//g , -t[i][1]//g)\n if a not in y:\n y[a]=1\n else:\n y[a]+=1\n\ncnt=0\nx=1\nfor i in y:\n if (-i[1],i[0]) in y:\n x *= pow(2,y[(-i[1],i[0])],MOD) + pow(2,y[(i[0],i[1])],MOD)-1\n cnt+= y[(-i[1],i[0])] + y[(i[0],i[1])]\n\nans = pow(2,n-z-cnt,MOD) *x -1\nprint(x+z)', 'MOD=10**9+7\nn=int(input())\np=[]\nm=[]\nfor i in range(n):\n a,b=map(int,input().split())\n if a*b<0:\n m.append(a*b)\n else:\n p.append(a*b)\nm.sort()\np=sorted(p,reverse=True)\nr=0\nl=0\ncnt=0\nwhile l<len(m) and r<len(p):\n if p[r]+m[l]>0:\n l+=1\n elif p[r]+m[l]<0:\n r+=1\n else:\n print(0)\n cnt+=1\n if len(m)-l<len(p)-r:\n r+=1\n else:\n l+=1\nif l==len(m):\n cnt+=p.count(m[-1])\nelse:\n cnt+=m.count(p[-1])\nprint(cnt)\nans=(pow(2,n,MOD)-1-pow(2,n-2,MOD)*cnt)%MOD\n\nprint(ans)', 'import functools\nMOD=10**9+7\n\ndef euclid(a, b):\n if b == 0:\n return a\n else:\n return euclid(b, a%b)\n\ndef gcd(nums):\n return functools.reduce(euclid, nums)\n\nn=int(input())\nt=[]\nfor i in range(n):\n a,b=map(int,input().split())\n t.append((a,b))\nz=0\ny={}\nfor i in range(n):\n if t[i][0]==0 and t[i][1]==0:\n z+=1\n else:\n g=abs(gcd([t[i][0],t[i][1]]))\n if t[i][1]==0:\n a=(1,0)\n elif t[i][1]>0:\n a=(t[i][0]//g , t[i][1]//g)\n else:\n a=(-t[i][0]//g , -t[i][1]//g)\n if a not in y:\n y[a]=1\n else:\n y[a]+=1\n\ncnt=0\nx=1\nfor i in y:\n if (-i[1],i[0]) in y:\n x *= pow(2,y[(-i[1],i[0])],MOD) + pow(2,y[(i[0],i[1])],MOD)-1\n cnt+= y[(-i[1],i[0])] + y[(i[0],i[1])]\n\nans = pow(2,n-z-cnt,MOD) *x -1\nprint((ans+z)%MOD)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s091559306', 's793247682', 's708029547'] | [74000.0, 21308.0, 73824.0] | [1728.0, 535.0, 1730.0] | [828, 556, 837] |
p02679 | u677523557 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\ninput = sys.stdin.readline\nimport math\n\nmod = 10**9+7\n\nN = int(input())\nAs = {}\nEmpty = 0\nfor _ in range(N):\n x, y = map(int, input().split())\n g = math.gcd(x, y)\n x, y = x//g, y//g\n if x == 0 and y == 0:\n Empty += 1\n else:\n if y < 0 or (y==0 and x < 0):\n y = -y\n if (x, y) in As:\n As[(x, y)] += 1\n else:\n As[(x, y)] = 1\n\nM = N - Empty\nans = 1\nfor (x, y), num in As.items():\n if (-y, x) in As:\n if x > 0:\n ans = (ans * (pow(2, num, mod) + pow(2, As[(-y, x)], mod) - 1)) % mod\n elif not (y, -x) in As:\n ans = (ans * pow(2, num, mod)) % mod\n\nprint((ans-1)%mod)', 'import sys\ninput = sys.stdin.readline\nimport math\n\nmod = 10**9+7\n\nN = int(input())\nAs = {}\nEmpty = 0\nfor _ in range(N):\n x, y = map(int, input().split())\n g = math.gcd(x, y)\n if g == 0:\n Empty += 1\n continue\n x, y = x//g, y//g\n if y < 0 or (y==0 and x < 0):\n y = -y\n x = -x\n if (x, y) in As:\n As[(x, y)] += 1\n else:\n As[(x, y)] = 1\n\nans = 1\nfor (x, y), num in As.items():\n if (-y, x) in As:\n ans = (ans * (pow(2, num, mod) + pow(2, As[(-y, x)], mod) - 1)) % mod\n elif not (y, -x) in As:\n ans = (ans * pow(2, num, mod)) % mod\n\nprint((ans-1+Empty)%mod)'] | ['Runtime Error', 'Accepted'] | ['s325040544', 's906923630'] | [46336.0, 46196.0] | [653.0, 725.0] | [676, 633] |
p02679 | u695811449 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\nimport io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nfrom collections import Counter\nfrom fractions import Fraction\n\nN=int(input())\nmod=10**9+7\n\nS=[tuple(map(int,input().split())) for i in range(N)]\n\ndef main():\n C=Counter()\n PLUS=0\n for a,b in S:\n if a==0 and b==0:\n PLUS+=1\n elif b!=0:\n C[Fraction(a,b)]+=1\n else:\n C[float("inf")]+=1\n \n ANS=1\n\n for x in list(C.keys()):\n if x!=float("inf") and x!=Fraction(0,1):\n n=x.numerator\n d=x.denominator\n\n ANS=ANS*(pow(2,C[x],mod)+pow(2,C[Fraction(-d,n)],mod)-1)%mod\n\n C[x]=0\n C[Fraction(-d,n)]=0\n \n else:\n ANS=ANS*(pow(2,C[float("inf")],mod)+pow(2,C[Fraction(0,1)],mod)-1)%mod\n\n C[float("inf")]=0\n C[Fraction(0,1)]=0\n\n print((ANS-1+PLUS)%mod)\n\nmain()\n \n', 'import sys\ninput = sys.stdin.readline\n\nN=int(input())\nmod=10**9+7\n\nS=[tuple(map(int,input().split())) for i in range(N)]\n\nfrom collections import Counter\nfrom fractions import Fraction\nC=Counter()\n\nfor a,b in S:\n if a==0 and b==0:\n continue\n if b!=0:\n C[Fraction(a,b)]+=1\n else:\n C[float("inf")]+=1\n \nANS=1\nprint(C)\nfor x in list(C.keys()):\n if x!=float("inf") and x!=Fraction(0,1):\n n=x.numerator\n d=x.denominator\n\n ANS=ANS*(pow(2,C[x],mod)+pow(2,C[Fraction(-d,n)],mod)-1)%mod\n\n C[x]=0\n C[Fraction(-d,n)]=0\n \n else:\n ANS=ANS*(pow(2,C[float("inf")],mod)+pow(2,C[Fraction(0,1)],mod)-1)%mod\n\n C[float("inf")]=0\n C[Fraction(0,1)]=0\n\nprint((ANS-1)%mod)', 'import sys\ninput = sys.stdin.readline\nfrom collections import Counter\nfrom fractions import Fraction\nfrom math import gcd\n\nN=int(input())\nmod=10**9+7\n\nS=[tuple(map(int,input().split())) for i in range(N)]\n\ndef main():\n C=Counter()\n PLUS=0\n for a,b in S:\n if a==0 and b==0:\n PLUS+=1\n elif a==0:\n C[(0,1)]+=1\n elif b!=0 and a>0:\n C[(a//gcd(a,b),b//gcd(a,b))]+=1\n elif b!=0 and a<0:\n C[(-a//gcd(a,b),-b//gcd(a,b))]+=1\n \n else:\n C[float("inf")]+=1\n \n ANS=1\n\n #print(C)\n\n for x in list(C.keys()):\n if x!=float("inf") and x!=(0,1):\n\n a,b=x\n\n if b>0:\n ANS=ANS*(pow(2,C[x],mod)+pow(2,C[(b,-a)],mod)-1)%mod\n C[(b,-a)]=0\n else:\n ANS=ANS*(pow(2,C[x],mod)+pow(2,C[(-b,a)],mod)-1)%mod\n C[(-b,a)]=0\n \n C[x]=0\n\n \n else:\n ANS=ANS*(pow(2,C[float("inf")],mod)+pow(2,C[(0,1)],mod)-1)%mod\n\n C[float("inf")]=0\n C[(0,1)]=0\n\n print((ANS-1+PLUS)%mod)\n\nmain()\n \n'] | ['Time Limit Exceeded', 'Wrong Answer', 'Accepted'] | ['s363902345', 's849164147', 's089840464'] | [53544.0, 45928.0, 109032.0] | [2207.0, 2207.0, 1057.0] | [923, 750, 1146] |
p02679 | u708255304 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import degrees, atan2\nfrom collections import defaultdict\n\nMOD = 10**9+7\nN = int(input())\n\n\n\npoints = [list(map(int, input().split())) for _ in range(N)]\ntmp = defaultdict(int)\nhoge = defaultdict(lambda: defaultdict(int))\nfor i in range(N):\n a, b = points[i] \n v = degrees(atan2(b, a))\n if v > 0:\n tmp[degrees(atan2(b, a)) % -90] += 1\n tmp[degrees(atan2(b, a)) % 90] += 1\n else:\n tmp[degrees(atan2(b, a)) % -90] += 1\n tmp[degrees(atan2(b, a)) % 90] += 1\n\n\n\n\n\nans = pow(2, N, MOD)\nprint(ans)\nfor k, v in tmp.items():\n if k > 0:\n ans -= v * tmp[k%(-90)]\n else:\n ans -= v * tmp[k%(90)]\nprint(ans-1)\n', 'from math import gcd\nMOD = 10**9+7\nN = int(input())\nd = {}\nzero = 0\nfor _ in range(N):\n a, b = map(int, input().split())\n if a == b == 0:\n zero += 1\n continue\n \n if b < 0:\n b = -b\n a = -a\n g = gcd(a, b)\n b //= g\n a //= g\n \n if b == 0 and a == -1:\n a = 1\n\n \n \n if a > 0:\n if (a, b) in d:\n d[(a, b)][0] += 1\n else:\n d[(a, b)] = [1, 0]\n else:\n \n if (b, -a) in d:\n d[(b, -a)][1] += 1\n else:\n d[(b, -a)] = [0, 1]\n\nans = 1\nfor (a, b), (k, l) in d.items():\n ans *= (pow(2, k, MOD)-1 + pow(2, l, MOD)-1 + 1) \n ans %= MOD\nans -= 1\nans += zero\nans %= MOD\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s743334052', 's272800764'] | [87588.0, 60404.0] | [889.0, 968.0] | [893, 959] |
p02679 | u709304134 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nMOD = 1000000007\nN = int(input())\nd_p = dict()\nd_m = dict()\nzz = 0 # a=b=0\nfor n in range(N):\n a,b = map(int,input().split())\n if a==0 and b==0:\n zz += 1\n continue\n if a==0:\n n_sign = 0\n elif b==0:\n n_sign = 1\n \n else: \n n_sign = ((a<0) + (b<0))%2\n a = abs(a)\n b = abs(b)\n gcd = math.gcd(a,b)\n a//=gcd\n b//=gcd\n \n\n #print(n_sign,a,b)\n # print(n_sign,a,b)\n\n\n if n_sign==1:\n s =str(b/a)\n d_m[s] = d_m.get(s,0) + 1\n elif n_sign==0:\n s =str(a/b)\n d_p[s] = d_p.get(s,0) + 1 \n \nprint (d_p,d_m)\n\nans = 1\nfor k,v in d_m.items():\n if k in d_p:\n ans *= (2**v + 2**d_p[k] - 1)\n \n d_p.pop(k)\n else:\n ans *= 2**v\n ans %= MOD\n\nfor k,v in d_p.items():\n ans *= 2**v\n ans %= MOD\nans -= 1\nans += zz\nans %= MOD\nprint (ans)\n', "import math\nMOD = 1e+9+7\nN = int(input())\n\nd_p = dict()\nd_m = dict()\nans = 1\nzz = 0\n\nfor n in range(N):\n a,b = map(int,input().split())\n\n if a==0 and b==0:\n zz += 1\n continue\n if a==0:\n n_sign = 0\n b = 0\n elif b==0:\n n_sign = 1\n a = 0\n\n else: \n n_sign = ((a<0) + (b<0))%2\n a = abs(a)\n b = abs(b)\n gcd = math.gcd(a,b)\n a//=gcd\n b//=gcd\n\n if n_sign==1:\n s =str(b)+'/'+str(a)\n d_m[s] = d_m.get(s,0) + 1\n elif n_sign==0:\n s =str(a)+'/'+str(b)\n d_p[s] = d_p.get(s,0) + 1 \n\nfor k,v in d_m.items():\n if k in d_p:\n ans *= (2**v + 2**d_p[k] - 1)\n d_p.pop(k)\n else:\n ans *= 2**v\n ans %= MOD\n\nfor k,v in d_p.items():\n ans *= 2**v\n ans %= MOD\n \nans -= 1\nans += zz\nans %= MOD\nprint (ans)\n", "import math\nMOD = 1000000007\nN = int(input())\nd_p = dict()\nd_m = dict()\nzz = 0\nfor n in range(N):\n a,b = map(int,input().split())\n\n if a==0 and b==0:\n zz += 1\n continue\n if a==0:\n n_sign = 1\n a=0\n b=0\n elif b==0:\n n_sign = 0\n a=0\n b=0 \n\n\n else: \n n_sign = ((a<0) + (b<0))%2\n a = abs(a)\n b = abs(b)\n gcd = math.gcd(a,b)\n a//=gcd\n b//=gcd\n #print(n_sign,a,b)\n\n \n\n if n_sign==1:\n s =str(b)+'/'+str(a)\n d_m[s] = d_m.get(s,0) + 1\n elif n_sign==0:\n s =str(a)+'/'+str(b)\n d_p[s] = d_p.get(s,0) + 1 \n \nprint (d_m,d_p)\n\nans = 1\nfor k,v in d_m.items():\n if k in d_p:\n ans *= (2**v + 2**d_p[k] - 1)\n \n d_p.pop(k)\n else:\n ans *= 2**v\n ans %= MOD\n\nfor k,v in d_p.items():\n ans *= 2**v\n ans %= MOD\nans -= 1\nans += zz\nans %= MOD\nprint (ans)\n", 'import math\nMOD = 1000000007\nN = int(input())\nd_p = dict()\nd_m = dict()\nzz = 0\nfor n in range(N):\n a,b = map(int,input().split())\n\n if a==0 and b==0:\n zz += 1\n continue\n if a==0:\n n_sign = 0\n elif b==0:\n n_sign = 1\n \n else: \n n_sign = ((a<0) + (b<0))%2\n a = abs(a)\n b = abs(b)\n gcd = math.gcd(a,b)\n a//=gcd\n b//=gcd\n \n\n #print(n_sign,a,b)\n # print(n_sign,a,b)\n\n\n if n_sign==1:\n s =str(b/a)\n d_m[s] = d_m.get(s,0) + 1\n elif n_sign==0:\n s =str(a/b)\n d_p[s] = d_p.get(s,0) + 1 \n \nprint (d_p,d_m)\n\nans = 1\nfor k,v in d_m.items():\n if k in d_p:\n ans *= (2**v + 2**d_p[k] - 1)\n \n d_p.pop(k)\n else:\n ans *= 2**v\n ans %= MOD\n\nfor k,v in d_p.items():\n ans *= 2**v\n ans %= MOD\nans -= 1\nans += zz\nans %= MOD\nprint (ans)\n', "import math\nMOD = 1000000007\nN = int(input())\n\nd_p = dict()\nd_m = dict()\nans = 1\nzz = 0\n\nfor n in range(N):\n a,b = map(int,input().split())\n\n if a==0 and b==0:\n zz += 1\n continue\n if a==0:\n n_sign = 0\n b = 0\n elif b==0:\n n_sign = 1\n a = 0\n\n else: \n n_sign = ((a<0) + (b<0))%2\n a = abs(a)\n b = abs(b)\n gcd = math.gcd(a,b)\n a//=gcd\n b//=gcd\n\n if n_sign==1:\n s =str(b)+'/'+str(a)\n d_m[s] = d_m.get(s,0) + 1\n elif n_sign==0:\n s =str(a)+'/'+str(b)\n d_p[s] = d_p.get(s,0) + 1 \n\nfor k,v in d_m.items():\n if k in d_p:\n ans *= (2**v + 2**d_p[k] - 1)\n d_p.pop(k)\n else:\n ans *= 2**v\n ans %= MOD\n\nfor k,v in d_p.items():\n ans *= 2**v\n ans %= MOD\n\nans -= 1\nans += zz\nans %= MOD\nprint (ans)\n"] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s467425363', 's669028519', 's709358412', 's973248577', 's993519410'] | [39872.0, 38184.0, 49508.0, 39788.0, 38220.0] | [972.0, 910.0, 968.0, 1000.0, 871.0] | [909, 855, 938, 902, 855] |
p02679 | u745514010 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['\nfrom collections import Counter\nmod = 1000000007\n\nn = int(input())\na_div_b = []\na_0 = 0\nb_0 = 0\na_b_0 = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 or b == 0:\n if a == 0 and b == 0:\n a_b_0 += 1\n elif a == 0:\n a_0 += 1\n else b == 0:\n b_0 += 1\n continue\n if a * b < 0:\n a_div_b.append(a/b)\n else:\n a_div_b.append(b/a)\n\ncnt = Counter(a_div_b)\ncnt2 = sorted(cnt.items())\nlst = []\ntotal = 0\nfor num, _ in cnt2:\n if num > 0:\n break\n a1 = cnt[num]\n a2 = cnt[-num]\n if a1 * a2 != 0:\n total += a1 + a2\n lst.append([a1, a2])\nif a_0 > 0 and b_0 > 0:\n total += a_0 + b_0\n lst.append([a_0, b_0])\nn -= a_b_0\nans = pow(2, n - total, mod)\nfor a, b in lst:\n ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod\nans = (ans - 1 + a_b_0) % mod\n \nprint(ans)\n \n', 'from collections import Counter\nmod = 1000000007\n\nn = int(input())\na_div_b = []\na_0 = 0\nb_0 = 0\na_b_0 = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 or b == 0:\n if a == 0 and b == 0:\n a_b_0 += 1\n elif a == 0:\n a_0 += 1\n else b == 0:\n b_0 += 1\n continue\n if a * b < 0:\n a_div_b.append(a/b)\n else:\n a_div_b.append(b/a)\n\ncnt = Counter(a_div_b)\ncnt2 = sorted(cnt.items())\nlst = []\ntotal = 0\nfor num, _ in cnt2:\n if num > 0:\n break\n a1 = cnt[num]\n a2 = cnt[-num]\n if a1 * a2 != 0:\n total += a1 + a2\n lst.append([a1, a2])\nif a_0 > 0 and b_0 > 0:\n total += a_0 + b_0\n lst.append([a_0, b_0])\nn -= a_b_0\nans = pow(2, n - total, mod)\nfor a, b in lst:\n ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod\nans = (ans - 1 + a_b_0) % mod\n \nprint(ans)\n \n', 'from collections import defaultdict\nfrom math import gcd\nmod = 1000000007\n\nn = int(input())\nplus = defaultdict(int)\nminus = defaultdict(int)\na_0 = 0\nb_0 = 0\na_b_0 = 0\nxxx = 10 ** 10\nfor _ in range(n):\n a, b = map(int, input().split())\n if a == 0 or b == 0:\n if a == 0 and b == 0:\n a_b_0 += 1\n elif a == 0:\n a_0 += 1\n else:\n b_0 += 1\n continue\n g = gcd(a, b)\n a //= g\n b //= g\n if a * b < 0:\n minus[(abs(a), abs(b))] += 1\n else:\n plus[(abs(b), abs(a))] += 1\n\ntotal = 0\nlst = []\nfor num, _ in minus.items():\n a1 = minus[num]\n a2 = plus[num]\n if a1 * a2 != 0:\n total += a1 + a2\n lst.append([a1, a2])\nif a_0 > 0 and b_0 > 0:\n total += a_0 + b_0\n lst.append([a_0, b_0])\nn -= a_b_0\nans = pow(2, n - total, mod)\nfor a, b in lst:\n ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod\nans = (ans - 1 + a_b_0) % mod\n \nprint(ans)\n \n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s192968487', 's719627194', 's928693755'] | [9052.0, 8964.0, 55076.0] | [20.0, 20.0, 763.0] | [902, 901, 960] |
p02679 | u764956288 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["from sys import stdin\nfrom collections import defaultdict\nfrom math import gcd\n\n\ndef main():\n MOD = 1000000007\n\n N, *AB = map(int, stdin.buffer.read().split())\n\n d = defaultdict(int)\n n_zeros = 0\n\n for a, b in zip(AB[::2], AB[1::2]):\n if a == 0 and b == 0:\n n_zeros += 1\n continue\n\n g = gcd(a, b)\n a, b = a // g, b // g\n\n if a * b > 0 or b == 0:\n c = (abs(a), abs(b))\n else:\n c = (-abs(b), -abs(a))\n\n d[c] += 1\n\n ans = 1\n n_not_paired = 0\n for ab, n in d.items():\n ab_pair = (-ab[1], -ab[0])\n if ab_pair in d:\n if ab[0] > 0:\n m = d[ab_pair]\n ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD\n else:\n n_not_paired += n\n\n ans = (ans * pow(2, n_not_paired, MOD) + n_zeros - 1) % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "from sys import stdin\nfrom collections import defaultdict\nfrom math import gcd\n\n\ndef main():\n MOD = 1000000007\n\n N, *AB = map(int, stdin.buffer.read().split())\n\n d = defaultdict(int)\n n_zeros = 0\n\n for a, b in zip(AB[::2], AB[1::2]):\n if a == 0 and b == 0:\n n_zeros += 1\n continue\n\n g = gcd(a, b)\n a, b = a // g, b // g\n\n if a * b > 0 or b == 0:\n c = (abs(a), abs(b))\n else:\n c = (-abs(b), -abs(a))\n\n d[c] += 1\n\n ans = 1\n n_not_paired = 0\n for ab, n in d.items():\n ab_pair = (-ab[1], -ab[0])\n if ab_pair in d:\n if ab[0] > 0:\n ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD\n else:\n n_not_paired += n\n\n ans = (ans * pow(2, n_not_paired, MOD) + n_zeros - 1) % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "from sys import stdin\nfrom collections import defaultdict\nfrom math import gcd\n\n\ndef main():\n MOD = 1000000007\n\n N, *AB = map(int, stdin.buffer.read().split())\n\n d = defaultdict(int)\n n_zeros = 0\n\n for a, b in zip(AB[::2], AB[1::2]):\n if a == 0 and b == 0:\n n_zeros += 1\n continue\n\n g = gcd(a, b)\n a, b = a // g, b // g\n\n if a * b > 0 or b == 0:\n c = (abs(a), abs(b))\n else:\n c = (-abs(a), -abs(b))\n\n d[c] += 1\n\n ans = 1\n n_not_paired = 0\n for ab, n in d.items():\n ab_pair = (-ab[1], -ab[0])\n if ab_pair in d:\n if ab[0] > 0:\n m = d[ab_pair]\n ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD\n else:\n n_not_paired += n\n\n ans = (ans * pow(2, n_not_paired, MOD) + n_zeros - 1) % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s014980854', 's432873494', 's483871680'] | [74184.0, 74324.0, 74104.0] | [481.0, 484.0, 462.0] | [927, 896, 927] |
p02679 | u814986259 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['def main():\n import math\n import collections\n N = int(input())\n\n mod = 10**9+7\n AB = [tuple(map(int, input().split())) for i in range(N)]\n\n d = collections.defaultdict(set)\n i = 0\n ab = []\n for a, b in AB:\n g = math.gcd(a, b)\n a = a // g\n b = b // g\n # d[(a, b)] += 1\n if a > 0 and b < 0:\n a = -a\n b = -b\n d[(a, b)].add(i)\n ab.append((a, b))\n i += 1\n\n ans = 0\n r = set()\n\n dd = [1]\n for i in range(1, N+1):\n dd.append(dd[i-1]*2 % mod)\n\n r = set()\n ans = 1\n for (a, b) in d:\n if (a, b) in r:\n continue\n l1 = len(d[(a, b)])\n\n tmp = dd[l1]\n s = set()\n if (-b, a) in d:\n s |= d[(-b, a)]\n if (b, -a) in d:\n s |= d[(b, -a)]\n l2 = len(s)\n if l2:\n ans *= tmp + dd[l2] - 1\n N -= l1 + l2\n ans %= mod\n\n r.add((-b, a))\n r.add((b, -a))\n else:\n continue\n if N:\n ans *= dd[N]*2\n ans -= 1\n\n print(ans % mod)\n\n\nmain()\n', 'def main():\n import math\n import collections\n N = int(input())\n\n mod = 10**9+7\n AB = [tuple(map(int, input().split())) for i in range(N)]\n\n d = collections.defaultdict(set)\n i = 0\n ans2 = 0\n for a, b in AB:\n if a == 0 and b == 0:\n N -= 1\n ans2 += 1\n continue\n g = math.gcd(a, b)\n if g != 0:\n a = a // g\n b = b // g\n\n d[(a, b)].add(i)\n i += 1\n\n ans = 0\n r = set()\n\n dd = [1]\n for i in range(1, N+1):\n dd.append(dd[i-1]*2 % mod)\n\n r = set()\n ans = 1\n for a, b in d:\n if (a, b) in r:\n continue\n s1 = d[(a, b)]\n if (-a, -b) in d:\n s1 |= d[(-a, -b)]\n l1 = len(s1)\n r.add((-a, -b))\n if l1:\n s2 = set()\n if (-b, a) in d:\n s2 |= d[(-b, a)]\n if (b, -a) in d:\n s2 |= d[(b, -a)]\n s2 -= s1\n l2 = len(s2)\n if l2:\n ans *= dd[l1] + dd[l2] - 1\n N -= l1 + l2\n ans %= mod\n r.add((-b, a))\n r.add((b, -a))\n else:\n continue\n if N:\n ans *= dd[N]\n ans += ans2\n ans -= 1\n print(ans % mod)\n\n\nmain()\n'] | ['Runtime Error', 'Accepted'] | ['s137963236', 's434672855'] | [144892.0, 170708.0] | [1085.0, 1223.0] | [1112, 1299] |
p02679 | u879309973 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\n\nMOD = 1000000007\n\ndef solve(n, a, b):\n zero = 0\n D = {}\n for i in range(n):\n p, q = a[i], b[i]\n if (p == 0) and (q == 0):\n zero += 1\n else:\n if p < 0 and q < 0:\n p, q = -p, -q\n if p == 0:\n r = abs(q)\n elif q == 0:\n r = abs(p)\n else:\n r = gcd(p, q)\n k = (p // r, q // r)\n if not k in D:\n D[k] = 0\n D[k] += 1\n group = {}\n for (p, q), v in D.items():\n if (q, -p) in group:\n group[q, -p] += v elif (-q, p) in group: group[-q, p] += v\n else: group[p, q] = v pow2 = [0] * (n+1) \n pow2[0] = 1 for i in range(n): pow2[i+1] = (pow2[i] * 2) % MOD\n ans = 1 for (p, q), v in group.items(): t = pow2[D[p,q]] \n hit = False if (q, -p) in D: hit = True \n t += pow2[D[q, -p]] if (-q, p) in D: hit = True \n t += pow2[D[-q, p]] ans = (ans * (t-hit)) % MOD return (ans + zero - 1) % MOD \n\nn = int(input())\na = [0] * n \nb = [0] * n\nfor i in range(n):\n a[i], b[i] = map(int, input().split()) \nprint(solve(n, a, b))', 'from math import gcd\n\nMOD = 1000000007\n\ndef inv(a, b):\n if a < 0:\n a, b = -a, -b\n return (-b, a)\n\ndef solve(n, a, b):\n zero_zero = 0\n zero = 0\n inf = 0\n D = {}\n for i in range(n):\n p, q = a[i], b[i]\n if (p == 0) and (q == 0):\n zero_zero += 1\n elif p == 0:\n zero += 1\n elif q == 0:\n inf += 1\n else:\n r = gcd(p, q)\n p, q = (p // r, q // r)\n if q < 0:\n p, q = -p, -q\n k = (p, q)\n if not k in D:\n D[k] = 0\n D[k] += 1\n group = set()\n for (p, q), v in D.items():\n if not inv(p,q) in group:\n group.add((p,q))\n pow2 = [0] * (n+1)\n pow2[0] = 1\n for i in range(n):\n pow2[i+1] = (pow2[i] * 2) % MOD\n ans = 1\n for p, q in group:\n t = pow2[D[p,q]]\n if inv(p, q) in D:\n t += pow2[D[inv(p, q)]] - 1\n ans = (ans * t) % MOD\n ans *= pow2[zero] + pow2[inf] - 1\n return (ans + zero_zero - 1) % MOD\n\nn = int(input())\na = [0] * n\nb = [0] * n\nfor i in range(n):\n a[i], b[i] = map(int, input().split())\nprint(solve(n, a, b))'] | ['Runtime Error', 'Accepted'] | ['s534007221', 's813629590'] | [8992.0, 94304.0] | [24.0, 1019.0] | [2973, 1179] |
p02679 | u888092736 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from math import gcd\nfrom collections import defaultdict\n\n\ndef cmb(n, r):\n return (fac[n] * pow(fac[r], p - 2, p) * pow(fac[n - r], p - 2, p)) % p\n\n\np = 1000000007\nfac = [1] * (2 * 10 ** 6 + 1)\nfor i in range(1, 2 * 10 ** 6 + 1):\n fac[i] = (fac[i - 1] * i) % p\n\n\nN = int(input())\n\nAB = defaultdict(int)\nfor i in range(N):\n a, b = map(int, input().split())\n g = gcd(a, b)\n AB[(a // g, b // g)] += 1\n\nbad_pairs_cnt = 0\nfor a, b in AB:\n bad_pairs_cnt += AB[(a, b)] * (AB.get((-b, a), 0) + AB.get((b, -a), 0))\n\nans = N\nfor i in range(2, N + 1):\n b = cmb(N, 2) - bad_pairs_cnt * (N ** (i - 1))\n if b <= 0:\n break\n ans += b\n ans %= p\nprint(ans)\n', 'from collections import defaultdict\nfrom math import gcd\n\n\nMOD = 1000000007\nN = int(input())\nboth_zeros_cnt = 0\nbads = defaultdict(lambda: [0, 0])\nfor _ in range(N):\n A, B = map(int, input().split())\n if A == 0 and B == 0:\n both_zeros_cnt += 1\n continue\n if B < 0 or (B == 0 and A < 0):\n A, B = -A, -B\n g = gcd(A, B)\n A, B = A // g, B // g\n if A > 0:\n bads[(A, B)][0] += 1\n else:\n bads[(B, -A)][1] += 1\n\n\nNMAX = 2 * 10 ** 5 + 1\npow2 = [1] * (NMAX + 1)\nfor i in range(1, NMAX + 1):\n pow2[i] = pow2[i - 1] * 2 % MOD\nans = 1\nfor k, l in bads.values():\n ans *= pow2[k] + pow2[l] - 1\n ans %= MOD\nprint((ans + both_zeros_cnt - 1) % MOD)\n'] | ['Runtime Error', 'Accepted'] | ['s713690063', 's139364378'] | [125548.0, 68240.0] | [2210.0, 911.0] | [676, 696] |
p02679 | u894265012 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["import math\nimport itertools\nimport numpy as np\ndef main():\n N = int(input())\n AB = []\n for _ in range(N):\n AB.append(list(map(int, input().split())))\n mod = 1000000007\n total = math.factorial(N) % mod\n violate = []\n set_N = set({i for i in range(N)})\n for i, j in itertools.combinations([i for i in range(N)], 2):\n if AB[i][0] * AB[j][0] + AB[i][1] * AB[j][1] == 0:\n violate.append((i, j))\n set_N -= set((i, j))\n #print(set_N)\nif __name__ == '__main__':\n main()", "import math\nimport numpy as np\ndef main():\n mod = 1000000007\n N = int(input())\n mp = {}\n zero = 0\n for _ in range(N):\n x , y = map(int, input().split())\n if x == 0 and y == 0:\n zero += 1\n else:\n g = math.gcd(x, y)\n x //= g\n y //= g\n rot = 0\n if x == 0:\n y = 1\n else:\n if y == 0:\n rot = 1\n x = 0\n y = 1\n else:\n if x < 0 and y < 0:\n x *= -1\n y *= -1\n elif x < 0:\n rot = 1\n x *= -1\n x, y = y, x\n elif y < 0:\n rot = 1\n y *= -1\n x, y = y, x\n if (x, y) not in mp.keys():\n mp[x, y] = [0, 0]\n mp[x, y][rot] = 1\n else:\n mp[x, y][rot] += 1\n #print(mp) \n #print(mp)\n ans = 1\n for (a, b) in mp.keys():\n now = 1\n #now += np.power(2, mp[a, b][0]) -1 \n #now += np.power(2, mp[a, b][1]) -1\n now += pow(2, mp[a, b][0], mod) -1 \n now += pow(2, mp[a, b][1], mod) -1\n ans *= now % mod\n ans += zero - 1\n print(ans % mod)\n \nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s118653388', 's671280039'] | [237716.0, 81568.0] | [2213.0, 1604.0] | [528, 1440] |
p02679 | u895515293 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\nimport math\nimport heapq\nsys.setrecursionlimit(10**7)\nINTMAX = 9223372036854775807\nINTMIN = -9223372036854775808\nDVSR = 1000000007\ndef POW(x, y): return pow(x, y, DVSR)\ndef INV(x, m=DVSR): return pow(x, m - 2, m)\ndef DIV(x, y, m=DVSR): return (x * INV(y, m)) % m\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef FLIST(n):\n res = [1]\n for i in range(1, n+1): res.append(res[i-1]*i%DVSR)\n return res\n\ndef gcd(x, y):\n if x < y:\n x = x ^ y\n y = x ^ y\n x = x ^ y\n div = x % y\n while div != 0:\n x = y\n y = div\n div = x % y\n return y\n\n\nN=II()\nMP1={}\nA0 = 0\nB0 = 0\nAB0 = 0\nRES=1\nfor i in range(N):\n A, B = LI()\n G = gcd(abs(A),abs(B))\n A //= G\n B //= G\n if A*B != 0:\n v = (abs(A), abs(B), A*B > 0)\n if not v in MP1:\n MP1[v] = 1\n else:\n MP1[v] += 1\n\n if A == 0 and B != 0: A0 += 1\n if A != 0 and B == 0: B0 += 1\n\nprint(MP1)\n\nVIS = set()\nfor (vv, n) in MP1.items():\n \n (A, B, isPos) = vv\n v = (B, A, not isPos)\n if not v in VIS and not vv in VIS:\n VIS.add(v)\n VIS.add(vv)\n if v in MP1:\n m = MP1[v]\n RES = (RES*POW(2, n))%DVSR + (RES*POW(2, m))%DVSR - RES\n RES %= DVSR\n else:\n RES *= POW(2, n)\n RES %= DVSR\n # print(RES)\n\nif A0 and B0:\n RES = (RES*POW(2, A0))%DVSR + (RES*POW(2, B0))%DVSR\nelif A0:\n RES = RES*POW(2, A0)%DVSR\nelif B0:\n RES = RES*POW(2, B0)%DVSR\n\nprint(RES-1)\n', 'import sys\nimport math\nimport heapq\nsys.setrecursionlimit(10**7)\nINTMAX = 9223372036854775807\nINTMIN = -9223372036854775808\nDVSR = 1000000007\ndef POW(x, y): return pow(x, y, DVSR)\ndef INV(x, m=DVSR): return pow(x, m - 2, m)\ndef DIV(x, y, m=DVSR): return (x * INV(y, m)) % m\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef FLIST(n):\n res = [1]\n for i in range(1, n+1): res.append(res[i-1]*i%DVSR)\n return res\n\ndef gcd(x, y):\n if x < y:\n x = x ^ y\n y = x ^ y\n x = x ^ y\n div = x % y\n while div != 0:\n x = y\n y = div\n div = x % y\n return y\n\n\nN=II()\nMP1={}\nA0 = 0\nB0 = 0\nAB0 = 0\nRES=1\nfor i in range(N):\n A, B = LI()\n if A*B != 0:\n G = gcd(abs(A),abs(B))\n A //= G\n B //= G\n v = (abs(A), abs(B), A*B > 0)\n if not v in MP1:\n MP1[v] = 1\n else:\n MP1[v] += 1\n\n if A == 0 and B != 0: A0 += 1\n if A != 0 and B == 0: B0 += 1\n if A == 0 and B == 0: AB0 += 1\n\n# print(MP1)\n\nVIS = set()\nfor (vv, n) in MP1.items():\n (A, B, isPos) = vv\n v = (B, A, not isPos)\n if not v in VIS and not vv in VIS:\n VIS.add(v)\n VIS.add(vv)\n if v in MP1:\n m = MP1[v]\n RES = (RES*POW(2, n))%DVSR + (RES*POW(2, m))%DVSR - RES\n RES %= DVSR\n else:\n RES *= POW(2, n)\n RES %= DVSR\n\nif A0 and B0:\n RES = (RES*POW(2, A0))%DVSR + (RES*POW(2, B0))%DVSR - RES\nelif A0:\n RES = RES*POW(2, A0)%DVSR\nelif B0:\n RES = RES*POW(2, B0)%DVSR\n\n\nprint((RES+AB0-1)%DVSR)\n'] | ['Runtime Error', 'Accepted'] | ['s645359017', 's639099916'] | [92784.0, 85792.0] | [1752.0, 1586.0] | [1697, 1728] |
p02679 | u896741788 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\ninput=sys.stdin.buffer.readline\nmod=10**9+7\nn=int(input())\nd={}\nz=0\nfrom math import gcd \nfor i in range(n):\n x,y=map(int,input().split())\n if x==y==0:z+=1\n else:\n f=gcd(x,y)\n x//=f;y//=f\n if x<0:x*=-1;y*=-1\n if x==0 and y<0:y=-y\n d[(x,y)]+=1 if (x,y)in d else d[(x,y)]=1\nans=1\nfor (a,s) in d:\n if d[(a,s)]==0:continue\n ng=0\n if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0\n if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0\n ans*=(pow(2,d[(a,s)],mod)-1 + pow(2,ng,mod)-1 +1)%mod\n ans%=mod\n d[(a,s)]=0\nprint((ans+z-1)%mod)', 'import sys\ninput=sys.stdin.buffer.readline\nmod=10**9+7\nn=int(input())\nd={}\nz=0\nfrom math import gcd \nfor i in range(n):\n x,y=map(int,input().split())\n if x==y==0:z+=1\n else:\n f=gcd(x,y)\n x//=f;y//=f\n if x<0:x*=-1;y*=-1\n if x==0 and y<0:y=-y\n d[(x,y)]=1 if (x,y)not in d else d[(x,y)]+=1\nans=1\nfor (a,s) in d:\n if d[(a,s)]==0:continue\n ng=0\n if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0\n if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0\n ans*=(pow(2,d[(a,s)],mod)-1 + pow(2,ng,mod)-1 +1)%mod\n ans%=mod\n d[(a,s)]=0\nprint((ans+z-1)%mod)', 'mod=10**9+7\nn=int(input())\nd={}\nx0=0\ny0=0\nz=0\nfrom math import gcd \nfor i in range(n):\n x,y=map(int,input().split())\n if x==y==0:z+=1\n elif x==0:x0+=1\n elif y==0:y0+=1\n else:\n f=gcd(x,y)\n x//=f;y//=f\n if (x,y)in d:d[(x,y)]+=1;d[(x,y)]%=(mod-1)\n else:d[(x,y)]=1\nans=1\nif x0 and y0:ans=(pow(2,x0,mod)+pow(2,y0,mod)-1)%mod\nelif x0 or y0:ans=pow(2,x0+y0,mod)\nprint(d)\nfor (a,s) in d:\n if d[(a,s)]==0:continue\n ng=0\n if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0\n if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0\n ng%=mod-1\n ans*=(pow(2,d[(a,s)]%(mod-1),mod)+(pow(2,ng,mod)-1 if ng else 0))%mod\n ans%=mod\nprint((ans+z-1)%mod)', 'import sys\ninput=sys.stdin.buffer.readline\nmod=10**9+7\nn=int(input())\nd={}\nz=0\nfrom math import gcd \nfor i in range(n):\n x,y=map(int,input().split())\n if x==y==0:z+=1\n else:\n f=gcd(x,y)\n x//=f;y//=f\n if x<0:x*=-1;y*=-1\n if x==0 and y<0:y=-y\n if (x,y)not in d:d[(x,y)]=1\n else:d[(x,y)]+=1\nans=1\nfor (a,s) in d:\n if d[(a,s)]==0:continue\n ng=0\n if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0\n if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0\n ans*=(pow(2,d[(a,s)],mod)-1 + pow(2,ng,mod)-1 +1)%mod\n ans%=mod\n d[(a,s)]=0\nprint((ans+z-1)%mod)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s154580443', 's599395993', 's968079854', 's224457591'] | [9064.0, 9068.0, 69864.0, 49444.0] | [21.0, 22.0, 1125.0, 807.0] | [580, 584, 669, 592] |
p02679 | u899782392 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['from collections import defaultdict, deque\nimport math\n\nkMod = 10**9 + 7\n\nN = int(input())\nkey2count = defaultdict(lambda: [0, 0])\n\nfor _ in range(N):\n a, b = map(int, input().split())\n g = math.gcd(a, b)\n a, b = a//g, b//g\n if a < 0:\n a, b = -a, -b\n idx = 0\n if b < 0:\n idx = 1\n a, b = -b, a\n key2count[(a, b)][idx] += 1\n\nprint(key2count)\nans = 1\nfor key, val in key2count.items():\n plus, minus = val\n ans *= (pow(2, plus, kMod) + pow(2, minus, kMod)-1)\n ans %= kMod\n\nprint((ans + kMod-1) % kMod)', 'from collections import defaultdict, deque\nimport math\n\nkMod = 1000000007\n\nN = int(input())\nkey2count = defaultdict(lambda: [0, 0])\n\nfor _ in range(N):\n a, b = map(int, input().split())\n g = math.gcd(a, b)\n if a < 0 or a == 0 and b < 0:\n a, b = -a, -b\n if g > 0:\n a, b = a//g, b//g\n idx = 0\n if b <= 0:\n idx = 1\n a, b = -b, a\n key2count[(a, b)][idx] += 1\n\nans = 1\nfor key, val in key2count.items():\n if key == (0, 0):\n continue\n plus, minus = val\n ans *= (pow(2, plus, kMod) + pow(2, minus, kMod)-1)\n ans %= kMod\n\nans += sum(key2count[(0, 0)])\n\nprint((ans + kMod-1) % kMod)'] | ['Runtime Error', 'Accepted'] | ['s354994848', 's432755627'] | [84664.0, 60552.0] | [1120.0, 977.0] | [548, 641] |
p02679 | u916323984 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ["from collections import defaultdict\nfrom math import gcd\n\ndef main():\n n = int(input())\n mod = 1000000007\n zeroes = 0\n quad1 = defaultdict(int)\n quad2 = defaultdict(int)\n for _ in range(n):\n if a == b == 0:\n zeroes += 1\n continue\n\n a, b = map(int, input().split())\n g = gcd(a, b)\n a //= g; b//= g\n \n if b < 0:\n a, b = -a ,-b\n \n if a <= 0:\n a, b = b, -a\n quad1[(a,b)] += 0\n quad2[(a,b)] += 1\n else:\n quad1[(a,b)] += 1\n quad2[(a,b)] += 0\n\n ans = 1\n for k, v in quad1.items():\n now = 1\n now += pow(2, v, mod) -1\n now += pow(2, quad2[k], mod) -1\n ans = ans * now % mod\n \n ans += (zeroes - 1)\n print (ans % mod)\n\n\nif __name__ == '__main__':\n main()", "from collections import defaultdict\nimport math\n\ndef main():\n n = int(input())\n mod = 1000000007\n zeroes = 0\n quadrant1 = defaultdict(int)\n quadrant2 = defaultdict(int)\n\n for _ in range(n):\n a, b = map(int, input().split())\n if a == b == 0:\n zeroes += 1\n continue\n\n g = math.gcd(a, b)\n a, b = a//g, b//g \n \n if b < 0:\n a, b = -a, -b\n \n if a <= 0:\n a, b = b, -a\n quadrant1[(a, b)] += 0\n quadrant2[(a, b)] += 1\n else:\n quadrant1[(a, b)] += 1\n quadrant2[(a, b)] += 0\n \n ans = 1\n for key, value in quadrant1.items():\n now = 1\n now += pow(2, value, mod) - 1\n now += pow(2, quadrant2[key], mod) - 1\n ans = (ans * now) % mod\n \n ans += (zeroes - 1)\n return ans % mod\n\nif __name__ == '__main__':\n print (main())"] | ['Runtime Error', 'Accepted'] | ['s618243460', 's581799157'] | [9480.0, 68192.0] | [25.0, 939.0] | [858, 920] |
p02679 | u920977317 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nimport copy\n\ndef main():\n N=int(input())\n zero_fish=0\n\n Pair={}\n\n for i in range(N):\n A,B=map(int,input().split())\n\n if A==0 and B==0:\n zero_fish+=1\n continue\n if B==0:\n bunsi=1\n bunbo=0\n elif B>0:\n bunsi=A//math.gcd(A,B)\n bunbo=B//math.gcd(A,B)\n else:\n bunsi=-1*A//math.gcd(A,B)\n bunbo=-1*B//math.gcd(A,B)\n\n key = str(bunsi) + "/" + str(bunbo)\n\n if bunsi == 0 or bunbo == 0:\n rev_bunsi = bunbo\n rev_bunbo = bunsi\n elif bunsi < 0:\n rev_bunsi = bunbo\n rev_bunbo = -1 * bunsi\n else:\n rev_bunsi = -1 * bunbo\n rev_bunbo = bunsi\n rev_key = str(rev_bunsi) + "/" + str(rev_bunbo)\n\n if (key in Pair.keys()):\n Pair[key][0]+=1\n elif (rev_key in Pair.keys()):\n Pair[rev_key][1]+=1\n else:\n Pair[key]=[1,0]\n\n res=1\n mod=1000000007\n print(Pair)\n for p in Pair.values():\n if p[1]==0:\n temp=pow(2,p[0],mod)\n else:\n temp=pow(2,p[0],mod)+pow(2,p[1],mod)-1\n res=(res*temp)%mod\n res+=zero_fish-1\n\n print(res)\n\nif __name__=="__main__":\n main()\n', 'import math\nimport copy\n\ndef main():\n N=int(input())\n zero_fish=0\n\n Pair={}\n\n for i in range(N):\n A,B=map(int,input().split())\n\n if A==0 and B==0:\n zero_fish+=1\n continue\n if B==0:\n bunsi=1\n bunbo=0\n elif B>0:\n bunsi=A//math.gcd(A,B)\n bunbo=B//math.gcd(A,B)\n else:\n bunsi=-1*A//math.gcd(A,B)\n bunbo=-1*B//math.gcd(A,B)\n\n key = str(bunsi) + "/" + str(bunbo)\n\n if bunsi == 0 or bunbo == 0:\n rev_bunsi = bunbo\n rev_bunbo = bunsi\n elif bunsi < 0:\n rev_bunsi = bunbo\n rev_bunbo = -1 * bunsi\n else:\n rev_bunsi = -1 * bunbo\n rev_bunbo = bunsi\n rev_key = str(rev_bunsi) + "/" + str(rev_bunbo)\n\n if (key in Pair.keys()):\n Pair[key][0]+=1\n elif (rev_key in Pair.keys()):\n Pair[rev_key][1]+=1\n else:\n Pair[key]=[1,0]\n\n res=1\n mod=1000000007\n for p in Pair.values():\n if p[1]==0:\n temp=pow(2,p[0],mod)\n else:\n temp=(pow(2,p[0],mod)+pow(2,p[1],mod)-1)%mod\n res=(res*temp)%mod\n res+=zero_fish-1\n\n print(res%mod)\n\nif __name__=="__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s783943585', 's618492937'] | [81652.0, 54672.0] | [1261.0, 1163.0] | [1289, 1283] |
p02679 | u924691798 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\n\n# Combination\nMOD = 10**9+7\nMAX = 2*10**5\nfac = [1,1] + [0]*MAX\nfinv = [1,1] + [0]*MAX\ninv = [0,1] + [0]*MAX\nfor i in range(2,MAX+2):\n fac[i] = fac[i-1] * i % MOD\n inv[i] = -inv[MOD%i] * (MOD // i) % MOD\n finv[i] = finv[i-1] * inv[i] % MOD\n\ndef comb(n,r):\n if n < r: return 0\n if n < 0 or r < 0: return 0\n return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD\n\nfrom collections import defaultdict\n\nN = int(input())\ndic = defaultdict(int)\ngp = []\nfor i in range(N):\n a,b = map(int, input().split())\n g = math.gcd(a, b)\n a //= g\n b //= g\n dic[str(a)+":"+str(b)] += 1\n gp.append((a, b))\ncnt = 0\nprint(dic)\nfor a,b in gp:\n if (a >= 0 and b >= 0) or (a <= 0 and b <= 0):\n cnt += dic[str(b)+":"+str(-a)]\n cnt += dic[str(-b)+":"+str(a)]\n else:\n cnt += dic[str(b)+":"+str(a)]\n cnt += dic[str(-b)+":"+str(-a)]\n#print(cnt)\ncnt //= 2\nans = N\nfor i in range(2,N+1):\n c = comb(N, i) - cnt*comb(N-2, i-2)\n c = max(0, c)\n #print(i, comb(N, i), cnt*comb(N-2, i-2))\n if c < 0:\n c += MOD\n ans += c\n ans %= MOD\nprint(ans)\n', 'import sys\nimport math\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import defaultdict\n\nMOD = 10**9+7\nN = int(input())\ndic = defaultdict(int)\nzero = 0\nfor i in range(N):\n a, b = map(int, input().split())\n if b < 0:\n a = -a\n b = -b\n if a == 0 and b == 0:\n zero += 1\n continue\n elif a == 0:\n b = 1\n elif b == 0:\n a = 1\n g = math.gcd(a, b)\n a //= g\n b //= g\n dic[a,b] += 1\ndone = set()\nans = 1\nfor a,b in dic:\n k = (a, b)\n if k in done: continue\n c, d = -b, a\n if d <= 0:\n c = -c\n d = -d\n rk = (c, d)\n done.add(k)\n done.add(rk)\n c = pow(2, dic[k], MOD)-1\n if rk in dic:\n c += pow(2, dic[rk], MOD)-1\n c += 1\n ans *= c\n ans %= MOD\nprint((ans+zero-1)%MOD)\n'] | ['Runtime Error', 'Accepted'] | ['s330380412', 's083654690'] | [150688.0, 103384.0] | [1868.0, 1057.0] | [1107, 804] |
p02679 | u940831163 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\nimport collections\n\nn = int(input())\niwashi = [None for _ in range(n)]\nfor i in range(n):\n a, b = map(int, input().split())\n iwashi[i] = (math.degrees(math.atan2(a, b)) + 180) % 180\n# print(iwashi)\niwashi = collections.Counter(iwashi)\nk_list = list(iwashi.keys())\nv = list(iwashi.values())\n# k_list.sort(key=lambda x: -x)\n\nmod = 1000000007\nans = 1\ncounter = 0\nfor k in k_list:\n a = iwashi[k]\n b = iwashi[k+90] + iwashi[k-90]\n if a*b != 0:\n ans *= (pow(2, a, mod) + pow(2, b, mod) -1)\n if a+b == b:\n ans += 1\n else:\n ans *= pow(2, a, mod)\n iwashi[k] = 0\n iwashi[k+90] = 0\n iwashi[k-90] = 0\n # print(a, b, ans)\n ans %= mod\nif counter == 0:\n print(ans-2)\nelse:\n print(ans-1)\n', "import math\nimport collections\n\nn = int(input())\niwashi = []\nsub_ans = 0\nfor i in range(n):\n a, b = map(int, input().split())\n if a == 0 and b == 0:\n sub_ans += 1\n else:\n if b == 0:\n iwashi.append('1/0')\n elif b > 0:\n c = math.gcd(a, b)\n iwashi.append('{}/{}'.format(a//c, b//c))\n else:\n c = math.gcd(a, b)\n iwashi.append('{}/{}'.format(-a//c, -b//c))\n# print(iwashi)\niwashi = collections.Counter(iwashi)\nk_list = list(iwashi.keys())\nv = list(iwashi.values())\n# k_list.sort(key=lambda x: -x)\n\nmod = 1000000007\nans = 1\nfor k in k_list:\n a = iwashi[k]\n if k == '1/0':\n anti_k = '0/1'\n elif k == '0/1':\n anti_k = '1/0'\n else:\n c, d = k.split('/')\n if int(c) < 0:\n anti_k = '{}/{}'.format(d, -int(c))\n else:\n anti_k = '{}/{}'.format(-int(d), c)\n\n b = iwashi[anti_k]\n if a*b != 0:\n ans *= (pow(2, a, mod) + pow(2, b, mod) -1)\n else:\n ans *= pow(2, a, mod)\n iwashi[k] = 0\n iwashi[anti_k] = 0\n # print(k, anti_k ,a, b, ans)\n ans %= mod\nprint((ans+sub_ans-1)%mod)\n"] | ['Wrong Answer', 'Accepted'] | ['s136468592', 's477639470'] | [54280.0, 76152.0] | [962.0, 1240.0] | [755, 1152] |
p02679 | u945181840 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import sys\nimport numpy as np\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nN, *AB = map(int, read().split())\nA = np.array(AB[::2], np.int64)\nB = np.array(AB[1::2], np.int64)\ng = np.gcd(A, B)\nA //= g\nB //= g\na = Counter(A.tolist())\nb = Counter(B.tolist())\n\n', 'import sys\nfrom math import gcd\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nN, *AB = map(int, read().split())\nmod = 10 ** 9 + 7\n\nab = []\nzero = 0\nfor A, B in zip(*[iter(AB)] * 2):\n if A == 0 and B == 0:\n zero += 1\n continue\n if A == 0:\n B = -1\n elif B == 0:\n A = 1\n else:\n g = gcd(A, B)\n A //= g\n B //= g\n if A < 0:\n A, B = -A, -B\n ab.append((A, B))\n\ncnt = Counter(ab)\nanswer = 1\nchecked = set()\nok = 0\n\nfor (i, j), n in cnt.items():\n if (i, j) in checked:\n continue\n if j < 0:\n c, d = -j, i\n else:\n c, d = j, -i\n if (c, d) in cnt:\n m = cnt[(c, d)]\n answer = (answer * (pow(2, n, mod) + pow(2, m, mod) - 1)) % mod\n checked.add((c, d))\n else:\n ok += n\n\nanswer *= pow(2, ok, mod)\nanswer %= mod\nanswer -= 1\nanswer += zero\nprint(answer+1)\n', 'import sys\nfrom math import gcd\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nN, *AB = map(int, read().split())\nmod = 10 ** 9 + 7\n\nab = []\nzero = 0\nfor A, B in zip(*[iter(AB)] * 2):\n if A == 0 and B == 0:\n zero += 1\n continue\n if A == 0:\n B = -1\n elif B == 0:\n A = 1\n else:\n g = gcd(A, B)\n A //= g\n B //= g\n if A < 0:\n A, B = -A, -B\n ab.append((A, B))\n\ncnt = Counter(ab)\nanswer = 1\nchecked = set()\nok = 0\n\nfor (i, j), n in cnt.items():\n if (i, j) in checked:\n continue\n if j < 0:\n c, d = -j, i\n else:\n c, d = j, -i\n if (c, d) in cnt:\n m = cnt[(c, d)]\n answer = (answer * (pow(2, n, mod) + pow(2, m, mod) - 1)) % mod\n checked.add((c, d))\n else:\n ok += n\n\nanswer *= pow(2, ok, mod)\nanswer -= 1\nanswer += zero\nanswer %= mod\nprint(answer)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s435671246', 's777417333', 's122444363'] | [91660.0, 72752.0, 72600.0] | [446.0, 524.0, 481.0] | [297, 915, 913] |
p02679 | u952708174 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['def e_bullet(MOD=10**9 + 7):\n from math import gcd\n from collections import defaultdict\n N = int(input())\n\n zero_all = 0\n pair = defaultdict(int)\n for _ in range(N):\n a, b = [int(i) for i in input().split()]\n if a == 0 and b == 0:\n zero_all += 1\n continue\n\n \n if a != 0 and b != 0:\n g = gcd(a, b) * a // abs(a)\n elif a != 0:\n g = a\n else:\n g = b\n pair[(a // g, b // g)] += 1 \n\n done = set()\n total = 1\n for (a, b), v in list(pair.items()):\n if (b, -a) in done or (-b, a) in done:\n continue \n done.add((a, b))\n\n \n w = pair[(b, -a)] + pair[(-b, a)]\n \n \n \n \n total *= pow(2, v, MOD) + pow(2, w, MOD) - 1\n total %= MOD\n\n ans = (total + zero_all - 1) % MOD\n\nprint(e_bullet())', 'def e_bullet(MOD=10**9 + 7):\n from math import gcd\n from collections import defaultdict\n N = int(input())\n\n zero_all = 0\n pair = defaultdict(int)\n for _ in range(N):\n a, b = [int(i) for i in input().split()]\n if a == 0 and b == 0:\n zero_all += 1\n continue\n\n g = gcd(a, b)\n if b == 0:\n pair[(1, 0)] += 1\n elif b > 0:\n pair[(a // g, b // g)] += 1\n else:\n pair[(-a // g, -b // g)] += 1\n\n is_checked = set()\n total = 1\n for (a, b), v in list(pair.items()):\n if (b, -a) in is_checked or (-b, a) in is_checked:\n continue \n is_checked.add((a, b))\n \n w = pair[(b, -a)] + pair[(-b, a)]\n \n \n \n \n total *= pow(2, v, MOD) + pow(2, w, MOD) - 1\n total %= MOD\n\n ans = (total + zero_all - 1) % MOD\n return ans\n\nprint(e_bullet())'] | ['Wrong Answer', 'Accepted'] | ['s593633915', 's472595120'] | [135008.0, 135352.0] | [1154.0, 1169.0] | [1476, 1452] |
p02679 | u961674365 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['import math\n\n\nn = int(input())\nmod = 1000000007\nab = [list(map(int,input().split())) for _ in range(n)]\ndic = {}\nz = 0\nnz,zn = 0,0\nfor a,b in ab:\n if a == 0 and b == 0:\n z += 1\n continue\n elif a == 0:\n zn += 1\n continue\n elif b == 0:\n nz += 1\n if a< 0:\n a = -a\n b = -b\n g = math.gcd(a,b)\n tp = (a//g,b//g)\n if tp not in dic:\n dic[tp] = 1\n else:\n dic[tp] += 1\n \nans = 1\nnn = n - z - zn - nz\nfor tp,v in dic.items():\n if v == 0:\n continue\n vt = (tp[1],-1*tp[0])\n if vt in dic:\n w = dic[vt]\n #print(tp)\n e = pow(2,v,mod) + pow(2,w,mod) - 1\n ans *= e\n ans %= mod\n nn -= v + w \n dic[tp] = 0\n dic[vt] = 0\nans *= pow(2,nn,mod)\nans += z\nif zn == 0:\n ans *= pow(2,nz,mod)\nelif nz == 0:\n ans *= pow(2,zn,mod)\nelse:\n ans *= pow(2,nz,mod) + pow(2,zn,mod) - 1\nprint(ans%mod)\n#print(dic)\n', 'import math\n\n\nn = int(input())\nmod = 1000000007\nab = [list(map(int,input().split())) for _ in range(n)]\ndic = {}\nz = 0\nnz,zn = 0,0\nfor a,b in ab:\n if a == 0 and b == 0:\n z += 1\n continue\n elif a == 0:\n zn += 1\n continue\n elif b == 0:\n nz += 1\n if a< 0:\n a = -a\n b = -b\n g = math.gcd(a,b)\n tp = (a//g,b//g)\n if tp not in dic:\n dic[tp] = 1\n else:\n dic[tp] += 1\n \nans = 1\nnn = n - z - zn - nz\nfor tp,v in dic.items():\n if v == 0:\n continue\n vt = (tp[1],-1*tp[0])\n if vt in dic:\n w = dic[vt]\n #print(tp)\n e = pow(2,v,mod) + pow(2,w,mod) - 1\n ans *= e\n ans %= mod\n nn -= v + w \n dic[tp] = 0\n dic[vt] = 0\nans *= pow(2,nn,mod)\nif zn == 0:\n ans *= pow(2,nz,mod)\nelif nz == 0:\n ans *= pow(2,zn,mod)\nelse:\n ans *= pow(2,nz,mod) + pow(2,zn,mod) - 1\nans += z - 1\nprint(ans%mod)\n#print(dic)\n'] | ['Wrong Answer', 'Accepted'] | ['s093318543', 's065148434'] | [82688.0, 82684.0] | [820.0, 783.0] | [945, 949] |
p02679 | u984592063 | 2,000 | 1,048,576 | We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0. In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007. | ['mod = 10 ** 9 + 7\ndef gcd(a, b):\n return gcd(b, a%b) if b else a\nN = int(input())\nfrom collections import defaultdict\nX = defaultdict(lambda: [0, 0])\nx = 0\ny = 0\nz = 0\nfor i in range(N):\n a, b = map(int, input().split())\n g = abs(gcd(a, b))\n if a * b > 0:\n X[(abs(a) // g, abs(b) // g)][0] += 1\n elif a * b < 0:\n X[(abs(b) // g, abs(a) // g)][1] += 1\n else:\n if a:\n x += 1\n elif b:\n y += 1\n else:\n z += 1\nprint(X)\nprint(X.values())\nans = 1\npow2 = [1]\nfor i in range(N):\n pow2 += [pow2[-1] * 2 % mod]\nfor i in X.values():\n \n ans *= pow2[i[0]] + pow2[i[1]]- 1\n ans %= mod\nans *= pow2[x] + pow2[y] - 1\nans += z\nans %= mod\nprint(ans)\n', 'from collections import defaultdict\n\ndef gcd(a, b):\n return gcd(b, a%b) if b else a\n\nmod = 10 ** 9 + 7\nN = int(input())\nX = defaultdict(lambda: [0, 0])\nprint(X[(1, 1)])\n\nx = 0\ny = 0\nz = 0\nfor i in range(N):\n a, b = map(int, input().split())\n g = abs(gcd(a, b))\n if a * b > 0:\n X[(abs(a) / g, abs(b) / g)][0] += 1\n elif a * b < 0:\n X[(abs(b) / g, abs(a) / g)][1] += 1\n else:\n if a:\n x += 1\n elif b:\n y += 1\n else:\n z += 1\n# suppose we have a super head point which can put togother with every point.\nans = 1\npow2 = [1]\nfor i in range(N):\n pow2 += [pow2[-1] * 2 % mod]\nfor i in X.values():\n ans *= pow2[i[0]] + pow2[i[1]]- 1\n ans %= mod\nans *= pow2[x] + pow2[y] - 1\nprint((ans+z-1)%mod)\n', 'mod = 10 ** 9 + 7\ndef gcd(a, b):\n return gcd(b, a%b) if b else a\nN = int(input())\nfrom collections import defaultdict\nX = defaultdict(lambda: [0, 0])\nx = 0\ny = 0\nz = 0\nfor i in range(N):\n a, b = map(int, input().split())\n g = abs(gcd(a, b))\n if a * b > 0:\n X[(abs(a) // g, abs(b) // g)][0] += 1\n elif a * b < 0:\n X[(abs(b) // g, abs(a) // g)][1] += 1\n else:\n if a:\n x += 1\n elif b:\n y += 1\n else:\n z += 1\nprint(X)\nprint(X.values())\nans = 0\npow2 = [1]\nfor i in range(N):\n pow2 += [pow2[-1] * 2 % mod]\nfor i in X.values():\n \n ans *= pow2[i[0]] + pow2[i[1]]- 1\n ans %= mod\nans *= pow2[x] + pow2[y] - 1\nans += z\nans %= mod\nprint(ans)\n', 'mod = 10 ** 9 + 7\nfrom math import gcd\nN = int(input())\nfrom collections import defaultdict\nX = defaultdict(lambda: [0, 0])\nx = 0\ny = 0\nz = 0\nfor i in range(N):\n a, b = map(int, input().split())\n g = abs(gcd(a, b))\n if a * b > 0:\n X[(abs(a) // g, abs(b) // g)][0] += 1\n elif a * b < 0:\n X[(abs(b) // g, abs(a) // g)][1] += 1\n else:\n if a:\n x += 1\n elif b:\n y += 1\n else:\n z += 1\nans = 1\npow2 = [1]\nfor i in range(N):\n pow2 += [pow2[-1] * 2 % mod]\nfor i in X.values():\n ans *= pow2[i[0]] + pow2[i[1]]- 1\n ans %= mod\nans *= pow2[x] + pow2[y] - 1\nans += z - 1\nans %= mod\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s332349251', 's421900785', 's711286520', 's388389766'] | [84420.0, 68824.0, 84580.0, 68572.0] | [1930.0, 1789.0, 1955.0, 885.0] | [728, 792, 728, 617] |
p02680 | u165429863 | 3,000 | 1,048,576 | There is a grass field that stretches infinitely. In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0). There are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j). What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print `INF` instead. | ['#168 - F\nimport sys\nimport numpy as np\n\n\ndef main():\n N, M = map(int, sys.stdin.buffer.readline().split())\n LineData = np.int64(sys.stdin.buffer.read().split())\n\n INF = 10**9 + 1\n\n LineData = LineData.reshape(-1, 3)\n A, B, C = LineData[:N].T\n D, E, F = LineData[N:].T\n X = np.unique(np.concatenate([D, [-INF, 0, INF]]))\n Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))\n A = np.searchsorted(X, A)\n B = np.searchsorted(X, B, \'right\') - 1\n C = np.searchsorted(Y, C)\n D = np.searchsorted(X, D)\n E = np.searchsorted(Y, E)\n F = np.searchsorted(Y, F, \'right\') - 1\n\n LenX = len(X)\n LenY = len(Y)\n XY = LenX * LenY\n\n LineX = np.zeros((LenX, LenY), np.bool)\n LineY = np.zeros((LenX, LenY), np.bool)\n\n for x1, x2, y in zip(A, B, C):\n for x in range(x1, x2):\n LineY[x, y] = True\n\n for x, y1, y2 in zip(D, E, F):\n for y in range(y1, y2):\n LineX[x, y] = True\n \n visit = np.zeros((LenX, LenY), np.bool)\n x = np.searchsorted(X, 0, \'right\') - 1\n y = np.searchsorted(Y, 0, \'right\') - 1\n visit[x, y] = True\n area = 0\n queue = [(x, y)]\n\n for _ in range(XY):\n x, y = queue.pop()\n\n if x == 0 or x == LenX - 1 or y == 0 or y == LenY - 1:\n area = 0\n break\n \n area += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y])\n\n if not LineX[x, y] and not visit[x - 1, y]:\n visit[x - 1, y] = True\n queue.append((x - 1, y))\n if not LineY[x, y] and not visit[x, y - 1]:\n visit[x, y - 1] = True\n queue.append((x, y - 1))\n if not LineX[x + 1, y] and not visit[x + 1, y]:\n visit[x + 1, y] = True\n queue.append((x + 1, y))\n if not LineY[x, y + 1] and not visit[x, y + 1]:\n visit[x, y + 1] = True\n queue.append((x, y + 1))\n\n if not queue:\n break\n \n if area == 0:\n print("INF")\n else:\n print(area)\n\n\nif __name__ == \'__main__\':\n\tmain()\n\nsys.exit()\n', '#168 - F\nimport sys\nimport numpy as np\n\n\ndef main():\n N, M = map(int, sys.stdin.buffer.readline().split())\n LineData = np.int64(sys.stdin.buffer.read().split())\n\n INF = 10**9 + 1\n\n LineData = LineData.reshape(-1, 3)\n A, B, C = LineData[:N].T\n D, E, F = LineData[N:].T\n X = np.unique(np.concatenate([D, [-INF, 0, INF]]))\n Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))\n A = np.searchsorted(X, A)\n B = np.searchsorted(X, B, \'right\') - 1\n C = np.searchsorted(Y, C)\n D = np.searchsorted(X, D)\n E = np.searchsorted(Y, E)\n F = np.searchsorted(Y, F, \'right\') - 1\n\n LenX = len(X)\n LenY = len(Y)\n\n LineX = np.zeros((LenX, LenY), np.bool)\n LineY = np.zeros((LenX, LenY), np.bool)\n\n for x1, x2, y in zip(A, B, C):\n for x in range(x1, x2):\n LineY[x, y] = True\n\n for x, y1, y2 in zip(D, E, F):\n for y in range(y1, y2):\n LineX[x, y] = True\n \n visit = np.zeros((LenX, LenY), np.bool)\n x = np.searchsorted(X, 0, \'right\') - 1\n y = np.searchsorted(Y, 0, \'right\') - 1\n visit[x, y] = True\n area = 0\n queue = [(x, y)]\n\n while queue:\n x, y = queue.pop()\n\n if x == 0 or x == LenX - 1 or y == 0 or y == LenY - 1:\n print("INF")\n break\n \n area += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y])\n\n if not LineX[x, y] and not visit[x - 1, y]:\n visit[x - 1, y] = True\n queue.append((x - 1, y))\n if not LineY[x, y] and not visit[x, y - 1]:\n visit[x, y - 1] = True\n queue.append((x, y - 1))\n if not LineX[x + 1, y] and not visit[x + 1, y]:\n visit[x + 1, y] = True\n queue.append((x + 1, y))\n if not LineY[x, y + 1] and not visit[x, y + 1]:\n visit[x, y + 1] = True\n queue.append((x, y + 1))\n \n else:\n print(area)\n\n\nif __name__ == \'__main__\':\n\tmain()\n\nsys.exit()\n', '#168 - F\nimport sys\nimport numpy as np\n\n\ndef main():\n N, M = map(int, sys.stdin.buffer.readline().split())\n LineData = np.int64(sys.stdin.buffer.read().split())\n\n INF = 10**9 + 1\n\n LineData = LineData.reshape(-1, 3)\n A, B, C = LineData[:N].T\n D, E, F = LineData[N:].T\n X = np.unique(np.concatenate([D, [-INF, INF]]))\n Y = np.unique(np.concatenate([C, [-INF, INF]]))\n A = np.searchsorted(X, A)\n B = np.searchsorted(X, B, \'right\') - 1\n C = np.searchsorted(Y, C)\n D = np.searchsorted(X, D)\n E = np.searchsorted(Y, E)\n F = np.searchsorted(Y, F, \'right\') - 1\n\n area = cal_area(A, B, C, D, E, F, X, Y)\n\n if area == 0:\n print("INF")\n else:\n print(area)\n\n\ndef cal_area(A, B, C, D, E, F, X, Y):\n x = np.searchsorted(X, 0, \'right\') - 1\n y = np.searchsorted(Y, 0, \'right\') - 1\n\n DX = X[1:] - X[:-1]\n DY = Y[1:] - Y[:-1]\n\n A = A.tolist()\n B = B.tolist()\n C = C.tolist()\n D = D.tolist()\n E = E.tolist()\n F = F.tolist()\n X = X.tolist()\n Y = Y.tolist()\n DX = DX.tolist()\n DY = DY.tolist()\n\n LenX = len(X)\n LenY = len(Y)\n\n visit = [[False] * LenY for _ in range(LenX)]\n visit[x][y] = True\n area = 0\n queue = [(x, y)]\n\n LineX = [[False] * LenY for _ in range(LenX)]\n LineY = [[False] * LenY for _ in range(LenX)]\n\n for x1, x2, y in zip(A, B, C):\n for x in range(x1, x2):\n LineY[x][y] = True\n\n for x, y1, y2 in zip(D, E, F):\n for y in range(y1, y2):\n LineX[x][y] = True\n\n LenX -= 1\n LenY -= 1\n\n q_pop = queue.pop\n q_append = queue.append\n \n while queue:\n x, y = q_pop()\n \n if x == 0 or x == LenX or y == 0 or y == LenY:\n area = 0\n break\n \n area += DX[x] * DY[y]\n \n x1 = x - 1\n if not LineX[x][y] and not visit[x1][y]:\n visit[x1][y] = True\n q_append((x1, y))\n y1 = y - 1\n if not LineY[x][y] and not visit[x][y1]:\n visit[x][y1] = True\n q_append((x, y1))\n x1 = x + 1\n if not LineX[x1][y] and not visit[x1][y]:\n visit[x1][y] = True\n q_append((x1, y))\n y1 = y + 1\n if not LineY[x][y1] and not visit[x][y1]:\n visit[x][y1] = True\n q_append((x, y1))\n\n return area\n\n\nif __name__ == \'__main__\':\n\tmain()\n\nsys.exit()\n'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s045555143', 's719724883', 's861750481'] | [45248.0, 45364.0, 66200.0] | [3309.0, 3309.0, 2587.0] | [2026, 1922, 2389] |
p02680 | u268210555 | 3,000 | 1,048,576 | There is a grass field that stretches infinitely. In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0). There are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j). What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print `INF` instead. | ["import numpy as np\nfrom bisect import *\nn, m = map(int, input().split())\na, b, c = zip(*(map(int, input().split()) for _ in range(n)))\nd, e, f = zip(*(map(int, input().split()) for _ in range(m)))\nx = sorted(set(c + e + f))\ny = sorted(set(a + b + d))\nh = len(y)-1\nw = len(x)-1\ndef tx(i):\n return bisect(x, i)-1\ndef ty(i):\n return bisect(y, i)-1\nu = np.ones((h+1, w))\nfor d, e, f in zip(d, e, f):\n d, e, f = ty(d), tx(e), tx(f)\n u[d, e:f] = false\nl = np.ones((h, w+1))\nfor a ,b, c in zip(a, b, c):\n a, b, c = ty(a), ty(b), tx(c)\n l[a:b, c] = false\ns = np.outer(np.diff(y), np.diff(x)) \ni = bisect(y, 0)-1\nj = bisect(x, 0)-1\ns = [(i,j)]\nv = set()\nr = 0\nwhile s:\n i, j = s.pop()\n if (i,j) in v:\n continue\n v.add((i,j))\n if not (0<=i<h and 0<=j<w):\n print('inf')\n break\n r += s[i][j]\n if u[i][j]:\n s.append((i-1,j))\n if u[i+1][j]:\n s.append((i+1,j))\n if l[i][j]:\n s.append((i,j-1))\n if l[i][j+1]:\n s.append((i,j+1))\nelse:\n print(r)", "import numpy as np\nfrom bisect import *\nn, m = map(int, input().split())\nA, B, C = zip(*(map(int, input().split()) for _ in range(n)))\nD, E, F = zip(*(map(int, input().split()) for _ in range(m)))\nX = sorted(set(C + E + F))\nY = sorted(set(A + B + D))\nH = len(Y)-1\nW = len(X)-1\ndef TX(i):\n return bisect(X, i)-1\ndef TY(i):\n return bisect(Y, i)-1\nU = np.ones((H+1, W))\nfor d, e, f in zip(D, E, F):\n d, e, f = TY(d), TX(e), TX(f)\n U[d, e:f] = False\nL = np.ones((H, W+1))\nfor a ,b, c in zip(A, B, C):\n a, b, c = TY(a), TY(b), TX(c)\n L[a:b, c] = False\nS = np.outer(np.diff(Y), np.diff(X)) \ni = bisect(Y, 0)-1\nj = bisect(X, 0)-1\ns = [(i,j)]\nexit()\nv = set()\nr = 0\nwhile s:\n i, j = s.pop()\n if (i,j) in v:\n continue\n v.add((i,j))\n if not (0<=i<H and 0<=j<W):\n print('INF')\n break\n r += S[i][j]\n if U[i][j]:\n s.append((i-1,j))\n if U[i+1][j]:\n s.append((i+1,j))\n if L[i][j]:\n s.append((i,j-1))\n if L[i][j+1]:\n s.append((i,j+1))\nelse:\n print(r)\n", "import numpy as np\nfrom numba import njit\nfrom bisect import *\nn, m = map(int, input().split())\nA, B, C = zip(*(map(int, input().split()) for _ in range(n)))\nD, E, F = zip(*(map(int, input().split()) for _ in range(m)))\nX = sorted(set(C + E + F))\nY = sorted(set(A + B + D))\nH = len(Y)-1\nW = len(X)-1\ndef TX(i):\n return bisect(X, i)-1\ndef TY(i):\n return bisect(Y, i)-1\nU = np.ones((H+1, W))\nfor d, e, f in zip(D, E, F):\n d, e, f = TY(d), TX(e), TX(f)\n U[d, e:f] = False\nL = np.ones((H, W+1))\nfor a ,b, c in zip(A, B, C):\n a, b, c = TY(a), TY(b), TX(c)\n L[a:b, c] = False\nS = np.outer(np.diff(Y), np.diff(X)) \n@njit\ndef f(i,j):\n s = [(i,j)]\n v = set()\n r = 0\n while s:\n i, j = s.pop()\n if (i,j) in v:\n continue\n v.add((i,j))\n if not (0<=i<H and 0<=j<W):\n print('INF')\n break\n r += S[i][j]\n if U[i][j]:\n s.append((i-1,j))\n if U[i+1][j]:\n s.append((i+1,j))\n if L[i][j]:\n s.append((i,j-1))\n if L[i][j+1]:\n s.append((i,j+1))\n else:\n print(r)\nf()", "import numpy as np\nfrom bisect import *\nA, B, C = zip(*(map(int, input().split()) for _ in range(n)))\nD, E, F = zip(*(map(int, input().split()) for _ in range(m)))\nX = sorted(set(C + E + F))\nY = sorted(set(A + B + D))\nH = len(Y)-1\nW = len(X)-1\ndef TX(i):\n return bisect(X, i)-1\ndef TY(i):\n return bisect(Y, i)-1\nU = np.ones((H+1, W))\nfor d, e, f in zip(D, E, F):\n d, e, f = TY(d), TX(e), TX(f)\n U[d, e:f] = False\nL = np.ones((H, W+1))\nfor a ,b, c in zip(A, B, C):\n a, b, c = TY(a), TY(b), TX(c)\n L[a:b, c] = False\nS = np.outer(np.diff(Y), np.diff(X)) \ni = bisect(Y, 0)-1\nj = bisect(X, 0)-1\ns = [(i,j)]\nv = set()\nr = 0\nwhile s:\n i, j = s.pop()\n if (i,j) in v:\n continue\n v.add((i,j))\n if not (0<=i<H and 0<=j<W):\n print('INF')\n break\n r += S[i][j]\n if U[i][j]:\n s.append((i-1,j))\n if U[i+1][j]:\n s.append((i+1,j))\n if L[i][j]:\n s.append((i,j-1))\n if L[i][j+1]:\n s.append((i,j+1))\nelse:\n print(r)\n", "import numpy as np\nfrom numba import njit\nfrom bisect import *\nn, m = map(int, input().split())\nA, B, C = zip(*(map(int, input().split()) for _ in range(n)))\nD, E, F = zip(*(map(int, input().split()) for _ in range(m)))\nX = sorted(set(C))\nY = sorted(set(D))\nH = len(Y)-1\nW = len(X)-1\ndef TX(i):\n return bisect(X, i)-1\ndef TY(i):\n return bisect(Y, i)-1\nU = np.ones((H+1, W))\nfor d, e, f in zip(D, E, F):\n #d, e, f = TY(d), TX(e), TX(f)\n d = TY(d)\n e = bisect_left(X, e)\n f = bisect_right(X, f)-1\n U[d, e:f] = False\nL = np.ones((H, W+1))\nfor a ,b, c in zip(A, B, C):\n #a, b, c = TY(a), TY(b), TX(c)\n c = TX(c)\n a = bisect_left(Y, a)\n b = bisect_right(Y, b)-1\n L[a:b, c] = False\nS = np.outer(np.diff(Y), np.diff(X))\n@njit\ndef dfs(i, j):\n s = [(i,j)]\n v = np.zeros((H,W))\n r = 0\n while s:\n i, j = s.pop()\n if not (0<=i<H and 0<=j<W):\n return -1\n if v[i,j]:\n continue\n v[i,j] = True\n r += S[i,j]\n if U[i,j]:\n s.append((i-1,j))\n if U[i+1,j]:\n s.append((i+1,j))\n if L[i,j]:\n s.append((i,j-1))\n if L[i,j+1]:\n s.append((i,j+1))\n return r\nr = dfs(TY(0), TX(0))\nprint('INF' if r<0 else r)"] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s248232466', 's463153570', 's856553123', 's900361398', 's192252993'] | [97880.0, 238780.0, 303372.0, 27188.0, 209696.0] | [139.0, 197.0, 468.0, 116.0, 1315.0] | [1024, 1032, 1119, 992, 1257] |
p02680 | u704252625 | 3,000 | 1,048,576 | There is a grass field that stretches infinitely. In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0). There are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j). What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print `INF` instead. | ["import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nfrom bisect import bisect_left, bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(C)\nys = np.unique(D)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor a, b, c in zip(A, B, C):\n\tc = bisect_right(xs, c)\n\ta = bisect_left(ys, a) + 1\n\tb = bisect_right(ys, b)\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\td = bisect_right(ys, d)\n\te = bisect_left(xs, e) + 1\n\tf = bisect_right(xs, f)\n\ty_guard[e:f, d] = True\n\ncow = (\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n)\nnexts = deque([cow])\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\nvisited[cow] = True\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not visited[xi-1, yi] and not x_guard[xi, yi]:\n\t\t\tvisited[xi-1, yi] = True\n\t\t\tnexts.append((xi-1, yi))\n\t\tif not visited[xi+1, yi] and not x_guard[xi+1, yi]:\n\t\t\tvisited[xi+1, yi] = True\n\t\t\tnexts.append((xi+1, yi))\n\t\tif not visited[xi, yi-1] and not y_guard[xi, yi]:\n\t\t\tvisited[xi, yi-1] = True\n\t\t\tnexts.append((xi, yi-1))\n\t\tif not visited[xi, yi+1] and not y_guard[xi, yi+1]:\n\t\t\tvisited[xi, yi+1] = True\n\t\t\tnexts.append((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\tfor i in range(nrows):\n\t\tdata[i, :] = input_row(ncols, type, **kwargs)\n\treturn data\n\nfrom collections import deque\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((bisect_right(xs, 0), bisect_right(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.zeros((nrows, ncols), dtype=type)\n\tfor i in range(nrows):\n\t\tdata[i, :] = input_row(ncols, type, **kwargs)\n\treturn data\n\nfrom collections import deque\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((bisect_right(xs, 0), bisect_right(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(C)\nys = np.unique(D)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nC = np.searchsorted(xs, C, side='right')\nA = np.searchsorted(ys, A, side='right')\nB = np.searchsorted(ys, B, side='right')\n\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='right')\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\ncow = (\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n)\nnexts = deque([cow])\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\nvisited[cow] = True\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not visited[xi-1, yi] and not x_guard[xi, yi]:\n\t\t\tvisited[xi-1, yi] = True\n\t\t\tnexts.append((xi-1, yi))\n\t\tif not visited[xi+1, yi] and not x_guard[xi+1, yi]:\n\t\t\tvisited[xi+1, yi] = True\n\t\t\tnexts.append((xi+1, yi))\n\t\tif not visited[xi, yi-1] and not y_guard[xi, yi]:\n\t\t\tvisited[xi, yi-1] = True\n\t\t\tnexts.append((xi, yi-1))\n\t\tif not visited[xi, yi+1] and not y_guard[xi, yi+1]:\n\t\t\tvisited[xi, yi+1] = True\n\t\t\tnexts.append((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\n\nxs = sorted({*C, *E, *F})\nys = sorted({*A, *B, *D})\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nA = np.searchsorted(ys, A)\nB = np.searchsorted(ys, B)\nC = np.searchsorted(xs, C)\nD = np.searchsorted(ys, D)\nE = np.searchsorted(xs, E)\nF = np.searchsorted(xs, F)\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((np.searchsorted(xs, 0), np.searchsorted(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(C)\nys = np.unique(D)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nC = np.searchsorted(xs, C, side='right')\nA = np.searchsorted(ys, A, side='left') + 1\nB = np.searchsorted(ys, B, side='right')\n\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='left') + 1\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\ncow = (\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n)\nnexts = deque([cow])\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\nvisited[cow] = True\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not visited[xi-1, yi] and not x_guard[xi, yi]:\n\t\t\tvisited[xi-1, yi] = True\n\t\t\tnexts.append((xi-1, yi))\n\t\tif not visited[xi+1, yi] and not x_guard[xi+1, yi]:\n\t\t\tvisited[xi+1, yi] = True\n\t\t\tnexts.append((xi+1, yi))\n\t\tif not visited[xi, yi-1] and not y_guard[xi, yi]:\n\t\t\tvisited[xi, yi-1] = True\n\t\t\tnexts.append((xi, yi-1))\n\t\tif not visited[xi, yi+1] and not y_guard[xi, yi+1]:\n\t\t\tvisited[xi, yi+1] = True\n\t\t\tnexts.append((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((bisect_right(xs, 0), bisect_right(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(np.concatenate((C, E, F)))\nys = np.unique(np.concatenate((A, B, D)))\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nA = np.searchsorted(ys, A, side='right')\nB = np.searchsorted(ys, B, side='right')\nC = np.searchsorted(xs, C, side='right')\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='right')\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(np.concatenate((C, E, F)))\nys = np.unique(np.concatenate((A, B, D)))\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nA = np.searchsorted(ys, A, side='right')\nB = np.searchsorted(ys, B, side='right')\nC = np.searchsorted(xs, C, side='right')\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='right')\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tvisited[xi, yi] = True\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not visited[xi-1, yi] and not x_guard[xi, yi]:\n\t\t\tnexts.append((xi-1, yi))\n\t\tif not visited[xi+1, yi] and not x_guard[xi+1, yi]:\n\t\t\tnexts.append((xi+1, yi))\n\t\tif not visited[xi, yi-1] and not y_guard[xi, yi]:\n\t\t\tnexts.append((xi, yi-1))\n\t\tif not visited[xi, yi+1] and not y_guard[xi, yi+1]:\n\t\t\tnexts.append((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\n\nxs = sorted({*C, *E, *F})\nys = sorted({*A, *B, *D})\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((bisect_right(xs, 0), bisect_right(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.zeros((nrows, ncols), dtype=type)\n\tfor i in range(nrows):\n\t\tdata[i, :] = input_row(ncols, type, **kwargs)\n\treturn data\n\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_closed = set()\ny_closed = set()\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tfor y in range(a, b):\n\t\tx_closed.add(((c-1, c), y))\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\tfor x in range(e, f):\n\t\ty_closed.add((x, (d-1, d)))\n\nnexts = [(bisect_right(xs, 0), bisect_right(ys, 0))]\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.pop()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif ((xi-1, xi), yi) not in x_closed:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif ((xi, xi+1), yi) not in x_closed:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif (xi, (yi-1, yi)) not in y_closed:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif (xi, (yi, yi+1)) not in y_closed:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((bisect_right(xs, 0), bisect_right(ys, 0)))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.zeros((nrows, ncols), dtype=type)\n\tfor i in range(nrows):\n\t\tdata[i, :] = input_row(ncols, type, **kwargs)\n\treturn data\n\nfrom bisect import bisect_right\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = set()\nys = set()\n\nfor i in range(N):\n\txs.add(C[i])\n\tys.add(A[i])\n\tys.add(B[i])\n\nfor i in range(M):\n\tys.add(D[i])\n\txs.add(E[i])\n\txs.add(F[i])\n\nxs = sorted(xs)\nys = sorted(ys)\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nfor i in range(N):\n\tc = bisect_right(xs, C[i])\n\ta = bisect_right(ys, A[i])\n\tb = bisect_right(ys, B[i])\n\tx_guard[c, a:b] = True\n\nfor i in range(M):\n\td = bisect_right(ys, D[i])\n\te = bisect_right(xs, E[i])\n\tf = bisect_right(xs, F[i])\n\ty_guard[e:f, d] = True\n\nnexts = [(bisect_right(xs, 0), bisect_right(ys, 0))]\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.pop()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.unique(np.concatenate((C, E, F)))\nys = np.unique(np.concatenate((A, B, D)))\n\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nA = np.searchsorted(ys, A, side='right')\nB = np.searchsorted(ys, B, side='right')\nC = np.searchsorted(xs, C, side='right')\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='right')\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nx0, y0 = (\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n)\nnexts.append((x0, y0))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\nvisited[x0, y0] = True\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not visited[xi-1, yi] and not x_guard[xi, yi]:\n\t\t\tvisited[xi-1, yi] = True\n\t\t\tnexts.append((xi-1, yi))\n\t\tif not visited[xi+1, yi] and not x_guard[xi+1, yi]:\n\t\t\tvisited[xi+1, yi] = True\n\t\t\tnexts.append((xi+1, yi))\n\t\tif not visited[xi, yi-1] and not y_guard[xi, yi]:\n\t\t\tvisited[xi, yi-1] = True\n\t\t\tnexts.append((xi, yi-1))\n\t\tif not visited[xi, yi+1] and not y_guard[xi, yi+1]:\n\t\t\tvisited[xi, yi+1] = True\n\t\t\tnexts.append((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n", "import sys\nimport numpy as np\nfrom itertools import chain\n\n\ndef inputs(func=lambda x: x, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef input_row(n : int, type=np.int, **kwargs):\n\treturn np.fromiter(inputs(type, **kwargs), dtype=type)\n\ndef input_2d(nrows : int, ncols : int, type=np.int, **kwargs):\n\tdata = np.fromiter(\n\t\tchain.from_iterable(\n\t\t\tinputs(type) for _ in range(nrows)\n\t\t),\n\t\tdtype=type\n\t)\n\treturn data.reshape(nrows, ncols)\n\nfrom collections import deque\nimport numpy as np\n\n\nN, M = inputs(int)\nA, B, C = input_2d(N, 3).T\nD, E, F = input_2d(M, 3).T\nxs = np.fromiter({*C, *E, *F}, dtype=int)\nys = np.fromiter({*A, *B, *D}, dtype=int)\nxs.sort()\nys.sort()\nx_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\ny_guard = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\nA = np.searchsorted(ys, A, side='right')\nB = np.searchsorted(ys, B, side='right')\nC = np.searchsorted(xs, C, side='right')\nD = np.searchsorted(ys, D, side='right')\nE = np.searchsorted(xs, E, side='right')\nF = np.searchsorted(xs, F, side='right')\n\nfor a, b, c in zip(A, B, C):\n\tx_guard[c, a:b] = True\n\nfor d, e, f in zip(D, E, F):\n\ty_guard[e:f, d] = True\n\nnexts = deque()\nnexts.append((\n\tnp.searchsorted(xs, 0, side='right'),\n\tnp.searchsorted(ys, 0, side='right')\n))\nvisited = np.zeros((len(xs)+1, len(ys)+1), dtype=bool)\n\narea = 0\n\nwhile nexts:\n\txi, yi = nexts.popleft()\n\tif not visited[xi, yi]:\n\t\tvisited[xi, yi] = True\n\t\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\t\tif not x_guard[xi, yi]:\n\t\t\t\tnexts.append((xi-1, yi))\n\t\t\tif not x_guard[xi+1, yi]:\n\t\t\t\tnexts.append((xi+1, yi))\n\t\t\tif not y_guard[xi, yi]:\n\t\t\t\tnexts.append((xi, yi-1))\n\t\t\tif not y_guard[xi, yi+1]:\n\t\t\t\tnexts.append((xi, yi+1))\n\t\telse:\n\t\t\tarea = 'INF'\n\t\t\tbreak\n\nprint(area)\n\n", "import sys\nfrom typing import Iterable, Tuple, Union\n\nclass nd (object):\n\tgetter = (\n\t\tlambda a, i: a,\n\t\tlambda a, i: a[i[0]],\n\t\tlambda a, i: a[i[0]][i[1]],\n\t\tlambda a, i: a[i[0]][i[1]][i[2]],\n\t\tlambda a, i: a[i[0]][i[1]][i[2]][i[3]],\n\t\tlambda a, i: a[i[0]][i[1]][i[2]][i[3]][i[4]],\n\t\tlambda a, i: a[i[0]][i[1]][i[2]][i[3]][i[4]][i[5]],\n\t)\n\tclass _setter (object):\n\t\tdef __getitem__(self, n : int):\n\t\t\tsetter_getter = nd.getter[n-1]\n\t\t\tdef setter(a, i, v):\n\t\t\t\tsetter_getter(a, i[:-1])[i[-1]] = v\n\t\t\treturn setter\n\tsetter = _setter()\n\tinitializer = (\n\t\tlambda s, v: [v] * s,\n\t\tlambda s, v: [v] * s[0],\n\t\tlambda s, v: [[v] * s[1] for _ in range(s[0])],\n\t\tlambda s, v: [[[v] * s[2] for _ in range(s[1])] for _ in range(s[0])],\n\t\tlambda s, v: [[[[v] * s[3] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],\n\t\tlambda s, v: [[[[[v] * s[4] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],\n\t\tlambda s, v: [[[[[[v] * s[5] for _ in range(s[4])] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],\n\t)\n\tshape_getter = (\n\t\tlambda a: len(a),\n\t\tlambda a: (len(a),),\n\t\tlambda a: (len(a), len(a[0])),\n\t\tlambda a: (len(a), len(a[0]), len(a[0][0])),\n\t\tlambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0])),\n\t\tlambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0]), len(a[0][0][0][0])),\n\t\tlambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0]), len(a[0][0][0][0]), len(a[0][0][0][0][0])),\n\t)\n\tindices_iterator = (\n\t\tlambda s: iter(range(s)),\n\t\tlambda s: ((i,) for i in range(s[0])),\n\t\tlambda s: ((i, j) for j in range(s[1]) for i in range(s[0])),\n\t\tlambda s: ((i, j, k) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),\n\t\tlambda s: ((i, j, k, l) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),\n\t\tlambda s: ((i, j, k, l, m) for m in range(s[4]) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),\n\t\tlambda s: ((i, j, k, l, m, n) for n in range(s[5]) for m in range(s[4]) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),\n\t)\n\titerable_product = (\n\t\tlambda s: iter(s),\n\t\tlambda s: ((i,) for i in s[0]),\n\t\tlambda s: ((i, j) for j in s[1] for i in s[0]),\n\t\tlambda s: ((i, j, k) for k in s[2] for j in s[1] for i in s[0]),\n\t\tlambda s: ((i, j, k, l) for l in s[3] for k in s[2] for j in s[1] for i in s[0]),\n\t\tlambda s: ((i, j, k, l, m) for m in s[4] for l in s[3] for k in s[2] for j in s[1] for i in s[0]),\n\t\tlambda s: ((i, j, k, l, m, n) for n in s[5] for m in s[4] for l in s[3] for k in s[2] for j in s[1] for i in s[0]),\n\t)\n\t\n\t@classmethod\n\tdef full(cls, fill_value, shape : Union[int, Tuple[int], Iterable[int]]):\n\t\tif isinstance(shape, int):\n\t\t\treturn cls.initializer[0](shape, fill_value)\n\t\telif not isinstance(shape, tuple):\n\t\t\tshape = tuple(shape)\n\t\treturn cls.initializer[len(shape)](shape, fill_value)\n\t\n\t@classmethod\n\tdef fromiter(cls, iterable : Iterable, ndim=1):\n\t\tif ndim == 1:\n\t\t\treturn list(iterable)\n\t\telse:\n\t\t\treturn list(map(cls.fromiter, iterable))\n\t\n\t@classmethod\n\tdef nones(cls, shape : Union[int, Tuple[int], Iterable[int]]):\n\t\treturn cls.full(None, shape)\n\t\n\t@classmethod\n\tdef zeros(cls, shape : Union[int, Tuple[int], Iterable[int]], type=int):\n\t\treturn cls.full(type(0), shape)\n\t\n\t@classmethod\n\tdef ones(cls, shape : Union[int, Tuple[int], Iterable[int]], type=int):\n\t\treturn cls.full(type(1), shape)\n\t\n\tclass _range (object):\n\t\tdef __getitem__(self, shape : Union[int, slice, Tuple[Union[int, slice]]]):\n\t\t\tif isinstance(shape, int):\n\t\t\t\treturn iter(range(shape))\n\t\t\telif isinstance(shape, slice):\n\t\t\t\treturn iter(range(shape.stop)[shape])\n\t\t\telse:\n\t\t\t\tshape = tuple(range(s.stop)[s] for s in shape)\n\t\t\t\treturn nd.iterable_product[len(shape)](shape)\n\t\tdef __call__(self, shape : Union[int, slice, Tuple[Union[int, slice]]]):\n\t\t\treturn self[shape]\n\trange = _range()\n\n\n\ndef bytes_to_str(x : bytes):\n\treturn x.decode('utf-8')\n\ndef inputs(func=bytes_to_str, sep=None, maxsplit=-1):\n\treturn map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))\n\ndef inputs_1d(func=bytes_to_str, **kwargs):\n\treturn nd.fromiter(inputs(func, **kwargs))\n\ndef inputs_2d(nrows : int, func=bytes_to_str, **kwargs):\n\treturn nd.fromiter(\n\t\t(inputs(func, **kwargs) for _ in range(nrows)),\n\t\tndim=2\n\t)\n\ndef inputs_2d_T(nrows : int, func=bytes_to_str, **kwargs):\n\treturn nd.fromiter(\n\t\tzip(*(inputs(func, **kwargs) for _ in range(nrows))),\n\t\tndim=2\n\t)\n\nfrom typing import Optional\n\n\nclass DepthFirstSearch (object):\n\t__slots__ = [\n\t\t'shape',\n\t\t'pushed',\n\t\t'_stack',\n\t\t'_getter',\n\t\t'_setter'\n\t]\n\t\n\tdef __init__(self, shape : Union[int, Iterable[int]]):\n\t\tself.shape = (shape,) if isinstance(shape, int) else tuple(shape)\n\t\tself.pushed = nd.zeros(self.shape, type=bool)\n\t\tself._stack = []\n\t\tself._getter = nd.getter[len(self.shape)]\n\t\tself._setter = nd.setter[len(self.shape)]\n\t\n\tdef push(self, position : Tuple[int]):\n\t\tif not self._getter(self.pushed, position):\n\t\t\tself._setter(self.pushed, position, True)\n\t\t\tself._stack.append(position)\n\t\n\tdef peek(self) -> Optional[Tuple[int]]:\n\t\treturn self._stack[-1] if self._stack else None\n\t\n\tdef pop(self) -> Optional[Tuple[int]]:\n\t\treturn self._stack.pop() if self._stack else None\n\t\n\tdef __bool__(self):\n\t\treturn bool(self._stack)\n\nDFS = DepthFirstSearch\n\nfrom bisect import bisect_left, bisect_right\nfrom collections import deque\n\n\nN, M = inputs(int)\nA, B, C = inputs_2d_T(N, int)\nD, E, F = inputs_2d_T(M, int)\nxs = sorted(set(C))\nys = sorted(set(D))\n\nx_guard = nd.zeros((len(xs)+1, len(ys)+1), type=bool)\ny_guard = nd.zeros((len(xs)+1, len(ys)+1), type=bool)\n\nfor a, b, c in zip(A, B, C):\n\tc = bisect_right(xs, c)\n\ta = bisect_left(ys, a) + 1\n\tb = bisect_right(ys, b)\n\tfor y in range(a, b):\n\t\tx_guard[c][y] = True\n\nfor d, e, f in zip(D, E, F):\n\td = bisect_right(ys, d)\n\te = bisect_left(xs, e) + 1\n\tf = bisect_right(xs, f)\n\tfor x in range(e, f):\n\t\ty_guard[x][d] = True\n\ncow = (\n\tbisect_right(xs, 0),\n\tbisect_right(ys, 0)\n)\n\nbfs = DepthFirstSearch(shape=(len(xs)+1, len(ys)+1))\nbfs.push(cow)\n\narea = 0\nwhile bfs:\n\txi, yi = bfs.pop()\n\t\n\tif 0 < xi < len(xs) and 0 < yi < len(ys):\n\t\tarea += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])\n\t\tif not x_guard[xi][yi]:\n\t\t\tbfs.push((xi-1, yi))\n\t\tif not x_guard[xi+1][yi]:\n\t\t\tbfs.push((xi+1, yi))\n\t\tif not y_guard[xi][yi]:\n\t\t\tbfs.push((xi, yi-1))\n\t\tif not y_guard[xi][yi+1]:\n\t\t\tbfs.push((xi, yi+1))\n\telse:\n\t\tarea = 'INF'\n\t\tbreak\n\nprint(area)\n\n"] | ['Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s065761599', 's234534511', 's357001945', 's409964009', 's590618326', 's599766515', 's644358570', 's655076580', 's675315567', 's740324531', 's797116993', 's815184956', 's911185336', 's957795004', 's968710011', 's776126620'] | [30040.0, 27220.0, 48568.0, 30076.0, 46740.0, 29888.0, 48620.0, 46796.0, 122748.0, 48448.0, 439016.0, 48236.0, 248132.0, 46760.0, 46612.0, 40508.0] | [3309.0, 115.0, 3309.0, 2484.0, 3310.0, 3309.0, 3310.0, 3309.0, 3313.0, 3309.0, 3321.0, 3309.0, 3317.0, 3309.0, 3309.0, 2362.0] | [1892, 1847, 1761, 1939, 1666, 1945, 1797, 1814, 1881, 1677, 1736, 1804, 1707, 2009, 1833, 6448] |
p02681 | u000037600 | 2,000 | 1,048,576 | Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above. | ['a=input()\nb=input()\nif len(a)+1==len(b) and a==b[0:a]:\n print("Yes")\nelse:\n print("No")', 'a=input()\nb=input()\nif len(a)+1=len(b) and a==b[0:a]:\n print("Yes")\nelse:\n print("No")', 'a=input()\nb=input()\nif len(a)+1==len(b) and b[:len(a)]==a:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s147656394', 's754323293', 's811465178'] | [9012.0, 8884.0, 8972.0] | [24.0, 27.0, 29.0] | [89, 88, 93] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.