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

N, K = map(int, input().split())
while True:
    if N < K:
        print(min(N, K-N))
        break
    else:
        N = abs(N - K)

### FIXED CODE ###

N, K = map(int, input().split())
N = N % K
print(min(N, K-N))
### BUGGY CODE ###

from functools import lru_cache, reduce

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

@lru_cache(maxsize=100000)
def gcd(a, b):
    a , b = (a, b) if a > b else (b, a)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
        pass
    return b

ans = max([ reduce(gcd, ( As[j] for j in range(N) if j != i )) for i in range(N) ])
print(ans)



### FIXED CODE ###

import sys
from collections import deque
from functools import *
from itertools import *

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

def gcd(a, b):
    if a == 0 or b == 0:
        return max(a, b)
    a , b = (a, b) if a > b else (b, a)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
        pass
    return b

def gcd_acc(acc, x):
    if len(acc) == 0:
        acc.append(x)
        return acc
    last = acc[-1]
    acc.append(gcd(last, x))
    return acc

def candidates(As):
    length = len(As)
    L = iter(reduce(gcd_acc, As, deque()))
    R = reversed(reduce(gcd_acc, reversed(As), deque()))
    next(R)

    yield next(R)

    if length == 1:
        return

    for _ in range(length-2):
        yield gcd(next(L), next(R))
        pass
    yield next(L)
    pass

print(max(candidates(As)))
### BUGGY CODE ###

s = list(input())[::-1]
word = ["dream", "dreamer", "erase", "eraser"]
while True:
    if "".join(s[:5][::-1]) in word:
        del s[:5]
        continue
    elif "".join(s[:6][::-1]) == "eraser":
        del s[:6]
        continue
    elif "".join(s[:7][::-1]) == "dreamer":
        del s[:7]
        continue
    break
if len(s) == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s = input()[::-1]
word = ["dream", "dreamer", "erase", "eraser"]
dream = "dream"[::-1]
dreamer = "dreamer"[::-1]
erase = "erase"[::-1]
eraser = "eraser"[::-1]
while True:
    if s[:5] == dream or s[:5] == erase:
        s = s[5:]
        continue
    elif s[:6] == eraser:
        s = s[6:]
        continue
    elif s[:7] == dreamer:
        s = s[7:]
        continue
    break
if len(s) == 0:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
flag = False
for i in range(n):
    for j in range(i + 1, n):
        if a[i] == a[j]:
            flag = True
            break

if flag:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
if len(a) != len(set(a)):
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

S = input()[::-1]
n = len(S)
dp = [0]*2019
dp[0] = 1
X = 0
Y = 1
for s in S:
    Z=(int(s)*Y)%2019
    X = (X+Z)%2019
    dp[X] += 1
    Y *= 10
answer = 0
for i in range(2019):
    answer += dp[i]*(dp[i]-1)/2
print(int(answer))

### FIXED CODE ###

S = input()[::-1]
n = len(S)
dp = [0]*2019
dp[0] = 1
X = 0
Y = 1
for s in S:
    Z=(int(s)*Y)%2019
    X = (X+Z)%2019
    dp[X] += 1
    Y = (10*Y)%2019
answer = 0
for i in range(2019):
    answer += dp[i]*(dp[i]-1)/2
print(int(answer))
### BUGGY CODE ###

#!/usr/bin/env python3
INF = 10**7
import sys
input = sys.stdin.readline
from collections import*

def bfs(sx, sy, gx, gy, c):
    q = deque([(sx, sy)])
    dist = [[INF] * W for _ in range(H)]
    dist[sx][sy] = 0
    
    while q:
        x, y = q.popleft()
        if (x, y) == (gx, gy): return dist[gx][gy]
        for nx, ny in [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]:
            if 0<=nx<H and 0<=ny<W and dist[nx][ny] > dist[x][y]:
                if c[nx][ny] == ".":
                    dist[nx][ny] = dist[x][y]
                    q.appendleft((nx, ny))
        for nx in range(x-2, x+3):
            for ny in range(y-2, y+3):
                if 0<=nx<H and 0<=ny<W and dist[nx][ny] > dist[x][y]:
                    if c[nx][ny] == ".":
                        dist[nx][ny] = dist[x][y] + 1
                        q.append((nx, ny)) 
    return -1
H, W = map(int, input().split())

cx, cy = map(int, input().split())
dx, dy = map(int, input().split())
ans = bfs(cx - 1, cy - 1, dx - 1, dy - 1, [input()[:-1] for _ in range(H)])
print(ans if ans != INF else -1)


### FIXED CODE ###

#!/usr/bin/env python3
INF = 10**7
import sys
input = sys.stdin.readline
from collections import*

def bfs():
    q = deque([(sx, sy)])
    dist = [[INF] * W for _ in range(H)]
    dist[sx][sy] = 0
    
    while q:
        x, y = q.popleft()
        b = dist[x][y]
        if (x, y) == (gx, gy):
            return b
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] > b and c[nx][ny] == ".":
                dist[nx][ny] = b
                q.appendleft((nx, ny))
        B = b + 1
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] > B and c[nx][ny] == ".":
                    dist[nx][ny] = B
                    q.append((nx, ny)) 
    return -1

H, W = map(int, input().split())
cx, cy = map(int, input().split())
dx, dy = map(int, input().split())
sx, sy, gx, gy = cx - 1, cy - 1, dx - 1, dy - 1
c = [input()[:-1] for _ in range(H)]
ans = bfs()
print(ans if ans != INF else -1)
### BUGGY CODE ###

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

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

for d in make_divisors(sum(A)):
  if d==1:
    print(d)
    exit()
  A_ = [a%d for a in A if a%d]
  if max(A_)+K < d:
    continue  
  A_.sort()
  left, right = 0, len(A_)-1
  for k in range(K):    
    A_[left] -= 1
    if A_[left]==0:
      left += 1
    A_[right]+= 1
    if A_[right]==d:
      right-= 1
    if sum([a%d for a in A_]) == 0:
      print(d)
      exit()




### FIXED CODE ###

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

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

for d in make_divisors(sum(A)):
  if d==1:
    print(d)
    exit()
  A_ = [a%d for a in A if a%d]
  if max(A_)+K < d:
    continue  
  A_.sort()
  lSum, rSum = 0, 0
  K_need = 1e9
  for a in A_:
    rSum += d - a
  for a in A_:
    lSum += a
    rSum -= d - a
    K_need = min(K_need, max(lSum,rSum))
  if K_need <= K:
    print(d)
    exit()
### BUGGY CODE ###

A,B=map(int,input().split())
C=0
for n in range(A,B+1):
    C^=n
print(C)

### FIXED CODE ###

A,B=map(int,input().split())
def f(n):
    if n%4==0:
        return n
    if n%4==1:
        return 1
    if n%4==2:
        return 1^n
    if n%4==3:
        return 0
print(f(A-1)^f(B))
### BUGGY CODE ###

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

INF = float('inf')
dp = [[INF]*N for i in range(N+1)]
dp[0] = A[:]

ans = sum(A)
for k in range(N):
    cost = k*X
    if cost > ans: break
    for i in range(N):
        dp[k+1][i] = min(dp[k][i], A[i-k])
    cost += sum(dp[k+1])
    ans = min(ans, cost)

print(ans)

### FIXED CODE ###

N,X = map(int,input().split())
src = list(map(int,input().split()))
dp = src[:]
ans = float('inf')
for n in range(N):
    for m in range(N):
       if dp[m] > src[m-n]:
           dp[m] = src[m-n]
    ans = min(ans, sum(dp)+n*X)
print(ans)
### BUGGY CODE ###

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

def erat():
    tmp = [False if i == 0 or i == 1 else True for i in range(10 ** 3)]
    for i in range(2, 10 ** 3):
        if tmp[i]:
            for j in range(2 * i, 10 ** 3, i):
                tmp[j] = False
            yield i

a = {}
for i in erat():
    for j in range(N):
        if A[j] % i == 0:
            while not A[j] % i:
                A[j] //= i
            if i in a:
                a[i] += 1
            else:
                a[i] = 1

for i in range(N):
    if A[i] != 1:
        if A[i] in a:
            a[A[i]] += 1
        else:
            a[A[i]] = 1

if max(a.values()) == 1:
    print('pairwise coprime')
elif max(a.values()) != N:
    print('setwise coprime')
else:
    print('not coprime')

### FIXED CODE ###

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

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def erat():
    end = 10 ** 6 + 1
    t = [False if i == 0 or i == 1 else True for i in range(end)]
    ret = [0 for i in range(end)]

    for i in range(2, end):
        if t[i]:
            for j in range(i * 2, end, i):
                t[j] = False
                if not ret[j]:
                    ret[j] = i
            ret[i] = i
    return ret

tmp = A[0]
for i in A[1:]:
    tmp = gcd(tmp, i)
isS = True if tmp == 1 else False
isP = True

e = erat()

D = dict(iter([(i, False) for i in range(10 ** 6 + 1)]))
for i in A:
    tmp = set()
    while i != 1:
        tmp.add(e[i])
        i //= e[i]
    for i in tmp:
        if D[i]:
            isP = False
            break
        else:
            D[i] = True
    if not isP:
        break

if isP:
    print('pairwise coprime')
elif isS:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

n=int(input())
ans=1
d=dict()
for i in range(1,n+1):
  k=1
  for j in range(1,i+1):
    if j==0 or j==i:
      continue
    if i%j==0:
      k=0
  if k:
    d[i]=0
    n0=n
    while n0:
      d[i]+=n0//i
      n0//=i
for i in d.values():
  ans*=i+1
print(ans)

### FIXED CODE ###

n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)
### BUGGY CODE ###


S = input()
T = input()

naga = len(S)

for i in range(naga):
    ss = S[i]
    tt = T[i]
    S = S.replace(ss,"!")
    S = S.replace(tt,ss)
    S = S.replace("!",tt)

if S == T:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
T = input()

naga = len(S)
count = 0
for i in range(naga):
    ss = S[i]
    tt = T[i]
    if S.find(ss) != -1 :
        count = count + 1
    S = S.replace(ss,"!")
    S = S.replace(tt,ss)
    S = S.replace("!",tt)

    if count > 28:
        break


if S == T:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+a[i], n):
        if j-i == a[i]+a[j]:
            ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

ans = 0
L = {}
R = {}
for i in range(n):
    if i+a[i] in L:
        L[i+a[i]].append(i)
    else:
        L[i+a[i]] = [i]
    if i-a[i] in R:
        R[i-a[i]].append(i)
    else:
        R[i-a[i]] = [i]
for i in range(n):
    if i in L and i in R:
        ans += len(L[i])*len(R[i])
print(ans)
### BUGGY CODE ###

n,t=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]


rieki=0

for ind,i in enumerate(A):
    lst=A[:ind+1]
    if(ind==len(A)-1):
        break
    elif(A[ind+1]-min(lst) >= rieki):
        rieki=A[ind+1]-min(lst)

count=0
for ind,i in enumerate(A):
    lst=A[:ind+1]
    if(ind==len(A)-1):
        break
    elif(A[ind+1]-min(lst) == rieki):
        count+=1
print(count)


### FIXED CODE ###

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

c=0
dif=0
m=a[0]
for i in range(1,n):
    if(m>a[i]):
        m=a[i]
    if(dif<a[i]-m):
        c=1
        dif=a[i]-m
    elif(dif==a[i]-m):
        c+=1
print(c)
### BUGGY CODE ###

from collections import Counter

s = list(input())
ls = len(s)
T = [0] * (ls+1)
modL = [0]
cnt = 0

for i in range(0, ls):
    T[i] = int("".join(s[i:ls]))
    modL.append(T[i] % 2019)

ans = 0
for c in Counter(modL).values():
    ans += c * (c - 1) // 2

print(ans)


### FIXED CODE ###

from collections import Counter

s = list(input())
ls = len(s)
T = [0] * (ls+1)
modL = [0]
cnt = 0
pad = 1

for i in reversed(range(0, ls)):
    T[i] = T[i+1] + int(s[i]) * pad
    modL.append(T[i] % 2019)
    pad = pad * 10 % 2019

ans = 0
for c in Counter(modL).values():
    ans += c * (c - 1) // 2

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

N, X = map(int, input().split())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(xlist[i+1]-xlist[i])
D = 1
for i in range(2, abs(min(dlist))+ 1):
    for d in dlist:
        if d % i != 0:
            break
    else:
        D = i
print(D)


### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
N, X = map(int, input().split())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(abs(xlist[i+1]-xlist[i]))
g = max(dlist)
for d in dlist:
    g = gcd(g, d)
print(g)
### BUGGY CODE ###

rules = ['dream', 'dreamer', 'erase', 'eraser']

stack = [input()]
mem = [stack[0]]
ok = False
while len(stack) > 0:
    string = stack.pop()
    if string == '':
        print('YES')
        ok = True
        break
    for rule in rules:
        if string.startswith(rule):
            part = string[len(rule):]
            if part not in mem:
                stack.append(part)
                mem.append(part)
if not ok:
    print('NO')

### FIXED CODE ###

rules = ['dream', 'dreamer', 'erase', 'eraser']

s = input()
stack = [0]
mem = [0 for _ in range(len(s)+1)]
ok = False
while len(stack) > 0:
    start_id = stack.pop()
    string = s[start_id:]
    if start_id == len(s):
        print('YES')
        ok = True
        break

    for rule in rules:
        if string.startswith(rule):
            next_start_id = start_id + len(rule)
            if next_start_id <= len(s):
                part = string[next_start_id:]
                if mem[next_start_id] == 0:
                    stack.append(next_start_id)
                    mem[next_start_id] = 1
if not ok:
    print('NO')
### BUGGY CODE ###

import math, fractions

a, b = map(int, input().split())
n = int(fractions.gcd(a, b))
res = 0
for i in range(3, n):
    if a % i or b % i:
        continue
    dest = int(math.sqrt(i))
    for j in range(2, dest+1):
        if i % j == 0:
            break
    else:
        res += 1
if n >= 2:
    print(res + 2)
else:
    print(res + 1)

### FIXED CODE ###

a, b = map(int, input().split())

def getPrimeFactors(x):
    ans = []
    for d in range(2, int(x**0.5)+1):
        while x%d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

res_a = getPrimeFactors(a)
res_b = getPrimeFactors(b)

res = len(set(res_a) & set(res_b))
print(res + 1)
### BUGGY CODE ###

class DisjointSet(object):

    def __init__(self):
        self.leader = {} # maps a member to the group's leader
        self.group = {} # maps a group leader to the group (which is a set)

    def add(self, a, b):
        leadera = self.leader.get(a)
        leaderb = self.leader.get(b)
        if leadera is not None:
            if leaderb is not None:
                if leadera == leaderb: return # nothing to do
                groupa = self.group[leadera]
                groupb = self.group[leaderb]
                if len(groupa) < len(groupb):
                    a, leadera, groupa, b, leaderb, groupb = b, leaderb, groupb, a, leadera, groupa
                groupa |= groupb
                del self.group[leaderb]
                for k in groupb:
                    self.leader[k] = leadera
            else:
                self.group[leadera].add(b)
                self.leader[b] = leadera
        else:
            if leaderb is not None:
                self.group[leaderb].add(a)
                self.leader[a] = leaderb
            else:
                self.leader[a] = self.leader[b] = a
                self.group[a] = set([a, b])

n, m = [int(x) for x in input().split()]
b = []
for i in range(m):
  b.append(tuple(int(x) for x in input().split()))
r = []
t = 0
ds = DisjointSet()
for i in range(m):
  q, p = b[-i-1]
  r.insert(0, n*(n-1)//2 - t)
  if p not in ds.leader or q not in ds.leader or ds.leader[p] != ds.leader[q]:
    aa = len(ds.group[ds.leader[p]]) if p in ds.leader else 1
    bb = len(ds.group[ds.leader[q]]) if q in ds.leader else 1
    t += aa*bb
  ds.add(p, q)
for x in r:
  print(x)

### FIXED CODE ###

class Unionfind():
    def __init__(self, progsize):
        self.table = [-1 for _ in range(progsize)]
        self.size = [1 for _ in range(progsize)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
                self.size[xl] += self.size[yl]
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
                self.size[yl] += self.size[xl]

n, m = map(int, input().split())
bridge = [tuple(map(int, input().split())) for _ in range(m)]
bridge.reverse()
uf = Unionfind(n)
cur = n * (n-1) // 2
ans = [cur]
for a, b in bridge:
    ap = uf.find(a-1)
    bp = uf.find(b-1)
    if ap != bp:
        cur -= uf.size[ap] * uf.size[bp]
    uf.union(a-1, b-1)
    ans.append(cur)
for a in reversed(ans[0:m]):
    print(a)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

from collections import Counter
counter=Counter(a)

# 番号nを取り除いた時の組み合わせをメモする
memo={}
def calc_combi_if_exclude(n):
    if n in memo:
        return memo[n]
    else:
        combi=0
        for num,cnt in counter.items():
            n_cnt=cnt
            if num==n:
                n_cnt-=1
            combi+=n_cnt*(n_cnt-1)//2
        memo[n]=combi
        return combi
    
for i in range(n):
    combi=0
    print(calc_combi_if_exclude(a[i]))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

from collections import Counter
counter=Counter(a)

# すべての組み合わせを事前に計算しておく
combi_sum=0
for num,cnt in counter.items():
    combi_sum+=cnt*(cnt-1)//2

for i in range(n):
    print(combi_sum - counter[a[i]] + 1)
### BUGGY CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

dp = Counter()

dp[0] = 0
dp[1] = 1

geta = 1000
geta2 = geta**2
for c in range(N+1):
    for b in range(N+1):
        if b + c > N:
            break
        for a in range(N+1):
            if a + b + c > N:
                break
            S = a + b + c
            res = 0 if S == 0 else N/S
            if a != 0:
                res += a/S*dp[(a-1)*geta2 + b*geta + c]
            if b != 0:
                res += b/S*dp[(a+1)*geta2 + (b-1)*geta + c]
            if c != 0:
                res += c/S*dp[a*geta2 + (b+1)*geta + c - 1]
            dp[a*geta2 + b*geta + c] = res
CA = Counter(A)
print(dp[CA[1]*geta2 + CA[2]*geta + CA[3]])

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

dp = [[[0]*(N+2) for _ in range(N+2)] for _ in range(N+2)]
CA = Counter(A)
SA = CA[1]
SB = CA[2]
SC = CA[3]
for c in range(SC+1):
    for b in range(SB+SC+1):
        if b + c > N:
            break
        for a in range(N+1):
            if a + b + c > N:
                break
            S = a + b + c
            if S == 0:
                continue
            dp[a][b][c] = N/S + a/S*dp[a-1][b][c]\
            +b/S*dp[a+1][b-1][c]\
            +c/S*dp[a][b+1][c - 1]

print(dp[SA][SB][SC])
### BUGGY CODE ###

n,m,k=map(int,input().split())
fr=[input() for i in range(m)]
bl=[input() for i in range(k)]
relfr=[set() for i in range(n)]
relbl=[set() for i in range(n)]
for l in fr:
  a,b=map(int,l.split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for l in bl:
  a,b=map(int,l.split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
cand={0}
searched=set()
gr=set()
all_gr={i for i in range(n)}
ans=['']*n
c=0
while True:
  while len(cand)!=0:
    now=cand.pop()
    gr.add(now)
    c+=1
    for point in relfr[now]-(relfr[now]&gr)-(relfr[now]&cand):
      cand.add(point)
  for i in gr:
    ans[i]=str(len(gr)-len(relfr[i])-len(relbl[i]&gr)-1)
    searched.add(i)
  all_gr-=searched
  gr.clear()
  if c!=n:
    cand.add(list(all_gr)[0])
  else:
    break
print(' '.join(ans))

### FIXED CODE ###

n,m,k=map(int,input().split())
relfr={i:set() for i in range(n)}
relbl={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for i in range(k):
  a,b=map(int,input().split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
blsiz=[0 for i in range(n)]
ans=[0]*n
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
uf=UnionFind(n)
for i in range(n):
  for j in relfr[i]:
    uf.Unite(i,j)
for i in range(n):
  for j in relbl[i]:
    if uf.isSameGroup(i,j):
      blsiz[i]+=1
for i in range(n):
  ans[i]=uf.Count(i)-len(relfr[i])-blsiz[i]-1

print(' '.join(map(str,ans)))
### BUGGY CODE ###

import math as m
n = int(input())


for i in range(1,n+1):
    c = 0
    for x in range(1,m.ceil(m.sqrt(i))):
        for y in range(1,m.ceil(m.sqrt(i-x))):
            for z in range(1,m.ceil(m.sqrt(i-x-y))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    c +=1 
    print(c)



### FIXED CODE ###

import math as m


n = int(input())

l = [0] * 10000

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if  ans <= 10000:
                l[ans-1] += 1

for i in range(n):
    print(l[i])
### BUGGY CODE ###

n=int(input())
a = list(map(int, input().split())) #
ans=1
for i in range(n):
    ans=ans*a[i]

if ans>10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n=int(input())
a = list(map(int, input().split())) #
ans=1
for i in range(n):
    if a[i]==0:
        print(0)
        exit()
for i in range(n):
    if a[i]*ans>10**18:
        print(-1)
        exit()
    else:
        ans=ans*a[i]
print(ans)
### BUGGY CODE ###

# 初期入力
N,M = (int(x) for x in input().split())
A = [int(input()) for i in range(M)]


#
mod_9 = 10**9 +7
dp =[0]*(N +1)
dp[0] = 1
if 1 not in A:
    dp[1] =1
for i in range(N-1):
    if i+2 not in A:
        dp[i+2] = dp[i+1] + dp[i] 
        dp[i+2] %= mod_9
kotae =dp[N] # % mod_9
print(kotae )

### FIXED CODE ###

# 初期入力
N,M = (int(x) for x in input().split())
A = set([int(input()) for i in range(M)])


#
mod_9 = 10**9 +7
dp =[0]*(N +1)
dp[0] = 1
if 1 not in A:
    dp[1] =1
for i in range(N-1):
    if i+2 in A:
        dp[i+2] = 0
    else:
        dp[i+2] = dp[i+1] + dp[i] 
        dp[i+2] %= mod_9
kotae =dp[N] # % mod_9
print(kotae )