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 |
|---|---|---|---|---|---|---|---|---|---|---|
p02721 | u711539583 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["n, k, c = map(int, input().split())\ns = input()\n\ncnt = 0\nd = c + 1 \nno = 0 \nf = 0\nans = []\ncand = []\n\n\n\n\n\nfor i in range(n):\n if d > c:\n if no == 0 and cand: \n ans.extend(cand)\n cand = []\n if s[i] == 'o':\n cnt += 1\n d = 0\n no = 0\n cand.append(i+1)\n else:\n if s[i] == 'o':\n no += 1\n d += 1\n\n\nif no == 0 and cand: \n ans.extend(cand)\n\n\nif cnt == k:\n for ansi in ans:\n print(ansi)", "n, k, c = map(int, input().split())\ns = input()\n\nl = [-c-1]\nfor i in range(n):\n if s[i] == 'o' and i - l[-1] > c:\n l.append(i)\nr = [n + c]\nfor i in reversed(range(n)):\n if s[i] == 'o' and r[-1] - i > c:\n r.append(i)\nr.reverse()\n\n\nif len(l)-1 == k:\n for li, ri in zip(l[1:], r):\n if li == ri:\n print(li + 1)"] | ['Wrong Answer', 'Accepted'] | ['s825830806', 's707297498'] | [12772.0, 22204.0] | [287.0, 297.0] | [818, 347] |
p02721 | u726285999 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["N, K, C = map(int, input().split())\nS = input()\n\nwork_date = []\ncount = 0\n\n\npw = 0\n\nfor d in range(K):\n\n w = S[pw:].index('o') + pw\n work_date.append(w)\n\n \n pw = w + C + 1\n \n\nwork_date_l = []\n\nSr = list(reversed(S))\npw = 0\n\nfor d in range(K):\n\n w = Sr[pw:].index('o') + pw\n work_date_l.append((N-1)-w)\n\n \n pw = w + C + 1\n\nwork_date_l.sort()\n \ncount = 0\nfor i in range(K):\n if work_date[i] == work_date_l[i]:\n count += 1\n \nprint(count)", 'N, K, C = map(int, input().split())\nS = input()\n\nSr = "".join(list(reversed(S)))\n\nwd = []\nwdl = []\n\npw = 0\npwl = 0\n\nfor d in range(K):\n\n \n while True:\n if S[pw] == (\'o\'):\n wd.append(pw)\n break\n pw += 1\n pw += C + 1\n \n \n while True:\n if Sr[pwl] == (\'o\'):\n wdl.append(pwl)\n break\n pwl += 1\n pwl += C + 1\n\nwdl.sort()\n \nfor i in range(K):\n if wd[i] == wdl[i]:\n print(wd[i] + 1)', 'N, K, C = map(int, input().split())\nS = input()\n\nSr = "".join(list(reversed(S)))\n\nwd = []\nwdl = []\n\npw = 0\npwl = 0\n\nfor d in range(K):\n\n \n while True:\n if S[pw] == (\'o\'):\n wd.append(pw)\n break\n pw += 1\n pw += C + 1\n \n \n while True:\n if Sr[pwl] == (\'o\'):\n wdl.append(pwl)\n break\n pwl += 1\n pwl += C + 1\n\nen = time.time()\n\nwdl.sort()\n \nfor i in range(K):\n if wd[i] == wdl[i]:\n print(wd[i] + 1)', "N, K, C = map(int, input().split())\nS = input()\n\nwork_date = []\ncount = 0\n\n\npw = 0\n\nfor d in range(K):\n\n w = S[pw:].index('o') + pw\n work_date.append(w)\n\n \n pw = w + C + 1\n \n\nwork_date_l = []\n\nSr = list(reversed(S))\npw = 0\n\nfor d in range(K):\n\n w = Sr[pw:].index('o') + pw\n work_date_l.append((N-1)-w)\n\n \n pw = w + C + 1\n\nwork_date_l.sort()\n \ncount = 0\nfor i in range(K):\n if work_date[i] == work_date_l[i]:\n count += 1\n \nprint(count)", "N, K, C = map(int, input().split())\nS = input()\n\nwork_date = []\n\n\npw = 0\n\nfor d in range(K):\n\n w = S[pw:].index('o') + pw\n work_date.append(w)\n\n \n pw = w + C + 1\n \n\nwork_date_l = []\n\nSr = str(list(reversed(S)))\npw = 0\n\nfor d in range(K):\n\n w = Sr[pw:].index('o') + pw\n work_date_l.append((N-1)-w)\n\n \n pw = w + C + 1\n\nwork_date_l.sort()\n \ncount = 0\nfor i in range(K):\n if work_date[i] == work_date_l[i]:\n count += 1\n \nprint(count)", 'N, K, C = map(int, input().split())\nS = input()\n\nSr = "".join(list(reversed(S)))\n\nwd = []\nwdl = []\n\npw = 0\npwl = 0\n\nfor d in range(K):\n\n \n while True:\n if S[pw] == (\'o\'):\n wd.append(pw)\n break\n pw += 1\n pw += C + 1\n \n \n while True:\n if Sr[pwl] == (\'o\'):\n wdl.append((N-1) - pwl)\n break\n pwl += 1\n pwl += C + 1\n\nwdl.sort()\n \nfor i in range(K):\n if wd[i] == wdl[i]:\n print(wd[i] + 1)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s020292852', 's091769368', 's454294122', 's732656859', 's888666474', 's008797705'] | [14324.0, 22548.0, 21196.0, 15048.0, 13724.0, 22548.0] | [2104.0, 323.0, 149.0, 2104.0, 2104.0, 342.0] | [663, 519, 537, 663, 658, 527] |
p02721 | u824237520 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["n, k, c = map(int, input().split())\ns = list(input())\n\nR = []\np = 0\nfor _ in range(k):\n R.append(p)\n p += c\n while s[p] == 'x':\n p += 1\n\nL = []\np = n - 1\nfor _ in range(k):\n L.append(p)\n p -= c\n while s[p] == 'x':\n p -= 1\n\nL = list(reversed(L))\n\nfor i in range(k):\n if R[i] == L[i]:\n print(i+1)\n", "n, k, c = map(int, input().split())\ns = list(input())\n\nR = []\np = 0\nfor _ in range(k):\n while s[p] == 'x':\n p += 1\n R.append(p)\n p += c + 1\n\nL = []\np = n - 1\nfor _ in range(k):\n while s[p] == 'x':\n p -= 1\n L.append(p)\n p -= c + 1\n\nL = list(reversed(L))\n\nfor i in range(k):\n if R[i] == L[i]:\n print(R[i] + 1)\n"] | ['Runtime Error', 'Accepted'] | ['s414207789', 's658642726'] | [15908.0, 22308.0] | [159.0, 324.0] | [337, 350] |
p02721 | u834983620 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ['a,b,c = map(int,(input().split()))\nmb = input()\n\nrl = list()\nll = list()\n\nfor i in range(a):\n if mb[i] == "x":continue\n if len(rl) == 0:\n rl.append(i + 1)\n else:\n if rl[-1] + c + 1 <= i + 1:\n rl.append(i + 1)\n #if len(rl) <= b:break\n\nfor i in range(a-1,-1,-1):\n if mb[i] == "x":continue\n if len(ll) == 0:\n ll.append(i + 1)\n else:\n d1 = ll[-1] - c - 1\n d2 = i + 1\n if d1 >= d2:\n ll.append(i + 1)\n #if len(ll) <= b:break\n\nans=list()\nfor i,k in zip(rl,reversed(ll)):\n if b == 1:break\n if i == k:\n ans.append(i)\n\nprint(ans)', 'a,b,c = map(int,(input().split()))\nmb = input()\n\nrl = list()\nll = list()\n\nfor i in range(a):\n if mb[i] == "x":continue\n if len(rl) == 0:\n rl.append(i + 1)\n else:\n if rl[-1] + c + 1 <= i + 1:\n rl.append(i + 1)\n if len(rl) == b:break\n\nfor i in range(a,-1,-1):\n if mb[i] == "x":continue\n if len(ll) == 0:\n ll.append(i + 1)\n else:\n d1 = ll[-1] - c - 1\n d2 = i + 1\n if d1 >= d2:\n ll.append(i + 1)\n if len(ll) == b:break\n\nans=list()\nfor i,k in zip(rl,reversed(ll)):\n if b == 1 or b==0:break\n if i == k:\n ans.append(i)\n\n[print(i) for i in ans]', 'a,b,c = map(int,(input().split()))\nmb = input()\n\nrl = list()\nll = list()\n\nfor i in range(a):\n if mb[i] == "x":continue\n if len(rl) == 0:\n rl.append(i + 1)\n else:\n if rl[-1] + c + 1 <= i + 1:\n rl.append(i + 1)\n if len(rl) == b:break\n\nfor i in range(a,-1,-1):\n if mb[i] == "x":continue\n if len(ll) == 0:\n ll.append(i + 1)\n else:\n d1 = ll[-1] - c - 1\n d2 = i + 1\n if d1 >= d2:\n ll.append(i + 1)\n if len(ll) == b:break\n\nans=list()\nfor i,k in zip(rl,reversed(ll)):\n if b == 1 or b==0:break\n if i == k:\n ans.append(i)\n\n[print(i) for i in ans]', 'a,b,c = map(int,(input().split()))\nmb = input()\n\nrl = list()\nll = list()\n\nfor i in range(a):\n if mb[i] == "x":continue\n if len(rl) == 0:\n rl.append(i + 1)\n else:\n if rl[-1] + c + 1 <= i + 1:\n rl.append(i + 1)\n #if len(rl) <= b:break\n\nfor i in range(a-1,-1,-1):\n if mb[i] == "x":continue\n if len(ll) == 0:\n ll.append(i + 1)\n else:\n d1 = ll[-1] - c - 1\n d2 = i + 1\n if d1 >= d2:\n ll.append(i + 1)\n #if len(ll) <= b:break\n\nans=list()\nfor i,k in zip(rl,reversed(ll)):\n if b == 1:break\n if i == k:\n ans.append(i)\n\nprint([i for i in ans])', 'a,b,c = map(int,(input().split()))\nmb = input()\n \nrl = list()\nll = list()\n \nfor i in range(a):\n if mb[i] == "x":continue\n if len(rl) == 0:\n rl.append(i + 1)\n else:\n if rl[-1] + c + 1 <= i + 1:\n rl.append(i + 1)\n if len(rl) == b:break\n \nfor i in range(a-1,-1,-1):\n if mb[i] == "x":continue\n if len(ll) == 0:\n ll.append(i + 1)\n else:\n d1 = ll[-1] - c - 1\n d2 = i + 1\n if d1 >= d2:\n ll.append(i + 1)\n if len(ll) == b:break\n \nans=list()\nfor i,k in zip(rl,reversed(ll)):\n if b == 1 and len(rl) != 1 or b==0:break\n if i == k:\n ans.append(i)\n \n[print(i) for i in ans]'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s053245114', 's457222197', 's696626385', 's999913896', 's950207484'] | [25216.0, 11432.0, 11432.0, 26884.0, 23696.0] | [285.0, 145.0, 141.0, 308.0, 446.0] | [637, 654, 654, 650, 678] |
p02721 | u837673618 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ['def solve():\n N, K, C = map(int, input().split())\n workable = [i for i, s in enumerate(input()) if s=="o"]\n if len(workable) == K:\n return workable\n \n latest = set()\n prev = workable[-1]+C+1\n for x in reversed(workable):\n if prev - x > C:\n latest.add(x)\n prev = x\n if len(latest) > K:\n return []\n must = []\n prev = -C-1\n for x in workable:\n if x - prev > C:\n if x in latest:\n must.append(x)\n prev = x\n return must\n\nprint("\\n".join(map(str, solve())))', 'def with_prev(filt, ad=None):\n prev = None\n def _filt(x):\n nonlocal prev\n if prev is None or filt(x, prev):\n prev = x\n return ad(x) if ad else True\n return False\n return _filt\n\ndef solve():\n N, K, C = map(int, input().split())\n workable = [i for i, s in enumerate(input(), 1) if s=="o"]\n \n if len(workable) == K:\n return workable\n \n filt = with_prev(lambda x,p:p-x>C)\n latest = set(filter(filt, reversed(workable)))\n\n if len(latest) > K:\n return []\n \n filt = with_prev((lambda x,p:x-p>C), latest.__contains__)\n return filter(filt, workable)\n\nprint("\\n".join(map(str, solve())))\n'] | ['Wrong Answer', 'Accepted'] | ['s649497011', 's508280571'] | [23972.0, 23968.0] | [72.0, 89.0] | [511, 617] |
p02721 | u852790844 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["import itertools\nn, k, c = map(int, input().split())\ns = input()\na = [i for i in range(n)]\nb = list(itertools.combinations(a,k))\nfor i in b:\n for j in range(k):\n if s[i[j]] == 'x':\n break\n if j != 0:\n if i[j] - i[j-1] <= c:\n break\n a = set(a) & set(i)\n\nfor i in a:\n print(i+1)", "n, k, c = map(int, input().split())\ns = input()\n\ndpl = [0 for i in range(n+1)]\ndpr = [0 for i in range(n+1)]\n\nfor i in range(n):\n dpl[i+1] = (dpl[i] if s[i] == 'x' else\n dpl[i-c] + 1 if i-c >= 0 else\n 1)\n\nfor i in range(n, 0, -1):\n dpr[i-1] = (dpr[i] if s[i-1] == 'x' else\n dpr[i+c] + 1 if i+c < n else\n 1)\n\nfor i in range(1, n+1):\n if dpl[i-1] + dpr[i] < k:\n print(i)"] | ['Wrong Answer', 'Accepted'] | ['s278994580', 's090306087'] | [1765108.0, 20620.0] | [2214.0, 397.0] | [340, 444] |
p02721 | u873927631 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ['#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, K: int, C: int, S: str):\n \n work = 0\n rest = 0\n startWork = -1\n girigiriIndices = []\n for i in range(N):\n \n # print(f"i=15{rest}")\n if S[i] == "o" and rest <= 0:\n rest = C\n work += 1\n startWork = i\n else:\n rest -= 1\n # rest = -1\n # startWork = -1\n \n # if S[i] == "o" and rest <= 0:\n # rest = C\n # startWork = i\n \n # print(f"i{i},{rest}")\n # else:\n # rest -= 1\n\n if work != K:\n print("")\n # print(work)\n exit()\n for i in girigiriIndices:\n print(i+1)\n return\n\n\n# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n K = int(next(tokens)) # type: int\n C = int(next(tokens)) # type: int\n S = next(tokens) # type: str\n solve(N, K, C, S)\n\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, K: int, C: int, S: str):\n \n work = 0\n rest = 0\n startWork = -1\n girigiriIndices = []\n for i in range(N):\n if i == 15:\n print(f"i=15{rest}")\n if S[i] == "o" and rest <= 0:\n rest = C\n work += 1\n startWork = i\n else:\n rest -= 1\n rest = -1\n startWork = -1\n for i in range(N-1, -1, -1):\n if S[i] == "o" and rest <= 0:\n rest = C\n startWork = i\n girigiriIndices.append(i)\n print(f"i{i},{rest}")\n else:\n rest -= 1\n\n if work != K:\n print("")\n # print(work)\n exit()\n for i in girigiriIndices:\n print(i+1)\n return\n\n\n# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n K = int(next(tokens)) # type: int\n C = int(next(tokens)) # type: int\n S = next(tokens) # type: str\n solve(N, K, C, S)\n\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, K: int, C: int, S: str):\n \n work = 0\n rest = 0\n startWork = -1\n leftIndices = set()\n rightIndices = set()\n for i in range(N):\n if S[i] == "o" and rest <= 0:\n rest = C\n work += 1\n leftIndices.add(i)\n else:\n rest -= 1\n if work != K:\n print("")\n exit()\n work = 0\n rest = 0\n for i in range(N-1, -1, -1):\n if S[i] == "o" and rest <= 0:\n rest = C\n work += 1\n rightIndices.add(i)\n else:\n rest -= 1\n for i in sorted(list(leftIndices.intersection(rightIndices))):\n print(i+1)\n \n # rest = -1\n # startWork = -1\n \n # if S[i] == "o" and rest <= 0:\n # rest = C\n # startWork = i\n \n # print(f"i{i},{rest}")\n # else:\n # rest -= 1\n\n \n # print("")\n # # print(work)\n # exit()\n \n # print(i+1)\n return\n\n\n# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n K = int(next(tokens)) # type: int\n C = int(next(tokens)) # type: int\n S = next(tokens) # type: str\n solve(N, K, C, S)\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s704420730', 's727536845', 's757009035'] | [3516.0, 2940.0, 47400.0] | [45.0, 17.0, 251.0] | [1370, 1346, 1725] |
p02721 | u875541136 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["N, K, C = map(int, input().split())\nS = input()\n\nL = []\nR = []\nholiday = 0\n\nfor i in range(N):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n L.append(i)\n holiday = C\nholiday = 0\nfor i in range(N-1, -1, -1):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n R.append(i)\n holiday = C\nout = set(L) and set(R)\nif len(L) >= K and len(R) >= K:\n for n in out:\n print(n+1)", "N, K, C = map(int, input().split())\nS = input()\n\nL = []\nR = []\nholiday = 0\n\nfor i in range(N):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n L.append(i)\n holiday = C\nholiday = 0\nfor i in range(N-1, -1, -1):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n R.append(i)\n holiday = C\nout = set(L) and set(R)\nif len(L) == K and len(R) == K:\n for n in out:\n print(n+1)", "N, K, C = map(int, input().split())\nS = input()\n\nL = []\nR = []\nholiday = 0\n\nfor i in range(N):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n L.append(i)\n holiday = C\nholiday = 0\nfor i in range(N-1, -1, -1):\n if holiday:\n holiday -= 1\n elif S[i] == 'o':\n R.append(i)\n holiday = C\nR = R[::-1]\nout = set(L) and set(R)\nif len(L) == K:\n for l, r in zip(L, R):\n if l == r: print(l+1)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s736627891', 's860225790', 's742117839'] | [35384.0, 35384.0, 35360.0] | [266.0, 269.0, 296.0] | [388, 388, 404] |
p02721 | u876295560 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["nkc=input().split()\nK=int(nkc[1])\nC=int(nkc[2])\ns=input()\nworkday_list=[]\nfor i,youso in enumerate(s) :\n if youso=='o' :\n workday_list.append(i+1)\n \n\ns=1\n\ncurrent_num=0\ncurrent_num1=1\nlist1=[]\nlist1.append(workday_list[0])\nwhile(s<K) :\n \n if current_num1>=len(workday_list):\n break\n elif workday_list[current_num1]-workday_list[current_num]>C :\n current_num=current_num1\n list1.append(workday_list[current_num1])\n s+=1\n else :\n current_num1=current_num1+1\nm=1 \n\ncurrent_num2=len(workday_list)-1\ncurrent_num3=len(workday_list)-2\nlist2=[]\nlist2.append(workday_list[-1])\nwhile(m<K) :\n \n if current_num3<=0:\n break\n elif workday_list[current_num2]-workday_list[current_num3]>C :\n current_num2=current_num3\n list2.append(workday_list[current_num3])\n m+=1\n else :\n current_num3=current_num3-1\n\nlist2.reverse()\nprint(list1)\nprint(list2)\nfor i in range(len(list1)) :\n if list1[i]==list2[i] :\n print(list1[i])", "import itertools\nnkc=input().split()\nK=int(nkc[1])\nC=int(nkc[2])\ns=input()\nworkday_list=[]\nfor i,youso in enumerate(s) :\n if youso=='o' :\n workday_list.append(i+1)\n \nwork_candidate=itertools.combinations(workday_list,K)\nwork_candidate1=[]\nfor item_list in work_candidate:\n flag=True\n for i in range(len(item_list)-1) :\n if abs(item_list[i]-item_list[i+1])<=C :\n flag=False\n break\n if flag==True :\n \twork_candidate1.append(item_list)\nlist1=set(work_candidate1[0])\n \nprint(work_candidate1)", "nkc=input().split()\nK=int(nkc[1])\nC=int(nkc[2])\ns=input()\nworkday_list=[]\nfor i,youso in enumerate(s) :\n if youso=='o' :\n workday_list.append(i+1)\n \n\ns=1\n\ncurrent_num=0\ncurrent_num1=1\nlist1=[]\nlist1.append(workday_list[0])\nwhile(s<K) :\n \n if current_num1>=len(workday_list):\n break\n elif workday_list[current_num1]-workday_list[current_num]>C :\n current_num=current_num1\n list1.append(workday_list[current_num1])\n s+=1\n else :\n current_num1=current_num1+1\nm=1 \n\ncurrent_num2=len(workday_list)-1\ncurrent_num3=len(workday_list)-2\nlist2=[]\nlist2.append(workday_list[-1])\nwhile(m<K) :\n \n if current_num3<0:\n break\n elif workday_list[current_num2]-workday_list[current_num3]>C :\n current_num2=current_num3\n list2.append(workday_list[current_num3])\n m+=1\n else :\n current_num3=current_num3-1\n\nlist2.reverse()\n\nflag=True\nfor i in range(len(list1)) :\n if list1[i]==list2[i] :\n flag=False\n print(list1[i])\nif flag :\n print()\n"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s441229699', 's557133743', 's152842434'] | [21304.0, 80108.0, 15648.0] | [482.0, 2108.0, 576.0] | [950, 511, 970] |
p02721 | u894521144 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["\n\nN, K, C = list(map(int, input().split()))\nS = list(input())\n\nF = []\nL = []\n\n# t1 = time.time()\n\n# if S[i] == 'o':\n# if len(F) == 0:\n# F.append(i)\n# elif F[-1] + C < i:\n# F.append(i)\n# if len(F) >= K:\n# break\n# print(F)\n# t2 = time.time()\ni = 0\nwhile len(F) < K and i < N:\n if S[i] == 'o':\n if len(F) == 0:\n F.append(i)\n elif F[-1] + C < i:\n F.append(i)\n i += 1\n# print(F)\n# t3 = time.time()\n\n# print(t2 - t1, t3 - t2)\n\ni = N - 1\nwhile len(L) < K and i >= 0:\n if S[i] == 'o':\n if len(L) == 0:\n L.append(i)\n elif L[-1] - C > i:\n L.append(i)\n i -= 1\n\nif len(F) == K and len(L) == K:\n ans = [i + 1 for i in set(F) & ", "import itertools\nimport time\n\nN, K, C = list(map(int, input().split()))\nS = list(input())\n\nF = []\nL = []\n\n# t1 = time.time()\n\n# if S[i] == 'o':\n# if len(F) == 0:\n# F.append(i)\n# elif F[-1] + C < i:\n# F.append(i)\n# if len(F) >= K:\n# break\n# print(F)\n# t2 = time.time()\ni = 0\nwhile len(F) < K:\n if S[i] == 'o':\n if len(F) == 0:\n F.append(i)\n elif F[-1] + C < i:\n F.append(i)\n i += 1\n# print(F)\n# t3 = time.time()\n\n# print(t2 - t1, t3 - t2)\n\ni = N - 1\nwhile len(L) < K:\n if S[i] == 'o':\n if len(L) == 0:\n L.append(i)\n elif L[-1] - C > i:\n L.append(i)\n i -= 1\n\n[print(i) for i in set(F) & set(L)]", "\n\nN, K, C = list(map(int, input().split()))\nS = list(input())\n\nF = []\nL = []\n\n# t1 = time.time()\n\n# if S[i] == 'o':\n# if len(F) == 0:\n# F.append(i)\n# elif F[-1] + C < i:\n# F.append(i)\n# if len(F) >= K:\n# break\n# print(F)\n# t2 = time.time()\ni = 0\nwhile len(F) <= K and i < N:\n if S[i] == 'o':\n if len(F) == 0:\n F.append(i)\n elif F[-1] + C < i:\n F.append(i)\n i += 1\n# print(F)\n# t3 = time.time()\n\n# print(t2 - t1, t3 - t2)\n\ni = N - 1\nwhile len(L) <= K and i >= 0:\n if S[i] == 'o':\n if len(L) == 0:\n L.append(i)\n elif L[-1] - C > i:\n L.append(i)\n i -= 1\n\nif len(F) == K and len(L) == K:\n ans = [i + 1 for i in set(F) & set(L)]\n if len(ans) != 0:\n ans.sort()\n [print(i) for i in ans]"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s254057445', 's570092228', 's748092450'] | [3064.0, 51788.0, 51792.0] | [17.0, 399.0, 403.0] | [790, 752, 872] |
p02721 | u919730120 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["def main():\n n,k,c=map(int,input().split())\n s=list(input())\n l=[0]*(k+1)\n r=[0]*(k+1)\n x=0\n i=0\n while i<=n-1:\n if s[i]=='o':\n x+=1\n l[x]=i+1\n i+=k+1\n if x==k:\n break\n else:\n i+=1\n print(l)\n i=n-1\n while 0<=i:\n if s[i]=='o':\n r[x]=i+1\n x-=1\n i-=k+1\n if x==1:\n break\n else:\n i-=1\n print(r)\n for i in range(1,k+1):\n if l[i]==r[i]:\n print(l[i])\n\nif __name__ == '__main__':\n main()", "def main():\n n,k,c=map(int,input().split())\n s=list(input())\n l,r=[0]*(k+1),[0]*(k+1)\n x,i=1,0\n while i<=n-1:\n if s[i]=='o':\n l[x]=i+1\n i+=c+1\n x+=1\n if x==k+1:\n break\n else:\n i+=1\n x,i=k,n-1\n while 0<=i:\n if s[i]=='o':\n r[x]=i+1\n x-=1\n i-=c+1\n if x==0:\n break\n else:\n i-=1\n for i in range(1,k+1):\n if l[i]==r[i]:\n print(l[i])\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s073534137', 's988859484'] | [10632.0, 21908.0] | [172.0, 285.0] | [603, 575] |
p02721 | u933929042 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["common = []\n\ndef bool_work(s, n, k, c):\n i = 0\n while s[i] == 'o':\n if i+c+1 < n:\n j = 1\n if s[j] == 'x':\n while s[j] == 'x':\n j += 1\n wo_i = bool_work(s[j:], n - j, k, c)\n if j < i+c+1:\n j = i+c+1\n if s[j] == 'x':\n while s[j] == 'x':\n j += 1\n w_i = bool_work(s[j:], n - j, k - 1, c)\n if wo_i == 0 and w_i == 1:\n common.append(i)\n return 1\n if wo_i + w_i >= 2:\n return 2\n else:\n return wo_i + w_i\n elif i+c+1 >= n:\n if k > 1:\n return 0\n elif n == 1:\n return 1\n else:\n for char in s[1:]:\n if char == 'o':\n return 2\n return 1\n\n\nn, k, c = map(int, input().split())\ns = input()\nwhile s[-1] == 'x':\n s.pop(-1)\nbool_work(s, n, k, c)\nfor com in common:\n print(com)\n\n", 'n, k, c = map(int, input().split())\ns = " " + input()\nwork_fw = [0]*k\nwork_bw = [0]*k\ni = 1\nnow_k = 0\nwhile i <= n and now_k < k:\n if s[i] == \'o\':\n work_fw[now_k] = i\n now_k += 1\n i += c\n i += 1\nif now_k != k:\n print("")\nelse:\n i = n\n now_k = k - 1\n while i > 0 and now_k >= 0:\n if s[i] == \'o\':\n work_bw[now_k] = i\n now_k -= 1\n i -= c\n i -= 1\n # print(work_fw)\n # print(work_bw)\n for i in range(k):\n if work_fw[i] == work_bw[i]:\n print(work_fw[i] )\n'] | ['Runtime Error', 'Accepted'] | ['s651886210', 's348128435'] | [198656.0, 20548.0] | [189.0, 389.0] | [1074, 562] |
p02721 | u969639186 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ['import copy\n \nn,k,c = map(int,input().split())\ns = list(input())\n \nfront = []\nback = []\n \n\nj = copy.copy(k)\ni = 0\nwhile j > 0:\n if s[i] == "o":\n front.append(i)\n i += c+1\n j -= 1\n else:\n i += 1\n \n\n \nj = copy.copy(k)\ni = n-1\nwhile j > 0:\n if s[i] == "o":\n back.append(i)\n i -= c+1\n j -= 1\n else:\n i -= 1\n\nback.sort()\nfor i in range(k):\n if front[i] == back[i]:\n print(i+1)', 'import copy\n\nn,k,c = map(int,input().split())\ns = list(input())\n\nfront = [0]*n\nback = [0]*n\n\n\nj = copy.copy(k)\ni = 0\nwhile j > 0:\n if s[i] == "o":\n front[i] = 1\n i += c+1\n j -= 1\n else:\n i += 1\n\n\n\nj = copy.copy(k)\ni = n-1\nwhile j > 0:\n if s[i] == "o":\n back[i] = 1\n i -= c+1\n j -= 1\n else:\n i -= 1\n\n \nprint(front)\nprint(back)\nfor i in range(n):\n if front[i] == 1 and back[i] == 1:\n print(i+1)', 'import copy\n \nn,k,c = map(int,input().split())\ns = list(input())\n \nfront = []\nback = []\n \n\nj = copy.copy(k)\ni = 0\nwhile j > 0:\n if s[i] == "o":\n front.append(i)\n i += c+1\n j -= 1\n else:\n i += 1\n \n\n \nj = copy.copy(k)\ni = n-1\nwhile j > 0:\n if s[i] == "o":\n back.append(i)\n i -= c+1\n j -= 1\n else:\n i -= 1\n\nback.sort()\nfor i in range(k):\n if front[i] == back[i]:\n print(front[i]+1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s285191362', 's820420059', 's242367900'] | [22560.0, 11380.0, 22564.0] | [339.0, 341.0, 336.0] | [440, 462, 447] |
p02721 | u980205854 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ["\nN,K,C = map(int,input().split())\nS = input()\nL = [0]*K\nR = [0]*K\n\ni = 0\nfor j in range(K):\n while S[i]!='o':\n i += 1\n L[j] = i\n i += C+1\n\ni = K-1\nfor j in range(K-1,-1,-1):\n while S[i]!='o':\n i -= 1\n R[j] = i\n i -= C+1\n \nfor j in range(K):\n if L[j]==R[j]:\n print(L[j])", "\nN,K,C = map(int,input().split())\nS = input()\nL = [0]*K\nR = [0]*K\n\ni = 0\nfor j in range(K):\n while S[i]!='o':\n i += 1\n L[j] = i\n i += C+1\n\ni = N-1\nfor j in range(K-1,-1,-1):\n while S[i]!='o':\n i -= 1\n R[j] = i\n i -= C+1\n \nfor j in range(K):\n if L[j]==R[j]:\n print(L[j]+1)"] | ['Wrong Answer', 'Accepted'] | ['s523149817', 's280275644'] | [25088.0, 25024.0] | [194.0, 202.0] | [326, 328] |
p02721 | u989345508 | 2,000 | 1,048,576 | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: * After working for a day, he will refrain from working on the subsequent C days. * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on. Find all days on which Takahashi is bound to work. | ['n,k,c=map(int,input().split())\ns=input()\n\n\n\n\n\n\nl=[-1]*k\nr=[-1]*k\nnowl=0\nindl=0\nwhile nowl<n and indl<k:\n for i in range(nowl,n):\n if s[i]=="o":\n l[indl]=i\n nowl=i+c+1\n indl+=1\n break\nnowr=n-1\nindr=k-1\nwhile nowr>=0 and indr>=0:\n for i in range(nowr,-1,-1):\n if s[i]=="o":\n r[indr]=i\n nowr=i-c-1\n indr-=1\n break\nfor i in k:\n if l[i]==r[i]:\n print(i+1)', 'n,k,c=map(int,input().split())\ns=input()\n\n\n\n\n\n\nl=[-1]*k\nr=[-1]*k\nnowl=0\nindl=0\nwhile nowl<n and indl<k:\n for i in range(nowl,n):\n if s[i]=="o":\n l[indl]=i\n nowl=i+c+1\n indl+=1\n break\nnowr=n-1\nindr=k-1\nwhile nowr>=0 and indr>=0:\n for i in range(nowr,-1,-1):\n if s[i]=="o":\n r[indr]=i\n nowr=i-c-1\n indr-=1\n break\nfor i in range(k):\n if l[i]==r[i]:\n print(l[i]+1)'] | ['Runtime Error', 'Accepted'] | ['s917458575', 's285882736'] | [19164.0, 20608.0] | [364.0, 523.0] | [879, 889] |
p02722 | u006883624 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\ndef judge(n, k):\n m = n % k\n while m == 0:\n n //= k\n m = n % k\n return m\n\n\ndef calc(n):\n cnt = 3\n for k in range(2, n // 2):\n if judge(n, k) == 1:\n cnt += 1\n return cnt\n\n\ndef cal(n):\n cnt = 3\n for d in range(3, 10):\n if n % d <= 1:\n k = n // d\n if judge(k) == 1:\n cnt += 1\n\n for k in range(2, n // 10):\n if judge(n, k) == 1:\n cnt += 1\n return cnt\n\n\ndef main():\n N = int(input())\n s = {}\n cnt = 0\n\n print(calc(N))\n\n\nmain()\n', 'import math\n\n\ndef judge(n, k):\n m = n % k\n while m == 0:\n n //= k\n m = n % k\n return m\n\n\ndef div_list(n):\n l = set()\n for i in range(1, int(math.sqrt(n)) + 1):\n if n % i == 0:\n l.add(i)\n j = n // i\n if i != j:\n l.add(j)\n return l\n\n\ndef main():\n N = int(input())\n\n cnt = len(div_list(N-1)) - 1\n cnt += sum(1 for d in div_list(N) if d != 1 and judge(N, d) == 1)\n\n print(cnt)\n\n\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s025724446', 's995846328'] | [3064.0, 3828.0] | [2104.0, 210.0] | [559, 481] |
p02722 | u008079810 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\n\nN=int(input())\ncand=[]\n\ndef check(N0,K0):\n if N0%K0==0:\n return check(int(N0/K0),K0)\n elif N0%K0==1:\n return 1\n else:\n return 0\n\ndef check0(N0,K0):\n while N0%K0==0:\n N0=int(N0/K0)\n if N0%K0==1:\n return 1\n else:\n return 0\n\n\nfor i in range(2,int((N-1)**0.5)+1):#O(N**0.5)\n if (N-1)%i==0:\n cand.append(i)\n if i!=int((N-1)/i):\n cand.append(int((N-1)/i))\nif N>2:\n cand.append(N-1)\n\n\nfor i in range(2,int(N**0.5)+1):#O(N**0.5)\n if N%i==0:\n cand.append(i)\n if i!=int(N/i):\n cand.append(int(N/i))\ncand.append(N)\n\nprint(cand)\ncount=0\nfor i in range(len(cand)):\n if check(N,cand[i]):\n count+=1\n\nprint(count)', '\n\nN=int(input())\ncand=[]\n\ndef check(N0,K0):\n if N0%K0==0:\n return check(int(N0/K0),K0)\n elif N0%K0==1:\n return 1\n else:\n return 0\n\ndef check0(N0,K0):\n while N0%K0==0:\n N0=int(N0/K0)\n if N0%K0==1:\n return 1\n else:\n return 0\n\n\nfor i in range(2,int((N-1)**0.5)+1):#O(N**0.5)\n if (N-1)%i==0:\n cand.append(i)\n if i!=int((N-1)/i):\n cand.append(int((N-1)/i))\nif N>2:\n cand.append(N-1)\n\n\nfor i in range(2,int(N**0.5)+1):#O(N**0.5)\n if N%i==0:\n cand.append(i)\n if i!=int(N/i):\n cand.append(int(N/i))\ncand.append(N)\n\n#print(cand)\ncount=0\nfor i in range(len(cand)):\n if check(N,cand[i]):\n count+=1\n\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s595278750', 's152359831'] | [3316.0, 3188.0] | [297.0, 308.0] | [777, 778] |
p02722 | u021916304 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ["n = int(input())\nif n == 2:\n print(1)\n exit()\nans = []\ndivisors = []\nfor i in range(2,int(n**0.5)+1):\n \n if (n-1) % i == 0:\n ans.append(i)\n if i != (n-1) // i:\n ans.append((n-1)//i)\n \n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\nfor item in divisors:\n num = n\n while num%item == 0:\n num = num//item\n if num%item == 1:\n ans.append(item)\nprint(divisors)\nprint(ans)\nprint(len(ans)+2)\n\n'''\nimport math\nn = int(input())\nans = []\ndivisors = []\n\nfor i in range(2,math.ceil(n**0.5)+1):\n num = n\n while num >= i:\n if num%i == 0:\n num //= i\n else:\n num -= i\n print(num)\n if num == 1:\n ans.append(i)\n if n % i == 0:\n divisors.append(i+1)\n if i != n // i:\n divisors.append(n//i+1)\n\nprint(ans)\nprint(divisors)\nprint(len(ans)+len(divisors))\n\n#[2, 3, 4, 5, 10, 20, 157, 314, 628, 785, 1570, 3140, 3141]\n'''", "n = int(input())\nif n == 2:\n print(1)\n exit()\nans = []\ndivisors = []\nfor i in range(2,int(n**0.5)+1):\n \n if (n-1) % i == 0:\n ans.append(i)\n if i != (n-1) // i:\n ans.append((n-1)//i)\n \n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\nfor item in divisors:\n num = n\n while num%item == 0:\n num = num//item\n if num%item == 1:\n ans.append(item)\n\n#print(ans)\nprint(len(ans)+2)\n\n'''\nimport math\nn = int(input())\nans = []\ndivisors = []\n\nfor i in range(2,math.ceil(n**0.5)+1):\n num = n\n while num >= i:\n if num%i == 0:\n num //= i\n else:\n num -= i\n print(num)\n if num == 1:\n ans.append(i)\n if n % i == 0:\n divisors.append(i+1)\n if i != n // i:\n divisors.append(n//i+1)\n\nprint(ans)\nprint(divisors)\nprint(len(ans)+len(divisors))\n\n#[2, 3, 4, 5, 10, 20, 157, 314, 628, 785, 1570, 3140, 3141]\n'''"] | ['Wrong Answer', 'Accepted'] | ['s762095073', 's983532918'] | [3316.0, 3188.0] | [288.0, 288.0] | [1087, 1089] |
p02722 | u075595666 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n if arr==[]:\n arr.append([n, 1])\n return arr\n \nn = int(input())\na = factorization(n)\nans = 1\nb = factorization(n-1)\nchk = 1\nfor i in range(len(b)):\n chk *= (b[i][1]+1)\nans += chk-1\nfor i in range(len(a)):\n for j in range(1,a[i][1]+1):\n cnt = 0\n cnt += a[i][1]-a[i][1]%j\n #print(a[i][0]**j,cnt,n/(a[i][0]**cnt),n/(a[i][0]**cnt) % (a[i][0]**(j)))\n if n/(a[i][0]**cnt) % (a[i][0]**(j)) == 1:\n ans += 1\nif len(a) == 1:\n ans -= 1\nif n == 2:\n ans = 1', 'def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n if arr==[]:\n arr.append([n, 1])\n return arr\n \nn = int(input())\na = factorization(n)\nans = 1\nif n == 2:\n print(1)\n exit()\n \nb = factorization(n-1)\nchk = 1\nfor i in range(len(b)):\n chk *= (b[i][1]+1)\nans += chk-1\nfor i in range(len(a)):\n for j in range(1,a[i][1]+1):\n cnt = 0\n cnt += a[i][1]-a[i][1]%j\n print(a[i][0]**j,cnt,n/(a[i][0]**cnt),n/(a[i][0]**cnt) % (a[i][0]**(j)))\n if n/(a[i][0]**cnt) % (a[i][0]**(j)) == 1:\n ans += 1\nif len(a) == 1:\n ans -= 1\nprint(ans)', 'def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\nn = int(input())\na = factorization(n)\nans = 1\nif len(a) == 1 and a[0]!=n:\n ans += a[1]-1\nb = factorization(n-1)\nchk = 1\nfor i in range(len(b)):\n chk *= (b[i][1]+1)\nans += chk-1\nprint(a)\nif len(a) >= 2:\n for i in range(len(a)):\n for j in range(a[i][1]+1):\n if j!=0 and int(n/(a[i][0]**(j)))%(a[i][0]**(j)) == 1:\n ans += 1\nprint(ans)', 'def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\nn = int(input())\na = factorization(n)\nans = 2\nif len(a) == 1 and a[0]!=n:\n ans += a[1]-1\nb = factorization(n-1)\nchk = 1\nfor i in range(len(b)):\n chk *= (b[i][1]+1)\nans += chk-1\n\nif len(a) >= 2:\n for i in range(len(a)):\n for j in range(a[i][1]):\n if int(n/(a[i][0]**j))%a[i][0]**j == 0:\n ans += 1\nprint(ans)', 'def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n if arr==[]:\n arr.append([n, 1])\n return arr\n \ndef divisorize(n):\n \n f = factorization(n)\n divisors = [1]\n for k in range(len(f)):\n num_divisors = len(divisors)\n for i in range(1, f[k][1] + 1):\n for j in range(num_divisors):\n divisors.append(divisors[j] * f[k][0] ** i)\n return sorted(divisors)\n \nn = int(input())\nans = 0\nchk = divisorize(n-1)\nfor i in divisorize(n)[1:]:\n m = n\n while True:\n if m == 1:\n ans += 1\n chk.append(i)\n break\n if m < i:\n break\n if m%i == 0:\n m = m//i\n else:\n m = m%i\n\nchk = set(chk)\nprint(len(chk)-1)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s303399585', 's445659065', 's500010098', 's968380440', 's369410566'] | [3064.0, 3188.0, 3064.0, 3064.0, 3316.0] | [195.0, 196.0, 196.0, 195.0, 196.0] | [787, 810, 701, 676, 948] |
p02722 | u078932560 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import numpy as np\n \nN = int(input())\n \n \ndef divisor(N):\n x = np.arange(1, int(N**(1/2)), dtype=np.int64)\n div = set(x[N % x == 0])\n return div | set(N // x for x in div)\n \n \ncand = divisor(N) | divisor(N - 1)\n \n \ndef test(N, K):\n if K == 1:\n return False\n while N % K == 0:\n N //= K\n return N % K == 1\n \n \nanswer = sum(test(N, d) for d in cand)\nprint(answer)', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n \nN = int(read())\n \n \ndef divisor(N):\n x = np.arange(1, int(N**(1/2)), dtype=np.int64)\n div = set(x[N % x == 0])\n return div | set(N // x for x in div)\n \n \ncand = divisor(N) | divisor(N - 1)\n \n \ndef test(N, K):\n if K == 1:\n return False\n while N % K == 0:\n N //= K\n return N % K == 1\n \n \nanswer = sum(test(N, d) for d in cand)\nprint(answer)', 'import numpy as np\n \nN = int(input())\n \n \ndef divisor(N):\n x = np.arange(1, int(N**(1/2))+1, dtype=np.int64)\n div = set(x[N % x == 0])\n return div | set(N // x for x in div)\n \n \ncand = divisor(N) | divisor(N - 1)\n \n \ndef test(N, K):\n if K == 1:\n return False\n while N % K == 0:\n N //= K\n return N % K == 1\n \n \nanswer = sum(test(N, d) for d in cand)\nprint(answer)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s176605973', 's718464687', 's439672872'] | [28796.0, 30360.0, 28896.0] | [239.0, 240.0, 238.0] | [392, 507, 394] |
p02722 | u091051505 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import math\nimport copy\ndef prime_factorize(n):\n a = [n]\n for i in range(2, math.floor(n ** 0.5) + 1):\n if n % i == 0:\n a.append(i)\n if n // i != i:\n a.append(n // i)\n return a\n\nN = int(input())\nprime_n = prime_factorize(N)\nprime_n_1 = prime_factorize(N - 1)\n\nans = 0\nfor i in prime_n:\n n = copy.deepcopy(N)\n while (n % i) == 0:\n n = n // i\n if (n % i) == 1:\n ans += 1\nans += len(prime_n_1)\nif n > 2:\n print(ans)\nelse:\n print(1)', 'def prime_factorize(n):\n a = [n]\n for i in range(2, math.floor(n ** 0.5) + 1):\n if n % i == 0:\n a.append(i)\n if n // i != i:\n a.append(n // i)\n return a\n\nN = int(input())\nprime_n = prime_factorize(N)\nprime_n_1 = prime_factorize(N - 1)\n\nans = 0\nfor i in prime_n:\n n = copy.deepcopy(N)\n while (n % i) == 0:\n n = n // i\n if (n % i) == 1:\n ans += 1\nans += len(prime_n_1)\nprint(ans)', 'import math\ndef prime_factorize(n):\n a = [n]\n for i in range(2, math.floor(n ** 0.5) + 1):\n if n % i == 0:\n a.append(i)\n if n // i != i:\n a.append(n // i)\n return a\n\nN = int(input())\nprime_n = prime_factorize(N)\nprime_n_1 = prime_factorize(N - 1)\n\nans = 0\nfor i in prime_n:\n n = copy.deepcopy(N)\n while (n % i) == 0:\n n = n // i\n if (n % i) == 1:\n ans += 1\nans += len(prime_n_1)\nprint(ans)', 'import math\nimport copy\ndef prime_factorize(n):\n a = [n]\n for i in range(2, math.floor(n ** 0.5) + 1):\n if n % i == 0:\n a.append(i)\n if n // i != i:\n a.append(n // i)\n return a\n\nN = int(input())\nprime_n = prime_factorize(N)\nprime_n_1 = prime_factorize(N - 1)\n\nans = 0\nfor i in prime_n:\n n = copy.deepcopy(N)\n while (n % i) == 0:\n n = n // i\n if (n % i) == 1:\n ans += 1\nans += len(prime_n_1)\nif N > 2:\n print(ans)\nelse:\n print(1)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s048232456', 's522566448', 's674926318', 's336973382'] | [9504.0, 9208.0, 9552.0, 9608.0] | [198.0, 26.0, 196.0, 198.0] | [514, 457, 469, 514] |
p02722 | u095021077 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\ndef f(x):\n out=set() \n for i in range(1, int(pow(x, 1/2))):\n \n if x%i==0:\n \n out.add(i)\n out.add(x//i)\n \n \n if x%(x**(1/2))==0:\n out.add(x**(1/2))\n \n \n out=list(out)\n out.sort()\n \n \n return out[1:]\n\n\nN=int(input())\nans=0 \n\nfor K in f(N): \n x=N \n \n while x%K==0:\n x/=K\n \n \n x%=K\n \n \n if x==1:\n ans+=1\n \n\nans+=len(f(N-1))\n\n\nprint(ans)', '\ndef f(x):\n out=set() \n for i in range(1, (pow(x, 1/2)):\n \n if x%i==0:\n \n out.add(i)\n out.add(x//i)\n \n \n if x%(x**(1/2))==0:\n out.add(x**(1/2))\n \n \n out=list(out)\n out.sort()\n \n \n return out[1:]\n\n\nN=int(input())\nans=0 \n\nfor K in f(N): \n x=N \n \n while x%K==0:\n x/=K\n \n \n x%=K\n \n \n if x==1:\n ans+=1\n \n\nans+=len(f(N-1))\n\n\nprint(ans)', '\ndef f(x):\n out=set() \n for i in range(1, int(-(-pow(x, 1/2)//1))):\n \n if x%i==0:\n \n out.add(i)\n out.add(x//i)\n \n \n if x%(x**(1/2))==0:\n out.add(x**(1/2))\n \n \n out=list(out)\n out.sort()\n \n \n return out[1:]\n\n\nN=int(input())\nans=0 \n\nfor K in f(N): \n x=N \n \n while x%K==0:\n x/=K\n \n \n x%=K\n \n \n if x==1:\n ans+=1\n \n\nans+=len(f(N-1))\n\n\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s185643112', 's846132749', 's648588067'] | [3828.0, 2940.0, 3828.0] | [209.0, 17.0, 210.0] | [1402, 1398, 1409] |
p02722 | u106181248 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\n\ndef make_divisors(n): \n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n divisors.remove(1)\n return divisors\n\nans = make_divisors(n-1) \ny = make_divisors(n) \n\nfor i in y:\n z = n\n while z >= i and z%i == 0: \n z = int(z / i)\n if z % i == 1: \n ans.append(i)\n break\n\nset(ans)\nprint(ans)\nprint(len(ans))', 'n = int(input())\n\ndef make_divisors(n): \n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n divisors.remove(1)\n return divisors\n\nans = make_divisors(n-1) \ny = make_divisors(n) \n\nfor i in y:\n z = n\n while z >= i and z%i == 0: \n z = int(z / i)\n if z % i == 1: \n ans.append(i)\n break\n\nset(ans)\n#print(ans)\nprint(len(ans))'] | ['Wrong Answer', 'Accepted'] | ['s498496833', 's707612310'] | [3188.0, 3188.0] | [209.0, 210.0] | [710, 711] |
p02722 | u110615365 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n%i == 0:\n divisors.append(i)\n if i != n//i:\n divisors.append(n//i)\n return sorted(divisors) \nn = int(input())\nans = len(divisors(n-1))-1;\nfor k in divisors(N)[1:]:\n boz = n\n while (n % k == 0):\n n = n//k\n if (n % k == 1):\n\t ans += 1\n n = boz\nprint(ans)', 'def divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n%i == 0:\n divisors.append(i)\n if i != n//i:\n divisors.append(n//i)\n return sorted(divisors) \nn = int(input())\nans = len(divisors(n-1))-1;\nfor k in divisors(n)[1:]:\n boz = n\n while (n % k == 0):\n n = n//k\n if (n % k == 1):\n\t ans += 1\n n = boz\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s001678370', 's836614691'] | [3064.0, 3316.0] | [114.0, 210.0] | [399, 400] |
p02722 | u116233709 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n=int(input())\ndef prime_factorize(n):\n a=[]\n while n%2==0:\n a.append(2)\n n//=2\n f=3\n while f**2<=n:\n if n%f==0:\n a.append(f)\n n//=f\n else:\n f+=2\n if n!=1:\n a.append(n)\n return(a)\n\nimport collections\nA=collections.Counter(prime_factorize(n-1))\nB=collections.Counter(prime_factorize(n))\n\nans=1\ncnt=0\nfor a,b in A.items():\n ans*=(b+1)\nfor a, b in B.items():\n if b>=2:\n for i in range(2,b+1):\n if (n//(a**i))%a==1:\n cnt+=1\nimport math\nfor i in range(1,math.floor(n**0.5)+1):\n if n%i==0:\n if ((n//i)-1)%i==0:\n cnt+=1\n if ((n//i)-1)%(n//i)==0:\n cnt+=1\n\nprint(ans-2+cnt)\n\n', 'n=int(input())\ndef prime_factorize(n):\n a=[]\n while n%2==0:\n a.append(2)\n n//=2\n f=3\n while f**2<=n:\n if n%f==0:\n a.append(f)\n n//=f\n else:\n f+=2\n if n!=1:\n a.append(n)\n return(a)\n\nimport collections\nA=collections.Counter(prime_factorize(n-1))\nans=1\ncnt=0\nfor a,b in A.items():\n ans*=(b+1)\n\nimport math\nfor i in range(1,math.floor(n**0.5)+1):\n x=n\n if n%i==0:\n while x%i==0:\n x//=i \n if (x-1)%i==0:\n cnt+=1\n if (i-1)%(n//i)==0:\n cnt+=1\n\nprint(ans-2+cnt)\n\n', 'n=int(input())\ndef prime_factorize(n):\n a=[]\n while n%2==0:\n a.append(2)\n n//=2\n f=3\n while f**2<=n:\n if n%f==0:\n a.append(f)\n n//=f\n else:\n f+=2\n if n!=1:\n a.append(n)\n return(a)\n\nimport collections\nA=collections.Counter(prime_factorize(n-1))\nB=collections.Counter(prime_factorize(n))\nans=1\ncnt=0\nfor a,b in A.items():\n ans*=(b+1)\n\nimport math\nfor i in range(1,math.floor(n**0.5)+1):\n x=n\n if n%i==0:\n if n//(i**B[i])%i==0:\n cnt+=1\n if (i-1)%(n//i)==0:\n cnt+=1\n\nprint(ans-2+cnt)\n\n', 'n=int(input())\ndef prime_factorize(n):\n a=[]\n while n%2==0:\n a.append(2)\n n//=2\n f=3\n while f**2<=n:\n if n%f==0:\n a.append(f)\n n//=f\n else:\n f+=2\n if n!=1:\n a.append(n)\n return(a)\n\nimport collections\nA=collections.Counter(prime_factorize(n-1))\nB=collections.Counter(prime_factorize(n))\nans=1\ncnt=0\nfor a,b in A.items():\n ans*=(b+1)\n\nimport math\nfor i in range(1,math.floor(n**0.5)+1):\n if n%i==0:\n if j in B.keys():\n if (n // (j ** B[j])) % j == 1:\n cnt+=1\n else:\n if (n//i)%i==1:\n cnt+=1\n \n if (i-1)%(n//i)==0:\n cnt+=1\n \nprint(ans-1+cnt)', 'n=int(input())\ndef prime_factorize(n):\n a=[]\n while n%2==0:\n a.append(2)\n n//=2\n f=3\n while f**2<=n:\n if n%f==0:\n a.append(f)\n n//=f\n else:\n f+=2\n if n!=1:\n a.append(n)\n return(a)\n\nimport collections\nA=collections.Counter(prime_factorize(n-1))\nans=1\ncnt=0\nfor a,b in A.items():\n ans*=(b+1)\n\nimport math\nli=[]\nfor i in range(2,math.floor(n**0.5)+1):\n if n%i==0:\n li.append(i)\n if i!=n//i:\n li.append(n//i)\nli.append(n)\nfor i in li:\n x = n\n while x % i == 0:\n x //= i\n if x % i == 1:\n cnt += 1\nprint(ans - 1 + cnt)\n\n '] | ['Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s017639312', 's356355525', 's614089683', 's683950343', 's900978233'] | [3316.0, 3316.0, 3444.0, 3436.0, 3564.0] | [346.0, 2106.0, 382.0, 218.0, 321.0] | [730, 606, 612, 740, 662] |
p02722 | u163320134 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def divisors(n):\n ret=[]\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n ret.append(i)\n if n//i!=i:\n ret.append(n//i)\n return ret\n\nn=int(input())\ndivs1=divisors(n)\ndivs2=divisors(n-1)\ncnt=len(divs2)-1\nfor val in divs1:\n if val==1:\n continue\n tmp=n\n while tmp%val==0:\n tmp=tmp//val\n if tmp%val==1:\n cnt+=1\nprint(cnt)', 'def divisors(n):\n ret=[]\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n ret.append(i)\n if n//i!=i:\n ret.append(n//i)\n return ret\n\nn=int(input())\ndivs1=divisors(n)\ndivs2=divisors(n-1)\ncnt=len(divs2)\nfor val in divs1:\n if val==1:\n continue\n tmp=n\n while tmp%val==0:\n tmp=tmp//val\n if tmp%val==1:\n cnt+=1\nprint(cnt)', 'def divisors(n):\n ret=[]\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n ret.append(i)\n if n//i!=i:\n ret.append(n//i)\n return ret\n\nn=int(input())\ndivs1=divisors(n)\ndivs2=divisors(n-1)\nprint(divs1)\nprint(divs2)\ncand=divs2\nfor val in divs2:\n cand.add(val)\nfor val in divs1:\n tmp=n\n while tmp%val==0:\n tmp=tmp//val\n if tmp%val==1:\n cand.append(val)\nif n not in cand:\n cand.append(n)\nif n-1!=1 and n-1 not in cand:\n cand.append(n-1)\nprint(cand)\nprint(len(cand))', 'def divisors(n):\n ret=[]\n for i in range(1,int(n**0.5)+1):\n if n%i==0:\n ret.append(i)\n if n//i!=i:\n ret.append(n//i)\n return ret\n\nn=int(input())\ndivs1=divisors(n)\ndivs2=divisors(n-1)\ncnt=len(divs2)-1\nfor val in divs1:\n if val==1:\n continue\n tmp=n\n while tmp%val==0:\n tmp=tmp//val\n if tmp%val==1:\n cnt+=1\nprint(cnt)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s037264332', 's134499193', 's476649211', 's589177131'] | [3188.0, 3188.0, 3444.0, 3188.0] | [213.0, 209.0, 214.0, 209.0] | [350, 348, 491, 350] |
p02722 | u169350228 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\n\ndef yakusu(x):\n xx = 2\n y = []\n while xx*2 <= x:\n if x%xx == 0:\n y.append(xx)\n xx += 1\n return y\n\nans = len(yakusu(n-1))\n\nkk = yakusu(n)\nfor i in kk:\n nn = n\n while True:\n if nn%i == 0:\n nn = nn//i\n else:\n break\n if nn%i == 1:\n ans += 1\n\nprint(ans)\n', 'n = int(input())\n\ndef yakusu(x):\n xx = 2\n y = []\n while xx**2 < x:\n if x%xx == 0:\n y.append(xx)\n y.append(x//xx)\n xx += 1\n if xx**2 == x:\n y.append(xx)\n y.append(x)\n return y\n \nif n == 2:\n ans = 0\nelse:\n ans = len(yakusu(n-1))\n\nfor i in yakusu(n):\n nn = n\n while True:\n if nn%i == 0:\n nn = nn//i\n else:\n break\n if nn%i == 1:\n ans += 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s669592150', 's371391584'] | [2940.0, 3188.0] | [2107.0, 758.0] | [356, 469] |
p02722 | u190616335 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['#!/usr/bin/python3\n# -*- coding: utf-8 -*-\ndef make_divisors(n):\n divisors = []\n for i in range(2, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\nn = int(input())\nif n == 2:\n print(0)\nelif n == 3:\n print(2)\nelif n == 4:\n print(3)\nelse:\n count = 2\n check_list = make_divisors(n-1)\n count += len(check_list)\n temp_n = str(n)\n suma = 0\n for i in range(len(temp_n)):\n suma += int(temp_n[i])\n if suma % 3 == 1:\n count += 1\n\n """\n for k in [3]:\n temp_n = n\n while(True):\n if temp_n % k == 0:\n temp_n = temp_n // k\n else:\n temp_n = temp_n - k\n if temp_n <= 0:\n break\n if temp_n == 1:\n count += 1\n break\n """\n print(count)\n', '#!/usr/bin/python3\n# -*- coding: utf-8 -*-\ndef make_divisors(n):\n divisors = []\n for i in range(2, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\nn = int(input())\nif n == 2:\n print(1)\nelif n == 3:\n print(2)\nelif n == 4:\n print(3)\nelse:\n count = 2\n check_list = make_divisors(n-1)\n count += len(check_list)\n check_list = make_divisors(n)\n for k in check_list:\n temp_n = n // k\n while(True):\n if temp_n % k == 0:\n temp_n = temp_n // k\n elif temp_n % k == 1:\n count += 1\n break\n else:\n break\n print(count)\n'] | ['Wrong Answer', 'Accepted'] | ['s649151497', 's326260699'] | [3188.0, 3188.0] | [114.0, 210.0] | [950, 775] |
p02722 | u192042624 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import math\n\n\nN = int(input())\n\nnn = int(math.sqrt(N))\n\nans = 0\nfor x in range(2,nn+1):\n\n if N % x > 1:\n continue\n\n if N % x == 1:\n ans += 1\n continue\n \n tmp = N\n while True:\n tmp = tmp / x\n if tmp % x == 1:\n ans += 1\n break\n elif tmp == x :\n ans += 1\n break\n elif tmp % x >= 1:\n break\n\nprint(ans+3)\n\n\n\n\n', 'import math\n\n\nN = int(input())\n\nnn = int(math.sqrt(N))\n\n\nans = 1\nfor x in range(2,nn+1):\n\n if N % x == 1:\n ans += 1\n continue\n \n if N % x > 1:\n continue\n\n tmp = N\n while tmp > x:\n tmp = tmp / x\n if tmp % x == 1 :\n ans += 1\n break\n elif tmp % x > 1 :\n break\n elif tmp == x:\n ans += 1\n break\n\nx = 1\ntmp = N - 1\nwhile tmp / x > nn:\n if tmp % x == 0:\n ans += 1\n x += 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s086127594', 's516180711'] | [3060.0, 3064.0] | [144.0, 623.0] | [424, 527] |
p02722 | u228223940 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\nn = n-1\nans = 0\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\nli = make_divisors(n)\n\nfor i in range(2,n+1):\n if i**2 > n:\n break\n tmp = n\n #print(i)\n while tmp % i == 0:\n #print(tmp)\n #exit()\n tmp = tmp / i\n if tmp % i == 1:\n ans += 1\n li.append(i)\n \nprint(unique(li)-1)\n\nexit()\n\nfor i in range(2,n+1):\n """\n if i**2 > n:\n break\n """\n tmp = n\n #print(i)\n if tmp % i == 0:\n #print(tmp)\n #exit()\n #tmp = tmp / i\n ans += 1\n print(i)\n """\n if tmp == 1:\n ans += 1\n print(i)\n """\n \nprint(ans)', 'n = int(input())\nn = n-1\nans = 0\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\nli = make_divisors(n)\nn = n+1\nfor i in range(2,n+1):\n if i**2 > n:\n break\n tmp = n\n #print(i)\n while tmp % i == 0:\n #print(tmp)\n #exit()\n tmp = tmp / i\n if tmp % i == 1:\n ans += 1\n li.append(i)\n#print(li)\nprint(len(set(li)))\n\nexit()\n\nfor i in range(2,n+1):\n """\n if i**2 > n:\n break\n """\n tmp = n\n #print(i)\n if tmp % i == 0:\n #print(tmp)\n #exit()\n #tmp = tmp / i\n ans += 1\n print(i)\n """\n if tmp == 1:\n ans += 1\n print(i)\n """\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s768074697', 's204987086'] | [3188.0, 3064.0] | [686.0, 671.0] | [855, 864] |
p02722 | u231189826 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import math\nN = int(input())\nans = [N-1,N]\n\n#N-1\nfor i in range(2,int(math.sqrt(N-1)+1)):\n if (N-1) % i == 0:\n ans.append(i)\n if i != (N-1)//i:\n ans.append((N-1)//i)\n\n#N\nfor j in range(2,int(math.sqrt(N))+1):\n if N % j == 0:\n n1 = N\n n2 = N\n while n1 % j == 0:\n n1 = n1/j\n while n2 % N//j == 0:\n n2 = n2*j//N\n \n \n if n1 % j == 1:\n ans.append(j)\n if n2 % j == 1:\n ans.append(N//j)\n\nprint(ans)\nprint(len(ans))', 'N = int(input())\ncount = 0\nif N ==2:\n print(1)\nelse:\n\n for i in range(2,int((N-1)**0.5)+1):\n if (N-1)%i == 0:\n count += 1\n if (N-1)//i != i:\n count += 1\n\n for j in range(2,int(N**0.5)+1):\n if N%j == 0:\n n = N\n while n%j == 0:\n n = n//j\n if n%j == 1:\n count += 1\n if N//j != j:\n n = N\n while n%(N//j) == 0:\n n = n//(N//j)\n if n%(N//j) == 1:\n count += 1\n print(count+2)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s001815778', 's198073544'] | [3064.0, 3188.0] | [297.0, 306.0] | [538, 589] |
p02722 | u243714267 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\nif n == 2:\n print(1)\nelif n == 3:\n print(2)\nelse:\n \n print(len(make_divisors(n-1))+1)', 'def make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\nN = int(input())\ndivsN = make_divisors(N)\ndivsN2 = make_divisors(N-1)\ndivsN.pop(0)\n\nans = len(divsN2)-1\n\nfor div in divsN:\n n = N\n while True:\n if n%div != 0 or n==1:\n break\n n //= div\n if n%div == 1:\n ans += 1\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s937217584', 's716471192'] | [9056.0, 9152.0] | [24.0, 293.0] | [140, 558] |
p02722 | u266014018 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import collections\ndef prime_factorize(n):\n a = []\n while n%2 == 0:\n a.append(2)\n n//=2\n f =3\n while f*f <= n:\n if n%f == 0:\n a.append(f)\n n//=f\n else:\n f +=2\n if n != 1:\n a.append(n)\n return a\n\n\nN = int(input())\nfactor = collections.Counter(prime_factorize(N-1))\nK = 1\nfor i in factor.values():\n K *= i+1\nK -=1\n\nfor f in range(2, int(N**0.5)+1):\n while N%f ==0:\n print(f)\n N//=f\n if N%f ==1 or N==1:\n K+=1\n\nK +=1\nprint(K)', 'import collections\ndef prime_factorize(n):\n a = []\n while n%2 == 0:\n a.append(2)\n n//=2\n f =3\n while f*f <= n:\n if n%f == 0:\n a.append(f)\n n//=f\n else:\n f +=2\n if n != 1:\n a.append(n)\n return a\n\n\nN = int(input())\nfactor = collections.Counter(prime_factorize(N-1))\nK = 1\nfor i in list(factor.values()):\n K *= i+1\nK -=1\nprint(K)\nfor f in range(2, int(N**0.5)+1):\n n = N\n if n%f != 0:\n continue\n while n%f ==0:\n n//=f\n if n%f ==1 or n==1:\n print(f)\n K+=1\n\nK +=1\nprint(K)', 'import collections\ndef prime_factorize(n):\n a = []\n while n%2 == 0:\n a.append(2)\n n//=2\n f =3\n while f*f <= n:\n if n%f == 0:\n a.append(f)\n n//=f\n else:\n f +=2\n if n != 1:\n a.append(n)\n return a\n\n\nN = int(input())\nfactor = collections.Counter(prime_factorize(N-1))\nK = 1\nfor i in list(factor.values()):\n K *= i+1\nK -=1\nfor f in range(2, int(N**0.5)+1):\n n = N\n if n%f != 0:\n continue\n while n%f ==0:\n n//=f\n if n%f ==1 or n==1:\n K+=1\n\nK +=1\nprint(K)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s010891939', 's068020926', 's185270040'] | [3316.0, 3316.0, 3316.0] | [368.0, 247.0, 245.0] | [601, 659, 633] |
p02722 | u268792407 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n=int(input())\nN=[n]\nimport collections\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0 and i!=1:\n divisors.append(i)\n if i != n // i and n//i!=1:\n divisors.append(n//i)\n return divisors+[n]\nt=make_divisors(n)+make_divisor(n-1)\nans=0\nfor k in t:\n n=N[0]\n while n>=k:\n if n%k==0:\n n//=k\n else:\n n-=k\n if n==1:\n ans+=1\nprint(ans)', 'n=int(input())\nN=[n]\nimport collections\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\nt=prime_factorize(n-1) \nc = collections.Counter(t)\nw=1\nfor i in c.values():\n w *= 1+i\nw-=1\n#print(w)\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0 and i!=1:\n divisors.append(i)\n if i != n // i and n//i!=1:\n divisors.append(n//i)\n return divisors\nt=make_divisors(n)+[n]\n\nfor i in t:\n n=N[0]\n while n%i==0:\n n//=i\n if n%i==1:\n w+=1\nprint(w)'] | ['Runtime Error', 'Accepted'] | ['s467748049', 's497307948'] | [3572.0, 3700.0] | [116.0, 194.0] | [411, 734] |
p02722 | u278057806 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from sys import stdin\nfrom math import sqrt\ninput = stdin.readline\n\nN = int(input())\ncnt = 2\n\nfor i in range(2, int(sqrt(N)) + 1):\n if (N - 1) % i == 0:\n cnt += 1\n\nfor i in range(2, int(sqrt(N)) + 1):\n tmp = N // i\n if (tmp - 1) % i == 0:\n cnt += 1\n\n\nfor i in range(2, int(sqrt(N)) + 1):\n for j in range(40):\n if pow(i, j + 1) + pow(i, j) == N:\n cnt += 1\n\n\nprint(cnt)\n', 'from sys import stdin\nfrom math import sqrt\ninput = stdin.readline\n\nN = int(input())\n\ns = set([N - 1, N])\n\n\nfor i in range(2, int(sqrt(N)) + 1):\n tmp = N\n if (tmp - 1) % i == 0:\n s.add(i)\n s.add((tmp - 1) // i)\n elif tmp % i == 0:\n while tmp % i == 0:\n tmp //= i\n\n if tmp % i == 1:\n s.add(i)\n\n tmp = N\n while tmp % (N // i) == 0:\n tmp //= (N // i)\n print(tmp)\n\n if tmp % (N // i) == 1:\n s.add(tmp // i)\n\n# print(s)\nprint(len(s))\n', 'from sys import stdin\nfrom math import sqrt\ninput = stdin.readline\n\nN = int(input())\n\nif N == 2:\n print(1)\n exit()\n\ns = set([N - 1, N])\n\n\nfor i in range(2, int(sqrt(N)) + 1):\n tmp = N\n if (tmp - 1) % i == 0:\n s.add(i)\n s.add((tmp - 1) // i)\n elif tmp % i == 0:\n while tmp % i == 0:\n tmp //= i\n\n if tmp % i == 1:\n s.add(i)\n\n tmp = N\n while tmp % (N // i) == 0:\n tmp //= (N // i)\n\n if tmp % (N // i) == 1:\n s.add(N // i)\n\n# print(s)\nprint(len(s))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s065459880', 's776425719', 's824398741'] | [3064.0, 3324.0, 3064.0] | [2104.0, 308.0, 326.0] | [412, 542, 553] |
p02722 | u281610856 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ["def make_divisors(n):\n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n return divisors\n\n\ndef main():\n n = int(input())\n \n ans = len(make_divisors(n-1))\n \n l = make_divisors(n)[1:] \n for i in l:\n num = n\n while num % i == 0:\n num //= i\n if num % i == 1:\n ans += 1\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "def make_divisors(n):\n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n return divisors\n\n\ndef main():\n n = int(input())\n \n ans = len(make_divisors(n - 1)) - 1\n \n l = make_divisors(n)[1:]\n for i in l:\n num = n\n while num % i == 0:\n num //= i\n if num % i == 1:\n ans += 1\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s653896550', 's092493119'] | [3188.0, 3316.0] | [207.0, 209.0] | [639, 616] |
p02722 | u347600233 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def calc_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.sort()\n return divisors\n\ndef div_or_sub(n, k):\n while k <= n:\n if n % k == 0:\n n //= k\n else:\n n -= k\n return n\n\nn = int(input())\ncnt = len(calc_divisors(n - 1)) - 1\nn_divisors = calc_divisors(n)\nfor divisor in n_divisors:\n if div_or_sub(n, divisor) == 1:\n cnt += 1\nprint(cnt)', 'def calc_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.sort()\n return divisors\n\ndef div_or_sub(n, k):\n while k <= n:\n if n % k == 0:\n n //= k\n else:\n n %= k\n return n\n\nn = int(input())\ncnt = len(calc_divisors(n - 1)) - 1\nn_divisors = calc_divisors(n)\nfor divisor in n_divisors:\n if div_or_sub(n, divisor) == 1:\n cnt += 1\nprint(cnt)', 'def calc_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.sort()\n return divisors\n\ndef div_or_sub(n, k):\n while k <= n:\n if n % k == 0:\n n //= k\n else:\n n %= k\n return n\n\nn = int(input())\ncnt = len(calc_divisors(n - 1)) - 1\nn_divisors = calc_divisors(n)\nfor divisor in n_divisors[1:]:\n if div_or_sub(n, divisor) == 1:\n cnt += 1\nprint(cnt)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s105068873', 's892589899', 's118373550'] | [3188.0, 3188.0, 3188.0] | [210.0, 210.0, 209.0] | [546, 546, 546] |
p02722 | u363074342 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\n\ndivisor = [N]\nans = 0\n\n\nfor i in range(2,N+1,1):\n if i*i <= N:\n if N % i == 0:\n divisor.append(i)\n divisor.append(N//i)\n\n\nyakusuuu = [N-1]\nfor i in range(2,N,1):\n if i*i <= N:\n if N % i == 1:\n yakusuuu.append(i)\n yakusuuu.append((N-1)//i)\n\nfor i in yakusuuu:\n if N % i == 1:\n ans += 1\n\n\n\n\nfor K in divisor:\n \n for i in range(N):\n if N % K == 0:\n N = N//K\n else:\n break\n \n\n if N == 1:\n ans += 1\n \n else:\n N %= K\n if N == 1:\n ans += 1 \n \n\n\n\n\nprint(ans)', 'N = int(input())\n\ndivisor = [N]\nans = 0\n\n\nfor i in range(2,N+1,1):\n if i*i < N:\n if N % i == 0:\n divisor.append(i)\n divisor.append(N//i)\n elif i*i == N:\n divisor.append(i)\n else:\n break\n\n\nyakusuuu = [N-1]\nfor i in range(2,N,1):\n if i*i < (N-1):\n if (N - 1)% i == 0:\n yakusuuu.append(i)\n yakusuuu.append((N-1)//i)\n elif i*i == (N-1):\n yakusuuu.append(i)\n else:\n break\n\nfor i in yakusuuu:\n if N % i == 1:\n ans += 1\n\n\n\n\nM = N\n\nfor K in divisor:\n \n while M % K == 0:\n M = M//K\n\n \n\n if M == 1:\n ans += 1\n \n else:\n M = M % K\n if M == 1:\n ans += 1 \n \n M = N\n \n\n\n\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s651941240', 's349773305'] | [3188.0, 3188.0] | [2104.0, 520.0] | [759, 838] |
p02722 | u365364616 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from collections import defaultdict\n\ndef prime_factrize(n):\n b = defaultdict(int)\n while n % 2 == 0:\n b[2] += 1\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n b[f] += 1\n n //= f\n else:\n f += 2\n if n != 1:\n b[n] += 1\n return b\n\nn = int(input())\nprimes = prime_factrize(n)\nans = 0\nif n not in primes.keys():\n ans += 1\nfor k, v in primes.items():\n ans += (n // k ** v) % k == 1\n\nm = 2\nn1 = n - 1\nwhile m * m <= n1:\n ans += n1 % m == 0\n m += 1\nprint(ans)\n', 'def divisors(n):\n x = set()\n m = 1\n while m * m <= n:\n if n % m == 0:\n x.add(m)\n x.add(n // m)\n m += 1\n return x\n\nn = int(input())\nd = divisors(n)\nans = 0\nfor k in d:\n if k == 1:\n continue\n nn = n\n while nn % k == 0:\n nn = nn // k\n ans += nn % k == 1\n\nd1 = divisors(n - 1)\nans += len(d1) - 1\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s899254814', 's517895299'] | [3316.0, 3828.0] | [373.0, 349.0] | [554, 377] |
p02722 | u371132735 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def is_prime(n):\n if n == 2 or n%2 == 0:\n return False\n for i in range(2,int(n**0.5)):\n if n%i == 0:\n return False\n return True\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\nans = 2\nN = int(input())\nif is_prime(N):\n print(ans)\nelse:\n div = make_divisors(N)\n# print(div)\n# print(len(div)*2+1)\n\n', 'def is_prime(n):\n if n == 2 or n%2 == 0:\n return False\n for i in range(2,int(n**0.5)):\n if n%i == 0:\n return False\n return True\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\nans = 2\nN = int(input())\nif is_prime(N):\n print(ans)\nelse:\n div = make_divisors(N)\n print(len(div)*2+1)\n\n', 'def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\nans = 2\nN = int(input())\n\ndiv = make_divisors(N)\ndiv_1 = make_divisors(N-1)\nans = 0\nfor i in div:\n p = N\n if i == 1:\n continue\n while p%i == 0:\n p = p//i\n if p%i == 1:\n ans +=1\n\nprint(ans + len(div_1)-1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s662603525', 's974479381', 's658448899'] | [3316.0, 3316.0, 3316.0] | [114.0, 114.0, 210.0] | [535, 518, 477] |
p02722 | u392319141 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from math import gcd\n\nprint(gcd(120, 24))', 'from fractions import gcd\n\nprint(gcd(120, 24))\n', 'N = int(input())\n\ndef isOk(k):\n n = N\n while n % k == 0:\n n //= k\n return n % k == 1\n\n\ndef divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n \n return divisors\n\ndiv1 = divisors(N)\ndiv2 = divisors(N - 1)\n\nans = len([0 for d in div1 if d != 1 and isOk(d)]) + len([0 for d in div2 if d != 1 and isOk(d)])\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s704019170', 's895996755', 's907490304'] | [2940.0, 5304.0, 3188.0] | [17.0, 40.0, 211.0] | [41, 47, 536] |
p02722 | u413165887 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['num = int(input())\nnum -= 1\nresult = 1\nfor i in range(2, int(pow(num, 0.5))+1):\n c = 0\n while num%i==0:\n num //= i\n c += 1\n if c>0:\n result *= c+1\n\nif num > 1:\n result *= 2\nresult -= 1\nnum += 1\nfor i in range(2, int(pow(num, 0.5))+1):\n n = num\n if n%i==0:\n while n%i==0:\n n //= i\n if n%i==1 or i%n==1:\n result += 1\n\nprint(result)', 'num = int(input())\nn = num\nnum -= 1\nresult = 1\nfor i in range(2, int(pow(num, 0.5))+1):\n c = 0\n while num%i==0:\n num //= i\n c += 1\n if c>0:\n result *= c+1\n\nif num > 1:\n result *= 2\nresult -= 1\n\nr = set()\nfor i in range(2, int(pow(n, 0.5))+1):\n num = n\n if num%i==0:\n r.add(i)\n r.add(n//i)\nr.add(n)\nfor i in r:\n num = n\n while num%i==0:\n num //= i\n if num%i == 1:\n result += 1\n\nprint(result)'] | ['Wrong Answer', 'Accepted'] | ['s821879383', 's611925610'] | [3188.0, 3828.0] | [285.0, 352.0] | [404, 466] |
p02722 | u459419927 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from sys import stdin\ndef make_divisors(n):\n mod0 = set()\n mod1 = set()\n for i in range(2, int(n**0.5)+1):\n if n%i==0:\n mod0.add(i)\n mod0.add(n/i)\n if (n-1)%i==0:\n mod1.add(i)\n mod1.add((n-1)/i)\n print(mod0)\n print(mod1)\n return mod0,mod1\n\nN=list(map(int,(stdin.readline().strip().split())))\nnum=N[0]\nK=0\nmod0,mod1=(make_divisors(num))\n# mod0.remove(1)\n# mod1.remove(1)\nfor i in mod0:\n num = N[0]\n while(num % i == 0):\n num/=i\n\n if num%i==1:\n K+=1\nK+=len(mod1)+2\nprint(K)\n', 'from sys import stdin\ndef make_divisors(n):\n mod0 = set()\n mod1 = set()\n for i in range(2, int(n**0.5)+1):\n if n%i==0:\n mod0.add(i)\n mod0.add(n/i)\n if (n-1)%i==0:\n mod1.add(i)\n mod1.add((n-1)/i)\n print(mod0)\n print(mod1)\n return mod0,mod1\n\nN=list(map(int,(stdin.readline().strip().split())))\nnum=N[0]\nK=0\nmod0,mod1=(make_divisors(num))\n# mod0.remove(1)\n# mod1.remove(1)\nfor i in mod0:\n num = N[0]\n while(num % i == 0):\n num/=i\n\n if num%i==1:\n K+=1\nK+=len(mod1)+2\nprint(K)\n', 'from sys import stdin\ndef make_divisors(n):\n mod0 = set()\n mod1 = set()\n for i in range(1, int(n**0.5)+1):\n if n%i==0:\n mod0.add(i)\n # mod0.add(n//i)\n if (n-1)%i==0:\n mod1.add(i)\n # mod1.add((n-1)//i)\n return mod0,mod1\n\nN=list(map(int,(stdin.readline().strip().split())))\nnum=N[0]\nK=0\nmod0,mod1=(make_divisors(num))\nmod0.remove(1)\nmod1.remove(1)\nfor i in mod0:\n num = N[0]\n while(num % i == 0):\n num//=i\n\n if num%i==1:\n K+=1\nK+=len(mod1)\nprint(K)\n', 'from sys import stdin\ndef make_divisors(n):\n mod0 = set()\n mod1 = set()\n for i in range(2, int(n**0.5)+1):\n if n%i==0:\n mod0.add(i)\n mod0.add(n/i)\n if (n-1)%i==0:\n mod1.add(i)\n mod1.add((n-1)/i)\n return mod0,mod1\n\nN=list(map(int,(stdin.readline().strip().split())))\n\nnum=N[0]\nif num==2:print(1)\nelse:\n K=0\n mod0,mod1=(make_divisors(num))\n # mod0.remove(1)\n # mod1.remove(1)\n for i in mod0:\n num = N[0]\n while(num % i == 0):\n num/=i\n\n if num%i==1:\n K+=1\n K+=len(mod1)+2\n print(K)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s081310750', 's222945057', 's923151183', 's139123509'] | [3828.0, 3956.0, 3188.0, 3828.0] | [242.0, 243.0, 241.0, 242.0] | [571, 571, 540, 613] |
p02722 | u459590249 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\ndef make_divisors(n):\n\tdivisors = []\n\tfor i in range(1, int(n**0.5)+1):\n\t\tif n % i == 0:\n\t\t\tdivisors.append(i)\n\t\t\tif i != n // i:\n\t\t\t\tdivisors.append(n//i)\n\treturn divisors\n\n\nn=int(input())\n#n%k!=0\ncnt=len(make_divisors(n-1))\n\n#n%k==0\nlst=make_divisors(n)\nfor k in lst:\n\tt=n\n\twhile t%k==0:\n\t\tt//=k\n\tt%=k\n\tif t==1:\n\t\tcnt+=1\nprint(cnt-1)', '\ndef make_divisors(n):\n\tdivisors = []\n\tfor i in range(1, int(n**0.5)+1):\n\t\tif n % i == 0:\n\t\t\tdivisors.append(i)\n\t\t\tif i != n // i:\n\t\t\t\tdivisors.append(n//i)\n\treturn divisors\n\n\nn=int(input())\n#n%k!=0\ncnt=len(make_divisors(n-1))-1\n\n#n%k==0\nlst=make_divisors(n)\nfor k in lst:\n\tif k!=1:\n\t\tt=n\n\t\twhile t%k==0:\n\t\t\tt//=k\n\t\tif (t-1)%k==0:\n\t\t\tcnt+=1\nprint(cnt)'] | ['Time Limit Exceeded', 'Accepted'] | ['s384968879', 's150040788'] | [3188.0, 3188.0] | [2104.0, 210.0] | [353, 367] |
p02722 | u471641802 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\na = [n]\nif n != 2:\n a.append(n - 1)\n\ndef div_(N, k):\n while N % k == 0:\n N /= k\n if N % k == 1:\n a.append(k)\n\nfor k in range(2, int(n ** 0.5) + 1):\n if n % k == 0:\n div_(n,k)\n if k != n / k:\n div_(n, n // k)\n\n if (n - 1) % k == 0:\n a.append(k)\n if k != (n - 1) / k:\n a.append((n - 1) // k)\n\nprint(a)\nprint(len(a))', 'n = int(input())\na = [n]\nif n != 2:\n a.append(n - 1)\n\ndef div_(N, k):\n while N % k == 0:\n N /= k\n if N % k == 1:\n a.append(k)\n\nfor k in range(2, int(n ** 0.5) + 1):\n if n % k == 0:\n div_(n,k)\n if k != n / k:\n div_(n, n // k)\n\n if (n - 1) % k == 0:\n a.append(k)\n if k != (n - 1) / k:\n a.append((n - 1) // k)\n\nprint(len(a))'] | ['Wrong Answer', 'Accepted'] | ['s509426816', 's451042778'] | [3064.0, 3064.0] | [295.0, 303.0] | [409, 400] |
p02722 | u490642448 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\n\ndef check(p):\n _N = N\n while _N%p == 0:\n _N //= p\n return ((_N-1)%p == 0) or (_N == 1)\n\nn = int(N**0.5)\nP0 = set([N])\nP1 = set([N-1])\nfor i in range(2, n+1):\n if N%i == 0:\n P0.add(i)\n P0.add(N//i)\n\nn = int((N-1)**0.5)\nfor i in range(2, n+1):\n if N%i == 0:\n P1.add(i)\n P1.add((N-1)//i)\n\nans = len(P1)\nfor p in P0:\n ans += check(p)\n\nprint(ans)\n', 'N = int(input())\n\ndef check(p):\n _N = N\n while _N%p == 0:\n _N //= p\n return ((_N-1)%p == 0) or (_N == 1)\n\nn = int(N**0.5)\nP0 = set([N])\nP1 = set([N-1])\nfor i in range(2, n+1):\n if N%i == 0:\n P0.add(i)\n P0.add(N//i)\n\nn = int((N-1)**0.5)\nfor i in range(2, n+1):\n if N%i == 0:\n P1.add(i)\n P1.add(N//i)\n\nans = len(P1)\nfor p in P0:\n ans += check(p)\n\nprint(ans)\n', 'n = int(input())\nans = 0\n\ndef calc(n,k):\n while(n%k==0):\n n = n//k\n n %= k\n return n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1,int(n**0.5)+1):\n if(n%i == 0):\n divisors.append(i)\n if(i!= n//i):\n divisors.append(n//i)\n\n return divisors\n\ndivisors = make_divisors(n)\ndivisors += make_divisors(n-1)\ndivisors = set(divisors)\nfor i in divisors:\n if(i != 1):\n if( calc(n,i)==1 ):\n ans += 1\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s149464556', 's238248789', 's233043452'] | [4672.0, 4544.0, 3956.0] | [264.0, 282.0, 210.0] | [381, 377, 499] |
p02722 | u497952650 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from copy import deepcopy\nimport numpy as np\ndef factor(N):\n ans = []\n for i in range(1,int(np.sqrt(N))+1):\n if N%i == 0:\n ans.append(i)\n if N//i != i:\n ans.append(i)\n return ans\n\ndef check(K,N):\n while 1:\n if N%K == 0:\n N = N//K\n else:\n break\n if N%K == 1:\n return True\n else:\n return False\n\nN = int(input())\nans = len(factor(N-1)[1:])\nfor K in factor(N)[1:]:\n if check(K,N):\n ans += 1\n\nprint(ans) ', 'import numpy as np\ndef factor(N):\n ans = []\n for i in range(1,int(np.sqrt(N))+1):\n if N%i == 0:\n ans.append(i)\n if N//i != i:\n ans.append(N//i)\n return ans\n\ndef check(K,N):\n while N >= K:\n if N%K == 0:\n N //= K\n else:\n N %= K\n if N%K == 1:\n return True\n else:\n return False\n\nN = int(input())\nans = len(factor(N-1))-1\n\nfor K in factor(N)[1:]:\n if check(K,N):\n ans += 1\n\nprint(ans) \n'] | ['Time Limit Exceeded', 'Accepted'] | ['s797858591', 's401236718'] | [14408.0, 12476.0] | [2108.0, 338.0] | [523, 514] |
p02722 | u506086925 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n return divisors\n\nn = int(input())\nnl = make_divisors(n)\nnl_p = make_divisors(n+1)\nnl_m = make_divisors(n-1)\nl = sorted(list(set(nl + nl_p+nl_m)))\nprint(l)\n\nans = 0\nfor i in range(1, len(l)-1):\n p = n\n k = l[i]\n while p > k:\n if p%k == 0:\n p = p//k\n elif p%k == 1:\n p = 1\n break\n else:\n break\n if p == 1:\n ans += 1\nprint(ans+1)', 'def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n return divisors\n\nn = int(input())\nnl = make_divisors(n)\nnl_m = make_divisors(n-1)\nl = sorted(list(set(nl + nl_m)))\n\nans = 0\nfor i in range(1, len(l)-1):\n p = n\n k = l[i]\n while p%k == 0:\n p = p // k\n if p%k == 1:\n ans += 1\nprint(ans+1)'] | ['Wrong Answer', 'Accepted'] | ['s525500381', 's607238418'] | [3956.0, 4084.0] | [306.0, 209.0] | [633, 484] |
p02722 | u509405951 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import math\n\nN = int(input())\n\ncnt = 0\n\nif N == 2:\n print(1)\n exit()\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\nres1 = sorted(make_divisors(N))\nprint(res1)\nres1 = res1[1:math.ceil(len(res1)/2)]\n\nfor num in res1:\n kensa = N\n while True:\n if kensa % num == 0:\n kensa = kensa // num\n continue\n break\n if kensa % num == 1:\n cnt += 1\n\nres2 = sorted(make_divisors(N-1))\ncnt += len(res2[1:])+1\n\nprint(cnt)', 'import math\n \nN = int(input())\n \ncnt = 0\n \nif N == 2:\n print(1)\n exit()\n \ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n \n \n return divisors\nres1 = sorted(make_divisors(N))\nres1 = res1[1:math.ceil(len(res1)/2)]\n \nfor num in res1:\n kensa = N\n while True:\n if kensa % num == 0:\n kensa = kensa // num\n continue\n break\n if kensa % num == 1:\n cnt += 1\n \nres2 = sorted(make_divisors(N-1))\ncnt += len(res2[1:])+1\n \nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s655732814', 's692360466'] | [3444.0, 3444.0] | [209.0, 210.0] | [621, 617] |
p02722 | u513519822 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\nN_tmp = N\npf={}\nfor i in range(2,int(N**0.5)+1):\n while N%i==0:\n pf[i]=pf.get(i,0)+1\n N//=i\nif N>1:pf[N]=1\n\nkouho = [1]\nfor k in pf.keys():\n new_kouho = []\n for v in range(0, pf[k] + 1):\n for val in kouho:\n new_kouho.append(val * k ** v)\n new_kouho.append(val * k ** v - 1)\n kouho.extend(new_kouho)\n\ncnt = 0\nfor v in sorted(list(set(kouho)))[1:]:\n K = v\n tmp_N = N_tmp\n if K <= 1: continue\n print(tmp_N, K)\n while tmp_N >= K:\n if tmp_N % K == 0:\n tmp_N = tmp_N // K\n else:\n tmp_N = tmp_N % K\n if tmp_N == 1:\n cnt += 1\n\nprint(cnt)', 'N = int(input())\nN_tmp = N\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\ncnt = 0\ndivisors = make_divisors(N)\ndivisors_n1 = make_divisors(N-1)\ndivisors.extend(divisors_n1)\nfor K in divisors:\n tmp_N = N_tmp\n if K <= 1: continue\n while tmp_N % K == 0:\n tmp_N = tmp_N // K\n tmp_N = tmp_N % K\n if tmp_N == 1:\n cnt += 1\n\nprint(cnt)\n'] | ['Wrong Answer', 'Accepted'] | ['s886541931', 's841457975'] | [322516.0, 3188.0] | [2119.0, 209.0] | [666, 552] |
p02722 | u535803878 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from itertools import product\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\ndef _num(arr):\n out = 1\n for item in arr:\n out *= (item[1]+1)\n return out\n\nn_orig = int(input())\narr = factorization(n_orig)\narr1 = factorization(n_orig - 1)\n\nif len(arr)==1 and arr[0][1]==1:\n print(_num(arr1))\nelse:\n tmp = _num(arr1)-1\n \n for nums in product(*[range(item[1]+1) for item in arr]):\n n = n_orig\n kk = 1\n for num, base in zip(nums, arr):\n base = base[0]\n kk *= base**num\n if (kk==1):\n continue\n while n%kk==0:\n n /= kk\n if ((n - 1) % kk == 0):\n print(kk)\n tmp += 1\n print(tmp)', 'from itertools import product\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\ndef _num(arr):\n out = 1\n for item in arr:\n out *= (item[1]+1)\n return out\n\nn_orig = int(input())\narr = factorization(n_orig)\narr1 = factorization(n_orig - 1)\n\nif n_orig==2:\n print(1)\nelif len(arr)==1 and arr[0][1]==1:\n print(_num(arr1))\nelse:\n tmp = _num(arr1)-1\n \n for nums in product(*[range(item[1]+1) for item in arr]):\n n = n_orig\n kk = 1\n for num, base in zip(nums, arr):\n base = base[0]\n kk *= base**num\n if (kk==1):\n continue\n while n%kk==0:\n n /= kk\n if ((n - 1) % kk == 0):\n tmp += 1\n print(tmp)'] | ['Wrong Answer', 'Accepted'] | ['s280213542', 's762509285'] | [3188.0, 3064.0] | [195.0, 196.0] | [1012, 1019] |
p02722 | u550294762 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n \nn = int(input())\n\ntmp = n - 1\nret = len(make_divisors(tmp)) - 1\n\ntmplen = make_divisors(tmp)\n\nfor item in tmplen:\n if item == 1:\n continue\n val = n\n while True:\n if val % item == 0:\n val = val // item\n else:\n if val % item == 1:\n ret += 1\n break\n\nprint(ret)\n', 'def make_divisors(n):\n lower_divisors, upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\n\nn = int(input())\n\ntmp = n - 1\nret = len(make_divisors(tmp)) - 1\n\ntmplen = make_divisors(n)\n\nfor item in tmplen:\n if item == 1:\n continue\n val = n\n while True:\n if val % item == 0:\n val = val // item\n else:\n if val % item == 1:\n ret += 1\n break\n\nprint(ret)\n'] | ['Wrong Answer', 'Accepted'] | ['s935456397', 's886401005'] | [9216.0, 9212.0] | [296.0, 298.0] | [632, 628] |
p02722 | u557282438 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\ncnt = 0\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\nN1_yakusu = make_divisors(N-1)\nN_yakusu = make_divisors(N)\ncnt += len(N1_yakusu)\nfor s in N_yakusu:\n new_N = s\n while(new_N%K==0):\n new_N = new_N//K\n if(new_N%K == 1):\n cnt += 1\nprint(cnt)', 'N = int(input())\ncnt = 0\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.pop(0)\n return divisors\nN1_yakusu = make_divisors(N-1)\nN_yakusu = make_divisors(N)\ncnt += len(N1_yakusu)\nfor K in N_yakusu:\n new_N = N\n while(new_N%K==0):\n new_N = new_N//K\n if(new_N%K == 1):\n cnt += 1\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s331540557', 's508773020'] | [3188.0, 3188.0] | [208.0, 209.0] | [477, 474] |
p02722 | u593567568 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import sys\nsys.setrecursionlimit(10 ** 7)\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(input())\n\n\n\ndef divisor(n):\n ass = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n ass.append(i)\n if i**2 == n:\n continue\n ass.append(n//i)\n return ass \n\n\ndiv_n = divisor(N)\ndiv_n1 = divisor(N - 1)\n\nans = []\nfor d in div_n:\n nd = N // d\n if nd % d == 1:\n ans.append(d)\n\nfor d in div_n1:\n ans.append(d)\n\n\nans = list(set(ans))\nprint(ans)\nprint(len(ans)-1)\n', 'import sys\nsys.setrecursionlimit(10 ** 7)\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(input())\n\n\n\ndef divisor(n):\n ass = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n ass.append(i)\n if i**2 == n:\n continue\n ass.append(n//i)\n return ass \n\n\ndiv_n = divisor(N)\ndiv_n1 = divisor(N - 1)\n\nans = []\nfor d in div_n:\n if d == 1:\n continue\n n = N\n while n % d == 0:\n n //= d\n\n if n % d == 1 or n == 1:\n ans.append(d)\n\nfor d in div_n1:\n if d == 1:\n continue\n if N % d == 0:\n nd = N // d\n if nd % d == 1 or nd % d == 0:\n ans.append(d)\n else:\n ans.append(d)\n\n\nans = list(set(ans))\n# print(ans)\nprint(len(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s771863146', 's703578512'] | [3188.0, 3192.0] | [210.0, 209.0] | [641, 865] |
p02722 | u619144316 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import collections\nfrom itertools import combinations\nimport math\nN = int(input())\n\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nL = collections.Counter(prime_factorize(N-1))\n# print(L)\nA = 1\nfor i,v in L.items():\n A *= (v+1)\n\nA -= 1 \n\nc = collections.Counter(prime_factorize(N))\nprime = list(dict(c).keys())\nd = []\nfor i in range(1,len(c)):\n d += list(combinations(prime,i))\nbe = list(c.values())\n\n\nD = 0\nif len(be) > 1:\n beki = math.gcd(be)\nelse:\n beki = be[0]\n while beki%2 == 0:\n beki = beki //2\n D += 1\n\n# C = 1\n# for i,v in L.items():\n# C *= (v+1)\n# C -= 1\n\nB = 1\nfor divisor in d:\n a = N\n b = 1\n print(divisor)\n for i in divisor:\n b *= i ** c[i]\n a /= (i ** c[i])\n if b >= a:\n amari = b%a\n print(b,a,amari)\n if amari == 1:\n B += 1\n\n# print(A,B,D)\nprint(A+B+D)', 'import collections\nfrom itertools import combinations\nfrom functools import reduce\nimport fractions\nN = int(input())\n\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\nL = collections.Counter(prime_factorize(N-1))\n# print(L)\nA = 1\nfor i,v in L.items():\n A *= (v+1)\n\nA -= 1 \n\nc = collections.Counter(prime_factorize(N))\nprime = list(dict(c).keys())\nd = []\nfor i in range(1,len(c)):\n d += list(combinations(prime,i))\nbe = list(c.values())\n\n\nD = 0\nif len(be) > 1:\n # print(be)\n beki = gcd(be)\nelse:\n beki = be[0]\n while beki%2 == 0:\n beki = beki //2\n D += 1\n\n# C = 1\n# for i,v in L.items():\n# C *= (v+1)\n# C -= 1\n\nB = 1\n# print(c)\nfor divisor in d:\n a = N\n b = 1\n \n for i in divisor:\n a /= (i ** c[i])\n b = i\n # print(a,b)\n for j in range(c[i]):\n b = b**(j+1)\n if a > b:\n amari = a%b\n # print(b,a,amari)\n if amari == 1:\n B += 1\n\n# print(A,B,D)\nprint(A+B+D)', 'import math\nN = int(input())\nM = int(math.sqrt(N))\nM2 = int(math.sqrt(N-1))\ncount = 0\nfor i in range(1,M2+1):\n if (N-1)%i == 0:\n if i == M2:\n count += 1\n else:\n count += 2\n\ndivsion = []\nfor i in range(2,M+1):\n if N%i == 0:\n divsion.append(i)\n\nfor i in divsion:\n while N%i == 0:\n N = N/i\n if N % i == 1:\n count += 1\n break\n\nprint(count+1)\n', 'import math\nN = int(input())\nM = int(math.sqrt(N))\nM2 = int(math.sqrt(N-1))\ny = []\nfor i in range(1,M2+1):\n if (N-1)%i == 0:\n m = (N-1)//i\n if not m == 1:\n y.append(m)\n if i == 1 or i == m:\n continue\n else:\n y.append(i)\ncount = len(y)\n\ny = []\nfor i in range(1,M+1):\n if N%i == 0:\n m = N//i\n y.append(m)\n if i == 1 or i == m:\n continue\n else:\n y.append(i)\n\nfor i in y:\n NN = N\n while NN%i == 0:\n NN /= i\n # print(NN)\n if int(NN) % i == 1:\n count += 1\n # print(i)\n\nprint(count)\n\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s092467909', 's268550301', 's946716586', 's357791375'] | [3444.0, 166244.0, 3064.0, 3188.0] | [108.0, 2106.0, 300.0, 327.0] | [1158, 1297, 414, 627] |
p02722 | u621509924 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n return divisors\n\nL = len(make_divisors(N))\n\nans = 0\nfor i in range(L):\n t = N\n while t%(make_divisors(N)[i]) == 0:\n t = t//make_divisors(N)[i]\n if t%(make_divisors(N)[i]) == 1:\n ans = ans + 1\n \nprint(ans + len(make_divisors(N-1)) -1)', 'N = int(input())\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n return divisors\n\nL = len(make_divisors(N))\n\nA = make_divisors(N)\n\nans = 0\nfor i in range(1,L):\n t = N\n while t%(A[i]) == 0:\n t = t//A[i]\n if t%A[i] == 1:\n ans = ans + 1\n \nprint(ans + len(make_divisors(N-1)) -1)'] | ['Time Limit Exceeded', 'Accepted'] | ['s283320213', 's965366459'] | [3188.0, 3316.0] | [2104.0, 306.0] | [483, 460] |
p02722 | u651109406 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from math import sqrt\nfrom fractions import gcd\nfrom collections import Counter\n\nn = int(input()) \ntimes = 0\n\n\ndef gcd(tmpn):\n lists = []\n while True:\n end = True\n for i in range(2, int(sqrt(tmpn)) + 1):\n if tmpn % i == 0:\n lists.append(i)\n tmpn = tmpn // i\n end = False \n if end: \n lists.append(tmpn)\n break\n return lists\n\n\ndef gori(lists, num=1, ans=[]):\n if len(lists) == 0:\n ans.append(num)\n return ans\n for i in range(len(lists)):\n tmp = lists[0:i] + lists[i + 1:len(lists)]\n ans = gori(tmp, num * lists[i], ans)\n ans = gori(tmp, num, ans)\n return ans\n\n\na = Counter(gcd(n - 1))\ntimes = sum(map(lambda x: x+1, a.values())) - 1\n\na = set(gori(gcd(n)))\na.remove(1)\n\nfor i in a:\n tmp = n // i\n if tmp < i:\n if tmp == 1:\n times += 1\n \n else:\n while True:\n if tmp < i:\n if tmp == 1:\n times += 1\n break\n if tmp % i == 0:\n tmp = int(tmp / i)\n \n else:\n if tmp % i == 1:\n times += 1\n break\n\nprint(times) ', 'from collections import Counter\n\nn = int(input()) \ntimes = 0\n\ndef make_divisors(n):\n divisors = [n]\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n\n divisors.sort()\n return divisors\n \ntimes = len(make_divisors(n - 1))\na = make_divisors(n)\n\nfor i in a:\n tmp = n // i\n if tmp == 1:\n times += 1 \n continue\n while tmp % i == 0:\n tmp = tmp // i\n if tmp % i == 1:\n times += 1 \n \nprint(times if n != 2 else 1)'] | ['Wrong Answer', 'Accepted'] | ['s559170078', 's602535388'] | [91596.0, 3692.0] | [2110.0, 217.0] | [1350, 574] |
p02722 | u686230543 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\n\ncount = 1\ndivisor = []\n\nd = 2\nwhile d * d < n - 1:\n if n % d == 1:\n count += 2\n d += 1\nif d * d == n:\n count += 1\n\nd = 2\nwhile d * d < n:\n if n % d == 0:\n divisor.append(d)\n divisor.append(n // d)\n d += 1\nif d * d == n:\n divisor.append(d)\ncount += 1\n\nfor d in divisor:\n tmp = n\n while tmp % d == 0:\n tmp //= d\n if tmp % d == 1:\n count += 1', 'n = int(input())\n\nif n == 2:\n count = 1\nelse:\n count = 2\ndivisor = []\n\nd = 2\nwhile d * d < n - 1:\n if (n - 1) % d == 0:\n count += 2\n d += 1\nif d * d == n - 1:\n count += 1\n\nd = 2\nwhile d * d < n:\n if n % d == 0:\n divisor.append(d)\n divisor.append(n // d)\n d += 1\nif d * d == n:\n divisor.append(d)\n\nfor d in divisor:\n tmp = n\n while tmp % d == 0:\n tmp //= d\n if tmp % d == 1:\n count += 1\n\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s046829800', 's820043969'] | [9304.0, 9212.0] | [441.0, 459.0] | [381, 425] |
p02722 | u690536347 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\nans = set()\n\ndef check(N, k):\n if k<2:\n return False\n N //= k\n while N:\n if (N-1)%k==0:\n return True\n if N%k:\n return False\n N //= k\n\nfor k in range(1, int(N**0.5)+1):\n if (N-1)%k==0:\n ans.add(k)\n ans.add((N-1)//k)\n if N%k==0:\n if check(N, k):\n ans.add(k1)\n if check(N, N//k):\n ans.add(k2)\n\nans.remove(1)\nprint(len(ans))', 'N = int(input())\n\nans = set()\nfor k in range(1, int(N**0.5)+1):\n if (N-1)%k==0:\n k1, k2 = k, (N-1)//k\n if k1>=2:\n ans.add(k1)\n if k2>=2:\n ans.add(k2)\n if N%k==0:\n k1, k2 = k, N//k\n if k1>=2:\n v = N\n while v-1:\n if (v-1)%k1==0:\n ans.add(k1)\n break\n v //= k1\n if k2>=2:\n v = N\n while v-1:\n if (v-1)%k2==0:\n ans.add(k2)\n break\n v //= k2\nprint(len(ans))', 'N = int(input())\nans = set()\n\ndef check(N, k):\n if k<2:\n return False\n N //= k\n while N:\n if (N-1)%k==0:\n return True\n if N%k:\n return False\n N //= k\n\nfor k in range(1, int(N**0.5)+1):\n if (N-1)%k==0:\n ans.add(k)\n ans.add((N-1)//k)\n if N%k==0:\n if check(N, k):\n ans.add(k)\n if check(N, N//k):\n ans.add(N//k)\n\nans.remove(1)\nprint(len(ans))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s237113060', 's322963925', 's028126161'] | [9376.0, 9448.0, 9324.0] | [22.0, 2206.0, 255.0] | [452, 599, 453] |
p02722 | u767664985 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n divisors.sort()\n return divisors\n\n\nN = int(input())\nans = 0\nK_cand = set(make_divisors(N) + make_divisors(N-1)) \n\nfor K in K_cand:\n if K == 1: \n continue\n\n \n while N%K == 0:\n N = N // K\n\n \n N = N%K\n\n \n if N == 1:\n ans += 1\n\nprint(ans)\n', 'from copy import deepcopy\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n divisors.sort()\n return divisors\n\nN0 = int(input())\nans = 0\n\n\nK_cand = set(make_divisors(N0) + make_divisors(N0-1))\nprint(K_cand)\n\nfor K in K_cand:\n N = deepcopy(N0)\n if K == 1: \n continue\n else:\n while N%K == 0:\n N = N // K \n N = N%K \n if N == 1:\n ans += 1\n\nprint(ans)\n', 'from copy import copy\n\ndef make_divisors(n):\n \n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n divisors.sort()\n return divisors\n\n\nN0 = int(input())\ncand = set(make_divisors(N0) + make_divisors(N0-1))\n\nans = 0\nfor K in cand:\n if K == 1:\n continue\n N = copy(N0)\n while N%K == 0:\n N //= K\n N %= K\n if N == 1:\n ans += 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s169718951', 's237792958', 's972452912'] | [3856.0, 4424.0, 4424.0] | [209.0, 215.0, 219.0] | [686, 758, 543] |
p02722 | u887142477 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ["import numpy as np\n\nN, M = map(int, input().split())\nABC = np.zeros((N, 3))\nfor i in range(N):\n ABC[i][0], ABC[i][1], ABC[i][2] = map(int, input().split())\nDEF = np.zeros((M, 3))\nfor i in range(M):\n DEF[i][0], DEF[i][1], DEF[i][2] = map(int, input().split())\n\n\nx_co = {-10**9-1, 10**9+1}\ny_co = {-10**9-1, 10**9+1}\nfor i in range(N):\n x_co.add(ABC[i][0])\n x_co.add(ABC[i][1])\n y_co.add(ABC[i][2])\nfor i in range(M):\n x_co.add(DEF[i][0])\n y_co.add(DEF[i][1])\n y_co.add(DEF[i][2])\n\nx_co = np.array(sorted(list(x_co)))\ny_co = np.array(sorted(list(y_co)))\nxL = len(x_co) - 1\nyL = len(y_co) - 1\nx_co_d = {x_co[i]: i for i in range(xL+1)}\ny_co_d = {y_co[i]: i for i in range(yL+1)}\n\n\ns_ex_tate = np.zeros((yL+1, xL))\ns_ex_yoko = np.zeros((xL+1, yL))\nfor i in range(N):\n a = x_co_d[ABC[i][0]]\n b = x_co_d[ABC[i][1]]\n c = y_co_d[ABC[i][2]]\n s_ex_tate[c][a:b] = 1\nfor i in range(M):\n d = x_co_d[DEF[i][0]]\n e = y_co_d[DEF[i][1]]\n f = y_co_d[DEF[i][2]]\n s_ex_yoko[d][e:f] = 1\n\n\nfor i in range(xL):\n if x_co[i+1] > 0:\n xf = [i]\n break\n if x_co[i+1] == 0:\n xf = [i, i+1]\n break\nfor i in range(yL):\n if y_co[i+1] > 0:\n yf = [i]\n break\n if y_co[i+1] == 0:\n yf = [i, i+1]\n break\n\ndef sq(x, y):\n return int((x_co[x+1]-x_co[x]) * (y_co[y+1]-y_co[y]))\n\n\nQ = []\n# houmon = [[False] * yL for _ in range(xL)]\nhoumon = np.zeros((xL, yL))\nans = 0\nis_inf = False\nfor x in xf:\n for y in yf:\n houmon[x][y] = 1\n Q.append((x, y))\n\nwhile Q:\n x, y = Q.pop()\n if x in [0, xL-1] or y in [0, yL-1]:\n is_inf = True\n break\n ans += sq(x, y)\n if (not houmon[x-1][y]) and (not s_ex_yoko[x][y]):\n houmon[x-1][y] = True\n Q.append((x-1, y))\n if (not houmon[x][y-1]) and (not s_ex_tate[y][x]):\n houmon[x][y-1] = True\n Q.append((x, y-1))\n if (not houmon[x+1][y]) and (not s_ex_yoko[x+1][y]):\n houmon[x+1][y] = True\n Q.append((x+1, y))\n if (not houmon[x][y+1]) and (not s_ex_tate[y+1][x]):\n houmon[x][y+1] = True\n Q.append((x, y+1))\n \nif is_inf:\n print('INF')\nelse:\n print(ans)", 'N = int(input())\n\n\n# O(N**0.5)\ndef yakusu(N):\n ret = [[], []]\n for i in range(1, int(N ** 0.5)+1):\n if N % i == 0:\n ret[0].append(i)\n if i ** 2 != N:\n ret[1].append(N//i)\n return ret[0] + ret[1][::-1]\n\nans = 0\nfor a in yakusu(N):\n if a == 1: continue\n \n if N % a == 0:\n b = N\n while b % a == 0:\n b //= a\n if (b-1) % a == 0:\n ans += 1\nprint(ans + len(yakusu(N-1)) - 1)'] | ['Runtime Error', 'Accepted'] | ['s108547843', 's506197726'] | [27180.0, 9348.0] | [108.0, 197.0] | [2219, 480] |
p02722 | u904547029 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\n\ndef divisior(n):\n a = []\n i = 1\n while (i*i <= n):\n if n%i == 0:\n a.append(i)\n if (i*i != n): a.append(n//i)\n i += 1\n\n return a\n\nans = 0\na = divisior(n).sort()\n\nfor x in a[1:]:\n tmp = n\n while (tmp%x == 0): tmp = tmp//x\n if (tmp%x == 1) : ans += 1\n\nb = divisior(n-1)\n\nans = ans + len(b) -1\n\nprint(ans)\n\n\n', 'n = int(input())\n\ndef divisior(n):\n a = []\n i = 1\n while (i*i <= n):\n if n%i == 0:\n a.append(i)\n if (i*i != n): a.append(n//i)\n i += 1\n return a\n\nans = 0\na = divisior(n)\n\nfor x in a:\n if x == 1: continue\n tmp = n\n while (tmp%x == 0): tmp = tmp//x\n if (tmp%x == 1) : ans += 1\n\nb = divisior(n-1)\n\nans = ans + len(b) -1\n\nprint(ans)\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s714441160', 's460450605'] | [3188.0, 3188.0] | [183.0, 348.0] | [379, 391] |
p02722 | u922449550 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['N = int(input())\n\ndef check(p):\n _N = N\n while _N%p == 0:\n _N //= p\n return (_N-1)%p == 0\n\nn = int(N**0.5) + 1\nP0 = set([N])\nP1 = set([N-1])\nfor i in range(2, n+1):\n if (N-1)%i == 0:\n P1.add(i)\n P1.add((N-1)//i)\n if N%i == 0:\n P0.add(i)\n P0.add(N//i)\n\nP2.discard(1)\nP1.discard(1)\nans = len(P1)\nfor p in P0:\n ans += check(p)\n\nprint(ans)', 'def check(p):\n _N = N\n while _N%p == 0:\n _N //= p\n return (_N-1)%p == 0\n\ndef calc_divisors(n):\n m = int(n**0.5)\n left = []\n right = []\n for i in range(1, m+1):\n if n%i == 0:\n left.append(i)\n right.append(n//i)\n if left[-1] == right[-1]:\n right.pop()\n return left + right[::-1]\n\nN = int(input())\nP0 = calc_divisors(N)[1:] \nP1 = calc_divisors(N-1)[1:] \nans = len(P1)\nfor p in P0:\n ans += check(p)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s371177130', 's122437516'] | [3828.0, 3316.0] | [303.0, 208.0] | [356, 494] |
p02722 | u927839462 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n=int(input())\nnlist=make_divisors(n)\nn1list=make_divisors(n-1)\n# print(nlist)\n# print(n1list)\nanswer=len(n1list)-1\nfor i in nlist[1:len(nlist)]:\n pra=n\n while (pra%i==0):\n pra=pra/i\n if pra%i==1:\n answer+=1\nprint(answer)\n', 'def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n return divisors\nn=int(input())\nnlist=make_divisors(n)\nn1list=make_divisors(n-1)\n# print(nlist)\n# print(n1list)\nanswer=len(n1list)-1\nfor i in nlist[1:len(nlist)]:\n pra=n\n while (pra%i==0):\n pra=pra/i\n if pra%i==1:\n answer+=1\nprint(answer)\n'] | ['Runtime Error', 'Accepted'] | ['s236513241', 's158614237'] | [3064.0, 3316.0] | [19.0, 209.0] | [262, 501] |
p02722 | u928784113 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nimport math\nfrom copy import deepcopy\nimport queue\n#import numpy as np\n\nMod = 1000000007\ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[y] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n def divisor(n):\n res = []\n for i in range(1, int(np.sqrt(n)) + 1):\n if n % i == 0:\n res.append(i)\n j = n // i\n if j != i:res.append(j)\n res.sort(reverse = True)\n return res[::-1]\n n = int(input())\n div1 = divisor(n - 1)\n div2 = divisor(n)\n ans = len(div1) - 1\n for d in div2:\n if d == 1: continue\n nn = n\n while nn % d == 0:\n nn //= d\n if nn % d == 1:\n ans += 1\n\n print(ans)\n\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nimport math\nfrom copy import deepcopy\nimport queue\nimport numpy as np\n\nMod = 1000000007\ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[y] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n def divisor(n):\n res = []\n for i in range(1, int(np.sqrt(n)) + 1):\n if n % i == 0:\n res.append(i)\n j = n // i\n if j != i:res.append(j)\n res.sort(reverse = True)\n return res[::-1]\n n = int(input())\n div1 = divisor(n - 1)\n div2 = divisor(n)\n ans = len(div1) - 1\n for d in div2:\n if d == 1: continue\n nn = n\n while nn % d == 0:\n nn //= d\n if nn % d == 1:\n ans += 1\n\n print(ans)\n\nif __name__ == "__main__":\n main() '] | ['Runtime Error', 'Accepted'] | ['s760704296', 's865628841'] | [9840.0, 27384.0] | [29.0, 285.0] | [2049, 2042] |
p02722 | u933929042 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['n = int(input())\nk = 2\ncount = 0\nwhile k * k <= n:\n if n % k == 1:\n if k == n-1 or k*k == n-1:\n count += 1\n else:\n count += 2\n elif n % k == 0:\n n_copy = n\n while n_copy % k == 0:\n n_copy //= k\n if n_copy % k == 1:\n if k == n_copy-1 or k*k == n_copy-1:\n count += 1\n else:\n count += 2\n k += 1\nprint(count)\n', 'n = int(input())\nk = 2\ncount = set()\nwhile k * k <= n:\n if n % k == 1:\n count.add(k)\n count.add((n-1)//k)\n elif n % k == 0:\n n_copy = n\n while n_copy % k == 0:\n n_copy //= k\n if n_copy % k == 1:\n count.add(k)\n k += 1\nif n > 2:\n count.add(n-1)\ncount.add(n)\nprint(len(count))\n'] | ['Wrong Answer', 'Accepted'] | ['s778843853', 's661968938'] | [3060.0, 3064.0] | [384.0, 384.0] | [434, 343] |
p02722 | u934868410 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['from collections import defaultdict\n\nn = int(input())\n\n\ndef factorization_dict(k):\n ret = defaultdict(int)\n i = 2\n while k > 1 and i * i <= k:\n while k % i == 0:\n ret[i] += 1\n k //= i\n i += 1\n if k > 1:\n ret[k] += 1\n return ret\n\n\ndef factorization_list(k):\n ret = []\n i = 2\n while k > 1 and i * i <= k:\n while k % i == 0:\n ret += [i]\n k //= i\n i += 1\n if k > 1:\n ret += [k]\n return ret\n\n\nfact = factorization_list(n)\nfact1 = factorization_dict(n - 1)\nprint(fact)\n\ns = set()\n\n\nfor i in range(1, pow(2, len(fact))):\n k = 1\n for j in range(len(fact)):\n if (i >> j) & 1:\n k *= fact[j]\n nn = n\n while nn % k == 0:\n nn //= k\n\n if nn % k == 1:\n s.add(k)\n\nmul = 1\nfor v in fact1.values():\n mul *= v + 1\n\nprint(len(s) + mul - 1)', 'n = int(input())\nif n == 2:\n print(1)\n exit()\n\nfact = [n]\nfact1 = [n-1]\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n fact += [i]\n if n // i != i:\n fact += [n//i]\n i += 1\n\ni = 2\nwhile i * i <= n-1:\n if (n-1) % i == 0:\n fact1 += [i]\n if (n-1) // i != i:\n fact1 += [(n-1)//i]\n i += 1\n\nans = 0\nfor x in fact:\n k = n\n while k % x == 0:\n k //= x\n if k % x == 1:\n ans += 1\n\nprint(ans + len(fact1))'] | ['Wrong Answer', 'Accepted'] | ['s343767707', 's697831583'] | [3316.0, 3188.0] | [2104.0, 649.0] | [885, 477] |
p02722 | u952708174 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def f_division_or_substraction():\n N = int(input())\n\n def divisor_list(n):\n \n ret = set()\n for k in range(1, int(n**0.5) + 1):\n if n % k == 0:\n ret.update({k, n // k})\n return sorted(ret)\n\n ans = (len(divisor_list(N - 1)) - 1) \n for k in divisor_list(N):\n if k == 1:\n continue\n n = N\n while n % k == 0:\n n //= k\n ans += 1\n return ans\n\nprint(f_division_or_substraction())\n', 'def f_division_or_substraction():\n N = int(input())\n\n def divisor_list(n):\n \n ret = set()\n for k in range(1, int(n**0.5) + 1):\n if n % k == 0:\n ret.update({k, n // k})\n return sorted(ret)\n\n ans = (len(divisor_list(N - 1)) - 1) \n for k in divisor_list(N):\n if k == 1:\n continue\n n = N\n while n % k == 0:\n n //= k\n ans += 1\n\nprint(f_division_or_substraction())', 'def f_division_or_substraction():\n N = int(input())\n\n def divisor_list(n):\n \n ret = set()\n for k in range(1, int(n**0.5) + 1):\n if n % k == 0:\n ret.update({k, n // k})\n return sorted(ret)\n\n ans = (len(divisor_list(N - 1)) - 1) \n for k in divisor_list(N):\n if k == 1:\n continue\n n = N\n while n % k == 0:\n n //= k\n ans += 1 if n % k == 1 else 0\n return ans\n\nprint(f_division_or_substraction())'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s041676771', 's063126711', 's207504048'] | [3580.0, 3572.0, 3580.0] | [210.0, 209.0, 209.0] | [556, 540, 576] |
p02722 | u955251526 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['MAX_PRIME = 10**5\nis_prime = [1] * MAX_PRIME\nprimes = []\nis_prime[0] = 0\nis_prime[1] = 0\nfor i in range(MAX_PRIME):\n if is_prime[i]:\n primes.append(i)\n for j in range(2, ((MAX_PRIME-1)//i) + 1):\n is_prime[i*j] = 0\n\ndef factorization(n):\n factor = {}\n for p in primes:\n if p ** 2 > n:\n break\n while n % p == 0:\n n //= p\n if p not in factor:\n factor[p] = 1\n else:\n factor[p] += 1\n if n > 1:\n factor[n] = 1\n return factor\n\nn = int(input())\nans = 1\nfor _, c in factorization(n-1).items():\n ans *= c + 1\n\nf = factorization(n)\nk = list(f.keys())\ndef dfs(num, i, cum, searched):\n if num not in searched:\n x = n\n while x % num == 0 and x > 0:\n x //= num\n if x % num == 1:\n cum += 1\n searched.add(num)\n if i < len(k):\n p = k[i]\n for j in range(f[p]+1):\n cum = dfs(num * p ** j, i+1, cum, searched)\n return cum\n\nprint(f)\nprint(dfs(1, 0, 0, set()) + ans - 1, ans)', 'MAX_PRIME = 10 ** 6\nis_prime = [1] * MAX_PRIME\nprimes = []\nis_prime[0] = 0\nis_prime[1] = 0\nfor i in range(MAX_PRIME):\n if is_prime[i]:\n primes.append(i)\n for j in range(2, ((MAX_PRIME-1)//i) + 1):\n is_prime[i*j] = 0\n\ndef factorization(n):\n factor = {}\n for p in primes:\n if p ** 2 > n:\n break\n while n % p == 0:\n n //= p\n if p not in factor:\n factor[p] = 1\n else:\n factor[p] += 1\n if n > 1:\n factor[n] = 1\n return factor\n\nn = int(input())\nans = 1\nfor _, c in factorization(n-1).items():\n ans *= c + 1\n\nf = factorization(n)\nk = list(f.keys())\ndef dfs(num, i):\n ret = 0\n if i == len(k):\n if num != 1:\n x = n\n while x % num == 0:\n x //= num\n if x % num == 1:\n ret += 1\n return ret\n else:\n p = k[i]\n for j in range(f[p]+1):\n ret += dfs(num * p ** j, i+1)\n return ret\n\nprint(dfs(1, 0) + ans - 1)'] | ['Time Limit Exceeded', 'Accepted'] | ['s377268839', 's272872789'] | [4188.0, 14020.0] | [2104.0, 563.0] | [1070, 1046] |
p02722 | u985972698 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['\n# -*- coding: utf-8 -*-\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\n\nN_given = int(input())\n\n\nlist_found_K = []\n\n\n\ndivisors_N_minus_1 = make_divisors(N_given-1)\n\nfor divs in divisors_N_minus_1:\n\tif divs != 1:\n\t\tlist_found_K.append(divs)\n\n\n\ndivisors_N = make_divisors(N_given)\ndivisors_N.remove(1)\n\n\n\n\n\nfor candidate_K in divisors_N:\n\tN_wk = N_given\n\t\n\twhile N_wk % candidate_K == 0:\n\t\tN_wk //=candidate_K\n\n\t\n\tif (N_wk-1) % candidate_K == 0:\n\t\tlist_found_K.append(candidate_K)\n\nprint(list_found_K)\nprint(len(list_found_K))\n', '\n# -*- coding: utf-8 -*-\n\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\n\nN_given = int(input())\n\n\nlist_found_K = []\n\n\n\ndivisors_N_minus_1 = make_divisors(N_given-1)\n\nfor divs in divisors_N_minus_1:\n\tif divs != 1:\n\t\tlist_found_K.append(divs)\n\n\n\ndivisors_N = make_divisors(N_given)\ndivisors_N.remove(1)\n\n\nfor candidate_K in divisors_N:\n\tN_wk = N_given\n\t\n\twhile N_wk % candidate_K == 0:\n\t\tN_wk //=candidate_K\n\n\t\n\tif (N_wk-1) % candidate_K == 0:\n\t\tlist_found_K.append(candidate_K)\n\nprint(len(list_found_K))\n'] | ['Wrong Answer', 'Accepted'] | ['s396141661', 's986925562'] | [3316.0, 3188.0] | [210.0, 209.0] | [1122, 972] |
p02722 | u989345508 | 2,000 | 1,048,576 | Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. * Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? | ['def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.sort()\n return divisors\n\ndef all_pattern(n):\n ans=0\n for ds in make_divisors(n):\n k=n\n if ds==1:\n continue\n while k%ds==0:\n k//=ds\n ans+=(k%ds==1 or k-k%ds==1)\n\nn=int(input())\nprint(all_pattern(n)+all_pattern(n-1))', 'def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n divisors.sort()\n return divisors\n\ndef all_pattern(l):\n global n\n ans=0\n for ds in make_divisors(l)[1:]:\n k=n\n while k%ds==0:\n k//=ds\n ans+=(k%ds==1)\n return ans\n\nn=int(input())\nprint(all_pattern(n)+all_pattern(n-1))'] | ['Runtime Error', 'Accepted'] | ['s379211788', 's087041677'] | [3188.0, 3188.0] | [209.0, 210.0] | [484, 464] |
p02723 | u000040786 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['s = input()\n\nif s[2] == s[3] and s[4] == s[5]:\n print("yes")\nelse:\n print("no")', 'n=str(input())\nif n[2] == n[3] and n[4] == n[5]:\n print("yes")\nelse:\n print("no")', 'n = input()\n\nif n[2] == n[3] and n[4] == n[5]:\n print("yes")\nelse:\n print("no")', "s = input()\n \nif s[2] == s[3] and s[4] == s[5]:\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s040568757', 's120798500', 's509165705', 's936442937'] | [2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 18.0, 17.0, 17.0] | [85, 87, 85, 88] |
p02723 | u004108273 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["#S = 'coffee'\n\nS = input('6文字の文字列を入力してください:')\n\nif S[2] == S[3] and S[4] == S[5] :\n print('YES')\n \nelse :\n print('No')\n ", "S = input()\n\nif S[2] == S[3] and S[4] == S[5] :\n print('Yes')\n\nelse :\n print('No')\n "] | ['Wrong Answer', 'Accepted'] | ['s818337038', 's207074733'] | [2940.0, 2940.0] | [18.0, 17.0] | [153, 87] |
p02723 | u004271495 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['"""\n"""\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ndef solve(string):\n if string[2] == string[3] and string[4] == string[5]:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nT = read_int()\n\nstring = input()\nsolve(string)\n', '"""\n"""\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ndef solve(string):\n if string[2] == string[3] and string[4] == string[5]:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nstring = input()\nsolve(string)\n'] | ['Runtime Error', 'Accepted'] | ['s387947489', 's554119732'] | [3064.0, 3064.0] | [17.0, 18.0] | [603, 587] |
p02723 | u006880673 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["w = input(':')\n\nif w[2] == w[3] and w[4] == w[5]:\n print('Yes')\n \nelse :\n print('No')", "s = input()\n\nif s[2] == s[3] and s[4] == s[5]:\n print('Yes')\n \nelse :\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s948613487', 's529083551'] | [2940.0, 2940.0] | [17.0, 17.0] | [94, 85] |
p02723 | u014333473 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["s=input();print('NYOE S'[s[2]==s[3]and s[4]==s[5]and s[2]!=s[4]::2])", "s=input();print('NYOE S'[s[2]==s[3]and s[4]==s[5]::2])", "s=input();print('NYoe s'[s[2]==s[3]and s[4]==s[5]::2])"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s315035437', 's728092807', 's599821794'] | [8776.0, 9020.0, 8960.0] | [29.0, 31.0, 27.0] | [68, 54, 54] |
p02723 | u015845133 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = list(str.imput())\n\nif S[2] == S[3]:\n if S[4] == S[5]:\n print("Yes")\n else:\n print("No")\nelse:\n print("No")\n', 'S = list(str, input())\n\nif S[2] == S[3]:\n if S[4] == S[5]:\n print("Yes")\n else:\n print("No")\nelse:\n print("No")', 'S = list(input())\n\nif S[2] == S[3]:\n if S[4] == S[5]:\n print("Yes")\n else:\n print("No")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s196752649', 's988395154', 's936701490'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0] | [120, 120, 115] |
p02723 | u016302627 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = list(input().split())\nif S[2] == S[3] or S[4] == S[5]:\n print("Yes")\nelse:\n print("No")', 'S = input()\n \nif S[2]==S[3] and S[4]==S[5]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s246178776', 's075756450'] | [2940.0, 2940.0] | [18.0, 17.0] | [93, 82] |
p02723 | u018771977 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["#! env/bin/local python3\n# -*- coding: utf-8 -*-\n\ns = input()\nif s[2] == s[3] and s[4] == 2[6]:\n print('Yes')\nelse:\n print('No')", "#! env/bin/local python3\n# -*- coding: utf-8 -*-\n\ns = input()\nif s[2] == s[3] and s[4] == s[5]:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s231259816', 's473089057'] | [2940.0, 2940.0] | [17.0, 18.0] | [134, 134] |
p02723 | u018846452 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["s = input()\nif s[3] == s[4] and s[5] == s[6]:\n print('Yes')\nelse:\n print('No')", "s = input()\nif s[2] == s[3] and s[4] == s[5]:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s386056850', 's524982008'] | [9016.0, 9020.0] | [27.0, 29.0] | [80, 80] |
p02723 | u020798319 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['a = str(input().split())\ns = list(a)\nprint(s)\nif s[4] == s[5] and s[7] == s[6]:\n print("Yes")\nelse :\n print("No")', 'a = str(input().split())\ns = list(a)\nif s[4] == s[5] and s[7] == s[6]:\n print("Yes")\nelse :\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s495752686', 's652992723'] | [9040.0, 9056.0] | [25.0, 30.0] | [123, 114] |
p02723 | u021019433 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["s = input()\nprint('YNeos'[s[2::2] != s[3::2]])\n", "s = input()\nprint('YNeos'[s[2::2] != s[3::2]::2])"] | ['Wrong Answer', 'Accepted'] | ['s109460239', 's156841083'] | [2940.0, 2940.0] | [17.0, 18.0] | [47, 49] |
p02723 | u021763820 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = input()\nif S[2] == S[3] and S[4] == S[5]:\n print(Yes)\nelse:\n print(No)', 's = input()\nif s[2] == s[3] and s[4] == s[5]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s022062780', 's977848712'] | [3060.0, 9032.0] | [19.0, 32.0] | [76, 80] |
p02723 | u021770165 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = input()\nif S[2]==S[3] and S[4]==S[5]:\n print("YES")\nelse:\n print("NO")', 'import sys\ninput = sys.stdin.readline\n\nS = input().split()\nif S[2]==S[3] and S[4]==S[5]:\n print("YES")\nelse:\n print("NO")', 'S = (input().split())\n\nif S[2]==S[3] and S[4]==S[5]:\n print("YES")\nelse:\n print("NO")', 's = input()\nif s[2]==s[3] and s[4]==s[5]:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s337940104', 's381093262', 's809183112', 's033191526'] | [9036.0, 9008.0, 9100.0, 9056.0] | [32.0, 22.0, 21.0, 28.0] | [76, 123, 87, 76] |
p02723 | u021849254 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['a=list.input()\n\nif a[2]==a[3] and a[4]==a[5]:\n print("Yes")\nelse:\n print("No")', 'a=list(input())\n \nif a[2]==a[3] and a[4]==a[5]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s248467483', 's881663594'] | [9012.0, 9032.0] | [20.0, 27.0] | [80, 82] |
p02723 | u023751250 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['s = input()\nif(s[1:2]==s[2:3] and s[3:4]==s[4:5]){print("Yes")}\nelse{print("No")}', 's = input()\nif(s[2]==s[3] and s[4]==s[5]){print("Yes")}\nelse{print("No")}', 's = input()\nif(s[2:3]==s[3:4] and s[4:5]==s[5:6]){print("Yes")}\nelse{print("No")}', 's = input()\nif(s[2:3]==s[3:4] and s[4:5]==s[5:6]):\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s234793226', 's526444645', 's983562973', 's179277727'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 18.0] | [81, 73, 81, 85] |
p02723 | u024450350 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["lst = list(input())\n\nif lst[2] == lst[3] and lst[4] == lst[5]:\n print('True')\nelse:\n print('No')\n", "lst = list(input())\n\nif lst[2] == lst[3] and lst[4] == lst[5]:\n print('Yes')\nelse:\n print('No')\n"] | ['Wrong Answer', 'Accepted'] | ['s002084672', 's785181976'] | [2940.0, 2940.0] | [17.0, 17.0] | [103, 102] |
p02723 | u025484801 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['s = input()\ns.lower()\n\nif s[2] == s[3] and s[4] == s[5]:\n print("yes")\nelse:\n print("no")', 's = input()\ns.lower()\n\nif s[2] == s[3] and s[4] == s[5]:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s133109941', 's859582681'] | [2940.0, 2940.0] | [17.0, 17.0] | [95, 95] |
p02723 | u027403702 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = input()\nT = input()\nhit = 0\nfor i in range(3):\n if S[i] == T[i]:\n hit = hit + 1\nprint(hit)', 'S = input()\nif S[2]==S[3] and S[4]==S[5]:\n print("Yes")\nelse:\n print("No")\n'] | ['Runtime Error', 'Accepted'] | ['s560913122', 's316858947'] | [2940.0, 2940.0] | [17.0, 17.0] | [104, 81] |
p02723 | u028395001 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["string = []\n\nstring = input('')\n\nif string[2] == string[3] and string[4] == string[5]:\n print('YES')\nelse:\n print('NO')", "string = []\n\nstring = input('')\n\nif string[2] == string[3] and string[4] == string[5]:\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s825702637', 's429672947'] | [2940.0, 2940.0] | [23.0, 17.0] | [125, 125] |
p02723 | u028862479 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = input()\n\nif S[3]==S[4] and S[5] == S[6]:\n print("Yes")\nelse:\n print("No")', 'S = input()\n\nif S[2]==S[3] and S[4] == S[5]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s183661259', 's037437407'] | [9096.0, 8732.0] | [25.0, 26.0] | [79, 79] |
p02723 | u034459102 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["S = input()\nif len(S) != 6:\n print('No')\n return\n\nif S[2]==S[3] and S[4]==S[5]:\n print('Yes')\nelse:\n print('No')\n", "S = input()\n\nif S[2]==S[3] and S[4]==S[5] and len(S)==6 :\n print('Yes')\nelse:\n print('No')\n"] | ['Runtime Error', 'Accepted'] | ['s797756299', 's963084371'] | [2940.0, 2940.0] | [17.0, 17.0] | [125, 97] |
p02723 | u036104576 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['S = input()\nif S[2] == S[3] and S[4] == S[5]:\n print("Yes")\nelse:\n print("No"', 'S = input()\nif S[2] == S[3] and S[4] == S[5]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s104807643', 's469255114'] | [8864.0, 8740.0] | [27.0, 28.0] | [83, 84] |
p02723 | u036204887 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["a,b,c,d,e,f = input().split()\nif c == d and e == f:\n print('Yes')\nelse:\n print('No')", "a,b,c,d,e,f = list(input())\nif c == d and e == f:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s425063329', 's792979747'] | [2940.0, 2940.0] | [17.0, 17.0] | [90, 88] |
p02723 | u039162142 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["\n\nst = input()\n\nif ( (st[2] == st[3]) and (st[4] == st[5]) ) :\n print ('YES')\nelse:\n print ('NO')", "\n\nst = input()\n\nif ( (st[2] == st[3]) and (st[4] == st[5]) ) :\n print ('Yes')\nelse:\n print ('No')"] | ['Wrong Answer', 'Accepted'] | ['s512309225', 's938415840'] | [2940.0, 2940.0] | [18.0, 18.0] | [103, 103] |
p02723 | u039881995 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["if num[2] == num[3] and num[-1] == num[-2]:\n print('Yes')\nelse:\n print('No')", "S = input()\nif S[2] == S[3] and S[-1] == S[-2]:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s154162647', 's142552516'] | [2940.0, 2940.0] | [17.0, 17.0] | [82, 86] |
p02723 | u044138790 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['s = input()\nif s[3] == s[4] and s[5] == s[6]:\n print(yes)\nelse:\n print(no)', 'S = input()\nif S[3] == S[4] and S[5] == S[6]:\n print(Yes)\nelse:\n print(No)\n \n', 'n = int(input())\nm = n%500\nprint(int((n - m)*1000/ 500 + m*5//5))', "S = input()\nif S[3] == S[4] and S[5] == S[6]:\n print('Yes')\nelse:\n print('No')\n \n", "input()\ns = [input()]\nif s[3] == [4] and s[5] == s[6]:\n print('yes')\nelse:\n print('no')", "s = input()\nif s[3] == s[4] and s[5] == s[6]:\n print('yes')\nelse:\n print('no')\n", "S = input()\nif S[2] == S[3] and S[4] == S[5]:\n print('Yes')\nelse:\n print('No')\n \n"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s222772009', 's252371366', 's579599774', 's593127518', 's861405414', 's867095187', 's485538260'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 17.0, 21.0, 17.0, 18.0, 17.0, 17.0] | [77, 80, 65, 84, 89, 82, 84] |
p02723 | u044220565 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ["S = list(input())\ncond1 = S[2] == S[3]\ncond2 = S[3] == S[4]\nif cond1 & cond2:\n print('Yes')\nelse:\n print('No')", "S = list(input())\ncond1 = S[2] == S[3]\ncond2 = S[4] == S[5]\nif cond1 & cond2:\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s809939090', 's796295476'] | [2940.0, 2940.0] | [17.0, 17.0] | [112, 112] |
p02723 | u046158516 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['s=input()\nflag=1\nif list(s)[2]==list(s)[3]:\n if list(s)[4]==list(s)[5]:\n flag=0\nif flag=0:\n print("Yes")\nelse:\n print("No")\n \n', 'X,Y,A,B,C = map(int, input().split())\np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\np.sort()\np.reverse()\nq.sort()\nq.reverse()\nr.sort()\nr.reverse()\nans=0\nccounter=0\nfor i in range(0,X):\n ans=p[i]+ans\nfor i in range(0,Y):\n ans=q[i]+ans\nfor i in range(0,X):\n if i>=C:\n break\n if p[X-1-i]<=r[i]:\n ccounter=ccounter+1\n ans=ans-p[X-1-i]+r[i]\n else:\n break\nfor i in range(0,Y):\n if i+ccounter>=C:\n break\n if q[Y-1-i]<=r[i+ccounter]:\n ans=ans-q[Y-1-i]+r[i+ccounter]\n ccounter=ccounter+1\n else:\n break\nprint(ans)\n', "s=input()\nif s[2]==s[3] and s[4]==s[5]:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s359097246', 's827665675', 's926364421'] | [2940.0, 3064.0, 2940.0] | [17.0, 18.0, 18.0] | [133, 635, 74] |
p02723 | u057993957 | 2,000 | 1,048,576 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. | ['N, x, y = [int(i) for i in input().split()]\n\ncnt = [0] * N\nfor i in range(1, N+1):\n for j in range(i+1, N+1):\n temp = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x))\n cnt[temp] += 1\n\nfor i in range(1, N):\n print(cnt[i])', 's = input()\nprint("Yes" if s[2] == s[3] and s[4] == s[5] else "No")'] | ['Runtime Error', 'Accepted'] | ['s842473184', 's894316109'] | [3060.0, 2940.0] | [18.0, 17.0] | [243, 67] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.