Harryxun/stf_run huggingface dataset:
N=int(input())
S=input()
flag=0

for i in  range(0,int(N/2)):
    if S[i]!=S[i+3]:
        flag+=1

if flag==0:
    if N!=1:
        print('Yes')
    else :
        print('No')
else :
    print('No')

### FIXED CODE ###

N=int(input())
S=input()
flag=0

if N%2==0:
    for i in  range(0,int(N/2)):
        if S[i]!=S[i+int(N/2)]:
            flag+=1

    if flag==0:
        print('Yes')
    else :
        print('No')
else :
    print('No')
import sys
A,B,K = map(int,input().split())
sum = []
if B-A +1 <= K * 2
    for i in range(A,B+1):
        if i > A+K or B-K < i:
            print(i)
    else:
        sys.exit(0)


for i in range(A,A+K): #AからB
    sum.append(i)

for i in range(B-K-1,B+1):
    sum.append(i)

sum = list(set(sum))
sum.sort()
[print(i) for i in sum]


### FIXED CODE ###

import sys
S = input()
abc = list("abc")

for i in range(len(abc)):
    if abc[i] in S:
        continue
    else :
        print("No")
        sys.exit(0)

print("Yes")
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
print(rst)

### FIXED CODE ###

x, n = map(int, input().split(' '))
min_num = 100

ls = [0] * 201
for i in range(0, 201):
    ls[i] = i

ls_in = [0] * n
if n > 0:
    ls_in = list(map(int, input().split(' ')))
    for i in ls_in:
        ls.remove(i)
    ls.reverse()
    for i in ls:
        min_num = min(abs(x-i), min_num)
        if abs(x-i) == min_num:
            ans = i 
    print(ans)
else:
    print(x)
l = list(map(int, input().split()))
lr = list(map(lambda x: x%10, l))
lr = [e for e in lr if e != 0]
lr = lr.sorted
print(sum(l) + sum(list(map(lambda x: 10-x, lr[1:]))))

### FIXED CODE ###

time=[]
back=0
for i in range(5):
    A=int(input())
    if A%10==0:
        pass
    else:
        back=max(back,10-A%10)
        A=(A//10)*10 +10

    time.append(A)

print(sum(time)-back)
W, H, x, y = map(int, input().split())
if x == W/2 and y == H/2:
  same = 1
print(W*H/2, same)

### FIXED CODE ###

W, H, x, y = map(int, input().split())
same=0
if x == W/2 and y == H/2:
  same = 1
print(W*H/2, same)
# Five Dishes
# https://atcoder.jp/contests/abc123/tasks/abc123_b

NUM_DISHES = 5
tt = 0
itvs = list()

for i in range(NUM_DISHES):
    st = int(input())
    tt += st
    if st % 10 == 0:
        itvs.append(0)
    else:
        itvs.append(10 - serve_time % 10)

itvs.sort()

for interval in range(len(itvs) - 1):
    tt += itvs[interval]

print "{}".format(tt)


### FIXED CODE ###

# TODO B - Five Dishes
# https://atcoder.jp/contests/abc123/tasks/abc123_b

NUM_DISHES = 5
intervals = list()

total_time = 0
for i in range(NUM_DISHES):
    serve_time = int(input())
    total_time += serve_time

    if serve_time % 10 == 0:
        intervals.append(0)
    else:
        intervals.append(10 - serve_time % 10)

intervals.sort()

for interval in range(len(intervals) - 1):
    total_time += intervals[interval]

print "{:d}".format(total_time)
n = int(input())
friendly = list(map(int, input().split()))
friendly.sort(reverse=True)
if len(friendly)<=2:
    print(sum[0:n-1])
else:
    ans = friendly[0]+sum(friendly[1:(n+1)//2-1])*2+friendly[(n+1)//2-1]*((n+1)%2+1)
    print(ans)

### FIXED CODE ###

n = int(input())
friendly = list(map(int, input().split()))
friendly.sort(reverse=True)
if len(friendly)<=2:
    print(sum(friendly[0:n-1]))
else:
    ans = friendly[0]+sum(friendly[1:(n+1)//2-1])*2+friendly[(n+1)//2-1]*((n+1)%2+1)
    print(ans)
def func(iro,tree,num,max_color):
  if num not in tree:
    return
  
  my_color = iro[num]
  arr = tree[num]
  
  for i in arr:
    my_color += 1
    iro[i] = my_color % max_color
    func(iro,tree,i,max_color)
    

n = int(input())
tree = {}

b_arr = []
for i in range(n-1):
  a,b = map(int,input().split())
  
  b_arr.append(b)
  if a not in tree:
    tree[a] = []
    
  tree[a].append(b)

tree = sorted(tree.items())
  
color = len(tree[1])
for key in tree.keys():
  if key == 1:
    continue
    
  arr = tree[key]
  color = max(len(arr)+1, color)

print(color)

iro = [-1] * (n+1)

for key in tree.keys():
  my_color = iro[key]
  arr = tree[key]
  for i in arr:
    my_color += 1
    iro[i] = my_color % color

for i in b_arr:
  print(iro[i]+1)

### FIXED CODE ###

def func(iro,tree,num,max_color):
  if num not in tree:
    return
  
  my_color = iro[num]
  arr = tree[num]
  
  for i in arr:
    my_color += 1
    iro[i] = my_color % max_color
    func(iro,tree,i,max_color)
    

n = int(input())
tree = {}

b_arr = []
for i in range(n-1):
  a,b = map(int,input().split())
  
  b_arr.append(b)
  if a not in tree:
    tree[a] = []
    
  tree[a].append(b)
  
color = len(tree[1])
for key,arr in sorted(tree.items()):
  if key == 1:
    continue
    
  color = max(len(arr)+1, color)

print(color)

iro = [-1] * (n+1)

for key,arr in sorted(tree.items()):
  my_color = iro[key]
  for i in arr:
    my_color += 1
    iro[i] = my_color % color

for i in b_arr:
  print(iro[i]+1)
s=input()
if a in s and b in s and c in s:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=input()
if "a" in s and "b" in s and "c" in s:
    print("Yes")
else:
    print("No")
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

time = 0
cnt = 0
b = []

for i in B:
    if i+time>K:
        break
    time += i
    cnt += 1
    b.append(i)

b.reverse()
# print(b)
# print(cnt)
bi = 0
for i in range(N):
    if time+A[i] <= K:
        cnt += 1
        time += A[i]
    else:
        if len(b)-1 >= bi:
            if A[i] <= b[bi]:
                time -= b[bi]-A[i]
                bi += 1
        else:
            break
            # print("a")
            # print(time+A[i])
       
    # print(time)

time2 = 0
cnt2 = 0
a = []

for i in A:
    if i+time>K:
        break
    time2 += i
    cnt2 += 1
    a.append(i)

a.reverse()
# print(b)
# print(cnt)
ai = 0
for i in range(N):
    if time2+B[i] <= K:
        cnt2 += 1
        time2 += B[i]
    else:
        if len(a)-1 >= ai:
            if B[i] <= a[ai]:
                time2 -= a[ai]-B[i]
                ai += 1
        else:
            break
            # print("a")
            # print(time+A[i])
       
    # print(time)


print(max((cnt, cnt2))

'''
5 3 8
5 0 0 1 1
1 2 1000
'''

### FIXED CODE ###

from itertools import accumulate

N, M, K = map(int, input().split())
A = list(accumulate([0] + list(map(int, input().split()))))
B = list(accumulate([0] + list(map(int, input().split()))))


ans, j = 0, M

for i in range(N+1):
    if A[i] > K:
        break
    while B[j] > K-A[i]:
        j -= 1
    ans = max(ans, i+j)


print(ans)
H,W = [int(x) for x in input().split()]
S = [list('.'*(W+2))]+[list('.'+input()+'.') for _ in range(H)]+[list('.'*(W+2))]
lix = [-1,0,1,0]
liy = [0,-1,0,1]
flag = True
def dfs(x,y):
    cnt = 0
    if(S[x][y]=='.'):
        return 0
    else:
        cnt += 1
        S[x][y]='.'
        for i in range(4):
            if(S[x+lix[i]][y+liy[i]]!='.'):
                cnt += dfs(x+lix[i],y+liy[i])
        return cnt

for i in range(1,H+1):
    for j in range(1,W+1):
          if(dfs(i,j)==1):
              flag = False
if(flag):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

H,W = [int(x) for x in input().split()]
S = [list('.'*(W+2))]+[list('.'+input()+'.') for _ in range(H)]+[list('.'*(W+2))]
lix = [-1,0,1,0]
liy = [0,-1,0,1]
flag = True
def dfs(x,y):
    cnt = 0
    if(S[x][y]=='.'):
        return 0
    else:
        cnt += 1
        S[x][y]='.'
        for i in range(4):
            if(S[x+lix[i]][y+liy[i]]!='.'):
                cnt += dfs(x+lix[i],y+liy[i])
        return cnt

for i in range(1,H+1):
    for j in range(1,W+1):
          if(dfs(i,j)==1):
              flag = False
if(flag):
    print('Yes')
else:
    print('No')
a, b, c, d = [int(i) for i in raw_input()]
if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print "Yes"
else:
    print "No"

### FIXED CODE ###

a, b, c, d = [int(i) for i in raw_input().split()]
if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print "Yes"
else:
    print "No"
import sys
X,N = map(int,input().split())

if N == 0:
  print(X)
  sys.exit()

P = list(map(int,input().split()))

if X not in P:
  print(X)
else:
  a = float("inf")
  b = float("inf")
  for i in range(X-1,0,-1):
    if i not in P:
      a = abs(X - i)
      break
  for j in range(X+1,max(P)+2):
    if j not in P:
      b = abs(j - X)
      break
      
if a <= b:
  print(i)
else:
  print(j)

### FIXED CODE ###

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

if N == 0:
  print(X)
else:
  for i in range(X,-2,-1):
    if i not in P:
      a = abs(X - i)
      break
  for j in range(X+1,102):
    if j not in P:
      b = abs(j - X)
      break
  if a <= b:
    print(i)
  else:
    print(j)
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    s = list(input())
    num = int(input())

    for i in range(len(s)):
        now_ind = ord(s[i])
        if now_ind + num > 122:
            num -= 123 - now_ind
            s[i] = 'a'

    last_ind = ord(s[-1])
    if last_ind + num <= 122:
        last_ind += num
    else:
        last_ind = last_ind + num - 27
    s[-1] = chr(last_ind)

    print(''.join(s))



if __name__ == '__main__':
    main()



### FIXED CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    s = list(input())
    num = int(input())

    for i in range(len(s)):
        now_ind = ord(s[i])
        if now_ind == 97:
            continue
        if now_ind + num > 122:
            num -= 123 - now_ind
            s[i] = 'a'

    last_ind = ord(s[-1]) - 97
    last_ind = (last_ind + num) % 26 + 97
    s[-1] = chr(last_ind)

    print(''.join(s))



if __name__ == '__main__':
    main()
n= int(input())
bdic = {'A':0,'B':1,'O':2}
aot = [[0 for i in range(3)] for i in range(3)]
ans=0
for i in range(n):
    s=input()
    subab=0
    for i in range(len(s)-1):
        if s[i]=='A' and s[i+1]=='B':subab+=1
    ans += subab
    f = 'O' if not s[0]  in bdic.keys() else s[0]
    l = 'O' if not s[-1] in bdic.keys() else s[-1]
    aot[bdic[f]][bdic[l]]+=1

oa = aot[bdic['O']][bdic['A']]+aot[bdic['A']][bdic['A']]
bo = aot[bdic['B']][bdic['O']]+aot[bdic['B']][bdic['B']]
ab = aot[bdic['A']][bdic['B']]
ba = aot[bdic['B']][bdic['A']]

if   oa==0 and bo==0:ans+=max(0,ba-1)
elif oa==0 and bo!=0:ans+=min(bo,ba)+max(0,ba-bo)
elif bo==0 and oa!=0:ans+=min(oa,ba)+max(0,ba-oa)
else:                ans+=min(oa,bo)+ba
print(ans)

### FIXED CODE ###

n= int(input())
bdic = {'A':0,'B':1,'O':2}
aot = [[0 for i in range(3)] for i in range(3)]
ans=0
for i in range(n):
    s=input()
    subab=0
    for i in range(len(s)-1):
        if s[i]=='A' and s[i+1]=='B':subab+=1
    ans += subab
    f = 'O' if not s[0]  in bdic.keys() else s[0]
    l = 'O' if not s[-1] in bdic.keys() else s[-1]
    aot[bdic[f]][bdic[l]]+=1

oa = aot[bdic['O']][bdic['A']]+aot[bdic['A']][bdic['A']]
bo = aot[bdic['B']][bdic['O']]+aot[bdic['B']][bdic['B']]
ab = aot[bdic['A']][bdic['B']]
ba = aot[bdic['B']][bdic['A']]

if   oa==0 and bo==0:ans+=max(0,ba-1)
elif oa==0 and bo!=0:ans+=min(bo,ba)+max(0,ba-bo)
elif bo==0 and oa!=0:ans+=min(oa,ba)+max(0,ba-oa)
else:                ans+=min(oa,bo)+ba
print(ans)
s=int(input())
str=input()
if s<3200:
  print(red)
else:
  print(str)

### FIXED CODE ###

s=int(input())
str=input()
if s<3200:
  print("red")
else:
  print(str)
l,r = map(int,input().split())
if r-l >=2019:
    print(0)
else:
    ans = 2019
    for i in raneg(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
    print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
ans = 2020
for i in range(l,r):
    for j in range(i+1,r+1):
        t =(i*j)%2019
        ans=min(ans,t)
print(ans)
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)
print(str(input()) + str(input()))

### FIXED CODE ###

a, b = input(). split()
c = (b + a)
print(c)
s = input()
ans = 'WA'
if s[0] == 'A' and s[2:-1].count('C') == 1\
   s.replace('A', '').replace('C', '').islower():
  ans = 'AC'
print(ans)

### FIXED CODE ###

s = input()
ans = 'WA'
if s[0] == 'A' and s[2:-1].count('C') == 1\
   and s.replace('A', '').replace('C', '').islower():
  ans = 'AC'
print(ans)
n, k, s = map(int, input().split())
if s != 10**9:
  if s % 2 == 0:
    a = [s//2]*(k+1)+[10**9]*(n-k-1)
  if s % 2 == 1:
    if k % 2 == 0:
      a = [s//2, s//2 + 1]*(k//2) +[s//2] +[10**9]*(n-k-1)
    else:
      a = [s//2, s//2 + 1]*(k//2+1) + [10**9]*(n-k-1)
else:
  if k % 2 == 0:
    a =[10**9,1]*k//2
  else:
    a =[10**9,1]*k//2 + [10**9]
print(*a)

### FIXED CODE ###

n, k, s = map(int, input().split())

if s < 10**9:

  if k > 0: 
      aa = [s]*k + [s+1]*(n-k)
  elif k == 0:
      aa = [s+1]*n

else:
  aa =[s]*k + [1]*(n-k)

print(*aa)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def calc_gcd(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def calc_lcm(a, b):
  gcd = calc_gcd(a, b)
  return int(a * b / gcd)

def main():
  n = int(input())
  As = list(map(int, input().strip().split()))
  lcm = As[0]
  total = 0
  for a in As[1:]:
    lcm = calc_lcm(lcm, a)
  for a in As:
    total += lcm / a
  print(int(total) % (10**9+7))


if __name__=='__main__':
  main()

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

def calc_gcd(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def calc_lcm(a, b):
  gcd = calc_gcd(a, b)
  return int(a * b // gcd)

def main():
  n = int(input())
  As = list(map(int, input().strip().split()))
  lcm = As[0]
  total = 0
  for a in As[1:]:
    lcm = calc_lcm(lcm, a)
  for a in As:
    total += lcm // a
  print(total % (10**9+7))


if __name__=='__main__':
  main()
n=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(n):
    if a[i]<=399:
        c.append('0')
    elif a[i]<=799:
        c.append('1') 
    elif a[i]<=1199:
        c.append('2')
    elif a[i]<=1599:
        c.append('3')
    elif a[i]<=1999:
        c.append('4')
    elif a[i]<=2399:
        c.append('5')
    elif  a[i]<=2799:
        c.append('6')
    elif  a[i]<=3199:
        c.append('7')
x=n-len(c)
#3200以上の人数
c=list(set(c))

print(max(len(c),1), len(c)+x)

### FIXED CODE ###

r,g,b=map(int,input().split())
if (10*g+b)%4==0:
    print('YES')
else:
    print('NO')
n,m=map(int,input().split())
A=[int(i) for i in input().split()]

A.sort()
#print(A)
for i in range(m):
    A[-1]=A[-1]//2
    if A[-1]<A[-2]:
        A.sort()
    #print(A)
print(sum(A))

### FIXED CODE ###

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

A.sort()
A.reverse()
#print(A)
if n==1:
    ans=A[0]//(2**m)
    print(ans)
else:
    A.append(0)
    big=A[0]
    stc=0
    now=0
    while m>0:
        A[now]=A[now]//2
        m-=1
        big=A[0]
        for i in range(n-1):
            if A[i+1]>=big and m>0:
                A[i+1]=A[i+1]//2
                m-=1
            else:
                A.sort()
                A.reverse()
                break
        #print(A)
    else:
        print(sum(A))
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # input()
    A,B,N=map(int, input().split())

    max=0
    # for x in range(N+1):
    #     # ans=int(A*x/B)-A*int(x/B)
    #     min,_=math.modf(x/B)
    #     # ans=int(A*min)
    #     # print(min)
    #     if x==0:
    #         max=min
    #     elif min > max:
    #         max=min
    #     else:
    #         break

    max=0
    max_x=0
    reg=[0]*B

    for x in range(N+1):
        rem = x%B
        if reg[rem]==1:
            break
        else:
            reg[rem]=1
        if rem > max:
            max=rem
            max_x=x

    # min,_=math.modf(max_x/B)

    print(int(A*max_x/B)-A*int(max_x/B))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
   # file_input()
    # input()
    A,B,N=map(int, input().split())

    max=0
    # for x in range(N+1):
    #     # ans=int(A*x/B)-A*int(x/B)
    #     min,_=math.modf(x/B)
    #     # ans=int(A*min)
    #     # print(min)
    #     if x==0:
    #         max=min
    #     elif min > max:
    #         max=min
    #     else:
    #         break

    # max=0
    # max_x=0
    # first=0
    #
    # for x in range(N+1):
    #     rem = x%B
    #     if x == 0:
    #         first=rem
    #     elif rem == first:
    #         break
    #     if rem > max:
    #         max=rem
    #         max_x=x

    if N<B:
        max_x=N
    else:
        max_x=B-1

    # min,_=math.modf(max_x/B)

    print(int(A*max_x/B)-A*int(max_x/B))

if __name__ == '__main__':
    main()
h,w = map(int,input().split())
sl = []
for _ in range(h):
   s = list(input())
   sl.append(s)

G = [[] for i in range(h*w)]
for i in range(h):
    for j in range(w):
        if sl[i][j] == "#":
            continue
        a = i*h + j
        if j != w - 1:
            if sl[i][j+1] != "#":
                b = i*h + j + 1
                G[a].append(b)
        if j != 0:
            if sl[i][j-1] != "#":
                b = i*h + j - 1
                G[a].append(b)
        if i != 0:
            if sl[i-1][j] != "#":
                b = i*h + j - h
                G[a].append(b)
        if i != h - 1:
            if sl[i+1][j] != "#":
                b = i*h + j + h
                G[a].append(b)

# G[v]: 頂点vに隣接する頂点list
# N: 頂点数

ans = 0
from collections import deque
for i in range(h*w):
    dist = [-1]*(w*h)
    que = deque([i])
    dist[i] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for p in G[v]:
            if dist[p] > -1:
                continue
            dist[p] = d + 1
            que.append(p)
    ans = max(ans, max(dist))
    


print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
sl = []
for _ in range(h):
   s = list(input())
   sl.append(s)

G = [[] for i in range(h*w)]
for i in range(h):
    for j in range(w):
        if sl[i][j] == "#":
            continue
        a = i*w + j
        if j != w - 1:
            if sl[i][j+1] != "#":
                b = i*w + j + 1
                G[a].append(b)
        if j != 0:
            if sl[i][j-1] != "#":
                b = i*w + j - 1
                G[a].append(b)
        if i != 0:
            if sl[i-1][j] != "#":
                b = i*w + j - w
                G[a].append(b)
        if i != h - 1:
            if sl[i+1][j] != "#":
                b = i*w + j + w
                G[a].append(b)

# G[v]: 頂点vに隣接する頂点list
# N: 頂点数

ans = 0
from collections import deque
for i in range(h*w):
    if sl[i//w][i%w] == "#":
        continue
    dist = [-1]*(w*h)
    que = deque([i])
    dist[i] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for p in G[v]:
            if dist[p] > -1:
                continue
            dist[p] = d + 1
            que.append(p)
    ans = max(ans, max(dist))
    
print(ans)
i = 1
x = int(input())
for x in x:
    if x == 0:
        break
    print(Case
    i: x)
    i += 1



### FIXED CODE ###

case_num = 1

while True:
    tmp_num = int(input())
    if tmp_num == 0:
        break
    else:
        print("Case %d: %d" % (case_num,tmp_num))
        case_num += 1
N,M=[int(x) for x in input().split()]
I=[[] for n in range(N)]
ans = int(N * (N-1) / 2)
E=[]
result=[]
V=[n for n in range(N)]
W=[1 for n in range(N)]

def union(i,g):
    if(V[i]!=g):
        V[i]=g
        for n in I[i]:
            union(n,g)

for m in range(M):
    A,B=[int(x) for x in input().split()]
    E.append((A-1,B-1))

for m in range(M):
    result.append(ans)
    if(ans>0):
        A,B=E.pop()
        Ga=V[A]
        Gb=V[B]
        Wa=W[Ga]
        Wb=W[Gb]
        W[Ga]=Wa+Wb
        W[Gb]=Wa+Wb
        if (Wb>Wa):
            union(A,Gb)
        else:
            union(B,Ga)
        ans=ans-(Wa*Wb)
        I[A].append(B)
        I[B].append(A)

for r in reversed(result):
    print(r)


### FIXED CODE ###

N,M=[int(x) for x in input().split()]
G=[-1] * N
W=[0] * N
E=[]

result=[]
ans = int(N * (N-1) / 2)

def union(i,j):
    gi=find(i)
    gj=find(j)

    if(gi!=gj):
        if W[gi] > W[gj]:
            G[gi]+=G[gj]
            G[gj]=gi
        else:
            G[gj]+=G[gi]
            G[gi]=gj
            if W[gi]==W[gj]:
                W[gj]+=1

def find(i):
    if G[i]<0:
        return i;
    else:
        G[i]=find(G[i])
        return G[i]

for m in range(M):
    A,B=[int(x) for x in input().split()]
    E.append((A-1,B-1))

for m in range(M):
    result.append(ans)
    if(ans>0):
        A,B=E.pop()
        ga,gb=find(A),find(B)
        if (ga!=gb):
            ans=ans-(G[ga]*G[gb])
            union(A,B)

for r in reversed(result):
    print(r)
import math
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
g = A.pop()
for a in A:
    g = math.gcd(g, a)

### FIXED CODE ###

N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


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


g = A[0]
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
h,w,k=map(int,input().split())
ans="No"
for i in xrange(h):
  for j in xrange(w):
    if i*j+(h-i)*(w-j) == k:
      ans="Yes"
print(ans)

### FIXED CODE ###

h,w,k=map(int,input().split())
ans="No"
for i in range(h+1):
  for j in range(w+1):
    if i*j+(h-i)*(w-j) == k:
      ans="Yes"
print(ans)
N,M = [int(x) for x in input().split()]
E ={i: [] for i in range(1, N+1)}
for _ in range(M):
  u,v = [int(x) for x in input().split()]
  E[u].append(v)
#print(E)
dp =[-1]*(N+1)
def memo(v):
  if dp[v]!= -1:
    return dp[v]
  res = 0
  for nv in E[v]:
    res = max(res,memo(nv)+1)
  dp[v] =res
  return dp[v]
res = 0
for v in range(1,N+1):
  res = max(res,memo(v))
print(res)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)
N,M = [int(x) for x in input().split()]
E ={i: [] for i in range(1, N+1)}
for _ in range(M):
  u,v = [int(x) for x in input().split()]
  E[u].append(v)
#print(E)
dp =[-1]*(N+1)
def memo(v):
  if dp[v]!= -1:
    return dp[v]
  res = 0
  for nv in E[v]:
    res = max(res,memo(nv)+1)
  dp[v] =res
  return dp[v]
res = 0
for v in range(1,N+1):
  res = max(res,memo(v))
print(res)