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

import sys
sys.setrecursionlimit(10 ** 7)

N, M, K = map(int, input().split())
edges = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

block_edges = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    block_edges[c].append(d)
    block_edges[d].append(c)

visited = [False] * N
cnt = 0

def dfs(u, s):
    if visited[u]:
        return

    visited[u] = True
    for v in edges[u]:
        if visited[v]:
            continue
        if v == s:
            continue

        if v not in block_edges[s] and v not in edges[s]:
            global  cnt
            cnt += 1

        dfs(v, s)


ans = []
for i in range(N):
    visited = [False] * N
    cnt = 0
    for v in edges[i]:
        dfs(v, i)
    ans.append(cnt)
print(*ans)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.d = [-1] * n

    def find(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M, K = map(int, input().split())
NMAX = 100005
deg = [0] * NMAX
to = [[] for _ in range(NMAX)]
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
anss = []
for i in range(N):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    anss.append(ans)
print(" ".join(map(str, anss)))
### BUGGY CODE ###

N = int(input())
L = sorted(map(int, input().split()), reverse=True)
cnt = 0

for i in range(N - 2):
    c = L[i]
    
    for j in range(i + 1, N - 1):
        b = L[j]
        l = j
        r = N - 1
        
        while True:
            idx = -(-(l + r) // 2)
            
            if L[idx] > abs(b - c):
                if l == idx:
                    break
                l = idx
            else:
                if r == idx:
                    break
                r = idx
                
        cnt += l - j
        
print(cnt)

### FIXED CODE ###

N = int(input())
L = sorted(map(int, input().split()), reverse=True)
cnt = 0

for i in range(N - 2):
    c = L[i]
    
    for j in range(i + 1, N - 1):
        b = L[j]
        l = j
        r = N - 1
        
        while True:
            idx = -(-(l + r) // 2)
            
            if L[idx] > c - b:
                if l == idx:
                    break
                l = idx
            else:
                if r == idx:
                    break
                r = idx
                
        cnt += l - j
        
print(cnt)
### BUGGY CODE ###


man_count = int(input())

infos = [int(i) for i in input().split()]

ans = []

for i in range(len(infos)+1):
    print(infos.count(i+1))
    # work = infos.count(i+1)
    # ans.append(work)

#for i in ans:
#    print(i)



### FIXED CODE ###

import bisect

man_count = int(input())

infos = [int(i) for i in input().split()]
infos.sort()

next_num = 0
end = 0
for i in range(len(infos)+1):
    if i != next_num:
        print(0)
        continue

    # 速度を上げるために添え字を吹き飛ばそう。
    start = bisect.bisect_right(infos, i+1, end)  # iが始まる添え字を得る。
    print(start - end)
    end = start

    # 添え字が最後の場合 or 最後でない で切り分け必要。
    if start == len(infos):
      next_num = infos[start-1] -1
    else:
      next_num = infos[start] -1

#for i in ans:
#    print(i)
### BUGGY CODE ###

S = list(map(int, list(input())))
N = len(S)
MOD = 2019
DP = [0] * MOD
DP[0] = 1

t = 0

for i in range(N):
  k = S[-1 - i]
  t = (t + k * 10 ** i) % MOD
  DP[t] += 1

ans = 0
for i in range(MOD):
  n = DP[i]
  ans += (n * (n - 1)) // 2

print(ans)

### FIXED CODE ###

S = list(map(int, list(input())))
N = len(S)
MOD = 2019
DP = [0] * MOD
DP[0] = 1

t = 0
p = 1
for i in range(N):
  k = S[-1 - i]
  t = (t + k * p) % MOD
  DP[t] += 1
  p = p * 10 % MOD

ans = 0
for i in range(MOD):
  n = DP[i]
  ans += (n * (n - 1)) // 2

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

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


n = int(input())
info = [list(map(int, input().split())) for i in range(n-1)]
MOD = 10**9 + 7

tree = [[] for i in range(n)]
for i in range(n-1):
    x, y = info[i]
    x -= 1
    y -= 1
    tree[x].append(y)
    tree[y].append(x)

def solve(pos):
    b = 1
    w = 1
    flag = False
    for next_pos in tree[pos]:
        if not visited[next_pos]:
            visited[next_pos] = True
            flag = True
            tmp_b, tmp_w = solve(next_pos)
            w *= (tmp_b + tmp_w)
            b *= tmp_w
            w %= MOD
            b %= MOD
    if not flag:
        black[pos] = 1
        white[pos] = 1
        return (black[pos], white[pos])
    else:
        black[pos] = b
        white[pos] = w
        return (black[pos], white[pos])

black = [0]*n
white = [0]*n
visited = [False]*n
visited[0] = True
print(sum(solve(0)) % MOD)

### FIXED CODE ###

import sys


sys.setrecursionlimit(100000)
MOD = 10**9 + 7
n = int(input())
tree = [[] for i in range(n)]
for i in range(n-1):
    tmp1, tmp2 = map(int, input().split())
    tree[tmp1 - 1].append(tmp2 - 1) 
    tree[tmp2 - 1].append(tmp1 - 1)
visited = [False]*n

def dfs(i):
    visited[i] = True
    if all([visited[j] for j in tree[i]]):
        return 1, 1  #黒の通り数, 白の通り数
    else:
        ans1 = 1
        ans2 = 1
        for j in tree[i]:
            if not visited[j]:
                tmp1, tmp2 = dfs(j)
                ans1 *= tmp2
                ans2 *= (tmp1 + tmp2)
                ans1 %= MOD
                ans2 %= MOD
        return ans1, ans2  #黒の通り数, 白の通り数

print(sum(dfs(0)) % MOD)
### BUGGY CODE ###

L,R = map(int,input().split())

ans = 2019

for i in range(L,R+1):
	for j in range(i+1,R+1):
		tmp = (i*j)%2019
		if ans>tmp:
			ans = tmp
print(ans)

### FIXED CODE ###

L,R = map(int,input().split())
 
ans = 2019
m = []
l = R-L+1
if l < 2019:
	for i in range(L,R+1):
		m.append(i%2019)
else:
	for i in range(L,L+2019):
		m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = (m[i]*m[j])%2019
		if ans> tmp:
			ans = tmp
		if tmp == 0:
			break				
print(ans)
### BUGGY CODE ###

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

for i in range(n-k+1):
    xtmp = x[i:i+k]
#     print(i, xtmp)

    if i==0:
        MIN = abs(xtmp[0])+2*abs(xtmp[-1])

    MIN = min(MIN, abs(xtmp[0]-xtmp[-1]) + abs(xtmp[0]), abs(xtmp[0]-xtmp[-1]) + abs(xtmp[-1]))

print(MIN)


### FIXED CODE ###

# -*- coding: utf-8 -*-

n, k = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**10
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    ans = min(ans, abs(left)+abs(left-right), abs(right)+abs(right-left))
print(ans)
### BUGGY CODE ###

import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0

for i in range(N):
    A_ = np.concatenate([A[:i], A[i+1:]])
    a = np.gcd.reduce(A_)
    ans = max(ans, a)

print(ans)


### FIXED CODE ###

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

DP_first = [0] * N
DP_last = [0] * N

DP_first[0] = A[0]
DP_last[0] = A[-1]

for i in range(1, N):
    DP_first[i] = fractions.gcd(DP_first[i-1], A[i])
    DP_last[i] = fractions.gcd(DP_last[i-1], A[-1-i])

ans = max(DP_first[N-2], DP_last[N-2])
for i in range(1, N-1):
    ans = max(ans, fractions.gcd(DP_first[i-1], DP_last[N-2-i]))
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=sorted(map(int,input().split()))
d=[]
for i in range(m):
	b,c=map(int,input().split())
	d+=[c]*b
d=sorted(d)[::-1]
i=j=0
while a[i]<d[j]:
	if a[i]<d[j]:
		a[i]=d[j]
		i+=1
		j+=1
		if len(a)<=i or len(d)<=j:
			break
	else:break
print(sum(a))

### FIXED CODE ###

# 2019/07/20

from heapq import heappop,heappush,heapify

n,m=map(int,input().split())
a=list(map(int,input().split()))
heapify(a)
bc=[]
for i in range(m):
    b,c=map(int,input().split())
    hq=(-c,b)
    heappush(bc,hq)



def cg(res):

    while bc:
        c,b=heappop(bc)
        c=-c
        while b and a:
            b-=1
            v=heappop(a)
            if c>v:res+=c
            else:
                res+=v
                return res
    return res
res=0
res=cg(res)
print(sum(a)+res)
### BUGGY CODE ###

#一時間以上かかった
#一つだけTLE
#そっから30ぷん

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

n,m=map(int ,input().split())
a1=[int(input()) for i in range(m)]
a1.append(n+1)
c1=1
a2=0
for i in a1:
    a3=i-1-a2
    c2=0
    for j in range(a3//2+1):
        c2+=combinations_count(a3-j,j)
    c1=(c1*c2)%(1000000007)
    a2=i+1
    if c1==0:
        break



print(c1)


### FIXED CODE ###

#フィボナッチ数列か…
#c問題も解けないのか…
#典型問題なんだろうな
#踏めない段の分は除いて考えれば良い
n,m=input().split()
n,m=int(n),int(m)
ax=[1]*(n+1)
for i in range(m):
    ax[int(input())]=0
bx=[1,1]
for i in range(2,n+1):
    if ax[i-1]==1:
        f1=bx[i-1]
    else:
        f1=0
    if ax[i-2]==1:
        f2=bx[i-2]
    else:
        f2=0
    bx.append((f1+f2)%(10**9+7))

print(bx[n])
### BUGGY CODE ###

k, s = map(int, input().split())
p = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    for z in range(0,k+1):
      if (x+y+z) == s:
        p+=1
print(p)

### FIXED CODE ###

k, s = map(int, input().split())
p = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    z = s - x - y
    if z >= 0 and z <= k:
      p += 1
print(p)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
d = [0]*((N+1)**3)
def encode(i,j,k):
    return i+j*(N+1)+k*((N+1)**2)
B = 0
for a in As:
    B += (N+1)**(a-1)
d[0] = 0
for k in range(N+1):
    for j in range(N+1-k):
        for i in range(N+1-k-j):
            E = 0
            x = encode(i,j,k)
            s0 = i+j+k
            if i:
                E += (i*N)/(s0**2) + d[x-1]*(i/s0)
            if j:
                E += (j*N)/(s0**2) + d[x-N]*(j/s0)
            if k:
                E += (k*N)/(s0**2) + d[x-N**2-N]*(k/s0)
            d[x] = E
print(d[B])


### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
d = dict()
def encode(i,j,k):
    return i+j*(N+1)+k*((N+1)**2)
def decode(x):
    return [(x // ((N+1)**i))%(N+1) for  i in range(3)]
B = 0
for a in As:
    B += (N+1)**(a-1)
d[0] = 0
for k in range(N+1):
    for j in range(N+1-k):
        for i in range(N+1-k-j):
            E = 0
            x = encode(i,j,k)
            s0 = N-i-j-k
            if i:
                E += (i*N)/((N-s0)**2) + d[x-1]*(i/(N-s0))
            if j:
                E += (j*N)/((N-s0)**2) + d[x-N]*(j/(N-s0))
            if k:
                E += (k*N)/((N-s0)**2) + d[x-N**2-N]*(k/(N-s0))
            d[x] = E
print(d[B])
### BUGGY CODE ###

import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        ma = bisect.bisect_right(L[j+1:], L[i] + L[j] -1)
        if ma >= 0:
            count += ma
print(count)


### FIXED CODE ###


import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        count += bisect.bisect(L,L[i]+L[j]-1)-j-1
print(count)
### BUGGY CODE ###

n= int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
  b=a.pop(i)
  print(max(a))
  a.insert(i,b)

### FIXED CODE ###

n= int(input())
a = [int(input()) for i in range(n)]
b=sorted(a,reverse=True)
for i in range(n):
  if a[i] == b[0]:
    print(b[1])
  else:
    print(b[0])
### BUGGY CODE ###

import re
N,Q=[int(s) for s in input().split()]
S=input()
for i in range(Q):
    (li, ri)=[int(s) for s in input().split()]
    s=S[li-1:ri]
    print(len(re.findall("AC", s)))

### FIXED CODE ###

import re
N,Q=[int(s) for s in input().split()]
S=input()
table=[1 if S[0:2] == "AC" else 0]
for i in range(1, N-1):
    table.append(table[i-1]+(1 if S[i:i+2] == "AC" else 0))
table.append(table[-1])
for i in range(Q):
    (li, ri)=[int(s) for s in input().split()]
    print(table[ri-2]-(table[li-2] if li > 1 else 0))
### BUGGY CODE ###

N=10**5
prime=[0]*(N+1)
for n in range(2,N+1):
  if all([n%i for i in range(2,int(n**.5)+1)]):
      prime[n]=1

check=[0]*(N+1)
for n in range(N+1):
    if n%2==1 and prime[n] and prime[(n+1)//2]:
        check[n]=1

accumulate=[0]*(N+1)
for n in range(1,N+1):
    accumulate[n]=accumulate[n-1]+check[n]

Q=int(input())
for q in range(Q):
    l,r=map(int,input().split())
    print(accumulate[r]-accumulate[l-1])

### FIXED CODE ###

N=10**5
prime=[1]*(N+1)
prime[0]=prime[1]=0
for i in range(2,int(N**.5)+1):
    if not prime[i]:
        continue
    for j in range(i*2,N+1,i):
        prime[j]=0

check=[0]*(N+1)
for n in range(N+1):
    if n%2==1 and prime[n] and prime[(n+1)//2]:
        check[n]=1

accumulate=[0]*(N+1)
for n in range(1,N+1):
    accumulate[n]=accumulate[n-1]+check[n]

Q=int(input())
for q in range(Q):
    l,r=map(int,input().split())
    print(accumulate[r]-accumulate[l-1])
### BUGGY CODE ###

def f(n):
    res = 0
    for x in range(1, 100):
        for y in range(x, 100):
            for z in range(y, 100):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    if x == y == z:
                        res += 1
                    elif x != y != z:
                        res += 6
                    else:
                        res += 3
    return res


N = int(input())
for i in range(1, N + 1):
    print(f(i))


### FIXED CODE ###

def g(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


N = int(input())
count = [0] * (N + 1)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            cur = g(x, y, z)
            if cur <= N:
                count[cur] += 1
for i in range(1, N + 1):
    print(count[i])
### BUGGY CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
B=[int(x) for x in input().split()]
B.sort(reverse=True)
C=[int(x) for x in input().split()]
C.sort(reverse=True)
D=[a+b for a in A for b in B]
D.sort(reverse=True)
D=D[:K]
E=[ab+c for ab in D for c in C]
E.sort(reverse=True)
for i in range(K):
  print(E[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
B=[int(x) for x in input().split()]
B.sort(reverse=True)
C=[int(x) for x in input().split()]
C.sort(reverse=True)
D=[a+b for a in A for b in B]
D.sort(reverse=True)
D=D[:3000]
E=[ab+c for ab in D for c in C]
E.sort(reverse=True)
for i in range(K):
  print(E[i])
### BUGGY CODE ###

#TLEしてしまう…
(N,D,A) = map(int,input().split())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])
    l.sort()
k = [0 for i in range(N)]
for i in range(N):
    k[i] = -((-l[i][1])//A)

m = [0] * N
ub = 0
cnt = 1
for i in range(N):
    if ub < N-1:
        while l[ub + 1][0]-l[i][0] <= 2*D:
            cnt += 1
            ub += 1
            if ub == N - 1:
                break
        m[i] = cnt
    else:
        cnt -= 1
        m[i] = cnt
    cnt -= 1

ans = 0
for i in range(N):
    if  k[i] != 0:
        for p in range(1,m[i]):
            if k[i+p] >= k[i]:
                k[i+p] -= k[i]
            else:
                k[i+p] = 0
        ans += k[i]

print(ans)

### FIXED CODE ###

(N,D,A) = map(int,input().split())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])
l.sort()
k = [0 for i in range(N)]
for i in range(N):
    k[i] = -((-l[i][1])//A)

m = [0] * N
ub = 0
cnt = 1
for i in range(N):
    if ub < N-1:
        while l[ub + 1][0]-l[i][0] <= 2*D:
            cnt += 1
            ub += 1
            if ub == N - 1:
                break
        m[i] = cnt
    else:
        m[i] = cnt
    cnt -= 1

ans = 0
al = 0
s = [0 for i in range(N)]
j = 0
for i in range(N):
    s[i] = max(k[i]-al,0)
    ans += s[i]
    al += s[i]
    if i < N-1:
        while j+m[j]-1 < i+1:
            al -= s[j]
            if j < N-1:
                j += 1

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

n = int(input())

ans = 0
from itertools import combinations_with_replacement
for i in range(1,n+1):
    ans = 0
    for x,y,z in combinations_with_replacement(range(1,int(i**0.5)), 3):
        #print(i, x,y,z, x**2+y**2+z**2+x*y+y*z+z*x, end=' ')
        if x**2+y**2+z**2+x*y+y*z+z*x == i:
            if x==y==z==x:
                ans +=1
            elif x==y or y==z or z==x:
                ans +=3
            else:
                ans +=6
        #print(ans)
    print(ans)


### FIXED CODE ###

n = int(input())
ans = [0]*10**5
for i in range(1,int(n**0.5)):
	for j in range(1,int(n**0.5)):
		for k in range(1,int(n**0.5)):
			res = i**2 + j**2 + k**2 +i*j + j*k + k*i
			ans[res-1] += 1
for i in range(n):
	print(ans[i])
### BUGGY CODE ###

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    s = list(map(int,input().split()))
    t = list(map(int,input().split()))
    
    dp = [[0] * (m + 1) for _ in range(n + 1)]
    if s[0] == t[0]:
        dp[1][1] = 1
    else:
        dp[1][1] = 0
    for i in range(n):
        for j in range(m):
            if i == j == 0:
                continue
            if s[i] == t[j]:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] + 1)%MOD
            else:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - dp[i][j])%MOD
    print((dp[-1][-1] + 1)%MOD)

if __name__ =='__main__':
    main()   


### FIXED CODE ###

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,m = map(int,input().split())
    s = list(map(int,input().split()))
    t = list(map(int,input().split()))
    
    dp = [[0] * (m + 1) for _ in range(n + 1)]
    if s[0] == t[0]:
        dp[1][1] = 1
    else:
        dp[1][1] = 0
    for i in range(n):
        for j in range(m):
            if i == j == 0:
                continue
            if s[i] == t[j]:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] + 1)%MOD
            else:
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - dp[i][j])%MOD
    print((dp[-1][-1] + 1)%MOD)

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

import numpy as np
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
expected_value = np.array([(p[i]+1)/2 for i in range(N)])
sum_expected = np.array([np.sum(expected_value[i:i+K]) for i in range(N-K+1)])
print(np.max(sum_expected))

### FIXED CODE ###

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
S = [0]
T = [0]
for i in range(N):
    S.append((p[i]+1)/2 + S[-1])

for i in range(N+1-K):
    T.append(S[i+K]-S[i])

print(max(T))
### BUGGY CODE ###

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

cnt = 0

for i in range(n - k + 2):
    buf_max = sum(list(range(n, -1, -1)[:i + k:]))
    buf_min = sum(list(range(n + 1)[:i + k:]))
    cnt += buf_max - buf_min + 1

cnt  = cnt % (10**9 + 7)

print(cnt)


### FIXED CODE ###

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

cnt = 0
buf2_min = 0
buf2_max = 0
buf_max = 0
buf_min = 0

for j in range(k):
    buf2_max += n - j
    buf2_min += j

buf_max = n - k + 1
buf_min = k - 1

for i in range(n - k + 2):
    cnt += buf2_max - buf2_min + 1
    buf_max -= 1
    buf_min += 1
    buf2_max += buf_max
    buf2_min += buf_min
cnt  = cnt % (10**9 + 7)

print(cnt)
### BUGGY CODE ###

import math
k = int(input())

ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      value = math.gcd(i,j)
      ans += math.gcd(value,k)

print(ans)

### FIXED CODE ###

import math
k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(1, k+1):
        num = math.gcd(i, j)
        for l in range(1, k+1):
            ans += math.gcd(num, l)

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

import collections
n,x,y=map(int,input().split())
w=n
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

################################

cost = [[float("inf") for i in range(n)] for i in range(n)] 
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(n-1):
    cost[i][i+1] = 1
    cost[i+1][i] = 1
    cost[x-1][y-1] = 1
    cost[y-1][x-1] = 1
lst=[]
for i in range(n):
    d=dijkstra(i,n,w,cost)
    for j in range(len(d)):
        lst.append(d[j])
Lst=list(collections.Counter(lst).items())
Key=list(collections.Counter(lst).keys())
m=max(Key)
for i in range(1,m+1):
    print(Lst[i][1]//2)
for i in range(m+1,n):
    print(0)

### FIXED CODE ###

import collections
n,x,y=map(int,input().split())
lst=[]
num=[0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
    if num[k]==0:
      num[k]+=1
    lst.append(k)
    
Lst=list(collections.Counter(lst).items())
key=0
for i in range(1,n):
  if num[i]==0:
    print(0)
  else:
    print(Lst[key][1])
    key+=1
### BUGGY CODE ###

import numpy as np

n = int(input())
map_ = {}
memo = []

for i in range(n):
  a = int(input())
  if a not in memo:
    map_.update({str(a):1})
    memo.append(a)
  else:
    map_[str(a)] += 1
    map_[str(a)] %= 2
print(np.sum(np.array(list(map_.values()))))

### FIXED CODE ###

n = int(input())
a_list = [int(input()) for _ in range(n)]

my_set = set()
for i in a_list:
  if i in my_set:
    my_set.remove(i)
  else:
    my_set.add(i)
print(len(my_set))
### BUGGY CODE ###

n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
    if ans>1000000000000000000:
        ans=-1
        break
if 0 in lis:
    ans=0

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

k,s=map(int,input().split())
x=0
b=0
while x<=k:
  y=0
  while x+y<=s and y<=k:
    z=s-x-y
    if z>=0 and z<=k:
      b=b+1
    y=y+1
  x=x+1
print(b)
      

### FIXED CODE ###

k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)