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

#At coder 2020/2/9 B

# 入力
N = int(input())
A = list(map(int, input().split())) 

ans='YES'
for ii in range(N-1):
    for jj in range(ii+1,N):
        if A[ii]==A[jj]:
            ans='NO'

print(ans)

### FIXED CODE ###

#At coder 2020/2/9 B

# 入力
N = int(input())
A = list(map(int, input().split())) 

if len(A)-len(set(A))==0:
    ans='YES'
else:
    ans='NO'
#ans='YES'
#for ii in range(N-1):
#    for jj in range(ii+1,N):
#        if A[ii]==A[jj]:
#            ans='NO'
#            break
#    if ans=='NO':
#        break


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

S=input() + ' '
if len(S) <= 4:
  print(0)
elif len(S) == 5:
  if int(S[:-1]) % 2019 == 0:
    print(1)
  else:
    print(0)
else:
  count = 0
  for i in range(len(S)-5):
    for j in range(i+4, len(S)):
      s = int(S[i:j])
      if s % 2019 == 0:
        count += 1
  print(count)


### FIXED CODE ###

from collections import Counter

S=input()

rlist=[0]
for i in range(len(S)):
  rlist.append((rlist[-1]+int(S[-i-1])*pow(10,i,2019))%2019)
  
c = Counter(rlist)
c[0] -= 1

def nC2(n):
  return n*(n-1)//2
  
ans = c[0]
for k in c.keys():
  if c[k] >= 2:
    ans += nC2(c[k])
    
print(ans)
### BUGGY CODE ###

from statistics import median
N = int(input())
X = list(map(int, input().split()))

for i in range(N):
    print(median(X[:i]+X[i+1:]))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))

tmpls = sorted(X)
low = tmpls[N//2 -1]
high = tmpls[N//2]

for i in X:
    if i > low:
        print(low)
    else:
        print(high)
### BUGGY CODE ###

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

p=0
for j in range(N-K+1):
    su=sum(dice[j:j+K])
    if su>p:
        p=su
print((p+K)/2)


### FIXED CODE ###

N,K=map(int,input().split())
dice = list(map(int, input().split()))
a=sum(dice[0:K])

l = [a]
for i in range(1,N-K+1):
    a = a - dice[i-1] + dice[K-1+i]
    l.append(a)
print((max(l)+K)/2)
### BUGGY CODE ###

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

check=a[0]
ans=0
if check==0:
    for i in range(1,n):
        if check+a[i]==0:
            continue
            
        elif check+a[i]>0:
            check=-1
            ans=1
            break
        else:
            check=1
            ans=1
            break

for i in range(1,n):
    check2=check+a[i]
    if check<0:
        if check2>0:
            check=check2
        else:
            while check2<=0:
                ans+=1
                check2+=1
            check=check2
    else:
        if check2<0:
            check=check2
        else:
            while check2>=0:
                ans+=1
                check2-=1
            check=check2
print(ans)
    
    

### FIXED CODE ###

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

check=a[0]
ans=0
if check<=0:
    ans=abs(check)+1
    check=1

for i in range(1,n):
    check2=check+a[i]
    if i%2==0:
        if check2<=0:
            ans+=(abs(check2)+1)
            check=1
        else:
            check=check2
            
    else:
        if check2>=0:
            ans+=(abs(check2)+1)
            check=-1
        else:
            check=check2

            
check=a[0]
ans2=0
if check>=0:
    ans2=abs(check)+1
    check=-1

for i in range(1,n):
    check2=check+a[i]
    if i%2!=0:
        if check2<=0:
            ans2+=(abs(check2)+1)
            check=1
        else:
            check=check2
            
    else:
        if check2>=0:
            ans2+=(abs(check2)+1)
            check=-1
        else:
            check=check2
print(min(ans,ans2))
### BUGGY CODE ###


# -*- coding: utf-8 -*-
import random
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))

def warshall_floyd(g):
    d = g
    N = len(g)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


def slv():
    N, M, L = list(map(int, input().split()))
    g = [[sys.maxsize]*(N) for _ in range(N)]
    for i in range(N):
        g[i][i] = 0
    for _ in range(M):
        a, b, c = list(map(int, input().split()))
        if c <= L:
            g[a-1][b-1] = c
            g[b-1][a-1] = c
    
    d = g
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    gg = [[sys.maxsize]*(N) for _ in range(N)]
    for u in range(N):
        for v in range(N):
            if d[u][v] <= L:
                gg[u][v] = 1
    
    d = gg
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    Q = read_int()
    for _ in range(Q):
        s, t = list(map(int, input().split()))
        c = d[s-1][t-1]
        if c != sys.maxsize:
            print(c-1)
        else:
            print(-1)



def main():
    slv()
    # N, M, L = read_int_n()
    # ABC = [read_int_n() for _ in range(M)]
    # Q = read_int()
    # ST = [read_int_n() for _ in range(Q)]
    
    # (slv(N, M, L, ABC, Q, ST))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n, m, l = list(map(int, input().rstrip('\n').split()))
    INF = 10 ** 11
    w = [[INF] * n for _ in range(n)]
    wl = [[INF] * n for _ in range(n)]

    for i in range(n):
        w[i][i] = 0

    for i in range(m):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= l:
            w[a - 1][b - 1] = c
            w[b - 1][a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                w[j][k] = min(w[j][k], w[j][i] + w[i][k])

    for i in range(n):
        for j in range(n):
            if w[i][j] <= l:
                wl[i][j] = 1
    for i in range(n):
        for j in range(n):
            for k in range(n):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        if wl[s-1][t-1] == INF:
            print(-1)
        else:
            print(wl[s-1][t-1] - 1)


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

import sys

input = sys.stdin.readline


def dot(a, b):
    c = [[0] * n for _ in range(n)]
    for i in range(n):
        ai = a[i]
        for j in range(n):
            ck = 0
            for ak, bk in zip(ai, [bi[j] for bi in b]):
                ck += ak * bk
                c[i][j] = ck % md
    return c


def pwr(a, k):
    c = None
    while c == None:
        if k & 1:
            c = a
        a = dot(a, a)
        k >>= 1

    while k > 0:
        if k & 1:
            c = dot(a, c)
        a = dot(a, a)
        k >>= 1
    return c


md = 10 ** 9 + 7
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum([sum(pk) % md for pk in pwr(a, k)]) % md)


### FIXED CODE ###

import sys

input = sys.stdin.readline


def dot(a, b):
    c = [[0] * n for _ in range(n)]
    for i, ai in enumerate(a):
        for j, bj in enumerate(zip(*b)):
            c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
    return c


def pwr(a, k):
    c = None
    while c == None:
        if k & 1:
            c = a
        a = dot(a, a)
        k >>= 1

    while k > 0:
        if k & 1:
            c = dot(a, c)
        a = dot(a, a)
        k >>= 1
    return c


md = 10 ** 9 + 7
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum([sum(pk) % md for pk in pwr(a, k)]) % md)
### BUGGY CODE ###

import sys

def solve():
    N, K = map(int, input().split())
    mod = 7 + 10 ** 9
    lim = 0
    for i in range(1, 10 ** 5):
        if i ** 2 > N:
            lim = i - 1
            break
    
    large = [0] * (lim + 1)
    for i in range(1, lim): large[i] = (N // i) - (N // (i + 1))
    large[lim] = N // lim - lim
   
    
    DP = [[0 for j in range(lim + 1)] for i in range(K)] #x <= lim
    DP[0] = [1] * (lim + 1)

    DPlarge = [[0 for j in range(lim + 1)] for i in range(K)] #x >= lim
    for i in range(1, lim+1): DPlarge[0][i] = large[i]

    for k in range(K-1):
        for i in range(1, lim + 1):
            for t in range(1, i + 1):
                DP[k+1][t] += DPlarge[k][i]
                DP[k+1][t] %= mod
                DP[k+1][t] += DP[k][i]
                DP[k+1][t] %= mod
            
            DPlarge[k+1][i] += (DP[k][i] * large[i]) % mod
            DPlarge[k+1][i] %= mod

            for t in range(i + 1, lim + 1):
                DPlarge[k+1][t] += (DP[k][i] * large[t]) % mod 
                DPlarge[k+1][t] %= mod
                DP[k+1][t] += DP[k][i]
                DP[k+1][t] %= mod
                

    ans = 0
    for i in range(1, lim+1):
        ans += (DP[K-1][i] + DPlarge[K-1][i]) % mod
        ans %= mod

    print(ans)
    #print(DP)
    #print(DPlarge)

    
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    mod = 7 + 10 ** 9
    S = 1
    while S ** 2 <= N:
        S += 1
    DP = [[[0, 0] for _ in range(S)] for _ in range(K)]
    Rev = [0] * S
    S -= 1
    Rev[S] = (N // S - S) % mod
    for i in reversed(range(1, S)):
        Rev[i] = ((N // i) - (N // (i + 1))) % mod
    for i in range(1, S + 1):
        DP[0][i][0] = 1
        DP[0][i][1] = Rev[i]
    for i in range(2, S + 1):
        DP[0][i][0] += DP[0][i-1][0]
        DP[0][i][0] %= mod
    DP[0][S][1] += DP[0][S][0]
    DP[0][S][1] %= mod
    for i in reversed(range(1, S)):
        DP[0][i][1] += DP[0][i+1][1]
        DP[0][i][1] %= mod

    for i in range(1, K):
        for j in range(1, S + 1):
            DP[i][j][0] += DP[i-1][j][1]
            DP[i][j][1] += (DP[i-1][j][0] * Rev[j]) % mod
            DP[i][j][1] %= mod
            DP[i][j][0] += DP[i][j-1][0]
            DP[i][j][0] %= mod
        DP[i][S][1] += DP[i][S][0]
        DP[i][S][1] %= mod
        for j in reversed(range(1, S)):
            DP[i][j][1] += DP[i][j+1][1]
            DP[i][j][1] %= mod

    print(DP[K-1][1][1])
    #print(DP)

    return 0

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

def binaryinsertion(A,x):
    left=0;right=len(A)-1;centre = len(A)//2
    while(True):
        if(left == right):
            if(x[0]<A[left][0]):
                A.insert(left,x)
                break
            else :
                A.insert(left+1,x)
                break
        else:
            if(x[0] < A[centre][0]) :
                right = centre - 1
            elif(A[centre][0] < x[0]) :
                left = centre + 1
            else : 
                A.insert(centre,x)
                break
            centre = left + (right-left)//2

[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
sweep = A[:L]
sweep = sorted(sweep)
ans = [str(sweep[0][0])]
for i in range(L,N) :
    sweep.remove(A[i-L])
    binaryinsertion(sweep,A[i])
    ans.append(str(sweep[0][0]))
print(" ".join(ans))

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

from collections import deque
import numpy as np
h, w = map(int, input().split())
mass = [[ord(i) for i in input()] for _ in range(h)]
wall = ord("#")
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]


def bfs(s, t):
    if mass[s][t] == wall:
        return 0
    visited = np.zeros((h, w))
    depth = np.zeros((h, w))
    q1 = deque([s])
    q2 = deque([t])
    while q1:
        x = q1.popleft()
        y = q2.popleft()
        visited[x][y] += 1
        r = depth[x][y] + 1
        for d in range(4):
            nx = x + dx[d]
            ny = y + dy[d]
            if nx < 0 or h - 1 < nx:
                continue
            if ny < 0 or w - 1 < ny:
                continue

            if mass[nx][ny] == wall:
                continue
            if visited[nx][ny]:
                continue

            q1.append(nx)
            q2.append(ny)
            depth[nx][ny] = r
    return np.max(depth)


ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(int(ans))


### FIXED CODE ###

import numpy as np
from collections import deque
h, w = map(int, input().split())
r = [list(input()) for i in range(h)]


def dist(s, t):
    if r[s][t] == "#":
        return 0
    else:
        visited = np.zeros((h, w))
        visited[s][t] += 1
        distance = np.zeros((h, w))
        q = deque([[s, t]])
        while len(q) > 0:
            i, j = q.popleft()
            d = distance[i][j] + 1
            if j != w-1:
                if r[i][j+1] == "." and not visited[i][j+1]:
                    q.append([i, j + 1])
                    visited[i][j+1] += 1
                    distance[i][j+1] += d
            if j != 0:
                if r[i][j-1] == "." and not visited[i][j-1]:
                    q.append([i, j - 1])
                    visited[i][j - 1] += 1
                    distance[i][j - 1] += d
            if i != 0:
                if r[i-1][j] == "." and not visited[i-1][j]:
                    q.append([i - 1, j])
                    visited[i-1][j] += 1
                    distance[i-1][j] += d
            if i != h-1:
                if r[i+1][j] == "." and not visited[i+1][j]:
                    q.append([i + 1, j])
                    visited[i+1][j] += 1
                    distance[i+1][j] += d
        return np.max(distance)


ans = 0
for s in range(h):
    for t in range(w):
        ans = max(ans, dist(s, t))

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

x,y,z,q=map(int,input().split())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=map(int,input().split())

class bisect:
  def bisect(self,l,r,opt):
    cnt=(l+r)//2
    if cnt==l:
      return l-1+opt+(opt^self.judge(l))
    if opt^self.judge(cnt):
      return self.bisect(cnt+1,r,opt)
    else:
      return self.bisect(l,cnt,opt)
  def judge(self,thr):
    m=0
    for i in a:
      for j in b:
        for k in c:
          if i+j+k>thr:
            m+=1
            if m>=q:
              return True
    return False

def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n>thr:
          m+=1
          l+=[n]
          if m>=q:
            l.sort(reverse=True)
            return l

s=bisect()
thr=s.bisect(0,max(a)+max(b)+max(c)+1,0)
ans=make(thr)
for w in ans:
  print(w)

### FIXED CODE ###

x,y,z,q=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
 
def bisect(l,r):
  cnt=(l+r)//2
  if cnt==l:
    return l-1+judge(l)
  if judge(cnt):
    return bisect(cnt+1,r)
  else:
    return bisect(l,cnt)
def judge(thr):
  m=0
  for i in range(x):
    for j in range(y):
      if i*j>q:
        break
      for k in range(z):
        if i*j*k>q or a[i]+b[j]+c[k]<thr:
          break
        m+=1
        if m>=q:
          return True
  return False
def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n<thr+1:
          break
        m+=1
        l+=[n]
  l.sort(reverse=True)
  return l+[thr]*(q-len(l))
thr=bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)
### BUGGY CODE ###

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
x,y = map(int,input().split())
s=2*x-y
t=2*y-x
if s%3!=0 or s<0 or t%3!=0 or t<0:
  print(0)
else:
  print(comb((s+t)//3,s//3,1000000007))

### FIXED CODE ###

def nCr(n, r, mod):
    x, y = 1, 1
    for i in range(1, r+1):
        x = x*(n+1-i)%mod
        y = y*i%mod
    return x*pow(y, mod-2, mod)%mod
a,b = map(int,input().split())
s=2*a-b
t=2*b-a
if s%3!=0 or s<0 or t%3!=0 or t<0:
  print(0)
else:
  print(nCr((s+t)//3,(t//3),10**9+7))
### BUGGY CODE ###

import math
import fractions
import copy
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""

def addbottom(total,tree,k,value,base):
    #print("current layer",k)
    #print(k,value)
    total[k]+=value
    #print(total)
    if len(tree[k]):
        for i in tree[k]:
            #print(k,i)
            total = addbottom(total, tree, i, value,base)
    return total


n ,m = ips()
tree = [[] for i in range(n+1)]
for i in range(n-1):
    x,y = ips()
    tree[x].append(y)
    tree[y].append(x)
total = [0 for i in range(n+1)]
for i in range(m):
    x,adder = ips()
    total[x]+=adder
base = copy.copy(total)
q = [1]
pos = 0
cs = set([1])
while len(q) > pos:
    #print("adding up",pos,q)
    i = q[pos]
    value = total[i]
    cs.add(i)
    if len(tree[i]):
        for k in tree[i]:
            if k not in cs:
                q.append(k)
                total[k]+=value
    pos+=1
for i in range(1,n):
    print(total[i],end=" ")
print(total[n])

### FIXED CODE ###

import copy
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)

n ,m = ips()
tree = [[] for i in range(n+1)]
for i in range(n-1):
    x,y = ips()
    tree[x].append(y)
    tree[y].append(x)
total = [0 for i in range(n+1)]
for i in range(m):
    x,adder = ips()
    total[x]+=adder
base = copy.copy(total)
q = [1]
pos = 0
cs = set([1])
while len(q) > pos:
    #print("adding up",pos,q)
    i = q[pos]
    value = total[i]
    cs.add(i)
    if len(tree[i]):
        for k in tree[i]:
            if k not in cs:
                q.append(k)
                total[k]+=value
    pos+=1
for i in range(1,n):
    print(total[i],end=" ")
print(total[n])
### BUGGY CODE ###

def solve():
    N = int(input())
    Ss = input().rstrip()

    dp = [[0]*(N+1) for _ in range(N+1)]
    for i in reversed(range(N)):
        for j in reversed(range(N)):
            if Ss[i] == Ss[j]:
                dp[i][j] = dp[i+1][j+1] + 1
            else:
                dp[i][j] = 0

    ans = 0
    for i in range(N):
        for j in range(N):
            L = j-i if j-i <= dp[i][j] else dp[i][j]
            if L > ans:
                ans = L

    print(ans)


solve()


### FIXED CODE ###

N = int(input())
Ss = input()

def isOK(k):
    strAs = ['' for _ in range(N)]
    strBs = ['' for _ in range(N)]
    for L in range(N-k+1):
        R = L+k-1
        ss = Ss[L:R+1]
        strAs[R] = ss
        strBs[L] = ss

    strCands = set()
    for iEn in range(N-1):
        if strAs[iEn] != '':
            strCands.add(strAs[iEn])
        if strBs[iEn+1] != '' and strBs[iEn+1] in strCands:
            return True

    return False


ng, ok = N//2 + 1, 0
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

N = int(input())
#A = [int(i) for i in input().split()]
A = [int(input()) for _ in range(N)]

for i in range(N):
	tmp = A[i]
	A[i] = 0
	print(max(A))
	A[i] = tmp

### FIXED CODE ###

N = int(input())
#A = [int(i) for i in input().split()]
A = [int(input()) for _ in range(N)]

idx1, ma1 = A.index(max(A)), max(A)

tmp = A[idx1]
A[idx1] = 0
idx2, ma2 = A.index(max(A)), max(A)

A[idx1] = tmp

for i in A:
	if i == ma1:
		print(ma2)
	else:
		print(ma1)
### BUGGY CODE ###

n=int(input())
a = list(map(int, input().split()))
ans=1
for i in a:
    ans*=i
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans=-1
print(ans)

### FIXED CODE ###

n=int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
b=10**18
for i in a:
    ans*=i
    if ans > b:
        ans=-1
        break
print(ans)
### BUGGY CODE ###

def canPartition(M, N, ret_cand):
    if ((M - (ret_cand * N)) % ret_cand) == 0:
        return True
    return False

N, M = map(int, input().split())
cand = M // N

while cand > 0:
    if canPartition(M, N, cand):
        print(cand)
        exit()
    cand -= 1

### FIXED CODE ###

import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = filter(lambda x: x <= M//N, divisors)
 
for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()
### BUGGY CODE ###

n, *A = map(int, open(0).read().split())

ans = 0
for l in range(n):
    r = l + 1
    s0 = s1 = A[l]
    while r < n and s0 == s1:
        s0 ^= A[r]
        s1 += A[r]
        if s0 != s1:
            break
        r += 1
    ans += r-l
print(ans)

### FIXED CODE ###

n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)
### BUGGY CODE ###

from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[-1]

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)

b=[]
sum_b=0
for ai in a:
    bi=a_lcm//ai
    b.append(bi)
    sum_b+=bi
print(sum_b%MOD)


### FIXED CODE ###

from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[-1]

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)

sum_b=0
for ai in a:
    bi=a_lcm//ai
    sum_b+=bi
print(sum_b%MOD)
### BUGGY CODE ###

from networkx import*
def main():
    g=Graph()
    for a in[*open(x:=0)][1:]:
        a,b=map(int,a.split())
        g.add_edge(a,b+.5)
    for c in connected_components(g):
        a,b=map(len,bipartite.sets(s:=g.subgraph(c)))
        x+=a*b-s.size()
    print(x)
main()

### FIXED CODE ###

class UnionFind():
    def __init__(self,size):
        self.table=[-1]*size
    def root(self,x):
        while self.table[x]>=0:
            x=self.table[x]
        return x
    def unite(self,x,y):
        s1=self.root(x)
        s2=self.root(y)
        if s1!=s2:
            if self.table[s1]>self.table[s2]:
                s1,s2=s2,s1
            self.table[s1]+=self.table[s2]
            self.table[s2]=s1
        return
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def size(self,x):
        return -self.table[self.root(x)]
n,*z=map(int,open(0).read().split())
u=UnionFind(10**5*2+1)
for x,y in zip(*[iter(z)]*2):
    u.unite(x,10**5+y)
d=[[0,set(),set()]for _ in range(10**5*2+1)]
for x,y in zip(*[iter(z)]*2):
    t=d[u.root(x)]
    t[0]+=1
    t[1].add(x)
    t[2].add(y)
print(sum(len(x)*len(y)-a for a,x,y in d))