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

A = list(map(int, input().split()))
A.sort()
ans = 0
while A[0] not in A[1:]:
  A[0] += 2
  ans += 1

if A[0] == A[1]:
  while A[1] != A[2]:
    A[1] += 1
    ans += 1
else:
  A.sort()
  while A[0] < max(A):
    A[0] += 2
    ans += 1
  A.sort()
  if A[0] == A[1]:
    while A[1] != A[2]:
      A[1] += 1
      ans += 1
print(ans)

### FIXED CODE ###

a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)
### BUGGY CODE ###

s = input()
cnt = 0
for l in range(len(s)):
    r = l + 1
    while r < len(s) and int(s[l:r]) % 2019 != 0:
        r += 1
    if int(s[l:r]) % 2019 == 0:
        cnt += 1
print(cnt)

### FIXED CODE ###

M = 2019
s = input()
tot, ten, ans = 0, 1, 0
cnt = [0] * M
for si in s[::-1]:
    cnt[tot] += 1
    tot += int(si) * ten
    tot %= M
    ans += cnt[tot]
    ten *= 10
    ten %= M
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * pr[i0-1]

    for i1 in range(1, n + 1):
        for i2 in range(1, n + 1):
            dp[i1][i2] = dp[i1-1][i2] * pr[i1-1] + dp[i1-1][i2-1] * p[i1-1]
    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    # pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * (1 - p[i0-1])

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

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

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

mod=10**9+7
asum=0
for i in range(n-1):
    for j in range(i+1,n):
        asum+=(a[i]^a[j])%mod

asum=asum%mod
print(asum)


### FIXED CODE ###

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

#n=10
#a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

mod=10**9+7
asum=0
for i in range(60):
    zcnt=0
    for ii in range(n):
        asht=a[ii]>>i
        if asht&1==0:
            zcnt+=1
    tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod)
    asum+=(tmp)%mod
               
asum=asum%mod
print(asum)
### BUGGY CODE ###

N = int(input())
s = list(input() for _ in range(N))

l = list(map(sorted,s))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if(l[i] == l[j]):
            cnt += 1
print(cnt)

### FIXED CODE ###

d,a = {},0
for i in range(int(input())):
    k = ''.join(sorted(input()))
    d[k] = d.get(k,-1)+1
    a+= d[k]
print(a)
### BUGGY CODE ###

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

kyotu_s = {k for k in range(1,n+1)}

for i in range(m):
    l,r = map(int,input().split())
    s = {j for j in range(l,r+1)}
    kyotu_s = s & kyotu_s
    if len(kyotu_s)==0:
        break

print(len(kyotu_s))

### FIXED CODE ###

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

min_i = 1
max_i = n

for i in range(m):
    l,r = map(int,input().split())
    min_i = max(min_i,l)
    max_i = min(max_i,r)

if max_i-min_i>=0:
    print(max_i-min_i+1)
else:
    print(0)
### BUGGY CODE ###

# from itertools import combinations
n=int(input())
a=[int(i) for i in input().split()]
pro=0
for i in range(n-1):
    for j in range(i+1,n):
        pro+=a[i]*a[j]
print(pro%(10**9+7))

### FIXED CODE ###

# from itertools import combinations
def Sum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) // 2
n=int(input())
a=[int(i) for i in input().split()]
print(Sum(a,n)%(10**9+7))
### BUGGY CODE ###

# seishin.py
from collections import deque
N = int(input())
*P, = map(int, input().split())
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
for i, p in enumerate(P):
    G[p].append(i+1)
Q = [None]*(N+1)
for i in range(N, -1, -1):

    # 子ノードのdequeを集める
    R = None
    for j in G[i]:
        S = Q[j]
        if not R:
            R = S
            continue

        # |R| > |S|
        if len(R) < len(S):
            R, S = S, R

        # dequeの小さい方から大きい方へマージする処理
        for s, r in zip(S, R):
            a0, a1, a2, c0 = s
            b0, b1, b2, c1 = r
            r[0] = a0*b0 % MOD
            r[1] = (a0*b1 + a1*b0) % MOD
            r[2] = (a0*b2 + a1*b1 + a2*b0 + a1*b2 + a2*b2 + a2*b1) % MOD
            r[3] = c0+c1
    if R:
        # a0 <- a2
        for e in R:
            e[0] += e[2]
            e[2] = 0
        R.appendleft([1, 1, 0, 1])
        Q[i] = R
    else:
        Q[i] = deque([[1, 1, 0, 1]])
ans = 0
for a0, a1, a2, c in Q[0]:
    ans += pow(2, N+1-c, MOD) * a1 % MOD
print(ans % MOD)

### FIXED CODE ###

# seishin.py
from collections import deque
N = int(input())
*P, = map(int, input().split())
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
U = [0]*(N+1)
C = [0]*(N+1)
for i, p in enumerate(P):
    G[p].append(i+1)
    U[i+1] = u = U[p]+1
    C[u] += 1
Q = [None]*(N+1)
PP = {}
def pp(k):
    if k not in PP:
        PP[k] = p = pow(2, k, MOD)
        return p
    return PP[k]
L = [0]*(N+1)

ept = []
sz = L.__getitem__
for i in range(N, -1, -1):
    g = G[i]
    if not g:
        continue

    # 子ノードのdequeを集める
    g.sort(key=sz, reverse=1)
    k = len(g)
    e = [pp(k) - k, k, 0]

    g0 = g[0]
    L[i] = L[g0] + 1
    if L[g0] == 0:
        Q[i] = deque([e])
        continue
    Q[i] = R = Q[g0]
    if k > 1:
        # a0 <- a2
        for s, r in zip(Q[g[1]] or ept, R):
            r[0] += r[2]; r[2] = 0

        for j in g[1:]:
            S = Q[j]
            if not S:
                break

            # dequeの小さい方から大きい方へマージする処理
            for (a0, a1, a2), r in zip(S, R):
                b0, b1, b2 = r; a0 += a2
                r[0] = a0*b0 % MOD
                r[1] = (a0*b1 + a1*b0) % MOD
                r[2] = ((a0+a1)*b2 + a1*b1) % MOD
    R.appendleft(e)
print((pp(N) + sum(pp(N+1-c) * a1 % MOD for (a0, a1, a2), c in zip(Q[0], C[1:]))) % MOD)
### BUGGY CODE ###

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

Z = [N]*N

while K > 0 and A != Z:
    K = K - 1
    B = [0]*(N+1)
    for i in range(N):
        B[max(0,i-A[i])]+=1
        B[min(N-1,i+A[i])+1]-=1
    for i in range(1,N):
        B[i]+=B[i-1]

    A = B[0:N]

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

### FIXED CODE ###

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

    Z = [N]*N

    while K > 0 and A != Z:
        K-=1
        B = [int(0)]*(N+1)
        for i in range(N):
            B[max(int(0),i-A[i])]+=1
            B[min(N-1,i+A[i])+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]

        A = B[0:N]

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

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

#C
L, R = list(map(int, input().split()))
if (R - L) == 2019:
    result = 0
else:
    result = 2018
    for i in range(L,R+1):
        for s in range(i+1,R+1):
            x = (i*s)%2019
            if x == 0:
                result = 0
                break
            elif result > x:
                result = x
print(result)

### FIXED CODE ###

#C
import sys
L, R = list(map(int, input().split()))
if (R - L) == 2019:
    result = 0
else:
    result = 2018
    for i in range(L,R+1):
        for s in range(i+1,R+1):
            x = (i*s)%2019
            if x == 0:
                result = 0
                print(0)
                sys.exit()
            elif result > x:
                result = x
print(result)
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline

n = int(input())
a = [deque([x for x in list(map(int, input().split()))]) for _ in range(n)]
nokori_games = n * (n - 1) / 2 
day = 1
r5000 = range(5000)
player_in_this_game = set()
for _ in r5000:
  rn = range(n)
  for m in rn: #選手ごとに判定
    #整合性のある対戦組み合わせがあれば配列から消す
    #全員の判定が終わって試合が残っていたら1日増やす
    la = len(a[m])      
    if la: #選手に試合予定が残っている
      teki = a[m][0] #対戦相手
      jibun = m + 1 #自分
      if m in player_in_this_game or teki - 1 in player_in_this_game:
        #自分または相手に既に試合が組まれている
        pass
      elif a[teki - 1][0] == jibun: #対戦相手の予定も自分でかつ相手がこのターンで試合中ではない
        a[m].popleft() #自分の予定を消す
        a[teki - 1].popleft() #相手の予定を消す
        player_in_this_game.add(m) #自分を試合中にする
        player_in_this_game.add(teki - 1) #相手を試合中にする
        nokori_games -= 1 #残り試合予定を1つ減らす

  if nokori_games: #残り試合があるのに
    if not len(player_in_this_game): #今回対戦が組まれなければ残りの予定が不整合なのでエラー
      print(-1)
      sys.exit()
  else: #誰も残り試合予定がなければ終了
    print(day)
    sys.exit()
  day += 1
  player_in_this_game.clear()


### FIXED CODE ###

import sys
import time
from collections import deque

start = time.time()

input = sys.stdin.readline

n = int(input())
a = [deque([x for x in list(map(int, input().split()))]) for _ in range(n)]
nokori_games = n * (n - 1) / 2 
day = 1
r5000 = range(5000)
player_in_this_game = set()
rn = range(n)
for _ in r5000:
  for m in rn: #選手ごとに判定
    #整合性のある対戦組み合わせがあれば配列から消す
    #全員の判定が終わって試合が残っていたら1日増やす
    if m in player_in_this_game:
      #自分が既に試合が組まれている
      continue

    la = len(a[m])      
    if la: #選手に試合予定が残っている
      teki = a[m][0] #対戦相手
      jibun = m + 1 #自分
      teki_idx = teki - 1
      if teki_idx in player_in_this_game:
        #相手が既に試合に組まれている
        continue

      if a[teki_idx][0] == jibun: #対戦相手の予定も自分でかつ相手がこのターンで試合中ではない
        a[m].popleft() #自分の予定を消す
        a[teki_idx].popleft() #相手の予定を消す
        player_in_this_game.add(m) #自分を試合中にする
        player_in_this_game.add(teki_idx) #相手を試合中にする
        nokori_games -= 1 #残り試合予定を1つ減らす

  if nokori_games: #残り試合があるのに
    if not len(player_in_this_game): #今回対戦が組まれなければ残りの予定が不整合なのでエラー
      print(-1)
      sys.exit()
  else: #誰も残り試合予定がなければ終了
    print(day)
    sys.exit()
  day += 1
  player_in_this_game.clear()
  elapsed_time = time.time() - start
  if elapsed_time > 1:
    print(n*(n-1)//2)
    exit()
### BUGGY CODE ###

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

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

if N == 2:
    print(max(l))
    exit()

p = l.pop(0)
ans = 1
for j in range(1,N+1):
    element = gcd(l[0], l[1])
    for i in range(2,N-1):
        element = gcd(element,l[i])
    ans = max(ans, element)
    l.append(p)
    p = l.pop(0)
print(ans)


### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.extend([i,int(n/i)])
    return divisors

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

p = make_divisors(l[0])
p.extend(make_divisors(l[1]))

p.sort(reverse=True)
for i in p:
    ans = 1
    flag = 0
    for j in l:
        if j%i != 0:
            if flag == 1:
                ans = 0
                break
            flag = 1
    if ans:
        print(i)
        exit()
### BUGGY CODE ###

n,m=map(int,input().split())
h={}
st=set([i for i in range(1,n+1)])
kos=set()
for _ in range(m):
    oy,ko=map(int,input().split())
    h.setdefault(oy,[])
    h[oy]+=[ko]
    kos.add(ko)
st=st-kos
dep=0
while 1:
    nst=set()
    for s in st:
        if s not in h:continue
        for ko in h[s]:
            nst.add(ko)
    if len(nst)==0:
        break
    st=nst
    dep+=1
print(dep)

### FIXED CODE ###

import sys

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


def get_kyori(i):
    if kos[i] == []:
        kyori[i] = 0
        return 0
    if kyori[i] > -1:
        return kyori[i]
    re = 0
    for ko in kos[i]:
        new = get_kyori(ko) + 1
        if re < new:
            re = new
    kyori[i] = re
    return re


n, m = map(int, input().split())
kos = [[] for _ in range(n + 1)]
kyori = [-1] * (n + 1)
for _ in range(m):
    oya, ko = map(int, input().split())
    kos[oya] += [ko]

for i in range(1, n + 1):
    if kyori[i] == -1:
        kyori[i] = get_kyori(i)

print(max(kyori[1:]))
### BUGGY CODE ###

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

tmp = [0] * n

def add_one(x):
    return x + 1

for i in range(m):
    l = lr[i][0] - 1
    r = lr[i][1] - 1
    tmp[l: r+1] = list(map(add_one, tmp[l: r + 1]))

counter = 0
for j in range(n):
    if tmp[j] == m:
        counter += 1

print(counter)


### FIXED CODE ###

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

l_list = [_lr[0] for _lr in lr]
r_list = [_lr[1] for _lr in lr]

a = min(r_list)
b = max(l_list)
print(max(a - b + 1, 0))
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()] 
count = 0
for i in range(100000):
    if a.count(i) > 0:
        check = i - a.count(i)
        if check < 0:
            count += abs(check)
        elif check > 0:
            count += i - check
for i in a:
    if i > 100000:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)
### BUGGY CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
         p[i] = (p[i]+1)/2
ans = 0
for i in range(n-(k-1)):
         if ans < sum(p[i:(i+k)]):
                  ans  = sum(p[i:(i+k)])
print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
ps = [0]
for i in range(len(p)):
         ps.append(((p[i] + 1)/2)+ps[i])
ans = 0
for i in range(n+1-k):
         if ans < (ps[i+k] - ps[i]):
                  ans = (ps[i+k] - ps[i])
print(ans)
### BUGGY CODE ###

n,x,y=map(int,input().split())
ans=[0 for _ in range(n+1)]
d=[]
for i in range(n+1):
    d.append([abs(i-j) for j in range(n+1)])
#    print(d[i])
d[x][y]=1
d[y][x]=1

for i in range(1,n+1):
    for j in range(i+1,n+1):
        d[i][j]=min(d[i][j],d[i][x]+d[x][y]+d[y][j],d[i][y]+d[y][x]+d[x][j])
        ans[d[i][j]]+=1

for i in range(1,n):
    print(ans[i])

### FIXED CODE ###

n,x,y=map(int,input().split())
ans=[0 for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans[min(abs(j-i),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(j-x))]+=1

for i in range(1,n):
    print(ans[i])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans *=i


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

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
for i in A:
    ans *=i
    if i==0:
        print(0)
        exit()
    elif ans > pow(10,18):
        print(-1)
        exit()
    else:
        continue


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

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

dp = [0]*N
dp[1] = abs(l[0]-l[1])

for i in range(2,N):
  num = int(10e10)
  for j in range(1,K+1):
    if i-j < 0:
      dp[i] = num
      break
    else:
      if l[i] > l[i-j]:
        tmp = dp[i-j]+l[i]-l[i-j]
        num = min(tmp,num)
      else:
        tmp = dp[i-j]+l[i-j]-l[i]
        num = min(tmp,num)    
  dp[i] = num

print(dp[N-1])

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
l = np.array(IL())

dp = np.zeros(N,dtype=int)
dp[0] = 0

for i in range(1,N):
    if i-K < 0:
        dp[i] = np.min(dp[:i]+np.abs(l[i]-l[:i]))
    elif i-K >= 0:
        dp[i] = np.min(dp[i-K:i]+np.abs(l[i]-l[i-K:i]))

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

n = int(input())
l = sorted(list(map(int, input().split())))
s = 0
for i in range(0,n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    for k in range(n-1,j,-1):
      c = l[k]
      if(a+b>c):
        s += k-j
        break
print(s)

### FIXED CODE ###

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

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

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {root: self.members(root) for root in self.roots()}

    def __str__(self):
        return '\n'.join(f'{root}: {self.members(root)}' for root in self.roots())


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

uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)

print(max(len(members) for members in uf.all_group_members().values()))


### FIXED CODE ###

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

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {root: self.members(root) for root in self.roots()}

    def __str__(self):
        return '\n'.join(f'{root}: {self.members(root)}' for root in self.roots())


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

uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)

print(max(uf.size(i) for i in range(N)))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a_new = sorted(a)
answer = []
for j in a_new:
  answer.append(a.index(j)+1)
print(*answer)

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split()))
answer = np.argsort(a) +1
print(*answer)
### BUGGY CODE ###

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

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

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

print(ans)


### FIXED CODE ###

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

import math
K = int(input())
ans_list = []
ans = 0
for i in range(1, K + 1):
    for j in range(1,K+1):
        ans_list.append(math.gcd(i,j))
for i in range(1,K+1):
    for j in range(0,len(ans_list)):
        ans += math.gcd(i,ans_list[j])

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

N,M=map(int,input().split())
m=[]
for i in range(M):
    m.append(list(input().split()))
cnt_ac=0
cnt_wa=0
num=1
while num <=N:
    for i in range(M):
        if int(m[i][0])==num:
            if m[i][1]=="AC":
                cnt_ac+=1
                num +=1
            else:
                cnt_wa+=1
        elif i <M-1:
            continue
        else:
            num +=1
print(cnt_ac,cnt_wa)

### FIXED CODE ###

N, M = map(int, input().split())
ac = [0] * (N+1)  
wa = [0] * (N+1)
ans= [0, 0]

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if ac[p] == 1:
        continue
    elif s == "WA":
        wa[p] += 1
    else:
        ans[0] += 1
        ans[1] += wa[p]
        ac[p] = 1
print(*ans)
### BUGGY CODE ###

N = int(input())
S = input()

count=[]
for i in range(len(S)+1):
    count_temp=0
    left = S[:i]
    right = S[i:]
    for _ in left:
        count_temp += 1 if _!='.' else 0
    for _ in right:
        count_temp += 1 if _!='#' else 0
        
    count.append(count_temp)

print(min(count)) 

### FIXED CODE ###

N = int(input())
S = input()

count = [0]*(len(S)+1)
count[0] = S.count('.')
for i in range(1, len(S)+1):
    count[i] = count[i-1] + (1 if S[i-1]=='#' else 0) - (1 if S[i-1]=='.' else 0)

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

s = input()
q = int(input())
ans_q = [s]
ans = []
one_count = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                ans_q.insert(0,i[2])
            else:
                ans_q.insert(len(ans_q),i[2])
        else:
            if int(i[1]) == 1:
                ans_q.insert(len(ans_q),i[2])
            else:
                ans_q.insert(0,i[2])
if one_count%2==0:
    print(''.join(ans_q))
else:
    print(''.join(ans_q)[::-1])


### FIXED CODE ###


from collections import deque
s = input()
q = int(input())
s = deque(s)
ans = []
ans_s = ''
one_count = 0
key = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                s.appendleft(i[2])
            else:
                s.append(i[2])
        else:
            if int(i[1]) == 1:
                s.append(i[2])
            else:
                s.appendleft(i[2])

if one_count%2==0:
    print(''.join(s))
else:
    print(''.join(s)[::-1])