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

N=int(input())
sn=[''.join(sorted(list(input()))) for _ in range(N)]
sm=set(sn)
res=0
for s in sm:
  cnt=sn.count(s)
  res+=(1+(cnt-1))*(cnt-1)//2
print(res)

### FIXED CODE ###

N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)
### BUGGY CODE ###

n = int(input())
lst = []
pair = 0
for i in range(n):
	st = ''.join(sorted(list(input())))
	for j in lst:
		if st == j:
			pair += 1
	lst.append(st)
print (pair)

### FIXED CODE ###

n = int(input())
lst = []
pair = 0
for i in range(n):
	st = ''.join(sorted(list(input())))
	lst.append(st)
lst = sorted(lst)
lst += ['end']
pre = ''
tmp_cnt = 0
cnt = 0
for i in lst:
	if i == pre:
		tmp_cnt += 1
	else:
		cnt += sum([j for j in range(tmp_cnt + 1)])
		tmp_cnt = 0
	pre = i
print (cnt)
### BUGGY CODE ###

import sys
from collections import deque

n, *ppp = map(int, sys.stdin.buffer.read().split())

n2 = n + 2
seats = [-1] * n2
row_base0 = list(range(n))
row_base1 = [-1] + row_base0 + [-1]
row_base0.reverse()
row_base2 = [-1] + row_base0 + [-1]
row_base = [min(a, b) for a, b in zip(row_base1, row_base2)]

for i in range(n):
    ud = min(i, n - 1 - i)
    seats.extend(min(a, ud) for a in row_base)
seats.extend([-1] * n2)

is_seated = [False] * n2
is_seated.extend(([False] + [True] * n + [False]) * n)
is_seated.extend([False] * n2)


def pg(aaa):
    for i in range(0, n2 ** 2, n2):
        print(aaa[i:i + n2])
    print()


ans = 0
MOVE = (-n2, -1, 1, n2)
for p in ppp:
    i, j = divmod(p - 1, n)
    i = (i + 1) * n2 + j + 1
    res = seats[i]
    ans += res
    is_seated[i] = False

    q = deque([(res, i + di) for di in MOVE])
    while q:
        val, j = q.popleft()
        if seats[j] <= val:
            continue
        seats[j] = val
        ist = is_seated[j]
        for dj in MOVE:
            nj = j + dj
            if ist:
                nv = val + 1
                if seats[nj] > nv:
                    q.append((nv, nj))
            else:
                if seats[nj] > val:
                    q.appendleft((val, nj))
    # print(p, i, res)
    # pg(seats)

print(ans)


### FIXED CODE ###

import sys
import numpy as np

from numba import njit


@njit('i4(i4,i4[:])', cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))
### BUGGY CODE ###

H,N = map(int,input().split())
spells = sorted([tuple(map(int,input().split())) for _ in range(N)])
max_a = spells[-1][0]

dp = [10000000000 for _ in range(H + max_a + 1)]
dp[0] = 0

for i in range(1, H + max_a + 1):
  for spell in spells:
    if spell[0] > i:
      break
    else:
      dp[i] = min(dp[i], dp[i - spell[0]] + spell[1])

print(min(dp[H:H + max_a + 1]))


### FIXED CODE ###

H,N = map(int,input().split())
spells = [tuple(map(int,input().split())) for _ in range(N)]
max_a = max(spells)[0]

dp = [0]
for i in range(1, H + max_a + 1):
  try:
    dp.append(min([dp[i - a] + b for a,b in spells if a <= i]))
  except ValueError:
    dp.append(10**8)

print(min(dp[H:]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
graph = [[] for _ in range(N+1)]

for _ in range(M):
    u, v = map(int, input().split())
    graph[u].append(v)

S, T = map(int, input().split())

graph_ken = [[]]
for i in range(1, N+1):
    now = i
    queue = graph[now]
    for _ in range(2):
        nextqueue = []
        for next in queue:
            nextqueue.extend(graph[next])
        queue = list(set(nextqueue))
    graph_ken.append(queue)



queue = [S]
visit = [False]*(N+1)
visit[S] = True
ans = 0
while len(queue) > 0:
    nextqueue = []
    for now in queue:
        visit[now] = True
        for next in graph_ken[now]:
            if not visit[next]:
                nextqueue.append(next)
    queue = list(set(nextqueue))
    if visit[T]:
        break
    ans += 1

if visit[T]:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
N, M = map(int, input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    u, v = map(int, input().split())
    graph[u].append(v)

S, T = map(int, input().split())

inf = 10**6
ans = [[inf, inf, inf] for i in range(N+1)]

q = deque([S])
ans[S][0] = 0
while q:
    now = q.popleft()
    for next in graph[now]:
        flag = 0
        for i in range(3):
            if ans[now][i] != inf:
                if ans[next][(i+1)%3] > ans[now][i] + 1:
                    flag = 1
                    ans[next][(i+1)%3] = ans[now][i] + 1
        if flag == 1:
            q.append(next)

if ans[T][0] == inf:
    print(-1)
else:
    print(ans[T][0]//3)
### BUGGY CODE ###

n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]

h.sort()
hh = [0]*(n-1)
for i in range(n-1):
  hh[i] = h[i+1] - h[i]

ans = 10**10
for i in range(n-k+1):
  ans = min(ans,sum(hh[i:i+k-1]))

print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]

#n,k = 7,3
#h = [10,11,12,14,15,20,0]
h.sort()

ans = 10**10
for i in range(n-k+1):
  ans = min(h[i+k-1] - h[i] , ans)

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

from collections import defaultdict
def divisor(b):
  lst = []
  init = 2
  while b > 1:
    for i in range(init, int(b ** (1 / 2)) + 1):
      if b % 2 == 0:
        lst.append(i)
        lst.append(b // i)
        b //= i
        init = i
    else:
      break
  return set(lst)
def main():
  t = int(input())
  for _ in range(t):
    a, b, c, d = map(int, input().split())
    if (a < b or d < b):
      print("No")
      continue
    if (c >= b):
      print("Yes")
      continue
  
    a %= b
    if a > c:
      print("No")
      continue
    d %= b
    lst = defaultdict(bool)
    while True:
      a %= b
      if a > c:
        print("No")
        break
      if lst[a]:
        print("Yes")
        break
      lst[a] = True
      a += d
main()

### FIXED CODE ###

def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    #exception
    if a < b or d < b:
        print("No")
        continue

    if c >= b:
        print("Yes")
        continue

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")
### BUGGY CODE ###

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

C = {}
for i in A:
    if i in C:
        C[i] += 1
    else:
        C[i] = 1

ans = 0    
for i in C.keys():
    ans += (C[i] * (C[i]-1)) // 2
    
for i in A:
    dec = 0
    D = C.copy()
    D[i] += -1
    dec = (C[i] * (C[i]-1) // 2) - (D[i] * (D[i]-1) // 2)
    print(ans-dec)


### FIXED CODE ###

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

#%%
C = {}
for i in A:
    if i in C:
        C[i] += 1
    else:
        C[i] = 1

ans = 0    
for i in C.keys():
    ans += C[i] * (C[i]-1) // 2
    
for i in A:
    dec =  C[i] * (C[i]-1) // 2 - (C[i]-1) * (C[i]-2) //2
    print(ans - dec)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
g = [set() for _ in range(n)]

while m:
    s, t = map(int, input().split())
    g[s].add(t)
    g[t].add(s)
    m -= 1


def find(s, t):
    global g
    visited = [0] * n

    def dfs(i):
        visited[i] = 1
        if i == t:
            return True
        for f in g[i]:
            if not visited[f]:
                if dfs(f):
                    return True
        return False

    return dfs(s)


q = int(input())
while q:
    s, t = map(int, input().split())
    print('yes' if find(s, t) else 'no')
    q -= 1

### FIXED CODE ###

n, m = map(int, input().split())
g = [set() for _ in range(n)]
group_ids = [0] * n

while m:
    s, t = map(int, input().split())
    g[s].add(t)
    g[t].add(s)
    m -= 1


def search(s, gid):
    global g, group_ids
    queue = set(g[s])
    group_ids[s] = gid

    while queue:
        i = queue.pop()
        if not group_ids[i]:
            group_ids[i] = gid
            queue.update(g[i])


gid = 1
for i in range(n):
    if group_ids[i]:
        continue
    search(i, gid)
    gid += 1

q = int(input())
while q:
    s, t = map(int, input().split())
    gs, gt = group_ids[s], group_ids[t]
    print('yes' if gs and gt and gs == gt else 'no')
    q -= 1
### BUGGY CODE ###

N = int(input())

A=[]
for i in input().split():
  A.append(int(i))

answer=1
for i in range(N):
  answer=answer*A[i]

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

### FIXED CODE ###

N = int(input())

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

answer=1
if 0 in A:
  print(0)
else:
  for i in range(N):
    answer = answer*A[i]
    if answer>10**18:
      print(-1)
      break
  else:
    print(answer)
### BUGGY CODE ###

import numpy as np
N,M=map(int,input().split(" "))
if M>N:
    A=list(sorted(map(int,input().split(" "))))
    L=np.array([A[s]-A[s+1] for s in range(M-1)])
    for s in range(N-1):
        L[np.argmin(L)]=0
    print(abs(sum(L)))
else:
    print(0)

### FIXED CODE ###

N,M=map(int,input().split(" "))
A=list(sorted(map(int,input().split(" "))))
L=[A[s]-A[s+1] for s in range(M-1)]
if M>N:
    print(abs(sum(sorted(L)[N-1:])))
else:
    print(0)
### BUGGY CODE ###

def main():
	N = int(input())
	s = []
	for _ in range(N):
		s.append("".join(sorted([a for a in input()])))
	pair = 0
	for i in range(N-1):
		for j in range(i+1, N):
			if s[i] == s[j]:
				pair += 1
	print(pair)
main()

### FIXED CODE ###

def main():
	N = int(input())
	s = {}
	pair = 0
	for _ in range(N):
		b = "".join(sorted([a for a in input()]))
		if b in s.keys():
			pair += s[b]
			s[b] += 1
		else:
			s[b] = 1
	print(pair)
main()
### BUGGY CODE ###

X = int(input())

p = 2
while p > 1:
    a = 1**2
    if a > X:
        p = 0
        a = a-1
        print(a)
    else:
        a += 1


### FIXED CODE ###

X = int(input())

max = 1
temp = 1
for i in range(2,11,1): #指数部分
    for j in range(1,33,1):#整数部分

        temp = j**i
        if temp > 1000:
            break
        elif X >= temp and temp > max:
            max = temp

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

N, Q = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for i, (ai, bi) in enumerate(ab):
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

from collections import deque
    
c = [0] * N
for j, (pj, xj) in enumerate(px):
    c[pj - 1] += xj
    
ans = [None] * N
q_0 = deque([(0, 0)])
while len(q_0) > 0:
    score, src = q_0.popleft()
    # print("#", score, src)
    score_tmp = score + c[src]
    ans[src] = score_tmp
    for dst in graph[src]:
        if ans[dst] == None:
            q_0.append((score_tmp, dst))

print(' '.join(map(str, ans)))

### FIXED CODE ###

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for ai, bi in ab:
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

parent = [None] * N
parent[0] = 0

score = [0] * N
for pi, xi in px:
    score[pi - 1] += xi

ans = [None] * N

from collections import deque

q = deque([(0, 0)])
while len(q) > 0:
    src, score_tmp = q.popleft()
    score_tmp += score[src]
    ans[src] = score_tmp
    for dst in graph[src]:
        if ans[dst] != None: continue
        q.append((dst, score_tmp))

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

K=int(input())
a=-1
b=0
for i in range(K):
    b+=7*10**i
    if(b%K==0):
        a=i+1
        break

print(a)

### FIXED CODE ###

K=int(input())
a=-1
b=0

for i in range(K):
    b=(10*b+7)%K
    if(b==0):
        a=i+1
        break

print(a)
### BUGGY CODE ###

from scipy.sparse import lil_matrix, csr_matrix
import numpy as np

s = input()
n = len(s)
a = lil_matrix((n,n))

for i in range(n):
    if s[i] == 'R':
        a[i+1, i] = 1
    else:
        a[i-1, i] = 1
a = a.tocsr()
a10 = a
for i in range(9):
    a10 = a.dot(a10)
a10_100 = a10
for _ in range(99):
    a10_100 = a10.dot(a10_100)

v = np.ones(n)
vv = a10_100.dot(v)
ans = [int(x) for x in vv]
print(*ans)

### FIXED CODE ###

s = input()
ss = []

tmp = ''
for i in range(len(s)-1):
    tmp += s[i]
    if s[i] == 'L' and s[i+1] == 'R':
        ss.append(tmp)
        tmp = ''
ss.append(tmp+'L')

ans = []
for sss in ss:
    l = len(sss)
    for i in range(l):
        if sss[i] == 'R' and sss[i+1] == 'L':
            ri = i
            break
    rn = ri//2 + 1 + (l-ri-1)//2
    ln = l-rn
    for i in range(l):
        if i == ri:
            ans.append(rn)
        elif i == (ri+1):
            ans.append(ln)
        else:
            ans.append(0)
print(*ans)
### BUGGY CODE ###

N, M = map(int, input().split())
L = []
R = []
ans = 0
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
for i in range(N):
    flg = 1
    for j in range(M):
        if not (L[j] <= i+1 <= R[j]):
            flg = 0
            break
    ans += flg
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
L = 0
R = N
ans = 0
for i in range(M):
    l, r = map(int, input().split())
    if l > L:
        L = l
    if r < R:
        R = r
for i in range(N):
    flg = 1
    if i+1 < L or i+1 > R:
            flg = 0
    ans += flg
print(ans)
### BUGGY CODE ###

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

l_list.sort()

count = 0
for i in range(n):
    start_j = i + 1
    a = l_list[i]
    for j in range(start_j, n):
        start_k = j + 1
        b = l_list[j]
        
        a_b = a + b
        for k in range(start_k, n):
            if (l_list[k] < a_b):
                count += 1
            else:
                break

print(count)

### FIXED CODE ###

import bisect

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

l_list.sort()

count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        a=l_list[i]
        b=l_list[j]
        
        count+=(bisect.bisect_left(l_list,a+b)-j-1)

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

n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
  a = l[i]
  for j in range(i+1, n-1):
    b = l[j]
    k_max = n-1
    k_min = j
    while k_min!=k_max:
      k = (k_max+k_min)//2+1
      c = l[k]
      if c < a + b:
        k_min = k
      else:
        k_max = k-1
    ans += k_min - j
print(ans)


### FIXED CODE ###

from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
A_1 = list(map(lambda x: x-1, A))
A_2 = list(map(lambda x: x+1, A))

ans = 0
for x in set(A):
    cnt = A.count(x) + A_1.count(x) + A_2.count(x)
    ans = max(cnt, ans)
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
c = [0]*100000
ans = 0
for a in A:
    c[a] += 1

for i in range(1, 99999):
    cnt = c[i-1] + c[i] +c[i+1]
    ans = max(ans, cnt)

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

n = int(input())

l = [0]*n
r = [0]*n

for i in range(n):
    l[i], r[i] = list(map(int, input().split()))

N = 10**9+1
dp = [[0 for i in range(N)] for j in range(n)]

# 一番上のブロックを動かした時のコスト
for i in range(N):
    if r[0] < i: d = i-r[0]
    elif i < l[0]: d = l[0]-i
    else: d = 0
    dp[0][i] = d

# 順番にコストを計算していく
for ni in range(1,n):
    for i in range(N):
        if r[ni] < i: d = i-r[ni]
        elif i < l[ni]: d = l[ni]-i
        else: d = 0
        dp[ni][i] = d + dp[ni-1][i]
print(min(dp[n-1]))

### FIXED CODE ###

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
 
INF = 10**18
 
from heapq import heappush, heappop
 
l0, r0 = P[0]
 
L = [-l0+1]
R = [l0-1]
s = t = 0
 
res = 0
for i in range(N-1):
    l0, r0 = P[i]
    l1, r1 = P[i+1]
    s += (r1 - l1); t += (r0 - l0)
    if -s-L[0] <= l1-1 <= t+R[0]:
        heappush(L, -l1+1-s)
        heappush(R, l1-1-t)
    elif l1-1 < -s-L[0]:
        heappush(L, -l1+1-s)
        heappush(L, -l1+1-s)
        p = -heappop(L)-s
        heappush(R, p-t)
        res += (p - (l1-1))
    elif t+R[0] < l1-1:
        heappush(R, l1-1-t)
        heappush(R, l1-1-t)
        p = heappop(R) + t
        heappush(L, -p-s)
        res += (l1-1 - p)
print(res)
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
ans = ans % (10**9+7)
print(ans)

### FIXED CODE ###

import math
n = int(input())
print(math.factorial(n) % (10**9+7))
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**6)

N, Q = map(int, input().split())

def update(v, p):
    for next in tree[v]:
        if next == p:
            continue
        counter[next] += counter[v]
        update(next, v)

tree = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x
update(0, -1)
print(" ".join(map(str, counter)))


### FIXED CODE ###

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

N, Q = map(int, input().split())

def update(v, p):
    for next in tree[v]:
        if next == p:
            continue
        counter[next] += counter[v]
        update(next, v)

tree = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x
update(0, -1)
print(" ".join(map(str, counter)))
### BUGGY CODE ###

s=int(input())
d=dict(zip(list(range(2019)),[0]*2019))
i=1
while i//10<=s:
  d[s%i%2019]+=1
  i*=10
ans=0
for _,i in d.items():
  ans+=i*(i-1)//2
print(ans)

### FIXED CODE ###

s=input()
n=len(s)
d=[0]*2019
d[0]=1
j=1
ans=0
now=0
for i in s[::-1]:
  now=(now+int(i)*j)%2019
  ans+=d[now]
  d[now]+=1
  j*=10
  j%=2019
print(ans)
### BUGGY CODE ###

import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

#maxvalue
k = int(arr_data[0][0])

#sumvalue
s = int(arr_data[0][1])


#print(k,s)

cnt = 0
    
x = 0
while x <= k:

    if x > s:
        
        break
        
    y = 0
    while y <= k:
        
        if y > s or x + y > s :
        
            break
            
#        print(x,y,s-x-y)    
        if s-x-y<=k:    
            
            cnt+=1
            
        y += 1
    
    x += 1

print(cnt)
    
    


### FIXED CODE ###

def getinputdata():

    array_result = []
    
    data = input()
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#maxvalue
k = int(arr_data[0][0])

#sumvalue
s = int(arr_data[0][1])

cnt = 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:
            
            cnt += 1
            
print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

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

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

    def union(self, x, y):

        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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


N, M = map(int, input().split()) 
union_find = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    union_find.union(A, B)

answer = 0
for i in range(N):
    answer = max(answer, union_find.size(i))

print(answer)


### FIXED CODE ###

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

root = [-1]*n
def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, -root[i])

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

n = int(input())
a = list(map(int, input().split()))
z = sum(a)
ln = []
for i in range(1, n):
    ln.append(abs(z - 2 * sum(a[0: i])))
print(min(ln))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
z = sum(a)
ln = []
x = 0
for i in range(n - 1):
    x += a[i]
    ln.append(abs(z - 2 * x))
print(min(ln))
### BUGGY CODE ###

N, W= map(int, input().split())
list1 = [ tuple(map(int, input().split())) for _ in range(N)]
dp = [ [0 for i in range(W+1)] for i in range(N)]

for i in range(N):
    for w in range(1,W+1):
        if list1[i][0] <= w:
            dp[i][w] =max(list1[i][1]+dp[i-1][w-list1[i][0]], dp[i-1][w])
        else:
            dp[i][w] =dp[i-1][w]
print(dp[-1][-1])

### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

DP = np.zeros((N+1,W+1), dtype=np.int64)

for i in range(N):
    DP [i+1] = np.array(DP[i])
    DP[i+1][w[i]:] = np.maximum(DP[i][:-w[i]]+ v[i], DP[i][w[i]:])

#print(DP)
print(DP[-1][-1])
### BUGGY CODE ###

N, K = list(map(int, input().split()))
H = []
for i in range(N):
        h = int(input())
        H.append(h)

H.sort()
ans = []

for i in range(N-K+1):
        dif = max(H[i:i+K]) - min(H[i:i+K])
        ans.append(dif)
        
print(min(ans))

### FIXED CODE ###

n,k=map(int,input().split())
H=[]
for i in range(n):
    H.append(int(input()))
 
H.sort()
 
#print(H)
 
ans=H[n-1]-H[0]
 
for i in range(n-k+1):
    #print(H[i+k-1]-H[i])
    ans=min(ans,H[i+k-1]-H[i])
 
print(ans)