TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()
print(list1)
print(list2)
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

import itertools
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    
work_candidate=itertools.combinations(workday_list,K)
work_candidate1=[]
for item_list in work_candidate:
  flag=True
  for i in range(len(item_list)-1) :
    if abs(item_list[i]-item_list[i+1])<=C :
      flag=False
      break
  if flag==True :
  	work_candidate1.append(item_list)
list1=set(work_candidate1[0])
 
print(work_candidate1)

nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()

flag=True
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    flag=False
    print(list1[i])
if flag :
  print()


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


N, K, C = list(map(int, input().split()))
S = list(input())

F = []
L = []

# t1 = time.time()

#     if S[i] == 'o':
#         if len(F) == 0:
#             F.append(i)
#         elif F[-1] + C < i:
#             F.append(i)
#     if len(F) >= K:
#         break
# print(F)
# t2 = time.time()
i = 0
while len(F) < K and i < N:
    if S[i] == 'o':
        if len(F) == 0:
            F.append(i)
        elif F[-1] + C < i:
            F.append(i)
    i += 1
# print(F)
# t3 = time.time()

# print(t2 - t1, t3 - t2)

i = N - 1
while len(L) < K and i >= 0:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

if len(F) == K and len(L) == K:
    ans = [i + 1 for i in set(F) & 

import itertools
import time

N, K, C = list(map(int, input().split()))
S = list(input())

F = []
L = []

# t1 = time.time()

#     if S[i] == 'o':
#         if len(F) == 0:
#             F.append(i)
#         elif F[-1] + C < i:
#             F.append(i)
#     if len(F) >= K:
#         break
# print(F)
# t2 = time.time()
i = 0
while len(F) < K:
    if S[i] == 'o':
        if len(F) == 0:
            F.append(i)
        elif F[-1] + C < i:
            F.append(i)
    i += 1
# print(F)
# t3 = time.time()

# print(t2 - t1, t3 - t2)

i = N - 1
while len(L) < K:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

[print(i) for i in set(F) & set(L)]



N, K, C = list(map(int, input().split()))
S = list(input())

F = []
L = []

# t1 = time.time()

#     if S[i] == 'o':
#         if len(F) == 0:
#             F.append(i)
#         elif F[-1] + C < i:
#             F.append(i)
#     if len(F) >= K:
#         break
# print(F)
# t2 = time.time()
i = 0
while len(F) <= K and i < N:
    if S[i] == 'o':
        if len(F) == 0:
            F.append(i)
        elif F[-1] + C < i:
            F.append(i)
    i += 1
# print(F)
# t3 = time.time()

# print(t2 - t1, t3 - t2)

i = N - 1
while len(L) <= K and i >= 0:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

if len(F) == K and len(L) == K:
    ans = [i + 1 for i in set(F) & set(L)]
    if len(ans) != 0:
        ans.sort()
        [print(i) for i in ans]

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    n,k,c=map(int,input().split())
    s=list(input())
    l=[0]*(k+1)
    r=[0]*(k+1)
    x=0
    i=0
    while i<=n-1:
        if s[i]=='o':
            x+=1
            l[x]=i+1
            i+=k+1
            if x==k:
                break
        else:
            i+=1
    print(l)
    i=n-1
    while 0<=i:
        if s[i]=='o':
            r[x]=i+1
            x-=1
            i-=k+1
            if x==1:
                break
        else:
            i-=1
    print(r)
    for i in range(1,k+1):
        if l[i]==r[i]:
            print(l[i])

if __name__ == '__main__':
    main()

def main():
    n,k,c=map(int,input().split())
    s=list(input())
    l,r=[0]*(k+1),[0]*(k+1)
    x,i=1,0
    while i<=n-1:
        if s[i]=='o':
            l[x]=i+1
            i+=c+1
            x+=1
            if x==k+1:
                break
        else:
            i+=1
    x,i=k,n-1
    while 0<=i:
        if s[i]=='o':
            r[x]=i+1
            x-=1
            i-=c+1
            if x==0:
                break
        else:
            i-=1
    for i in range(1,k+1):
        if l[i]==r[i]:
            print(l[i])

if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
common = []

def bool_work(s, n, k, c):
    i = 0
    while s[i] == 'o':
        if i+c+1 < n:
            j = 1
            if s[j] == 'x':
                while s[j] == 'x':
                    j += 1
            wo_i = bool_work(s[j:], n - j, k, c)
            if j < i+c+1:
                j = i+c+1
                if s[j] == 'x':
                    while s[j] == 'x':
                        j += 1
            w_i = bool_work(s[j:], n - j, k - 1, c)
            if wo_i == 0 and w_i == 1:
                common.append(i)
                return 1
            if wo_i + w_i >= 2:
                return 2
            else:
                return wo_i + w_i
        elif i+c+1 >= n:
            if k > 1:
                return 0
            elif n == 1:
                return 1
            else:
                for char in s[1:]:
                    if char == 'o':
                        return 2
                return 1


n, k, c = map(int, input().split())
s = input()
while s[-1] == 'x':
    s.pop(-1)
bool_work(s, n, k, c)
for com in common:
    print(com)



n, k, c = map(int, input().split())
s = " " + input()
work_fw = [0]*k
work_bw = [0]*k
i = 1
now_k = 0
while i <= n and now_k < k:
    if s[i] == 'o':
        work_fw[now_k] = i
        now_k += 1
        i += c
    i += 1
if now_k != k:
    print("")
else:
    i = n
    now_k = k - 1
    while i > 0 and now_k >= 0:
        if s[i] == 'o':
            work_bw[now_k] = i
            now_k -= 1
            i -= c
        i -= 1
    # print(work_fw)
    # print(work_bw)
    for i in range(k):
        if work_fw[i] == work_bw[i]:
            print(work_fw[i] )


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import copy
 
n,k,c = map(int,input().split())
s = list(input())
 
front = []
back = []
 

j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front.append(i)
    i += c+1
    j -= 1
  else:
    i += 1
 

 
j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back.append(i)
    i -= c+1
    j -= 1
  else:
    i -= 1

back.sort()
for i in range(k):
  if front[i] == back[i]:
    print(i+1)

import copy

n,k,c = map(int,input().split())
s = list(input())

front = [0]*n
back = [0]*n


j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front[i] = 1
    i += c+1
    j -= 1
  else:
    i += 1



j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back[i] = 1
    i -= c+1
    j -= 1
  else:
    i -= 1

  
print(front)
print(back)
for i in range(n):
  if front[i] == 1 and back[i] == 1:
    print(i+1)

import copy
 
n,k,c = map(int,input().split())
s = list(input())
 
front = []
back = []
 

j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front.append(i)
    i += c+1
    j -= 1
  else:
    i += 1
 

 
j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back.append(i)
    i -= c+1
    j -= 1
  else:
    i -= 1

back.sort()
for i in range(k):
  if front[i] == back[i]:
    print(front[i]+1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

N,K,C = map(int,input().split())
S = input()
L = [0]*K
R = [0]*K

i = 0
for j in range(K):
    while S[i]!='o':
        i += 1
    L[j] = i
    i += C+1

i = K-1
for j in range(K-1,-1,-1):
    while S[i]!='o':
        i -= 1
    R[j] = i
    i -= C+1
    
for j in range(K):
    if L[j]==R[j]:
        print(L[j])


N,K,C = map(int,input().split())
S = input()
L = [0]*K
R = [0]*K

i = 0
for j in range(K):
    while S[i]!='o':
        i += 1
    L[j] = i
    i += C+1

i = N-1
for j in range(K-1,-1,-1):
    while S[i]!='o':
        i -= 1
    R[j] = i
    i -= C+1
    
for j in range(K):
    if L[j]==R[j]:
        print(L[j]+1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,k,c=map(int,input().split())
s=input()






l=[-1]*k
r=[-1]*k
nowl=0
indl=0
while nowl<n and indl<k:
    for i in range(nowl,n):
        if s[i]=="o":
            l[indl]=i
            nowl=i+c+1
            indl+=1
            break
nowr=n-1
indr=k-1
while nowr>=0 and indr>=0:
    for i in range(nowr,-1,-1):
        if s[i]=="o":
            r[indr]=i
            nowr=i-c-1
            indr-=1
            break
for i in k:
    if l[i]==r[i]:
        print(i+1)

n,k,c=map(int,input().split())
s=input()






l=[-1]*k
r=[-1]*k
nowl=0
indl=0
while nowl<n and indl<k:
    for i in range(nowl,n):
        if s[i]=="o":
            l[indl]=i
            nowl=i+c+1
            indl+=1
            break
nowr=n-1
indr=k-1
while nowr>=0 and indr>=0:
    for i in range(nowr,-1,-1):
        if s[i]=="o":
            r[indr]=i
            nowr=i-c-1
            indr-=1
            break
for i in range(k):
    if l[i]==r[i]:
        print(l[i]+1)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):

def judge(n, k):
    m = n % k
    while m == 0:
        n //= k
        m = n % k
    return m


def calc(n):
    cnt = 3
    for k in range(2, n // 2):
        if judge(n, k) == 1:
            cnt += 1
    return cnt


def cal(n):
    cnt = 3
    for d in range(3, 10):
        if n % d <= 1:
            k = n // d
            if judge(k) == 1:
                cnt += 1

    for k in range(2, n // 10):
        if judge(n, k) == 1:
            cnt += 1
    return cnt


def main():
    N = int(input())
    s = {}
    cnt = 0

    print(calc(N))


main()


import math


def judge(n, k):
    m = n % k
    while m == 0:
        n //= k
        m = n % k
    return m


def div_list(n):
    l = set()
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            l.add(i)
            j = n // i
            if i != j:
                l.add(j)
    return l


def main():
    N = int(input())

    cnt = len(div_list(N-1)) - 1
    cnt += sum(1 for d in div_list(N) if d != 1 and judge(N, d) == 1)

    print(cnt)


main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):


N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0


for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        if i!=int((N-1)/i):
            cand.append(int((N-1)/i))
if N>2:
    cand.append(N-1)


for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        if i!=int(N/i):
            cand.append(int(N/i))
cand.append(N)

print(cand)
count=0
for i in range(len(cand)):
    if check(N,cand[i]):
        count+=1

print(count)



N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0


for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        if i!=int((N-1)/i):
            cand.append(int((N-1)/i))
if N>2:
    cand.append(N-1)


for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        if i!=int(N/i):
            cand.append(int(N/i))
cand.append(N)

#print(cand)
count=0
for i in range(len(cand)):
    if check(N,cand[i]):
        count+=1

print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())
if n == 2:
    print(1)
    exit()
ans = []
divisors = []
for i in range(2,int(n**0.5)+1):
    
    if (n-1) % i == 0:
        ans.append(i)
        if i != (n-1) // i:
            ans.append((n-1)//i)
    
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
for item in divisors:
    num = n
    while num%item == 0:
        num = num//item
    if num%item == 1:
        ans.append(item)
print(divisors)
print(ans)
print(len(ans)+2)

'''
import math
n = int(input())
ans = []
divisors = []

for i in range(2,math.ceil(n**0.5)+1):
    num = n
    while num >= i:
        if num%i == 0:
            num //= i
        else:
            num -= i
    print(num)
    if num == 1:
        ans.append(i)
    if n % i == 0:
        divisors.append(i+1)
        if i != n // i:
            divisors.append(n//i+1)

print(ans)
print(divisors)
print(len(ans)+len(divisors))

#[2, 3, 4, 5, 10, 20, 157, 314, 628, 785, 1570, 3140, 3141]
'''

n = int(input())
if n == 2:
    print(1)
    exit()
ans = []
divisors = []
for i in range(2,int(n**0.5)+1):
    
    if (n-1) % i == 0:
        ans.append(i)
        if i != (n-1) // i:
            ans.append((n-1)//i)
    
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
for item in divisors:
    num = n
    while num%item == 0:
        num = num//item
    if num%item == 1:
        ans.append(item)

#print(ans)
print(len(ans)+2)

'''
import math
n = int(input())
ans = []
divisors = []

for i in range(2,math.ceil(n**0.5)+1):
    num = n
    while num >= i:
        if num%i == 0:
            num //= i
        else:
            num -= i
    print(num)
    if num == 1:
        ans.append(i)
    if n % i == 0:
        divisors.append(i+1)
        if i != n // i:
            divisors.append(n//i+1)

print(ans)
print(divisors)
print(len(ans)+len(divisors))

#[2, 3, 4, 5, 10, 20, 157, 314, 628, 785, 1570, 3140, 3141]
'''

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import numpy as np
 
N = int(input())
 
 
def divisor(N):
    x = np.arange(1, int(N**(1/2)), dtype=np.int64)
    div = set(x[N % x == 0])
    return div | set(N // x for x in div)
 
 
cand = divisor(N) | divisor(N - 1)
 
 
def test(N, K):
    if K == 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1
 
 
answer = sum(test(N, d) for d in cand)
print(answer)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
 
N = int(read())
 
 
def divisor(N):
    x = np.arange(1, int(N**(1/2)), dtype=np.int64)
    div = set(x[N % x == 0])
    return div | set(N // x for x in div)
 
 
cand = divisor(N) | divisor(N - 1)
 
 
def test(N, K):
    if K == 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1
 
 
answer = sum(test(N, d) for d in cand)
print(answer)

import numpy as np
 
N = int(input())
 
 
def divisor(N):
    x = np.arange(1, int(N**(1/2))+1, dtype=np.int64)
    div = set(x[N % x == 0])
    return div | set(N // x for x in div)
 
 
cand = divisor(N) | divisor(N - 1)
 
 
def test(N, K):
    if K == 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1
 
 
answer = sum(test(N, d) for d in cand)
print(answer)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math
import copy
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
if n > 2:
    print(ans)
else:
    print(1)

def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
print(ans)

import math
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
print(ans)

import math
import copy
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
if N > 2:
    print(ans)
else:
    print(1)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):

def f(x):
  out=set() 
  for i in range(1, int(pow(x, 1/2))):
    
    if x%i==0:
      
      out.add(i)
      out.add(x//i)
      
  
  if x%(x**(1/2))==0:
    out.add(x**(1/2))
    
  
  out=list(out)
  out.sort()
  
  
  return out[1:]


N=int(input())
ans=0 

for K in f(N): 
    x=N 
    
    while x%K==0:
      x/=K
      
    
    x%=K
    
    
    if x==1:
        ans+=1
        

ans+=len(f(N-1))


print(ans)


def f(x):
  out=set() 
  for i in range(1, (pow(x, 1/2)):
    
    if x%i==0:
      
      out.add(i)
      out.add(x//i)
      
  
  if x%(x**(1/2))==0:
    out.add(x**(1/2))
    
  
  out=list(out)
  out.sort()
  
  
  return out[1:]


N=int(input())
ans=0 

for K in f(N): 
    x=N 
    
    while x%K==0:
      x/=K
      
    
    x%=K
    
    
    if x==1:
        ans+=1
        

ans+=len(f(N-1))


print(ans)


def f(x):
  out=set() 
  for i in range(1, int(-(-pow(x, 1/2)//1))):
    
    if x%i==0:
      
      out.add(i)
      out.add(x//i)
      
  
  if x%(x**(1/2))==0:
    out.add(x**(1/2))
    
  
  out=list(out)
  out.sort()
  
  
  return out[1:]


N=int(input())
ans=0 

for K in f(N): 
    x=N 
    
    while x%K==0:
      x/=K
      
    
    x%=K
    
    
    if x==1:
        ans+=1
        

ans+=len(f(N-1))


print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())

def make_divisors(n): 
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.remove(1)
    return divisors

ans = make_divisors(n-1) 
y = make_divisors(n) 

for i in y:
    z = n
    while z >= i and z%i == 0: 
        z = int(z / i)
        if z % i == 1: 
            ans.append(i)
            break

set(ans)
print(ans)
print(len(ans))

n = int(input())

def make_divisors(n): 
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.remove(1)
    return divisors

ans = make_divisors(n-1) 
y = make_divisors(n) 

for i in y:
    z = n
    while z >= i and z%i == 0: 
        z = int(z / i)
        if z % i == 1: 
            ans.append(i)
            break

set(ans)
#print(ans)
print(len(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return sorted(divisors) 
n = int(input())
ans = len(divisors(n-1))-1;
for k in divisors(N)[1:]:
    boz = n
    while (n % k == 0):
        n = n//k
    if (n % k == 1):
	    ans += 1
    n = boz
print(ans)

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return sorted(divisors) 
n = int(input())
ans = len(divisors(n-1))-1;
for k in divisors(n)[1:]:
    boz = n
    while (n % k == 0):
        n = n//k
    if (n % k == 1):
	    ans += 1
    n = boz
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
divs1=divisors(n)
divs2=divisors(n-1)
cnt=len(divs2)-1
for val in divs1:
  if val==1:
    continue
  tmp=n
  while tmp%val==0:
    tmp=tmp//val
  if tmp%val==1:
    cnt+=1
print(cnt)

def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
divs1=divisors(n)
divs2=divisors(n-1)
cnt=len(divs2)
for val in divs1:
  if val==1:
    continue
  tmp=n
  while tmp%val==0:
    tmp=tmp//val
  if tmp%val==1:
    cnt+=1
print(cnt)

def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
divs1=divisors(n)
divs2=divisors(n-1)
print(divs1)
print(divs2)
cand=divs2
for val in divs2:
  cand.add(val)
for val in divs1:
  tmp=n
  while tmp%val==0:
    tmp=tmp//val
  if tmp%val==1:
    cand.append(val)
if n not in cand:
  cand.append(n)
if n-1!=1 and n-1 not in cand:
  cand.append(n-1)
print(cand)
print(len(cand))

def divisors(n):
  ret=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if n//i!=i:
        ret.append(n//i)
  return ret

n=int(input())
divs1=divisors(n)
divs2=divisors(n-1)
cnt=len(divs2)-1
for val in divs1:
  if val==1:
    continue
  tmp=n
  while tmp%val==0:
    tmp=tmp//val
  if tmp%val==1:
    cnt+=1
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx*2 <= x:
        if x%xx == 0:
            y.append(xx)
        xx += 1
    return y

ans = len(yakusu(n-1))

kk = yakusu(n)
for i in kk:
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)


n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx**2 < x:
        if x%xx == 0:
            y.append(xx)
            y.append(x//xx)
        xx += 1
    if xx**2 == x:
        y.append(xx)
    y.append(x)
    return y
    
if n == 2:
    ans = 0
else:
    ans = len(yakusu(n-1))

for i in yakusu(n):
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors
n = int(input())
if n == 2:
    print(0)
elif n == 3:
    print(2)
elif n == 4:
    print(3)
else:
    count = 2
    check_list = make_divisors(n-1)
    count += len(check_list)
    temp_n = str(n)
    suma = 0
    for i in range(len(temp_n)):
        suma += int(temp_n[i])
    if suma % 3 == 1:
        count += 1

    """
    for k in [3]:
        temp_n = n
        while(True):
            if temp_n % k == 0:
                temp_n = temp_n // k
            else:
                temp_n = temp_n - k
                if temp_n <= 0:
                    break
            if temp_n == 1:
                count += 1
                break
    """
    print(count)


#!/usr/bin/python3
# -*- coding: utf-8 -*-
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors
n = int(input())
if n == 2:
    print(1)
elif n == 3:
    print(2)
elif n == 4:
    print(3)
else:
    count = 2
    check_list = make_divisors(n-1)
    count += len(check_list)
    check_list = make_divisors(n)
    for k in check_list:
        temp_n = n // k
        while(True):
            if temp_n % k == 0:
                temp_n = temp_n // k
            elif temp_n % k == 1:
                count += 1
                break
            else:
                break
    print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math


N = int(input())

nn = int(math.sqrt(N))

ans = 0
for x in range(2,nn+1):

    if N % x > 1:
        continue

    if N % x == 1:
        ans += 1
        continue
    
    tmp = N
    while True:
        tmp = tmp / x
        if tmp % x  == 1:
            ans += 1
            break
        elif tmp == x :
            ans += 1
            break
        elif tmp % x >= 1:
            break

print(ans+3)






import math


N = int(input())

nn = int(math.sqrt(N))


ans = 1
for x in range(2,nn+1):

    if N % x == 1:
        ans += 1
        continue
    
    if N % x > 1:
        continue

    tmp = N
    while tmp > x:
        tmp = tmp / x
        if tmp % x == 1 :
            ans += 1
            break
        elif tmp % x > 1 :
            break
        elif tmp == x:
            ans += 1
            break

x = 1
tmp = N - 1
while tmp / x  > nn:
    if tmp % x == 0:
        ans += 1
    x += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())
n = n-1
ans = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

li = make_divisors(n)

for i in range(2,n+1):
    if i**2 > n:
        break
    tmp = n
    #print(i)
    while tmp % i == 0:
        #print(tmp)
        #exit()
        tmp = tmp / i
    if tmp % i == 1:
        ans += 1
        li.append(i)
        
print(unique(li)-1)

exit()

for i in range(2,n+1):
    """
    if i**2 > n:
        break
    """
    tmp = n
    #print(i)
    if tmp % i == 0:
        #print(tmp)
        #exit()
        #tmp = tmp / i
        ans += 1
        print(i)
    """
    if tmp == 1:
        ans += 1
        print(i)
    """
        
print(ans)

n = int(input())
n = n-1
ans = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

li = make_divisors(n)
n = n+1
for i in range(2,n+1):
    if i**2 > n:
        break
    tmp = n
    #print(i)
    while tmp % i == 0:
        #print(tmp)
        #exit()
        tmp = tmp / i
    if tmp % i == 1:
        ans += 1
        li.append(i)
#print(li)
print(len(set(li)))

exit()

for i in range(2,n+1):
    """
    if i**2 > n:
        break
    """
    tmp = n
    #print(i)
    if tmp % i == 0:
        #print(tmp)
        #exit()
        #tmp = tmp / i
        ans += 1
        print(i)
    """
    if tmp == 1:
        ans += 1
        print(i)
    """
        
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
N = int(input())
ans = [N-1,N]

#N-1
for i in range(2,int(math.sqrt(N-1)+1)):
    if (N-1) % i == 0:
        ans.append(i)
        if i != (N-1)//i:
            ans.append((N-1)//i)

#N
for j in range(2,int(math.sqrt(N))+1):
    if N % j == 0:
        n1 = N
        n2 = N
        while n1 % j == 0:
            n1 = n1/j
        while n2 % N//j == 0:
            n2 = n2*j//N
        
        
        if n1 % j == 1:
            ans.append(j)
        if n2 % j == 1:
            ans.append(N//j)

print(ans)
print(len(ans))

N = int(input())
count = 0
if N ==2:
    print(1)
else:

    for i in range(2,int((N-1)**0.5)+1):
        if (N-1)%i == 0:
            count += 1
            if (N-1)//i != i:
                count += 1

    for j in range(2,int(N**0.5)+1):
        if N%j == 0:
            n = N
            while n%j == 0:
                n = n//j
            if n%j == 1:
                count += 1
            if N//j != j:
                n = N
                while n%(N//j) == 0:
                    n = n//(N//j)
                if n%(N//j) == 1:
                    count += 1
    print(count+2)



Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())
if n == 2:
    print(1)
elif n == 3:
    print(2)
else:
    
    print(len(make_divisors(n-1))+1)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
divsN = make_divisors(N)
divsN2 = make_divisors(N-1)
divsN.pop(0)

ans = len(divsN2)-1

for div in divsN:
    n = N
    while True:
        if n%div != 0 or n==1:
            break
        n //= div
    if n%div == 1:
        ans += 1

print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import collections
def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n//=2
    f =3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n//=f
        else:
            f +=2
    if n != 1:
        a.append(n)
    return a


N = int(input())
factor = collections.Counter(prime_factorize(N-1))
K = 1
for i in factor.values():
    K *= i+1
K -=1

for f in range(2, int(N**0.5)+1):
    while N%f ==0:
        print(f)
        N//=f
    if N%f ==1 or N==1:
        K+=1

K +=1
print(K)

import collections
def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n//=2
    f =3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n//=f
        else:
            f +=2
    if n != 1:
        a.append(n)
    return a


N = int(input())
factor = collections.Counter(prime_factorize(N-1))
K = 1
for i in list(factor.values()):
    K *= i+1
K -=1
print(K)
for f in range(2, int(N**0.5)+1):
    n = N
    if n%f != 0:
        continue
    while n%f ==0:
        n//=f
    if n%f ==1 or n==1:
        print(f)
        K+=1

K +=1
print(K)

import collections
def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n//=2
    f =3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n//=f
        else:
            f +=2
    if n != 1:
        a.append(n)
    return a


N = int(input())
factor = collections.Counter(prime_factorize(N-1))
K = 1
for i in list(factor.values()):
    K *= i+1
K -=1
for f in range(2, int(N**0.5)+1):
    n = N
    if n%f != 0:
        continue
    while n%f ==0:
        n//=f
    if n%f ==1 or n==1:
        K+=1

K +=1
print(K)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n=int(input())
N=[n]
import collections
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0 and i!=1:
      divisors.append(i)
      if i != n // i and n//i!=1:
        divisors.append(n//i)
  return divisors+[n]
t=make_divisors(n)+make_divisor(n-1)
ans=0
for k in t:
  n=N[0]
  while n>=k:
    if n%k==0:
      n//=k
    else:
      n-=k
  if n==1:
    ans+=1
print(ans)

n=int(input())
N=[n]
import collections
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a
t=prime_factorize(n-1) 
c = collections.Counter(t)
w=1
for i in c.values():
  w *= 1+i
w-=1
#print(w)


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0 and i!=1:
      divisors.append(i)
      if i != n // i and n//i!=1:
        divisors.append(n//i)
  return divisors
t=make_divisors(n)+[n]

for i in t:
  n=N[0]
  while n%i==0:
    n//=i
  if n%i==1:
    w+=1
print(w)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
from sys import stdin
from math import sqrt
input = stdin.readline

N = int(input())
cnt = 2

for i in range(2, int(sqrt(N)) + 1):
    if (N - 1) % i == 0:
        cnt += 1

for i in range(2, int(sqrt(N)) + 1):
    tmp = N // i
    if (tmp - 1) % i == 0:
        cnt += 1


for i in range(2, int(sqrt(N)) + 1):
    for j in range(40):
        if pow(i, j + 1) + pow(i, j) == N:
            cnt += 1


print(cnt)


from sys import stdin
from math import sqrt
input = stdin.readline

N = int(input())

s = set([N - 1, N])


for i in range(2, int(sqrt(N)) + 1):
    tmp = N
    if (tmp - 1) % i == 0:
        s.add(i)
        s.add((tmp - 1) // i)
    elif tmp % i == 0:
        while tmp % i == 0:
            tmp //= i

        if tmp % i == 1:
            s.add(i)

        tmp = N
        while tmp % (N // i) == 0:
            tmp //= (N // i)
            print(tmp)

        if tmp % (N // i) == 1:
            s.add(tmp // i)

# print(s)
print(len(s))


from sys import stdin
from math import sqrt
input = stdin.readline

N = int(input())

if N == 2:
    print(1)
    exit()

s = set([N - 1, N])


for i in range(2, int(sqrt(N)) + 1):
    tmp = N
    if (tmp - 1) % i == 0:
        s.add(i)
        s.add((tmp - 1) // i)
    elif tmp % i == 0:
        while tmp % i == 0:
            tmp //= i

        if tmp % i == 1:
            s.add(i)

        tmp = N
        while tmp % (N // i) == 0:
            tmp //= (N // i)

        if tmp % (N // i) == 1:
            s.add(N // i)

# print(s)
print(len(s))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def main():
    n = int(input())
    
    ans = len(make_divisors(n-1))
    
    l = make_divisors(n)[1:]  
    for i in l:
        num = n
        while num % i == 0:
            num //= i
        if num % i == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def main():
    n = int(input())
    
    ans = len(make_divisors(n - 1)) - 1
    
    l = make_divisors(n)[1:]
    for i in l:
        num = n
        while num % i == 0:
            num //= i
        if num % i == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def calc_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def div_or_sub(n, k):
    while k <= n:
        if n % k == 0:
            n //= k
        else:
            n -= k
        return n

n = int(input())
cnt = len(calc_divisors(n - 1)) - 1
n_divisors = calc_divisors(n)
for divisor in n_divisors:
    if div_or_sub(n, divisor) == 1:
        cnt += 1
print(cnt)

def calc_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def div_or_sub(n, k):
    while k <= n:
        if n % k == 0:
            n //= k
        else:
            n %= k
        return n

n = int(input())
cnt = len(calc_divisors(n - 1)) - 1
n_divisors = calc_divisors(n)
for divisor in n_divisors:
    if div_or_sub(n, divisor) == 1:
        cnt += 1
print(cnt)

def calc_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def div_or_sub(n, k):
    while k <= n:
        if n % k == 0:
            n //= k
        else:
            n %= k
    return n

n = int(input())
cnt = len(calc_divisors(n - 1)) - 1
n_divisors = calc_divisors(n)
for divisor in n_divisors[1:]:
    if div_or_sub(n, divisor) == 1:
        cnt += 1
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted