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

import bisect
import sys
input = sys.stdin.readline
class BinaryIndexedTree():
    def __init__(self,size):
        self.BIT = [0]*(size+1)
    def query(self,index):
        #sum of A1 ~ Ai O(logN)
        ret=0
        while index > 0:
            ret += self.BIT[index]
            index -= index & (-index)
        return ret
    def update(self,index,x):
        #add x to Ai O(logN)
        while index <=  len(self.BIT)-1:
            self.BIT[index] += x
            index += index & (-index)
        return
n=int(input())
a=list(map(int,input().split()))
if n==1:print(a[0]);exit()
elif n==2:print(a[1]);exit()
ng=2*max(a)+20
ok=0
while ng-ok>1:
    check=(ok+ng)//2
    cnt=0 #check以上の要素の数
    s=[0]*(n+1)
    B=BinaryIndexedTree(n+1)
    for i in range(1,n+1):
        if a[i-1]<check:s[i]=s[i-1]-1
        else:s[i]=s[i-1]+1
    
    # 座標圧縮
    S=sorted(s)
    for i,e in enumerate(s):
        s[i]=bisect.bisect_left(S,e)
    for i,e in enumerate(s):
        cnt += B.query(e+1)
        B.update(e+1,1)
    if cnt >= ((n+1)*n)//4:
        ok = check
    else:
        ng = check
print(ok)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a2=sorted(set(a))
L=len(a2)
if n==1:print(a[0]);exit()
elif n==2:print(a[1]);exit()
ng=L
ok=0
while ng-ok>1:
    check=a2[(ok+ng)//2]
    cnt=0 #check以上の要素の数
    idx=n
    cl=[0]*(2*n+1)
    cl[n]=1
    Ru=0
    for i in range(n):
        if a[i]<check:
            Ru-=cl[idx]-1
            idx-=1
        else:
            idx+=1
            Ru+=cl[idx]+1
        cnt += Ru
        cl[idx]+=1
    if cnt >= ((n+1)*n//2)//2:
        ok = (ok+ng)//2
    else:
        ng = (ok+ng)//2
print(a2[ok])
### BUGGY CODE ###

def calc(n):
  return (n+1)/2.0

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

cnt=0.0
for i in range(N-K+1):
  S=sum(Q[i:i+K])
  cnt=max(cnt,S)

print(cnt)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K,N+1):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
x = int(s, 2)
p = s.count("1")

for i in range(n):
	ans = 0
	tmp = x ^ (1 << (n-1-i))
	if tmp == 0:
		print(0)
		continue
	if tmp > x:
		ans = 1
		tmp %= p+1
	else:
		ans = 1
		tmp %= p-1
	while tmp > 0:
		ans += 1
		tmp %= bin(tmp).count("1")
	print(ans)

### FIXED CODE ###

n = int(input())
s = input()
x = int(s, 2)
p = s.count("1")
if p > 1:
	pre0 = x%(p-1)
pre1 = x%(p+1)

nxt = [i for i in range(n+10)]
for i in range(1, n+10):
	nxt[i] %= bin(i).count("1")

for i in range(n):
	if x == 1<<(n-1-i):
		print(0)
		continue
	if s[i] == "0":
		tmp = (pre1 + pow(2, n-1-i, p+1)) % (p+1)
	else:
		tmp = (pre0 - pow(2, n-1-i, p-1)) % (p-1)
	ans = 1
	while tmp > 0:
		ans += 1
		tmp = nxt[tmp]
	print(ans)
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
h.sort()
i = 0
ans = []
while N - i >= K:
    temp = h[i:i+K]
    ans.append(temp[-1] - temp[0])
    i += 1
print(min(ans))


### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
### BUGGY CODE ###

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

for i in range(1,N+1):
    if K-Q+A.count(i)<=0:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q) ]
point = [0]*(N+1)
for i in range(Q):
    point[A[i]] += 1
for i in range(N):
    if K-Q+point[i+1]<=0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

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

candidates=set(A)

# 配列に渡された配列内に，±1で数xに出来る数がいくつあるか判定
def neigh(array, x):
  cnt = 0
  for a in array:
    if a == x:
      cnt+=1
    elif a-1 == x:
      cnt+=1
    elif a+1 == x:
      cnt+=1
  return cnt

res=[]
for c in candidates:
  res.append(neigh(A,c))
  
print(max(res))

### FIXED CODE ###

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

cnt=dict()
# a内の数とその±1をdict型の配列に入れながら個数をカウント
for a in A:
  cnt[a] = cnt.setdefault(a,0) + 1
  cnt[a-1] = cnt.setdefault(a-1,0) + 1
  cnt[a+1] = cnt.setdefault(a+1,0) + 1
  
  
# カウントした数字で昇順にソート  
cnt_sort = sorted(cnt.items(), key=lambda x:x[1])
cnt_sort.reverse()

print(cnt_sort[0][1])
### BUGGY CODE ###

import string
letters=string.ascii_lowercase

s = input()
K = int(input())

ans = []
for i in range(26):
    for j in range(len(s)):
        if letters[i] == s[j]:
            for k in range(1, len(s)-j+1):
                ans.append(s[j:j+k])
    ans = sorted(set(ans))
    if len(ans) >= K:
        break

print(ans[K-1])

### FIXED CODE ###

s = input()
k = int(input())
n = len(list(s))
kouho = set()
for i in range(n):
    for d in range(1, k + 1):
        if i + d <= n:
            kouho.add(s[i : i + d])
ans = list(kouho)
ans.sort()
# print(ans)
print(ans[k - 1])
### BUGGY CODE ###

n,k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()
h.reverse()
for i in range(k):
    h.pop(0)
    if len(h) == 0:
        break
print(sum(h))


### FIXED CODE ###

n,k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()
for i in range(k):
    h.pop(-1)
    if len(h) == 0:
        break
print(sum(h))
### BUGGY CODE ###

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

for i in range(Q):
    l,r = map(int, input().split())
    S_ = S[l-1:r]
    print(S_.count("AC"))

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
count = [0]*N
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1] == "AC":
        count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

from itertools import product
from math import gcd

k = int(input())
nums = range(1,k+1)
##numsから重複を許して、3つを取り並べる(重複順列)
list = list(product(nums,repeat=3))

answer = []
##gcd(a,b,c) a,bの最大公約数を計算した後、その最大公約数とcの最大公約数を計算
for i in range(len(list)):
    answer.append(gcd(gcd(list[i][0],list[i][1]),list[i][2]))
print(sum(answer))

### FIXED CODE ###

from math import gcd
k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += gcd(gcd(a,b),c)
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
scaffolds = list(map(int, input().split()))
dp = [10 ** 5 * 10 ** 4] * n
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j >= n:
            break
        dp[i + j] = min(dp[i + j], abs(scaffolds[i] - scaffolds[i + j]) + dp[i])
print(dp[-1])

### FIXED CODE ###

n, k = map(int, input().split())
scaffolds = list(map(int, input().split()))
dp = [10 ** 5 * 10 ** 4] * n
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j >= n:
            break
        dp[i + j] = min(dp[i + j], abs(scaffolds[i] - scaffolds[i + j]) + dp[i])
print(dp[-1])
### BUGGY CODE ###

N = int(input())
P = list(map(float, input().split()))
dp = [[0 for j in range(N+1)] for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j] * (1-P[i])
        dp[i+1][j+1] += dp[i][j] * P[i]
print(sum(dp[N][N//2+1:]))

### FIXED CODE ###

import numpy as np
N = int(input())
P = list(map(float, input().split()))
dp = np.zeros((N+1,N+1),dtype=float)
dp[0,0] = 1

for i in range(N):
    dp[i+1] += dp[i] * (1-P[i])
    dp[i+1][1:] += dp[i][:-1] * P[i]
print(sum(dp[N, N//2+1:]))
### BUGGY CODE ###

import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    if s=="R":
        if a>=i:
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="G":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="B":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1


    i+=1
print(sum)

### FIXED CODE ###

a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)
### BUGGY CODE ###

import heapq
def SME(start,end):
    A = []
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] == 0:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * 0.999 : break
    for i in range(L):
        if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = [0]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
B = [list(map(int, input().split())) for i in range(H)]


X = [[0] * W for i in range(H)]
for h in range(H):
    for w in range(W):
        X[h][w] = abs(A[h][w] - B[h][w])


# dp[h][w][x] := (h, w)の時点で差をxにできるか？
M = 12800
dp = [[[False] * (M + 1) for j in range(W)] for i in range(H)]
dp[0][0][X[0][0]] = True


for h in range(H):
    for w in range(W):
        for m in range(M):
            if not dp[h][w][m]:
                continue

            x = X[h][w]
            if h + 1 < H and abs(m + X[h + 1][w]) <= M:
                dp[h + 1][w][abs(m + X[h + 1][w])] = True

            if h + 1 < H and abs(m - X[h + 1][w]) <= M:
                dp[h + 1][w][abs(m - X[h + 1][w])] = True

            if (w + 1 < W) and abs(m + X[h][w + 1]) <= M:
                dp[h][w + 1][abs(m + X[h][w + 1])] = True

            if (w + 1 < W) and abs(m - X[h][w + 1]) <= M:
                dp[h][w + 1][abs(m - X[h][w + 1])] = True


ans = float('inf')
for x in range(M + 1):
    if dp[H - 1][W - 1][x]:
        ans = min(ans, x)

print(ans)


### FIXED CODE ###

def main():
    import sys

    H, W = map(int, sys.stdin.readline().split())
    A = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    B = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    X = [[0] * W for i in range(H)]
    for h in range(H):
        for w in range(W):
            X[h][w] = abs(A[h][w] - B[h][w])

    dp = [[set() for j in range(W)] for i in range(H)]
    dp[0][0].add(X[0][0])
    dp[0][0].add(-X[0][0])

    for h in range(H):
        for w in range(W):
            if h == 0 and w == 0:
                continue
            x = X[h][w]
            s = set()

            if h > 0:
                for d in dp[h - 1][w]:
                    s.add(d + x)
                    s.add(abs(d - x))

            if w > 0:
                for d in dp[h][w - 1]:
                    s.add(d + x)
                    s.add(abs(d - x))

            dp[h][w] = s

    ans = min([abs(s) for s in dp[H - 1][W - 1]])
    print(ans)


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

n=int(input())
a=list(map(int,input().split()))
b=''
if n%2==0:
  for i in range(n):
    if i%2==0:
      b+=str(a[i])+' '
    else:
      b=str(a[i])+' '+b
else:
  for i in range(n):
    if i%2!=0:
      b+=str(a[i])+' '
    else:
      b=str(a[i])+' '+b
      
print(b[:-1])

### FIXED CODE ###

n=int(input())
a=list(input().split())
if n%2==0:
  b=a[-1::-2]+a[0::2]
else:
  b=a[-1::-2]+a[1::2]
ans=''
for i in range(n):
  ans+=b[i]+' '
print(ans[:-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
L = []
for i in range(N) :
    for j in range(i+1,N+1) :
        L.append(sum(A[i:j]))
        if sum(A[i:j]) == 0 :
            ans += 1
print(ans)



### FIXED CODE ###

from math import factorial
N = int(input())
A = list(map(int,input().split()))
L = []
D = {}
ans = 0
L.append(0)
for i in range(len(A)) :
    L.append(L[-1]+A[i])
for j in range(len(L)) :
    if L[j] not in D :
        D[L[j]] = 1
    else :
        D[L[j]] += 1
V = list(D.values())
for k in range(len(V)) :
    if V[k] >= 2 :
        c = factorial(V[k])//(factorial(2)*factorial(V[k]-2))
        ans += c
print(ans)
### BUGGY CODE ###

from fractions import gcd

N,M=map(int,input().split())
List=list(map(lambda x:int(x)/2,input().split()))

LCM=1
cut2count=0
a=List[0]
while a%2==0:
    a/=2
    cut2count+=1

for i in List:
    LCM*=i/gcd(LCM,i)
        
    cut2countb=0
    b=i
    while b%2==0:
        b/=2
        cut2countb+=1
    if cut2count!=cut2countb:
        print(0)
        exit()


#for i in List:
 #   if LCM/i%2==0:
  #      print(0)
   #     exit()

print(int(M//(LCM*2)+M%(LCM*2)//LCM))




### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
List=list(map(lambda x:int(x)//2,map(int, set(input().split()))))

def main():
    LCM=1

    for i in List:
        LCM*=i//gcd(LCM,i)

    for i in List:
        if LCM//i%2==0:
            print(0)
            exit()

    print(int(M//(LCM*2)+M%(LCM*2)//LCM))


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

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    print(a.count(i+1))


### FIXED CODE ###

n = int(input())
a = [0]*(n)
for e in input().split():
    a[int(e)-1] += 1
[print(i) for i in a]
### BUGGY CODE ###

from functools import reduce
def do():
    n=int(input())
    l=list(map(int,input().split()))
    # k=1
    v=reduce(lambda x, y: x*y, l)
    if v > 1 * 10 ** 18:
        return -1
    return v
print(do())


### FIXED CODE ###

def do():
    n=int(input())
    l=list(map(int,input().split()))
    k=1
    if 0 in l:
        return 0
    for i in l:
        k*=i
        if k>1*10**18:
            return -1
    return k
print(do())
### BUGGY CODE ###

K = int(input())
sum = 0
class gcd:
    def __init__(self,a,b,c):
        self.a=a
        self.b=b
        self.c=c
        
    def gcds(self):
        if self.a>self.b:
            x=self.a
            y=self.b
        else:
            x=self.b
            y=self.a
            
        while x % y!=0:
            tem_y = y
            y = x % y 
            x = tem_y
       
        gcd_1 = y
        
        if gcd_1>self.c:
            x=gcd_1
            y=self.c
        else:
            x=self.c
            y=gcd_1
            
        while x % y!=0:
            tem_y = y
            y = x % y 
            x = tem_y
       
        return int(y)

for i in range(K):
    for j in range(K):
        for l in range(K):
            sum = sum + gcd(i+1,j+1,l+1).gcds()
            
print(sum)

### FIXED CODE ###

K = int(input())
sum = 0
class gcd:
    def __init__(self,a,b,c):
        self.a=a
        self.b=b
        self.c=c
        
    def gcds(self):
        if self.a>self.b:
            x=self.a
            y=self.b
        else:
            x=self.b
            y=self.a
            
        while x % y!=0:
            tem_y = y
            y = x % y 
            x = tem_y
       
        gcd_1 = y
        
        if gcd_1>self.c:
            x=gcd_1
            y=self.c
        else:
            x=self.c
            y=gcd_1
            
        while x % y!=0:
            tem_y = y
            y = x % y 
            x = tem_y
       
        return int(y)

for i in range(1,K+1):
    for j in range(i,K+1):
        for l in range(j,K+1):
            if i==j and j==l:
                sum = sum + gcd(i,j,l).gcds()
            elif i != j and j==l:
                sum = sum + gcd(i,j,l).gcds()*3
            elif i==j and j!= l:
                sum = sum + gcd(i,j,l).gcds()*3
            elif i!=j and j!=l:
                sum = sum + gcd(i,j,l).gcds()*6         
            
print(sum)
### BUGGY CODE ###

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

nai = sorted(nai, key=lambda x: -x[1])

ans = 0
aru = []
spe = set()
m = 0

for i in range(k):
    anstmp = nai.pop(0)
    if(anstmp[0] not in spe):
        ans+=anstmp[1]
        spe.add(anstmp[0])
    else:
        aru.append(anstmp[1])

m = ans + sum(aru) + len(spe)**2

for i in range(len(nai)):
    if(len(aru) == 0): break
    if(nai[i][0] not in spe):
        aru.pop()
        ans+=nai[i][1]
        spe.add(nai[i][0])
    m = max(m, ans + sum(aru) + len(spe)**2)
print(m)


### FIXED CODE ###

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

nai = sorted(nai, key=lambda x: -x[1])

ans = 0
aru = []
spe = set()
m = 0
for i in range(k):
    anstmp = nai.pop(0)
    if(anstmp[0] not in spe):
        ans+=anstmp[1]
        spe.add(anstmp[0])
    else:
        aru.append(anstmp[1])
sumaru = sum(aru)
m = ans + sumaru + len(spe)**2

for i in range(len(nai)):
    if(len(aru) == 0): break
    if(nai[i][0] not in spe):
        sumaru-=aru.pop()
        ans+=nai[i][1]
        spe.add(nai[i][0])
    m = max(m, ans + sumaru + len(spe)**2)
print(m)
### BUGGY CODE ###

a, b, k = map(int, input().split())
num = [i for i in range(a, b+1)]
first_k = num[:k]
latter_k = num[-k:]

for i in first_k:
    print(i)
for i in latter_k:
    if i not in first_k:
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
length = b+1 -a
num = []

for i in range(a, min(b, a+k-1)+1):
    print(i)
    num.append(i)
for i in range(max(a, b - (k-1)), b+1):
    if i not in num:
        num.append(i)
        print(i)
### BUGGY CODE ###

H,W = map(int,input().split())
S = []
for i in range(H):
    S += [['#'] + list(input()) + ['#']]
S = [['#' for i in range(W+2)]] + S + [['#' for i in range(W+2)]]

ans,v = 0,[0 for i in range(W)]
for i in range(1,W+1):
    k = 1
    while S[k][i] == '.':
        k += 1
    v[i-1] = k - 1

for i in range(1,H+1):
    j,dot = 1,0
    while j < W+1:
        while S[i][j] == '.':
                dot += 1
                j += 1
        for k in range(j-dot,j):
            if ans < dot + v[k-1]:    ans = dot + v[k-1]

        dot = 0
        k = i+1
        if j < W+1:
            while S[k][j] == '.':
                k += 1
            v[j-1] = k - i - 1
            j += 1 
print(ans-1)    



### FIXED CODE ###

H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)
### BUGGY CODE ###

def delete(l, num):
    for i, x in enumerate(l):
        if x == num:
            return l[0:i] + l[i+1:]
    return l


n = int(input())
l = []
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        l = [int(com[1])] + l
    elif com[0] == 'delete':
        l = delete(l, int(com[1]))
    elif com[0] == 'deleteFirst':
        l = l[1:]
    elif com[0] == 'deleteLast':
        l = l[:-1]
print(*l)

### FIXED CODE ###

import collections
q = collections.deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop()
print(*q)
### BUGGY CODE ###

import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


x = ni()
s= [[] for i in range(26)]
sum=0
for i in range(x):
    si=ns()
    sn=ord(si[0:1])-97
    if si not in s[sn]:
       s[sn].append(si)
for s1 in s:
    sum+=len(s1)
print(sum)

### FIXED CODE ###

import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


x = ni()
s= [[[] for j in range(26)] for i in range(26)]
sum=0
for i in range(x):
    si=ns()
    sn1=ord(si[0:1])-97
    if len(si)==1:
        sn2=0
    else:
        sn2 = ord(si[1:2]) - 97
    if si not in s[sn1][sn2]:
       s[sn1][sn2].append(si)
for s1 in s:
    for s2 in s1:
        sum+=len(s2)
print(sum)