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

n=int(input())
slist=[]
var=0
for a in range(n):
  s=input()
  if not s in slist:
    var+=1
    slist.append(s)
print(var)

### FIXED CODE ###

n=int(input())
slist=[]
var=0
for a in range(n):
  s=input()
  slist.append(s)
sset=set(slist)
print(len(sset))
### BUGGY CODE ###

import itertools

N, C = map(int, input().split())
D = [ [ int(x) for x in input().split() ] for _ in range(C) ]
CC = [ [ int(x)-1 for x in input().split() ] for _ in range(N) ]
cost = [ [ 0 for _ in range(C) ] for _ in range(3) ]

for c in range(C):
    for i in range(N):
        for j in range(N):
            cost[(i+j) % 3][c] += D[CC[i][j]][c]

ans = float("inf")
for c in itertools.permutations(range(C), 3):
    tmp = 0
    for j in range(3):
        tmp += cost[j][c[j]]

    ans = min(ans, tmp)

print(ans)

### FIXED CODE ###

import itertools
 
 
def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]
 
    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]
 
    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)
 
    print(res)
 
main()
### BUGGY CODE ###

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

sq = [[0] * n for _ in range(n)]

for i in range(m):
    l = lr[i][0]
    r = lr[i][1]
    sq[l-1][r-1] += 1

for i in range(q):
    p = pq[i][0]
    q = pq[i][1]
    ans = 0
    for j in range(p, q + 1):
        ans += sum(sq[j-1][:q]) - sum(sq[j-1][:p-1])
    print(ans)



### FIXED CODE ###

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

sq = [[0] * n for _ in range(n)]

for i in range(m):
    l = lr[i][0]
    r = lr[i][1]
    sq[l-1][r-1] += 1

c = [[0] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if j == 0:
            c[i][j] = sq[i][j]
        else:
            c[i][j] = sq[i][j] + c[i][j-1]
            
for i in range(q):
    p = pq[i][0]
    q = pq[i][1]
    ans = 0
    for j in range(p, q + 1):
        if p != 1:
            ans += c[j-1][q-1] - c[j-1][p-2]
        else:
            ans += c[j-1][q-1]
    print(ans)
### BUGGY CODE ###

N = int(input())

def Luca(x):
    if x==0:
        return 2
    elif x==1:
        return 1
    else:
        return Luca(x-1)+Luca(x-2)

print(Luca(N))

### FIXED CODE ###

N = int(input())

def Luca(k,x,y):
    if k == N:
        return y
    else:
        return Luca(k+1,y,x+y)

print(Luca(1,2,1))
### BUGGY CODE ###

# abc177_c.py
import numpy as np
from numba import njit

@njit
def solve(N,A):
    ans = 0
    mod = 10**9+7
    for i in range(N-1):
        for j in range(i+1,N):
            if i != j:
                ans+=A[i]*A[j]
                ans%=mod
    return ans%mod

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

### FIXED CODE ###

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    square = []
    for i in A:
        square.append(i**2)
    return (sum(A)**2 - sum(square))//2 % (10**9+7)


print(solve())
### BUGGY CODE ###

from collections import defaultdict

N,Q=map(int,input().split())
l=[ tuple( map(int,input().split()) ) for i in range(N-1) ]
p_l=[ tuple( map(int,input().split()) ) for i in range(Q) ]
d=defaultdict(list)

for f,g in l:
    d[f].append(g)

d_2=defaultdict(int)
for p,x in p_l:
    d_2[p]+=x

for n in range(1,N+1):
    d_2[n]+=0
    for m in d[n]:
        d_2[m]+=d_2[n]

print(*d_2.values())


### FIXED CODE ###

from collections import defaultdict

N,Q=map(int,input().split())
l=[ tuple( map(int,input().split()) ) for i in range(N-1) ]
p=[ tuple( map(int,input().split()) ) for i in range(Q) ]
d=defaultdict(list)
for vert,childs in l:
    d[vert].append(childs)


d_2=defaultdict(int)
for i in range(1,N+1):
    d_2[i]=0

for p,x in p:
    d_2[p]+=x

for n in d_2.keys():
    for m in d[n]:
        d_2[m]+=d_2[n]

ans=d_2.values()
print(*ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(len(A)) :
    A[i] = A[i] % M
for j in range(len(A)) :
    P = 0
    for k in range(j,N) :
        P += A[k]
        if P % M == 0 :
            counter += 1
print(counter)



### FIXED CODE ###

from collections import Counter

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

cums = [0]
for a in A:
    cums.append((cums[-1] + a) % M)

ctr = Counter(cums)

ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)
### BUGGY CODE ###

H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
Srow = [[] for _ in range(H)]
for i in range(H):
    cur = 0
    cnt = 0
    for j in range(W):
        if S[i][j]!="#":
            cnt += 1
        else:
            Srow[i].append((cur,j,cnt))
            cnt = 0
            cur = j+1
    if S[i][W-1]!="#":
        Srow[i].append((cur,W,cnt))
Scol = [[] for _ in range(W)]
for j in range(W):
    cur = 0
    cnt = 0
    for i in range(H):
        if S[i][j]!="#":
            cnt += 1
        else:
            Scol[j].append((cur,i,cnt))
            cnt = 0
            cur = i+1
    if S[H-1][j]!="#":
        Scol[j].append((cur,H,cnt))
A = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for x in Srow[i]:
        s,e,cnt = x[0],x[1],x[2]
        for j in range(s,e):
            A[i][j] = cnt
for j in range(W):
    for y in Scol[j]:
        s,e,cnt = y[0],y[1],y[2]
        for i in range(s,e):
            A[i][j] += cnt
cmax = 0
for i in range(H):
    for j in range(W):
        cmax = max(cmax,A[i][j])
print(cmax-1)

### FIXED CODE ###

H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if j==0 and S[i][j]==".":
            L[i][j] = 1
        elif j>0 and S[i][j]==".":
            L[i][j] = L[i][j-1]+1
        if i==0 and S[i][j]==".":
            U[i][j] = 1
        elif i>0 and S[i][j]==".":
            U[i][j] = U[i-1][j]+1
for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if j==W-1 and S[i][j]==".":
            R[i][j] = 1
        elif j<W-1 and S[i][j]==".":
            R[i][j] = R[i][j+1]+1
        if i==H-1 and S[i][j]==".":
            D[i][j] = 1
        elif i>0 and S[i][j]==".":
            D[i][j] = D[i+1][j]+1
cmax = 0
for i in range(H):
    for j in range(W):
        cmax = max(cmax,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(cmax)
### BUGGY CODE ###

n = int(raw_input())
a = map(int, raw_input().split())

chk = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            #divisors.append(i)
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                #divisors.append(n//i)
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1

    # divisors.sort()
    return divisors

if n == 2:
    print max(a[0],a[1])
else:
    for i in range(2):
        make_divisors(a[i])
    cnt = 1
    for i in range(2,len(a)):
        k = a[i]
        del_list = []
        for j in chk:
            if k % j == 0:
                chk[j] += 1
            if chk[j] < cnt+1:
                del_list.append(j)
        for j in del_list:
            del chk[j]
        cnt += 1

    answer = max(chk.keys())
    print answer

### FIXED CODE ###

n = int(raw_input())
a = raw_input().split()

cnt = 0
for i in a:
    a[cnt] = int(i)
    cnt += 1

chk = {}
chk2 = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1
    return divisors

for i in range(2):
    make_divisors(a[i])
cnt = 1
for i in range(2,len(a)):
    k = a[i]
    if k not in chk2:
        chk2[k] = 1
    else:
        if chk2[k] == 1:
            chk2[k] += 1
        elif chk2[k] > 1:
            continue
    del_list = []
    for j in chk:
        if k % j == 0:
            chk[j] += 1
        if chk[j] < cnt+1:
            del_list.append(j)
    for j in del_list:
        del chk[j]
    cnt += 1

answer = 0
for i in chk:
    if int(chk[i]) >= chk[1] - 1 and i > answer:
        answer = i
print answer
### BUGGY CODE ###

#%%
n, m = map(int, input().split())
s = list(input())
s = s[::-1]

ans = []
tmp = 0
for i in range(n+1):
    last = tmp
    for j in range(0, m):
        j = m - j
        if tmp + j >= len(s): continue

        if s[tmp + j] == "0":
            tmp += j
            ans.append(str(j))
            break
    if last == tmp and last != len(s)-1:
        ans = -1
        break
if ans != -1:
    ans = ans[::-1]
    ans = ' '.join(ans)
    
print(ans)



### FIXED CODE ###

n, m = map(int, input().split())
s = list(input())
s = s[::-1]
ans_list = []

for i in range(n+1):
    if i == 0:
        tmp_count = 0
        tmp_ans = 0
    else:
        tmp_count += 1
        if s[i] == '0':
            tmp_ans = tmp_count
        if tmp_count == m:
            ans_list.append(tmp_ans)
            tmp_count -= tmp_ans
            tmp_ans = tmp_count

if 1 <= tmp_ans <= m:
    ans_list.append(tmp_ans)
if ans_list.count(0) >= 1:
    ans_list = [-1]
    
for i in range(len(ans_list)):
    ans_list[i] = str(ans_list[i])
ans_list = ans_list[::-1]
print(' '.join(ans_list))
### BUGGY CODE ###

def main():
    n = input()
    a = input().split()
    n = int(n)
    a = [int(s) for s in a]
    s =0

    for f in range(n):
      
      for g in range(n):
     
        if g != f:
        	if a[f] == a[g]:
          		s = s+1
          
    if s>0: print("NO")
    else: print('YES')
        
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

n = input()
a = input().split()
n = int(n)
a = [int(s) for s in a]
a.sort()
#print(a)
s=0

for i in range(len(a)-1):
    #print(a[i],a[i+1])
    
    if a[i]==a[i+1]:
        print("NO")
        s=s+1
        break
        
if s == 0: print("YES")
### BUGGY CODE ###

N,P=map(int,input().split())
S=input()
ans=0

for i in range(N):
  for j in range(i+1,N+1):
    s=int(S[i:j])
    if s%P==0:
      ans+=1

print(ans)

### FIXED CODE ###

from collections import defaultdict

N,P=map(int,input().split())
S=input()

def solMin():
  dp=[[0]*P for i in range(N+1)]
  
  for i,s in enumerate(map(int,S), start=1):
    dp[i][s%P]+=1
    for p in range(P):
      dp[i][(p*10+s)%P]+=dp[i-1][p]
  
  return sum(dp[i][0] for i in range(N+1))

def solLarge():
  cnt=defaultdict(int)
  ret=0
  now=0
  
  for d,s in enumerate(map(int, S[::-1])):
    now+=pow(10,d,P)*s
    now%=P
    ret+=cnt[(now-P)%P]
    if now==0:
      ret +=1
    cnt[now]+=1
  
  return ret

print(solMin() if P*N<=10**6 else solLarge())
### BUGGY CODE ###

def main():
    n= int(input())
    slis = list(input())
    total = 0
    lis_R = [n for n, v in enumerate(slis) if v == "R"]
    lis_G = [n for n, v in enumerate(slis) if v == "G"]
    lis_B = [n for n, v in enumerate(slis) if v == "B"]

    lenR = len(lis_R)
    lenG = len(lis_G)
    lenB = len(lis_B)
    total += lenR * lenG * lenB

    for i in lis_R:
        for j in lis_G:
            for k in lis_B:
                if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                    total -= 1
    print(total)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import re
    n = int(input())
    s = input()
    rindex = set()
    gindex = set()
    bindex = set()
    for i in range(n):
        if s[i] == "R":
            rindex.add(i)
        elif s[i] == "G":
            gindex.add(i)
        else:
            bindex.add(i)
    ans = len(rindex) * len(gindex) * len(bindex)

    for r in rindex:
        for g in gindex:
            if r > g:
                gap = r - g
                b1 = r + gap
                b2 = g - gap
                b3 = g + (gap/2)

            elif r < g:
                gap = g - r
                b1 = g + gap
                b2 = r - gap
                b3 = r + (gap/2)
            if b1 in bindex:
                ans -= 1
            if b2 in bindex:
                ans -= 1  
            if b3 in bindex:
                ans -= 1  
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
gcda = []
if N == 2:
    gcda.append(max(A))
else:
    
    for i in range(N):
        A2 = A.copy()
        A2.pop(i)
        element = gcd(A2[0],A2[1])
        for j in range(2,N-1):
            element = gcd(element,A2[j])
        gcda.append(element)
print(max(gcda))

### FIXED CODE ###

N = int(input())
A=sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
ans = []
gcdlist = [A[0]]
for i in range(1,N):
    gcdlist.append(gcd(gcdlist[i-1],A[i]))
gcdlistr = [A[-1]]
for i in range(N-2,-1,-1):
    gcdlistr.append(gcd(gcdlistr[N-i-2],A[i]))
gcdlistr.reverse()
gcdlist.insert(0,0)
gcdlist.append(0)
gcdlistr.insert(0,0)
gcdlistr.append(0)
for i in range(N):
    ans.append(gcd(gcdlist[i],gcdlistr[i+2]))
print(max(ans))
### BUGGY CODE ###

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

mod_num = 10 ** 9 + 7
a = [0] * N

for i in range(M):
    a[i] = int(input())

val = [0,1]
j = 0
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % mod_num
    val[0] = val[1]
    val[1] = ans
    if i in a:
        val[1] = 0
 
print(ans)

### FIXED CODE ###

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

a = []
for _ in range(M):
    a.append(int(input()))

val = [0,1]
for i in range(1, N + 1):
    ans = val[-2] + val[-1]
    val.append(ans)
    if len(a) > 0:
        if i == a[0]:
            val[-1] = 0
            a.pop(0)

print(ans % (10**9 +7))
### BUGGY CODE ###

#E
n=int(input())
a=list(map(int,input().split()))
import fractions
lcm=a[0]
b_sum=0
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])

num=10**9+7
for i in range(n):
    b_sum+=(lcm//a[i])%num

print(b_sum%num)


### FIXED CODE ###

#E
n=int(input())
a=tuple(map(int,input().split()))
import fractions
lcm=a[0]
b_sum=0
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])

num=10**9+7
for i in range(n):
    b_sum+=(lcm//a[i])

print(b_sum%num)
### BUGGY CODE ###

n,m = map(int,input().split())
l = []
numl = [[] for i in range(n+1)]
l = [list(map(int,input().split())) for i in range(m)]

for i in l:
  numl[i[0]].append(i[1])

for i in numl:
  i.sort()
  
for i in l:
  print(str(i[0]).zfill(6) + str((numl[i[0]].index(i[1]))+1).zfill(6))

### FIXED CODE ###

n,m = map(int,input().split())
L = [[] for i in range(n)]
ans = [None]*m
l = [list(map(int,input().split())) for i in range(m)]

for i in range(len(l)):
  L[l[i][0]-1].append([l[i][1],i+1])
  
for ind,lis in enumerate(L):
  lis.sort()
  for j in range(len(lis)):
    ans[lis[j][1] - 1] = str(ind+1).zfill(6) + str(j+1).zfill(6)
    
print(*ans,sep = '\n')
### BUGGY CODE ###

point = []
yes_no = []
minus = []
output = []

N,K,Q = map(int,input().split())
A = []
for _ in range(Q):
    A.append(input())

A = [int(a) for a in A]

for _ in range(N):
    point.append(K)

for _ in range(N):
    minus.append(Q)

for i in range(N):
    point[i] = point[i] - minus[i]

for j in range(N):
    point[j-1] = point[j-1] + A.count(j)

for p in point:
    if p >= 1:
        yes_no.append('Yes')
    else:
        yes_no.append('No')

for yn in yes_no:
    print(yn)


### FIXED CODE ###

N,K,Q=map(int,input().split())
A = [int(input()) for i in range(Q)]

import collections
c = collections.Counter(A)
c_i=c.items()

m=[K-Q]*N
for i in c_i:
    m[i[0]-1]=m[i[0]-1]+i[1]
o=[]

for i in m:
    if i<=0:
        o.append('No')
    else:
        o.append('Yes')
print('\n'.join(o))
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l==s:
                ans+=1
print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
            if k>=s-i-j>=0:
                ans+=1
print(ans)
### BUGGY CODE ###

k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  for j in range(k+1):
    if s < i + j:
      break
    for l in range(k+1):
      if i + j + l == s:
        cnt += 1
print(cnt)

### FIXED CODE ###

def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

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

from collections import deque

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())

c = [[] for i in range(h)]

for i in range(h):
    c[i] = input()
    
d = [[10000000 for i in range(w)] for j in range(h)]
    
d[ch-1][cw-1] = 0
que = deque([[ch-1,cw-1]])

dx = [1,0,-1,0]
dy = [0,1,0,-1]
ddx = [1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2]
ddy = [1,-1,1,-1,2,1,0,-1,-2,2,-2,2,-2,2,-2,2,1,0,-1,-2]
    
while que:
    y,x = que.popleft()
        
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
            
        if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
            if d[ny][nx] > d[y][x]:
                d[ny][nx] = d[y][x]
                que.append([ny,nx])
                
    for k in range(20):
        nx = x + ddx[k]
        ny = y + ddy[k]
            
        if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
            if d[ny][nx] > d[y][x] + 1:
                d[ny][nx] = d[y][x] + 1
                que.appendleft([ny,nx])

                
if d[dh-1][dw-1] == 10000000:
    print(-1)
else:
    print(d[dh-1][dw-1])

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())

c = [[] for i in range(h)]

for i in range(h):
    c[i] = input()
    
d = [[10000000 for i in range(w)] for j in range(h)]
    
d[ch-1][cw-1] = 0
que = deque([[ch-1,cw-1]])

dx = [1,0,-1,0]
dy = [0,1,0,-1]
ddx = [1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2]
ddy = [1,-1,1,-1,2,1,0,-1,-2,2,-2,2,-2,2,-2,2,1,0,-1,-2]
    
while que:
    y,x = que.popleft()
        
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
            
        if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
            if d[ny][nx] > d[y][x]:
                d[ny][nx] = d[y][x]
                que.appendleft([ny,nx])
                
    for k in range(20):
        nx = x + ddx[k]
        ny = y + ddy[k]
            
        if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
            if d[ny][nx] > d[y][x] + 1:
                d[ny][nx] = d[y][x] + 1
                que.append([ny,nx])

                
if d[dh-1][dw-1] == 10000000:
    print(-1)
else:
    print(d[dh-1][dw-1])
### BUGGY CODE ###

s = input()
q = int(input())
flag = 0
cnt = 0

for i in range(q):
    t = input()
    if len(t) == 1:
        cnt += 1
        if flag == 0:
            flag = 1
        elif flag == 1:
            flag = 0
    else:
        _, a, b = (str(i) for i in t.split())
        if a == "1":
            if flag == 0:
                s = b + s
            elif flag == 1:
                s = s + b
        elif a == "2":
            if flag == 0:
                s = s + b
            elif flag == 1:
                s = b + s

if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

def main():
    s = input()
    q = int(input())
    flag = 0
    cnt = 0
    front = []
    back = []

    for i in range(q):
        t = input()
        if len(t) == 1:
            cnt += 1
            if flag == 0:
                flag = 1
            elif flag == 1:
                flag = 0
        else:
            _, a, b = (str(i) for i in t.split())
            if a == "1":
                if flag == 0:
                    front.append(b)
                elif flag == 1:
                    back.append(b)
            elif a == "2":
                if flag == 0:
                    back.append(b)
                elif flag == 1:
                    front.append(b)

    if cnt % 2 == 0:
        front = front[::-1]
        s = ''.join(front) + s + ''.join(back)
    else:
        back = back[::-1]
        s = ''.join(back) + s[::-1] + ''.join(front)

    print(s)

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

n, m = (int(i) for i in input().split())
yl = []
[yl.append([]) for _ in range(n)]
dl = []

for _ in range(m):
    p, y = (int(i) for i in input().split())
    yl[p-1].append(y)
    dl.append((p, y))

[yl[i].sort() for i in range(n)]

for p, y in dl:
    print("{:0>6}{:0>6}".format(p, yl[p-1].index(y)+1))

### FIXED CODE ###

import bisect
n, m = (int(i) for i in input().split())
yl = []
[yl.append([]) for _ in range(n)]
dl = []

for _ in range(m):
    p, y = (int(i) for i in input().split())
    yl[p-1].append(y)
    dl.append((p, y))

[yl[i].sort() for i in range(n)]

for p, y in dl:
    print("{:0>6}{:0>6}".format(p, bisect.bisect_left(yl[p-1], y)+1))
### BUGGY CODE ###

N, M = map(int, input().split())
broken = [int(input()) for _ in range(M)]
div = 1000000007

comb_list = [0] * (N + 1)
comb_list[0] = 1  # 0段目にたどり着くには1通りの方法
if 1 not in broken:  # 1段目が壊れてなければ1段目にたどり着くには1通り
    comb_list[1] = 1


for i in range(2, N + 1):
    if i not in broken:
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div

print(comb_list[-1])

### FIXED CODE ###

def main():
    N, M, *a = map(int, open(0).read().split())
    div = 1000000007
    broken = set(a)

    comb_list = [0] * (N + 1)
    comb_list[0] = 1
    if 1 not in broken:
        comb_list[1] = 1

    for i in range(2, N + 1):
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div

    print(comb_list[-1])


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

import sys

input = sys.stdin.readline

def main():
    def hash_ini(t):
        h = 0
        p = 1
        for i in range(1, len(t)+1):
            h = hash_table[i] = (h * base + t[i-1]) % hash_md
            p = pw[i] = p * base % hash_md

    def hash(s):
        res = 0
        for i, c in enumerate(s[::-1]):
            res = (res + pw[i] * (ord(c) - ord_a)) % hash_md
        return res

    # インデックスがi以上j未満の文字列のハッシュ
    def hash_ij(i, j):
        return (hash_table[j] - hash_table[i] * pw[j - i]) % hash_md

    n = int(input())
    s = input()[:-1]

    # 初期化
    base = 29
    hash_md = pow(3, 19)
    ord_a = ord('a')
    t = [ord(c) - ord_a for c in s]
    hash_table = [0] * (len(t) + 1)
    pw = [1] * (len(t) + 1)
    hash_ini(t)

    ok = 0
    ng = n // 2 + 1
    while ok + 1 < ng:
        br = False
        w = (ok + ng) // 2
        for i in range(n - 2 * w + 1):
            ptn = hash_ij(i, i + w)
            for j in range(i + w, n - w + 1):
                if hash_ij(j, j + w) == ptn:
                    ok = w
                    br = True
                    break
            if br: break
        else:
            ng = w
    print(ok)

main()


### FIXED CODE ###

# YouTube
def main():
    n = int(input())
    s = input()
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for i, c in enumerate(s):
        for j in range(n):
            if c == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n+1):
            tmp=min(dp[i][j],j-i)
            ans=max(tmp,ans)
    print(ans)

main()