Harryxun/stf_run huggingface dataset:
import numpy as np

H,W,M=map(int,input().split())
hw = np.zeros([H,W],dtype=int)
for i in range(M):
  h,w=map(int,input().split())
  hw[h-1,w-1] = 1

sum1 = hw.sum(1)
sum2 = hw.sum(0)

sum1 = sorted(enumerate(sum1),key=lambda x:x[1],reverse=True)
sum2 = sorted(enumerate(sum2),key=lambda x:x[1],reverse=True)

ans=0
for idx1,val1 in sum1[:min(3,len(sum1))+1]:
  for idx2,val2 in sum2:
    tmp = val1+val2-hw[idx1,idx2]
    ans = max(ans,tmp)
    
print(ans)

### FIXED CODE ###

from collections import defaultdict

H,W,M=map(int,input().split())
hw = defaultdict(int)
sum1=[0]*H
sum2=[0]*W
for i in range(M):
  h,w=map(int,input().split())
  hw[(h-1,w-1)] += 1
  sum1[h-1] += 1
  sum2[w-1] += 1

sum1 = sorted(enumerate(sum1),key=lambda x:x[1],reverse=True)
sum2 = sorted(enumerate(sum2),key=lambda x:x[1],reverse=True)

max1,max2=set([sum1[0][0]]),set([sum2[0][0]])
for i in range(1,H):
  if sum1[i][1]<sum1[0][1]:
    break
  else:
    max1.add(sum1[i][0])
    
for i in range(1,W):
  if sum2[i][1]<sum2[0][1]:
    break
  else:
    max2.add(sum2[i][0])

ans = sum1[0][1]+sum2[0][1]
count=0
for k in hw.keys():
  h,w=k
  if h in max1 and w in max2:
    count += 1
    
if count < len(max1)*len(max2):
  print(ans)
else:
  print(ans-1)
n = int(input())
p = [int(input()) for _ in range(n)]
ex = l.pop(l.index(max(l)))
print(int(ex / 1) + sum(l))

### FIXED CODE ###

n = int(input())
p = [int(input()) for _ in range(n)]
ex = p.pop(p.index(max(p)))
print(int(ex / 2) + sum(p))
s = input()
t = input()

strings = s*len(t)

for str in t:
    if str not in s:
        print("-1")
        break
    strings.strip(str)

n = strings.index(t)
num = len(s)*(n-1)+(s.index(t[-1]))+1

print(num)

### FIXED CODE ###

s = input()
t = input()

idx = -1
count = 0

if set(t) <= set(s):
    for i in t:
        idx = s.find(i, idx+1)
        if idx == -1:
            idx = s.find(i)
            count += 1
    pdc = count * len(s)
    total_idx = (idx + 1) + pdc 
    print(total_idx)
else:
    print(-1)
k = input()
l = list(map(int,input()))
c = 0
for i in range(len(l)-1):
  x = l[i+1]-lis[i]
  if x<0:
    l[i+1]+=abs(x)
  	c+=abs(x)
print(c)

### FIXED CODE ###

try:
    k = int(input())
    l = list(map(int,input().split(' ')))
    c = 0
    for i in range(len(l)-1):
      x = l[i+1]-l[i]
      if x<0:
        l[i+1]+=abs(x)
        c+=abs(x)
    print(c)
except:
    pass
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)
n = int(input())
A = input().split()
m = [int(a) for a in A]
ans = 0
for i in range(n):
    B = m[:]
    B.pop(i)
    gcm = gcd(B[0], B[1])
    cand = gcm
    for j in range(len(B)-2):
        cand = gcd(B[j+2], gcm)
    if cand > ans:
        ans = cand
print(ans)


### FIXED CODE ###

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

N=int(input())
A=[int(i) for i in input().split()]
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])
Z=[gcd(X[i],Y[i]) for i in range(N)]
print(max(Z))
a,b=map(int, input().split())
if a==b:
  print(a*2)
else:
  print(max([a,b])*2-1

### FIXED CODE ###

a,b=map(int, input().split())
if a==b:
  print(a*2)
else:
  print(max([a,b])*2-1)
def solve(n, x, a):
	costs = []
	cost_min = 0
	for k in range(n):
		if k == 0:
			costs = a.copy()
		else:
			for i in range(n):
				costs[i] = min(costs[i], a[(i-k)%n])
		cost_k = sum(costs) + k*x
		if k == 0:
			cost_min = cost_k
		else:
			cost_min = min(cost_min, cost_k)		
		if cost_min < (k+1) *x:
			break

	return cost_min
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(solve(n,x,a))


### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if a*b*c %2==0:
  print(0)
else:
  print(min(a*b, a*c, b*c))
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]

sum_before = sum(T)
for i in range(M):
    sum_after = sum_before - T[PX[i][0]] + PX[i][1]
    print(sum_after)

### FIXED CODE ###

N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]

sum_before = sum(T)
for i in range(M):
    sum_after = sum_before - T[PX[i][0]-1] + PX[i][1]
    print(sum_after)
import math
def heikatu(A,B):
    if A % abs(B) ==0:
        return (A//abs(B),B//abs(B))
    if abs(B) % A == 0:
        return (1,B//A)
    
    c = 2
    while c <=math.sqrt(max(A,abs(B))):
        while A % c ==0 and B% c ==0:
            A //=c
            B//=c
        c+=1

    return (A,B)


def pow_r(x, n,mod=10**9+7):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r((x ** 2)%1000000007 , n // 2) % mod
    else:  # standard case ② n is odd
        return (x * pow_r((x ** 2)%1000000007, (n - 1) // 2) % mod) % mod



def resolve():
    N = int(input())

    kp = dict()
    km = dict()
    zero = [0,0]
    zerozero = 0
    for i in range(N):
        A,B = map(int,input().split())
        if A <0:
            A *= -1
            B *= -1
        if A == 0 and B == 0:
            zerozero+=1
            continue

        if A == 0:
            zero[0]+=1
            continue
        if B == 0:
            zero[1]+=1
            continue

        xx = heikatu(A,B)



        if B < 0:
            if not xx in km:
                km[xx]=0
            km[xx]+=1
        else:
            if not xx in kp:
                kp[xx]=0
            kp[xx]+=1

    tx = []
    if zero != [0,0]:
        tx.append(zero)

    for key in kp:
        A,B = key
        cou = kp[key]    
        if (B,-A) in km:
            tx.append([cou,km[(B,-A)]])
            km.pop((B,-A))
        else:
            tx.append([cou,0])
    for key in km:
        tx.append([0,km[key]])

    ans = 1
    mod = 1000000007
    for a,b in tx:
        xxx = 0
        if a != 0:
            xxx=(xxx+pow_r(2,a)) %mod
        if b != 0:
            xxx=(xxx+pow_r(2,a)) %mod
        if a !=0 and b!=0:
            xxx-=1
        ans = (ans*xxx) % mod

    ans = (ans+mod-1+zerozero) % mod 

    print(ans)       


        







resolve()

### FIXED CODE ###

def resolve():
    K= int(input())
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K]+"...")



if __name__ == "__main__":
    resolve()
m = map(int,raw_input().split())
for i in range(len(m)):
 if(m[i-1]==0):
  break
 print"Case %s* %s",%(i,m[i-1])

### FIXED CODE ###

i=0

while True:
    a = int(input())
    if(a==0):
      break
    i = i+1
    print "Case %d: %d" %  (i,a)
# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:
    if other%2==1:
        print(np.array(a))
        # if (N-other)//2<=mod40:
        #     print("Yes")
        #     exit()
        # else:
        #     print("No")
        #     exit()
    else:
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()

### FIXED CODE ###

# AtCoder Regular Contest 080
# C - 4-adjacent

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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:  # N>3 ,Nが奇数の時
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:   # N>3 ,Nが偶数の時
    if other%2==1:  #かつ、要素が偶数である数が奇数の時  
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
X = int(input())
for A in range(0, X):
  
  A5 = A**5
  B5 = X - A5
  B = B5 ** (1/5) 
  if float.is_integer(B):
    print(A, int(B*-1))
    break
  

### FIXED CODE ###

def calcurate(x):
  for a in range(1000):
    a5 = a**5
    for b in range(-1000, 1000):
      b5 = b**5
      if a5 - b5 == X:
        return a, b
      
if __name__ == "__main__":
  X = int(input())
  A, B = calcurate(X)
  print(A, B)
# encoding: utf-8

import sys

def solve(a, b, h):
    return (a + b) * h / 2

def main():
    a = sys.stdin.readline().rstrip()
    int(a)
    b = sys.stdin.readline().rstrip()
    int(b)
    h = sys.stdin.readline().rstrip()
    int(h)
    ans = solve(a, b, h)
    print "{0}".format(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def solve(a, b, h):
    return (a + b) * h / 2


a = raw_input()
a = int(a)
b = raw_input()
b = int(b)
h = raw_input()
h = int(h)
ans = solve(a, b, h)
print ans
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s  = S()
if s[1] == 'B':
    print('ARC')
else:
    print('ARC')



### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s  = S()
if s[1] == 'B':
    print('ARC')
else:
    print('ABC')
n , m = map(int , input().split())
A = list(map(int , input().split()))
B_C = []
b_sum = 0
for i in range(m):
    b , c = map(int , input().split())
    B_C.append([b , c])
    b_sum += b
A.sort()
B_C.sort(key = lambda x : -x[1])
k = 0
for b , c in B_C:
    for i in range(k , k + b):
        if i == len(A):
            break
        A[i] = max(A[i] , c)
        k += b
print(sum(A))

### FIXED CODE ###

n, m = map(int, input().split())
A = sorted(list(map(int, input().split())))

bc = []
for i in range(m):
    b, c = map(int, input().split())
    bc.append([b,c])

from operator import itemgetter
bc.sort(key=itemgetter(1), reverse = True)
k = 0
c = bc[0][1]
b = bc[0][0]
bn = 0
while A[k] < c:
    A[k]=c
    k+=1
    if k == len(A):
        break
    b-=1
    if b  == 0:
        bn += 1
        if bn == len(bc):
            break
        b = bc[bn][0]
        c = bc[bn][1]
print(sum(A))
N = int(input())
S = list(input())

ans = 0
T1 = S.copy()
f = False
for i in range(N):
    s = T1[i]
    if s == ".":
        continue
    else:
        if i < N - 1 and T1[i+1] == ".":
            if not f and i + 1 < N - 1 and T1[i+2] == ".":
                ans += 1
            else:
                f = True
                T1[i+1] = "#"
                ans += 1
        else:
            f = True
ans2 = 0

for i in range(N):
    s = S[i]
    if s == ".":
        continue
    else:
        ans2 += 1

ans3 = 0

for i in range(N):
    s = S[i]
    if s == ".":
        ans3 += 1
    else:
        continue

while S[-1] != ".":
    S.pop()
N = len(S)
ans4 = 0
for i in range(N):
    s = S[i]
    if s == ".":
        continue
    else:
        ans4 += 1

# print(ans, ans2, ans3)
print(min(ans2, ans, ans3, ans4))



### FIXED CODE ###

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

acc = [0]
acc2 = [0]
for s in S:
    if s == ".":
        acc.append(acc[-1] + 1)
        acc2.append(acc2[-1])
    else:
        acc.append(acc[-1])
        acc2.append(acc2[-1] + 1)
acc.pop(0)

ans = float("inf")

for i in range(N):
    s = S[i]
    tmp = acc[-1] - acc[i]
    tmp2 = acc2[i]
    ans = min(ans , tmp + tmp2)
print(ans)
from itertools import groupby
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    K = int(input())
    grouped = [len(tuple(s)) for _, s in groupby(S)]

    if len(grouped) > 1 and S[0] == S[-1]:
        _sum = 0
        top = grouped[0]
        tail = grouped[-1]
        for group in grouped[1:-1]:
            _sum += group[1] // 2
        dif = (top // 2) + (tail // 2) + (top + tail) * (K - 1) // 2
        print(_sum * K + dif)
    else:
        _sum = 0
        for group in grouped:
            _sum += group[1] // 2
        print(_sum * K)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from itertools import groupby


def main():

    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    ans = 0

    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            ans = a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0] + a[-1]) // 2 * (K - 1)
            ans += sum(n // 2 for n in a[1:-1]) * K
    else:
        ans = sum(n // 2 for n in a) * K
    print(ans)


if __name__ == "__main__":
    main()
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "L" + shortest_path(S + np.array([-1, 0]), T + np.array([0, 1])) + "D"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

### FIXED CODE ###

import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "U" + shortest_path(T + np.array([0, 1]), S + np.array([-1, 0])) + "R"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)
be=input()
af=input()
ans=0
for i in range (2):
  	if be[i]==af[i]:
    	ans+=1
print(ans)


### FIXED CODE ###

be=input()
af=input()
ans=0
for i in range (3):
    if be[i]==af[i]:
        ans+=1
print(ans)
import sys
input = sys.stdin.readline

n = int(input())
a = set()

for i in range(n):
    a.add(input())

print(len(a))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

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

flag = 1
while True:
    if flag > 0:
        c -= b
        if c <= 0:
            break
    else:
        a -= d
        if a <= 0:
            break
    flag = flag * (-1)

if flag > 0:
    print("Yes")
else:
    print("No")
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = a*cnt_2 + S*cnt_1
else:
    pay = N * S
print(pay)

### FIXED CODE ###

#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = D*cnt_2 + S*cnt_1
else:
    pay = N * S
print(pay)
x = list(map(input().split()))
y = list(map(input().split()))

if x[0]==y[2] and x[1]==y[1] and x[2]==y[0]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

x = input()
y = input()

if x[0]==y[2] and x[1]==y[1] and x[2]==y[0]:
  print("YES")
else:
  print("NO")
def sub():
    N = int(input())
    hs = [int(e) for e in input().split()]

    def optimal_value(a_index):
        if a_index >= N - 1:
            return 0

        if a_index < N - 2:
            a = optimal_value(a_index + 1) + abs(hs[a_index + 1] - hs[a_index])
            b = optimal_value(a_index + 2) + abs(hs[a_index + 2] - hs[a_index])
            return min(a, b)
        else:
            return optimal_value(a_index + 1) + abs(hs[a_index + 1] - hs[a_index])

    print(optimal_value(0))


sub()


### FIXED CODE ###

def sub():
    N = int(input())
    hs = [int(e) for e in input().split()]
    optimal_values = [None for _ in range(N)]
    optimal_values[0] = 0
    for i in range(1, N):
        if i > 1:
            a = optimal_values[i - 1] + abs(hs[i] - hs[i - 1])
            b = optimal_values[i - 2] + abs(hs[i] - hs[i - 2])
            optimal_values[i] = min(a, b)
        else:
            optimal_values[i] = optimal_values[i - 1] + abs(hs[i] - hs[i - 1])
    print(optimal_values[-1])


sub()
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
n , m = map(int , input().split())
dic = defaultdict(set)
for ii in range(m):
	u,v = map(int , input().split())
	dic[u].add(v)
	dic[v].add(u)
l = []
visited = [0]*(n+1)
def f(node):
	visited[node] = True
	if len(dic[node]) == 1:
		return 1
	temp = 1
	for nei in dic[node]:
		if not visited[nei]:
			temp += f(nei)
			#print("?",node, nei , temp)
	return temp
for i in range(1,n+1):
	if not visited[i]:
		l.append(f(i))
#print(dic)
#print(l)
print(max(l))








### FIXED CODE ###

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline


class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))

    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a

    def union(self, a, b):
        self.parent[self.find(b)] = self.find(a)




n , m = map(int , input().split())
#dic = defaultdict(set)
uf = UnionFind(n)
for ii in range(m):
	u,v = map(int , input().split())
	u-=1
	v-=1
	uf.union(u,v)
c = [0]*n
for i in range(n):
	c[uf.find(i)] += 1
print(max(c))



'''
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)






########################################
def solve():
	n , m = map(int , input().split())
	dic = defaultdict(set)
	for ii in range(m):
		u,v = map(int , input().split())
		dic[u].add(v)
		dic[v].add(u)
	l = []
	visited = [0]*(n+2)
	def f(node):
		visited[node] = True
		temp = 0
		for nei in dic[node]:
			if not visited[nei]:
				temp += f(nei)
				#print("?",node, nei , temp)
		return temp
	for i in range(1,n+1):
		if not visited[i]:
			l.append(f(i)+1)
	#print(dic)
	#print(l)
	print(max(l))


threading.Thread(target=solve).start()

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

print(min(A, B) + min(C, D))

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(min(A, B) + min(C, D))
s = input()
K = (int)(input())
k = K
for n in s:
  if k == 0:
    break
  elif n == '1':
    k = k-1
  else:
    print(n)
    exit(1)
if k == 0:
  print(s[K-1])


### FIXED CODE ###

s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)
N = int(input())
L,R = map(int,input().split())

if L-R > 672:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if minMod > tmp:
                minMod = tmp
                
            elif tmp == 0:
                minMod = 0 
                break
    print(minMod)

### FIXED CODE ###

L,R = map(int,input().split())

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)
N = int(input())
S = input()

r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(1,N+1):
    for d in range(1, N+1):
        j = i+d
        k = j+d
        if k > N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

### FIXED CODE ###

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

r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(N):
    for d in range(N):
        j = i+d
        k = j+d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
N = int(input())
R = N % 1000
if R = 0:
    print(0)
else:
    print(abs(R-1000))

### FIXED CODE ###

N = int(input())
R = N % 1000
if R == 0:
    print(0)
else:
    print(abs(R-1000))
def resolve():
    n = int(input())
    while n>0:
        n = n - 1000

    print(abs(n))
resolvea()

### FIXED CODE ###

def resolve():
    n = int(input())
    while n>0:
        n = n - 1000

    print(abs(n))
    
resolve()
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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

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

for i in range(Q):
	p, x = list(map(int, input().split()))






### FIXED CODE ###


a = int(input())
s = input()
if a >= 3200:
	print(s)
else:
	print("red")
a=[]
a=map(int, input().split())
for i in a:
 if a[i]==0:
   print(i)
 else:
  pass

### FIXED CODE ###

a=[]
a=input().split()
for i in range(5):
 if a[i]=='0':
   print(str(i+1))
 else:
   pass