Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N=int(input())
DN={N}
k=2
while(k*k<=N):
    if N%k==0:
        DN.add(k)
        DN.add(N//k)
    k+=1
DN1={N-1}
k=2
while(k*k<=(N-1)):
    if (N-1)%k==0:
        DN1.add(k)
        DN1.add((N-1)//k)
    k+=1
DN=sorted(list(DN))
DN1=sorted(list(DN1))
#print(DN)
#print(DN1)
ans=set()
for K in DN:
    tmp=N
    while(tmp>=K):
        if tmp%K==0:
            tmp//=K
        else:
            tmp%=K
    if tmp==1:
        ans.add(K)
for K in DN1:
    tmp=N
    while(tmp>=K):
        if tmp%K==0:
            tmp//=K
        else:
            tmp%=K
    if tmp==1:
        ans.add(K)


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


### FIXED CODE ###

N=int(input())
if N==2:
    print(1)
    exit()
DN={N}
k=2
while(k*k<=N):
    if N%k==0:
        DN.add(k)
        DN.add(N//k)
    k+=1
DN1={N-1}
k=2
while(k*k<=(N-1)):
    if (N-1)%k==0:
        DN1.add(k)
        DN1.add((N-1)//k)
    k+=1
DN1=len(DN1)
#print(DN)
#print(DN1)
ans=0
for K in DN:
    tmp=N
    while(tmp>=K):
        if tmp%K==0:
            tmp//=K
        else:
            tmp%=K
    if tmp==1:
        ans+=1

#print(ans)
print(DN1+ans)
### BUGGY CODE ###

import sys
from itertools import accumulate
input = sys.stdin.readline

n,q = map(int,input().split())
s = input()
lr = []
for _ in range(q):
    lr.append(list(map(int,input().split())))

count = [0]
for i in range(0,n-1):
    if s[i] == 'A' and s[i+1] == "C":
        count.append(1)
    else:
        count.append(0)
count.append(0)

for slr in lr:
    l = slr[0]
    r = slr[1]
    print(sum(count[l:r]))


### FIXED CODE ###

import sys
from itertools import accumulate
input = sys.stdin.readline

n,q = map(int,input().split())
s = input()
lr = []
for _ in range(q):
    lr.append(list(map(int,input().split())))

count = [0]
for i in range(0,n-1):
    if s[i] == 'A' and s[i+1] == "C":
        count.append(1)
    else:
        count.append(0)
count.append(0)

flag = list(accumulate(count))

for slr in lr:
    l = slr[0]
    r = slr[1]
    print(flag[r-1] - flag[l-1])
### BUGGY CODE ###

import numpy as np
N = int(input())
Hs = list(map(int, input().split()))
As = np.array([Hs for _ in range(N)])
h = As.T.copy()
idxs = np.tile([i for i in range(N)], (N, 1))
tidxs = idxs.T.copy()
co = As + h - np.abs(idxs-tidxs)
ans = N**2-np.count_nonzero(co)
print(ans//2)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
L = [A[i]+i for i in range(N)]
R = [i-A[i] for i in range(N)]
c = Counter(R)

ans = 0
for l in L:
    ans += c[l]

print(ans)
### BUGGY CODE ###

def main():
    import sys
    import time
    start=time.time()
    K=int(sys.stdin.readline())
    if K%2==0:
        print(-1)
        return

    L=[7%K]
    L2=[7%K]
    if L[0]==0:
        print(1)
        return

    idx=0
    while True:
        L2.append((L2[idx]*10)%K)
        L.append((L[idx]+L2[idx+1])%K)
        if L[-1]==0:
            print(len(L))
            return
        idx+=1

        if start-time.time()>=1.8:
            print(-1)
            return
main()

### FIXED CODE ###

def main():
    import sys
    import time
    start=time.time()
    K=int(sys.stdin.readline())
    if K%2==0:
        print(-1)
        return

    L=[7%K]
    L2=[7%K]
    if L[0]==0:
        print(1)
        return

    idx=0
    while True:
        L2.append((L2[idx]*10)%K)
        L.append((L[idx]+L2[idx+1])%K)
        if L[-1]==0:
            print(len(L))
            return
        idx+=1

        if time.time()-start>=1.5:
            print(-1)
            return
main()
### BUGGY CODE ###

q = int(input())
for _ in [0]*q:
    s1, s2 = input(), input()
    l1, l2 = len(s1), len(s2)

    dp = [[0]*(l2+1) for _ in [0]*(l1+1)]
    for i, c1 in enumerate(s1, start=1):
        for j, c2 in enumerate(s2, start=1):
            dp[i][j] = max(dp[i][j], dp[i-1][j], dp[i][j-1], dp[i-1][j-1]+(c1==c2))

    print(dp[-1][-1])


### FIXED CODE ###

def lcs_hs(s1, s2):
    from bisect import bisect_left

    s2, lis, result = s2[::-1], [], 0
    find, append = s2.find, lis.append

    for c in s1:
        i = find(c)+1
        while i:
            j = bisect_left(lis, -i)
            if j >= result:
                append(-i)
                result += 1
            else:
                lis[j] = -i
            i = find(c, i)+1

    return result


print(*(lcs_hs(input(), input()) for _ in [0]*int(input())), sep="\n")
### BUGGY CODE ###

N, W = map(int, input().split())
a = list()
a.append([0, 0])
inf = float('inf')
for _ in range(N):
  x = list(map(int, input().split()))
  a.append(x)
dp = [[-inf for _ in range(W+1)]for _ in range(N+1)]
# dp[i][w] : i-1番目までで、wを超えないように選んだ時の価値の最大値
for w in range(W+1):
  dp[0][w] = 0
for i in range(N):
  for w in range(W+1):
    # i番目を選ぶかもしれないとき
    if w - a[i+1][0] >= 0:
      dp[i+1][w] = max(dp[i][w], dp[i][w-a[i+1][0]] + a[i+1][1])
    # i番目を選ばないとき
    else:
      dp[i+1][w] = dp[i][w]
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
a = list()
a.append([0, 0])
inf = float('inf')
for _ in range(N):
  x = list(map(int, input().split()))
  a.append(x)
dp = [[-inf for _ in range(W+1)]for _ in range(N+1)]
# dp[i][w] : i番目までで、wを超えないように選んだ時の価値の最大値
for w in range(W+1):
  dp[0][w] = 0
for i in range(N):
  for w in range(W+1):
    # i+1番目を選ぶかもしれないとき
    if w - a[i+1][0] >= 0:
      dp[i+1][w] = max(dp[i][w], dp[i][w-a[i+1][0]] + a[i+1][1])
    # i+1番目を選ばないとき
    else:
      dp[i+1][w] = dp[i][w]
print(dp[N][W])
### BUGGY CODE ###

n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
max = 1
i = 1
while i**n <= p:
    i += 2
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

### FIXED CODE ###

n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)
### BUGGY CODE ###

def gcd3(a, b, c):
    return gcd(gcd(a,b), c)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

k = int(input())
sum = 0
for a in range(k):
    for b in range(k):
        for c in range(k):
            sum += gcd3(a+1,b+1,c+1)
print(sum)

### FIXED CODE ###

import math
def gcd3(a, b, c):
    return math.gcd(math.gcd(a,b), c)

k = int(input())
sum = 0
for a in range(k):
    if a == 0:
        sum += k * k
        continue
    else:
        for b in range(k):
            if b == 0:
                sum += k
                continue
            else:
                for c in range(k):
                    if c == 0:
                        sum += 1
                    else:
                        sum += gcd3(a+1,b+1,c+1)
print(sum)
### BUGGY CODE ###

N, X, M = map(int, input().split())
NN = N
li = []
while X not in li and N != 0:
    li = li + [X]
    X = X ** 2 % M
    N -= 1
    
if N == 0:
    print(sum(x for x in li))

elif N != 0 and X in li:
    l = len(li)
    s = li.index(X)
    T = l - s
    q = (NN - s) // T
    r = (NN - s) % T
    print(sum(li[i] for i in range(s)) + sum(li[i] for i in range(s, len(li))) * q
              + sum(li[i] for i in range(s, s + r)))


### FIXED CODE ###

N, X, M = map(int, input().split())
NN = N
li = []
isused = [False] * M
while isused[X] == False and N != 0:
    li.append(X)
    isused[X] = True
    X = (X ** 2) % M
    N -= 1
    
if N == 0:
    print(sum(li))

elif N != 0 and X in li:
    l = len(li)
    s = li.index(X)
    T = l - s
    q = (NN - s) // T
    r = (NN - s) % T
    print(sum(li) + sum(li[i] for i in range(s, len(li))) * (q-1) + sum(li[i] for i in range(s, s + r)))
### BUGGY CODE ###

n = int(input())

count = 0

for k in range(2, n+1):
    if n % k == 0:
        n_new = n // k
        while n_new % k == 0:
            n_new = n_new // k
        if n_new % k == 1:
            count += 1
    else:
        if n % k == 1:
            count += 1

print(count)  


### FIXED CODE ###

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()
    return divisors

a = make_divisors(n-1)
b = make_divisors(n)

a.remove(1)
b.remove(1)

count = len(a)

for i in b:
    n_new = n // i
    while n_new % i == 0:
        n_new = n_new // i
    if n_new % i == 1:
        count += 1

print(count)
### BUGGY CODE ###

from math import floor, ceil
a, b, n = map(int, input().split())
ans = 10 ** 6 * (-1)
x = 1
while x <= n:
    tmp = floor(a * x / b) - a * floor(x / b)
    ans = max(ans, tmp)
    x += ceil(b / a)
print(ans)


### FIXED CODE ###

from math import floor
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = floor(a * x / b) - a * floor(x / b)
print(ans)
### BUGGY CODE ###

def z_algo(S):
    '''
    Input: a string S
    Output: an array Z[0..|S| - 1]
            Z[i] = l: the length of the longest prefix of S[i..|S| - 1] which is also a prefix of S,
            i.e.,
                S[j] = S[i + j] for all 0 <= j < l (l != 0),
                S[0] != S[i] (l == 0)
    Time complexity: O(|S|) time
    '''
    N = len(S)
    Z = [-1] * N
    Z[0] = N
    L = 0; R = 0 # algorithm invariant: S[L..R] is always set to be the longest common prefix of S[L..|S| - 1]
    for i in range(1, N):
        if i > R: # naive calculation
            j = 0
            while i + j < N and S[j] == S[i + j]: j += 1
            Z[i] = j
            if j > 0: L = i; R = i + j - 1
        else: # i in [L, R]
            k = i - L
            if Z[k] < R - i + 1: Z[i] = Z[k]
            else:
                L = i
                while R < N and S[R - L] == S[R]: R += 1
                Z[i] = R - L
                R -= 1
    return Z

N = int(input())
S = input()
ans = 0
for i in range(N-1):
    Z = z_algo(S[i:])
    for j, z in enumerate(Z):
        ans = max(ans, min(z, j))
print(ans)

### FIXED CODE ###

def z_algo(S):
    '''
    Input: a string S
    Output: an array Z[0..|S| - 1]
            Z[i] = l: the length of the longest prefix of S[i..|S| - 1] which is also a prefix of S,
            i.e.,
                S[j] = S[i + j] for all 0 <= j < l (l != 0),
                S[0] != S[i] (l == 0)
    Time complexity: O(|S|) time
    '''
    N = len(S)
    Z = [-1] * N
    Z[0] = N
    L = 0; R = 0 # algorithm invariant: S[L..R] is always set to be the longest common prefix of S[L..|S| - 1]
    for i in range(1, N):
        if i > R: # naive calculation
            j = 0
            while i + j < N and S[j] == S[i + j]: j += 1
            Z[i] = j
            if j > 0: L = i; R = i + j - 1
        else: # i in [L, R]
            k = i - L
            if Z[k] < R - i + 1: Z[i] = Z[k]
            else:
                L = i
                while R < N and S[R - L] == S[R]: R += 1
                Z[i] = R - L
                R -= 1
    return Z

N = int(input())
S = input()
ans = 0
for i in range(N-1):
    Z = z_algo(S[i:])
    for j, z in enumerate(Z):
        ans = max(ans, min(z, j))
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)

for i in range(1,M+1):
    max_value = max(A[:i])
    max_index = A.index(max_value)
    A[max_index] = max_value // 2

print(sum(A))

### FIXED CODE ###

import heapq
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    A = list(map(lambda x: x*(-1),A))

    heapq.heapify(A)

    for _ in range(M):
        max_value = heapq.heappop(A) * (-1)
        heapq.heappush(A,max_value//2 * (-1))

    print(sum(A) * (-1))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

def lis_linear(a, n):
    dp = [0 for i in range(n)]
    longest = 1
    for i in range(n):
        max_val = 1
        for j in range(i):
            if a[j] < a[i] and max_val < dp[j] + 1:
                max_val = dp[j] + 1
        dp[i] = max_val
        if dp[i] > longest: longest = dp[i]
    return longest

print(lis_linear(a, n))


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

def lis_linear(a, n):
    dp = [0 for i in range(n)]
    longest = 1
    for i in range(n):
        max_val = 1
        for j in range(i):
            if a[j] < a[i] and max_val < dp[j] + 1:
                max_val = dp[j] + 1
        dp[i] = max_val
        if dp[i] > longest: longest = dp[i]
    return longest

def lis_binary(a, n):
    tail = [a[0]]
    for i in range(1, n):
        if a[i] > tail[-1]:
            tail.append(a[i])
            continue
        for j in range(len(tail)):
            if a[i] <= tail[j]:
                tail[j] = a[i]
                break
    return len(tail)

print(lis_binary(a, n))
### BUGGY CODE ###

n=int(input())
s=[input() for _ in range(n)]
ans=0
dic={}
for s1 in s:
    s=sorted(s1)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


### FIXED CODE ###

n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)
### BUGGY CODE ###

N, M = 10, 3
ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
BRR = [
    [3, 10],
    [4, 30],
    [1, 4]
]

import heapq

N,M = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = []
for i in range(M):
    BRR.append(list(map(int,input().split())))

def calculate(n, m, arr, brr):
    raw = []
    for ar in arr:
        heapq.heappush(raw,ar*-1)
    for br in brr:
        for i in range(br[0]):
            heapq.heappush(raw,br[1] * -1)

    sum = 0
    for i in range(n):
        sum = sum + -1 * heapq.heappop(raw)

    print(sum)


calculate(N, M, ARR, BRR)


### FIXED CODE ###

# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]


N,M = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = []
for i in range(M):
    BRR.append(list(map(int,input().split())))

def calculate(n, m, arr, brr):
    raw = []
    for ar in arr:
        raw.append([ar, 1])
    for br in brr:
        raw.append([br[1], br[0]])

    raw = sorted(raw,key=lambda x:-x[0])
    # print(raw)

    offset = 0
    sum = 0
    for ra in raw:
        if offset + ra[1] <= n:
            sum = sum + ra[1] * ra[0]
            offset = offset + ra[1]
        else:
            sum = sum + (n - offset) * ra[0]
            offset = n
            break
    print(sum)

calculate(N, M, ARR, BRR)
### BUGGY CODE ###

import numpy as np

N_K = list(map(int, input().split()))
 
count = 0

a = np.array([i for i in range(1, N_K[0]+1)])
b = np.array([i for i in range(1, N_K[0]+1)])

for i in range(len(b)):
    value = a % b[i]

    for l in range(len(value)):
        if value[l] >= N_K[1]:
            count += 1

'''
for a in range(1, N_K[0]+1):
  for b in range(1, N_K[0]+1):
    if a % b >= N_K[1]:
      count += 1
'''
print(count)

### FIXED CODE ###

N, K = list(map(int, input().split()))
ans = 0

for b in range(1, N+1):
	p = N // b
	r = N % b
	
	ans += p * max(0, b-K)
	ans += max(0, r-K+1)
	
print(ans-N*(not K))
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd(a,b,c)
      
      
print(s)
      
  


### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd(a,b,c)
      
      
print(s)
### BUGGY CODE ###

def main():
    INF = 10 ** 12
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = [0 for _ in range(N)]
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = A[i] + cumsum[i - 1]
    dp = [[0 for _ in range(N)] for _ in range(N)]

    def solve(left, right):
        if left == right:
            return 0
        ret = dp[left][right]
        if ret > 0:
            return ret
        ret = INF
        for mid in range(left, right):
            ret = min([
                ret,
                solve(left, mid) + solve(mid + 1, right)
            ])
        ret += cumsum[right] - (cumsum[left - 1] if left > 0 else 0)
        dp[left][right] = ret
        return ret

    print(solve(0, N - 1))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    INF = 10 ** 15
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = [0 for _ in range(N)]
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = A[i] + cumsum[i - 1]
    dp = [[0 for _ in range(N)] for _ in range(N)]

    def solve(left, right):
        if left == right:
            return 0
        ret = dp[left][right]
        if ret > 0:
            return ret
        ret = INF
        for mid in range(left, right):
            ret = min([
                ret,
                solve(left, mid) + solve(mid + 1, right)
            ])
        ret += cumsum[right] - (cumsum[left - 1] if left > 0 else 0)
        dp[left][right] = ret
        return ret

    print(solve(0, N - 1))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
S = input()

R = []
G = []
B = []

total = 0

for i in range(N):
  if S[i] == "R":
    R.append(i)
  elif S[i] == "G":
    G.append(i)
  else:
    B.append(i)
    
for i in range(len(R)):
  for j in range(len(G)):
    for k in range(len(B)):
      if (R[i] > G[j]) & (R[i] > B[k]):
        if (R[i] - G[j]) == (2 * (R[i] - B[k])):
          continue
        elif (2 * (R[i] - G[j])) == (R[i] - B[k]):
          continue
        else:
          total += 1
      if (G[j] > R[i]) & (G[j] > B[k]):
        if (G[j] - R[i]) == (2 * (G[j] - B[k])):
          continue
        elif (2 * (G[j] - R[i])) == (G[j] - B[k]):
          continue
        else:
          total += 1
      if (B[k] > R[i]) & (B[k] > G[j]):
        if (B[k] - R[i]) == (2 * (B[k] - G[j])):
          continue
        elif (2 * (B[k] - R[i])) == (B[k] - G[j]):
          continue
        else:
          total += 1 
        
print(total)

### FIXED CODE ###

N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      break
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)
### BUGGY CODE ###

import itertools
K,N = map(int,(input().split()))
A = list(map(int,(input().split())))

ans = []
for i in range(N):
    if i < N-1:
        ans.append(A[i+1]-A[i])

ans.append(K-A[N-1])

fin = []
for i in itertools.combinations(ans,N-1):
    fin.append(sum(i))
print(min(fin))

### FIXED CODE ###

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

ans = []
for i in range(N-1):
    ans.append(A[i+1]-A[i])

ans.append(K-A[N-1]+A[0])
print(K-(max(ans)))
### BUGGY CODE ###

from collections import deque
 
def dfs(friends, x):
    visited = [0] * n
    d = deque([x])
    ans = []
    while d:
        num = d.pop()
        
        #print(num, '->',end='')
        
        if visited[num] == 1:
            #print('x')
            continue
        
        visited[num] = 1
        ans.append(num)
        
        for a in friends[num]:
            d.append(a)
        
    #print()
    return ans
        
if __name__ == "__main__":    
    n, m, k = map(int, input().split())
     
    friends = [[] for _ in range(n)]
    for i in range(m):
        x, y = map(lambda z: int(z) - 1, input().split())
        friends[x].append(y)
        friends[y].append(x)
         
    blocks = [[] for _ in range(n)]
    for i in range(k):
        x, y = map(lambda z: int(z) - 1, input().split())
        blocks[x].append(y)
        blocks[y].append(x)
        
    #print(friends)
    #print(blocks)
    
    for i in range(n):
        vec = dfs(friends, i)
        ans = len(vec)
        
        ans -= len(friends[i])
        
        for b in blocks[i]:
            if b in vec:
                ans -= 1
        
        ans -= 1
                
        print(ans, end=' ')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n 
        self.size = [1] * n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
            
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] = self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
                
n, m, k = map(int, input().split())
friends = [[] for _ in range(n)]
blocks = [[] for _ in range(n)]

for i in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    friends[x].append(y)
    friends[y].append(x)

for i in range(k):
    x, y = map(lambda x: int(x) - 1, input().split())
    blocks[x].append(y)
    blocks[y].append(x)

uf = UnionFind(n)
for i in range(n):
    for f in friends[i]:
        uf.union(i, f)

# 自分を除くUnionFind木の大きさ
ans = [uf.size[uf.find(i)] - 1 for i in range(n)]
# 直接的な友達を引く
for i in range(n):
    ans[i] -= len(friends[i])

for i in range(n):
    for b in blocks[i]:
        if uf.same(i, b):
            ans[i] -= 1

print(*ans)
### BUGGY CODE ###

k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            break
        for z in range(k + 1):
            count += (x + y + z == s)

print(count)

### FIXED CODE ###

k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            x = k + 1
            y = k + 1
            continue
        count += (s <= x + y + k)

print(count)