Harryxun/stf_run huggingface dataset:
import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    # ball = list(map(list, set(map(tuple, ball))))
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    for i in range(len(ball)):
        for j in range(len(ball)):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            l1.append(list(dis1))

    c1 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
    m1 = np.max(np.array(c1, dtype=int))

    print(n-m1)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    ball = np.array(ball, dtype=int)
    if n == 1:
        print(1)
        exit()

    l1 = []
    for i in range(len(ball)):
        for j in range(len(ball)):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            l1.append(list(dis1))

    c1 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
    m1 = np.max(np.array(c1, dtype=int))

    print(n-m1)

if __name__ == "__main__":
    main()
import numpy as np
num=input().split(' ')
count=0
plot=np.zeros([int(num[0]),int(num[0])])
t=[]
for a in range(int(num[1])):
  tmp=input().split(' ')
  t.append([int(tmp[0])+a for a in range(int(tmp[1])-int(tmp[0])+1)])
for a in range(int(num[0])):
  if a==0:
    plot[0,0]=1
  else:
    for posit in np.where(plot[a-1]>0)[0]:
      for b in t:
        for c in b:
          if posit+c<int(num[0]):
	          plot[a,posit+c]+=plot[a-1,posit]
xx=int(np.sum(plot[:,-1]))
print(xx%998244353)

### FIXED CODE ###

a=input()
if a[-1]=='s':
  print(a+'es')
else:
  print(a+'s')
N,M=map(int,input().split())

from scipy.special import comb
# a = comb(n, r)
a = comb(N+M, 2, exact=True)
print(a-N*M)

### FIXED CODE ###

N,M=map(int,input().split())
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N+M,2)-N*M
print(a)
n = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
def f(x):
 if x%2:
  return 0
 else:
  return f(x//2)+1
for i in range(n):
 ans += f(lis[i])
print(ans)

### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 0
def f(x):
 if x%2:
  return(0)
 else:
  return(f(x//2)+1)
for i in range(n):
 ans += f(lis[i])
print(ans)
N, Q = map(int, input().split())
ki = [[[],0] for i in range(N)]

def dfs(ki_elms, num, ki):
    num_tmp = num+ki_elms[1]
    print(num_tmp)
    if not ki_elms[0]:
        return
    for child in ki_elms[0]:
        dfs(ki[child], num_tmp, ki)

for i in range(N-1):
    a, b = map(int, input().split())
    ki[a-1][0].append(b-1)

for i in range(Q):
    p, x = map(int, input().split())
    ki[p-1][1] += x

dfs(ki[0], 0, ki)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n
 
def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)
 
for i in range(n-1):
    a,b=[int(_) for _ in input().split()]
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
 
for i in range(q):
    p,x=[int(_) for _ in input().split()]
    ans[p-1]+=x
 
dfs(0,-1)
print(*ans)
N, K=map(int, input().split())
H=list(map(int, input().split()))

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(sum(H))




### FIXED CODE ###

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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))
n, x, m = map(int, input().split())

dp = [-1]*(10**5+2)
nums = [-1]*(10**5+2)
nums[x] = 1

dp[x] = x
bef = x
nex = (x**2)%m
r = [0, x]
while dp[nex] < 0:
    nums[nex] = nums[bef]+1
    dp[nex] = dp[bef]+nex
    r.append(dp[nex])
    nex, bef = (nex**2)%m, nex

if nex == 0:
    x = num[bef]
    print(r[min(len(r), n)])
else:
    roop = nums[bef] - nums[nex] + 1
    roop_value = r[nums[bef]] - r[nums[nex] - 1]
    plus = r[nums[nex]-1]*(n>=nums[nex])
    n = max(0, n-nums[nex]+1)
    print(
        roop_value*(n//roop)+plus+
        r[n%roop + nums[nex] -1]
        -r[nums[nex] - 1]
    )


### FIXED CODE ###

n, x, m = map(int, input().split())

dp = [-1 for _i in range(10**5+2)]
nums = [-1 for _i in range(10**5+2)]
nums[x] = 1

dp[x] = x
bef = x
nex = (x**2)%m
r = [0, x]
while dp[nex] < 0:
    nums[nex] = nums[bef]+1
    dp[nex] = dp[bef]+nex
    r.append(dp[nex])
    nex, bef = (nex**2)%m, nex

if nex == 0:
    print(r[min(len(r)-1, n)])
elif n <= nums[bef]:
    print(r[n])
else:
    roop = nums[bef] - nums[nex] + 1
    roop_value = r[nums[bef]] - r[nums[nex] - 1]
    plus = r[nums[nex]-1]*(n>=nums[nex]+1)
    n = max(0, n-nums[nex]+1)
    print(
        roop_value*(n//roop)+plus+
        r[n%roop + nums[nex] -1]
        -r[nums[nex] - 1]
    )
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-03 22:36:44 +0900
# LastModified: 2020-05-03 22:38:33 +0900
#


import os
import sys


def main():
    x=int(input())
    b=-1
    for i in range(x):
        if x==i**5+1:
            a=i
            break
    print("{} {}".format(a,b))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-08-08 01:53:55 +0900
# LastModified: 2020-08-08 01:56:11 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    x = int(input())
    for a in range(-120, 120):
        for b in range(-120, a):
            if a**5-b**5 == x:
                print("{} {}".format(a, b))
                return


if __name__ == "__main__":
    main()
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
sm=0
for i in l:
  sm+=(i*(i+1))//2
  
print(sm)

### FIXED CODE ###

s=input()
l=[]
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
sm=0
for i in l:
  sm+=(i*(i+1))//2
for i in range(0 if s[0]=='<' else 1,len(l)-1,2):
  sm-=min(l[i],l[i+1])
 
  
print(sm)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


K = int(input())

sum_gcd = 0
cand = itertools.combinations(K, 3))
for i in range(1, K + 1):
    for j in range(1, K + 1):
        g=gcd(i, j)
        for k in range(1, K + 1):
            sum_gcd += gcd(g, k)
print(sum_gcd)

### FIXED CODE ###

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


K = int(input())

sum_gcd = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        g = gcd(i, j)
        for k in range(1, K + 1):
            sum_gcd += gcd(g, k)
print(sum_gcd)
while 1:
    n = input()
    if n == 0:
        break
    status = {}
    god_st = 0
    res = {}
    for i in xrange(n):
        s = raw_input().split()
        #M, D = map(int, s[0].split("/"))
        h, m = map(int, s[1].split(":"))
        mi = 60*h + m
        st = s[2] == 'I'
        ID = s[3]

        if ID == '000':
            # goddness
            if st == 1:
                god_st = mi
            else:
                for k in status:
                    if k != ID and status[k] != -1:
                        res[k] = res.get(k, 0) + (mi - max(god_st, status[k]))
        else:
            if st == 1:
                status[ID] = mi
            else:
                status[ID] = -1
    print max(res.values())

### FIXED CODE ###

while 1:
    n = input()
    if n == 0:
        break
    status = {}
    god_st = -1
    res = {}
    for i in xrange(n):
        s = raw_input().split()
        #M, D = map(int, s[0].split("/"))
        h, m = map(int, s[1].split(":"))
        mi = 60*h + m
        st = s[2] == 'I'
        ID = s[3]

        if ID == '000':
            # goddness
            if st == 1:
                god_st = mi
            else:
                for k in status:
                    if k != ID and status[k] != -1:
                        res[k] = res.get(k, 0) + (mi - max(god_st, status[k]))
                god_st = -1
        else:
            if st == 1:
                status[ID] = mi
            else:
                if god_st != -1:
                    res[ID] = res.get(ID, 0) + (mi - max(god_st, status[ID]))
                status[ID] = -1
    print max(res.values()) if res else 0
n,k = map(int,input().split(" "))
goukei = k*(k-1)**(n-1)
print(goukei)

### FIXED CODE ###

s = list(input().split(" "))
s_set = list(set(s))
print(len(s_set))
N,D = array(input(),input())
print(roundup(N/2D ,0)

### FIXED CODE ###

n,d = (int(x) for x in input().split())
if n % (2*d + 1) == 0:
  print(n//(2*d + 1))
else:
  print(n//(2*d + 1) + 1)
#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):

    result = 0
    while len(H) >= 2:
        count = 0
        for i in range(len(H) - 1):
            if H[i] >= H[i + 1]:
                count += 1
            else:
                break
        result = max(result, count)

        H = H[count + 1 :]

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    count = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            count += 1
        else:
            pass
    print(count)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == "__main__":
    main()
_N, *_SP = open(0).read().split()
N = int(_N)

S = {}
P = {}

for i in range(N):
    S[i+1] = _SP[2*i]
    P[i+1] = int(_SP[2*i+1])
    
import pandas as pd

S_df = pd.DataFrame(S.values(), index=S.keys(), columns=["name"])
P_df = pd.DataFrame(P.values(), index=P.keys(), columns=["point"])

df = pd.concat([S_df, P_df], axis=1)
print(*list(df.sort_values(['name', 'point'], ascending=[True, False]).index), sep="\n")

### FIXED CODE ###

N = int(input())
data = [{}]*N

for i in range(N):
  tempS, tempP = input().split()
  data[i] = {'ID': i+1, 'Name': tempS, 'Point': int(tempP)}

data_sort = sorted(
  data,
  key = lambda x: (x['Name'], -x['Point'])
)

for i in range(N):
  print(data_sort[i]['ID'])
X, Y, A, B, C = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)
a2 = a[:]
b2 = b[:]
c2 = c[:]
sum1 = 0
for i in range(X):
    if a[0] < c[0]:
        sum1 += c.pop(0)
    else:
        sum1 += a.pop(0)
for i in range(Y):
    if b[0] < c[0]:
        sum1 += c.pop(0)
    else:
        sum1 += b.pop(0)
sum2 = 0
for i in range(Y):
    if b2[0] < c2[0]:
        sum2 += c2.pop(0)
    else:
        sum2 += b2.pop(0)
for i in range(X):
    if a2[0] < c2[0]:
        sum2 += c2.pop(0)
    else:
        sum2 += a2.pop(0)
        
if sum1 > sum2:
    print(sum1)
else:
    print(sum2)


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = sorted(a, reverse=True)[:X]
b = sorted(b, reverse=True)[:Y]
print(sum(sorted(a + b + c, reverse=True)[:X+Y]))
inp = [input() for _ in range(2)]
s = inp[0]
k = int(inp[1])
i = 0

while True:
  if s[i] == "1":
    i += 1
  else:
    ans = int(s[i])
    break

if i >= k:
  print(1)
else:
  print(ans)

### FIXED CODE ###

inp = [input() for _ in range(2)]
s = inp[0]
k = int(inp[1])
j = 0

for i in s:
  if i == "1":
    j += 1
  else:
    ans = int(i)
    break

if j >= k:
  print(1)
else:
  print(ans)
N,K=map(int,input().split())
cnt=[0]*N
for i in range(K):
    d=int(input())
    A=list(map(int(),input().split()))
    for a in A:
        cnt[a-1]=cnt[a-1]+1
ans=0
for i in range(N):
    if cnt[i]==0:
        ans=ans+1
print(ans)




### FIXED CODE ###

N,K=map(int,input().split())
cnt=[0]*N
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        cnt[a-1]=cnt[a-1]+1
ans=0
for i in range(N):
    if cnt[i]==0:
        ans=ans+1
print(ans)
I,*U=N,*D=9**9,
P,*L='x+y,',
M,*R='x-y,',
for t in[*open(n:=0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S in(D,U,'x,y,'),(U,R,P+M),(L,U,M+P),(D,R,M+P),(L,D,P+M),(L,R,'y,x,'):
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in P)'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')

### FIXED CODE ###

d=[[],[],[],[]]
for t in[*open(0)][1:]:*z,u=t.split();d[ord(u)%5]+=[*map(int,z)],
I=N=9**9
P,M='x+y,','x-y,'
for*A,S in(3,0,'x,y,'),(1,2,'y,x,'),(0,2,P+M),(1,3,P+M),(1,0,M+P),(3,2,M+P):
 n=p=-I
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in d[P])'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    ma=max(A)

    from functools import reduce
    from math import gcd

    g=reduce(gcd,A)
    if K%g==0 and K<=ma:
        print('POSSIBLE')
    else: print('IMPOSSIBLE')

resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    ma=max(A)

    from functools import reduce
    from fractions import gcd

    g=reduce(gcd,A)
    if K%g==0 and K<=ma:
        print('POSSIBLE')
    else: print('IMPOSSIBLE')

resolve()
from functools import reduce
from math import gcd
n, x = map(int, input().split())
y = [int(v) - x for v in input().split()]
y.append(0)
g = reduce(gcd, y)
print(g)


### FIXED CODE ###

from functools import reduce
from fractions import gcd
n, x = map(int, input().split())
y = [abs(int(v) - x) for v in input().split()]
g = y[0] if len(y) == 1 else reduce(gcd, y)
print(g)
# -*- coding: utf-8 -*-
import numpy as np

S = [int(x) for x in list(input())]

if len(S)==1:
    print(1)

elif len(S)==2:
    if S[0] == S[1]:
        print(2)
    else:
        print(1)
else:
    l = []
    c = 1
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            c += 1
        else:
            l.append(c)
            c = 1
    l.append(c)
    ans = max(l)
    #print(l)
    if ans in l[1:-1]:
        print(ans+1)
    else:
        print(ans)


### FIXED CODE ###

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

A, B, C, D = [int(x) for x in input().split()]

if A + B > C + D:
    print("Left")

elif A + B == C + D:
    print("Balanced")

elif A + B < C + D:
    print("Right")
a,b=int(input().split())
if a*500>=b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
if a*500>=b:
  print("Yes")
else:
  print("No")
import fractions
n = int(input())
a = list(map(int, input().split()))
forward = [0, a[0]]
back =[0, a[n-1]]
for i in range(1,n-1):
    forward.append(fractions.gcd(forward[i], a[i]))
    back.append(fractions.gcd(back[i], a[n-i-1]))

back.reverse()

ans = max(forward[n-2], back[0])
for i in range(n-2):
    ans = max(ans, fractions.gcd(forward[i], back[i]))
print(ans)


### FIXED CODE ###

a, b, t = map( int, input().split() )
print(b*(t//a))
n = int(input())
sum = list(map(int,input().split()))
x = 1

for i in range(n):
    x *= list[i]

if x>1000000000000000000:
    print(-1)
    
else:
    print(x)

### FIXED CODE ###

N=int(input())
number=list(map(int,input().split()))
ans=1
if 0 in number:
    print(0)
    exit(0)
    
for i in range(N):
    ans *= number[i]
    if ans>1000000000000000000:
        print(-1)
        exit(0)
print(ans)
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb=ballb*A
ballr.append('r')
ballr=ballr*B
ball=(ballb+ballr)*N
count=0
for i in range(N):
    if ball[i]=='b':
        count+=1
print(count)

### FIXED CODE ###

N,A,B=map(int,input().split())
a=N//(A+B)*A
c=N%(A+B)
b=min(A,c)
print(a+b)
N,K=map(int,input().split())
H=list(map(int,input().split())
print(N)
print(K)
s=0
if N<=K:
  print(0)
else:
  for i in range(H-N)
    s+=H[i]
  print(s)

### FIXED CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
I=sorted(H)
s=0
if N<=K:
  print(0)
else:
  for i in range(N-K):
    s+=I[i]
  print(s)
n,m,k=map(int,input().split())
flag=False
if n==1 or m==1:
  print('Yes')
  else:
  for i in range(n):
    for j in range(m):
      if i*j + (n-i)*(m-j) + k == n*m:
        flag=True
  if flag:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

n,m,k=map(int,input().split())
flag=False
if n==1 or m==1:
  print('Yes')
else:
  for i in range(n+1):
    for j in range(m+1):
      if i*j + (n-i)*(m-j) + k == n*m:
        flag=True
  if flag:
    print('Yes')
  else:
    print('No')
n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)+1):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
print(*A)
c1 = input().split()
c2 = input().split()
c3 = input().split()
print(c1[0]+c2[1]+c3[2])

### FIXED CODE ###

c1 = input()
c2 = input()
c3 = input()
print(c1[0]+c2[1]+c3[2])
A,B,C=map(int,input().split())
K=int(input())
if()
for i in range(0,K+1):
    for j in range(0,K+1-i):
        for k in range(0,K+1-i-j):
            #print('{},{},{}'.format(i,j,k))
            if(A*(2**i) < B*(2**j) and B*(2**j) < C*(2**k)):
                if(i==j==k==0):
                    break
                else
                    print('Yes')
                    exit()

print('No')


### FIXED CODE ###

A,B,C=map(int,input().split())
K=int(input())

for i in range(0,K+1):
    for j in range(0,K+1-i):
        for k in range(0,K+1-i-j):
            #print('{},{},{}'.format(i,j,k))
            if(A*(2**i) < B*(2**j) and B*(2**j) < C*(2**k)):

                print('Yes')
                exit()

print('No')
a,b,c.d = map(int,input().split())
while a>=0 ans b>=0:
  b-=c
  d-=a
if a == 0 and b==0:
  print('Yes')
elif b == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b,c,d = map(int,input().split())
while a>0 and b>0:
  a-=d
  c-=b

if a <= 0 and c<=0:
  print('Yes')
elif c <= 0:
  print('Yes')
else:
  print('No')
A = int(input())
B = int(input())

print(A*B)

### FIXED CODE ###

A, B = map(int, input().split())

print(A*B)
import sys

n, m, *ab = map(int, sys.stdin.read().split())
ab = list(zip(*[iter(ab)] * 2))

root = list(range(n+1)); root[0] = None
height = [0] * (n + 1); height[0] = None
size = [1] * (n + 1); size[0] = None

def find_root(v):
    u = root[v]
    if u == v:
        return u
    w = find_root(u)
    root[v] = w
    return w

def unite(v, u):
    rv = find_root(v)
    ru = find_root(u)
    if rv == ru:
        return
    if height[v] >= height[u]:
        root[ru] = rv
        height[rv] = max(height[rv], height[ru] + 1)
        size[rv] += size[ru]
    else:
        root[rv] = ru
        size[ru] += size[rv]

def is_alone(v, rv, sv):
    return v == rv and sv == 1

def main():
    res = [0] * (m + 1)
    for i in range(1, m):
        a, b = ab[m-i]
        ra = find_root(a)
        rb = find_root(b)
        sa = size[ra]
        sb = size[rb]
        
        bl_a = is_alone(a, ra, sa)
        bl_b = is_alone(b, rb, sb)

        if bl_a & bl_b:
            res[i+1] = res[i] + 1
        elif bl_a ^ bl_b:
            res[i+1] = res[i] + sa * sb
        else:
            if ra == rb:
                res[i+1] = res[i]
            else:
                res[i+1] = res[i] + sa * sb
        
        unite(a, b)

    res = res[::-1]
    all_pairs = n * (n - 1) // 2
    for i in range(m):
        yield all_pairs - res[i]
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

### FIXED CODE ###

import sys

n, m, *ab = map(int, sys.stdin.read().split())
ab = list(zip(*[iter(ab)] * 2))

root = list(range(n+1)); root[0] = None
height = [0] * (n + 1); height[0] = None
size = [1] * (n + 1); size[0] = None

sys.setrecursionlimit(10 ** 9)
def find_root(v):
    u = root[v]
    if u == v:
        return u
    w = find_root(u)
    root[v] = w
    return w

def unite(v, u):
    rv = find_root(v)
    ru = find_root(u)
    if rv == ru:
        return
    if height[v] >= height[u]:
        root[ru] = rv
        height[rv] = max(height[rv], height[ru] + 1)
        size[rv] += size[ru]
    else:
        root[rv] = ru
        size[ru] += size[rv]

def is_alone(v, rv, sv):
    return v == rv and sv == 1

def main():
    res = [0] * m
    for i in range(1, m):
        a, b = ab[m-i]
        ra = find_root(a)
        rb = find_root(b)
        sa = size[ra]
        sb = size[rb]
        
        bl_a = is_alone(a, ra, sa)
        bl_b = is_alone(b, rb, sb)

        if bl_a & bl_b:
            res[i] = res[i-1] + 1
        elif bl_a ^ bl_b:
            res[i] = res[i-1] + sa * sb
        else:
            if ra == rb:
                res[i] = res[i-1]
            else:
                res[i] = res[i-1] + sa * sb
        
        unite(a, b)

    all_pairs = n * (n - 1) // 2
    for i in res[::-1]:
        yield all_pairs - i
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')
n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
            print(i)
            break
solve()

### FIXED CODE ###

n=int(input())
if n==1:
  print("Hello World")
else:
  t=[int(input()) for i in range(2)] 
  print(t[0]+t[1])
import sys
N = int(input())
for n in renge(N//1.08,N):
  if n*1.08//1 == N:
    print(927)
    sys.exit()

### FIXED CODE ###

import sys
N = int(input())
for n in range(N*100//110,N+1):
  if n*1.08//1 == N:
    print(n)
    sys.exit()
print(":(")
import sys
X = int(input())
for A in range(1000):
    for B in range(1000):
        if A**5 - B**5 == X:
            print(A, B)
            sys.exit(1)
        elif A**5 + B**5 == X:
            print(A, -B)
            sys.exit(1)

### FIXED CODE ###

flag = 0
X = int(input())
for A in range(1000):
    if flag!=0:
        break
    for B in range(1000):
        if A**5 - B**5 == X:
            print(str(A) + " " + str(B))
            flag=1
            break
        elif A**5 + B**5 == X:
            print(str(A) + " " + str(-B))
            flag=1
            break