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

from collections import deque
s=deque(list(input()))
q=int(input())
direction=0 #0:順 1:逆

for i in range(q):
    query=input()
    if query[0]=='1':
        direction=direction^1
    elif query[0]=='2':
        i,f,c=query.split()
        if f=='1' and direction==0:
            s.appendleft(c)
        elif f=='1' and direction==1:
            s.append(c)
        elif f=='2' and direction==0:
            s.append(c)
        elif f=='2' and direction==1:
            s.appendleft(c)


if direction==0:
    print(''.join(s))
else:
    x=[]
    for i in range(len(s)):
        x.append(s[-1-i])
    print(''.join(x))

### FIXED CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
direction=0 #0:順 1:逆

for i in range(q):
    query=input()
    if query[0]=='1':
        direction=direction^1
    elif query[0]=='2':
        i,f,c=query.split()
        if f=='1' and direction==0:
            s.appendleft(c)
        elif f=='1' and direction==1:
            s.append(c)
        elif f=='2' and direction==0:
            s.append(c)
        elif f=='2' and direction==1:
            s.appendleft(c)


if direction==0:
    print(''.join(s))
else:
    x=[]
    for i in range(len(s)):
        x.append(s[-1-i])
    print(''.join(x))
### BUGGY CODE ###

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data
primes = get_sieve_of_eratosthenes(1000000)
smallprimes = [x for x in primes if x < 1000]
used = {}
for prime in primes:
    used[prime] = 0

n = int(input())
a = map(int, input().split())
for ai in a:
    for smallprime in smallprimes:
        if ai % smallprime == 0:
            used[smallprime] += 1
    if ai in primes and ai not in smallprimes:
        used[ai] += 1
pairwise = True
setwise = True
for prime in used:
    if used[prime] > 1:
        pairwise = False
    if used[prime] == n:
        setwise = False
if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

from collections import defaultdict
max = 10 ** 6
sieve = [None] * (max + 1)
for i in range(2, max + 1):
    if sieve[i] == None: # i is prime
        for ki in range(i, max + 1, i):
            sieve[ki] = i
def factors(n):
    while True:
        if sieve[n] is None:
            break
        yield sieve[n]
        n //= sieve[n]
used = defaultdict(lambda:0)

n = int(input())
a = map(int, input().split())
for ai in a:
    for factor in set(factors(ai)):
        used[factor] += 1
pairwise = True
setwise = True
for prime in used:
    if used[prime] > 1:
        pairwise = False
    if used[prime] == n:
        setwise = False
if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
count = n
a = 0
b = 0
# a: R->W, b: W->Rの回数
for i in range(n+1):
  if i == 0:
    a = c.count("R")
    ans = max(a, b)
    count = min(ans, count)
  else:
    a = a - c[0:i].count("R")
    b = b + c[0:i].count("W")
    ans = max(a, b)
    count = min(ans, count)
print(count)
 


### FIXED CODE ###

n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
a = c.count("R")
b = 0
count = max(a, b)
# a: R->W, b: W->Rの回数
for i in range(n):
  if c[i] == "R":
    a = a - 1
  else:
    b = b + 1
  ans = max(a, b)
  count = min(ans, count)
print(count)
### BUGGY CODE ###

# coding: utf-8
s=input()
n=len(s)
cnt=0
while "ST" in s:
    s=s.replace("ST", "")
    cnt+=1
    #print(s)
print(len(s))

### FIXED CODE ###

# coding: utf-8
from collections import deque
s=input()
n=len(s)
A=deque()
for i in range(n):
    if s[i]=="S":
        A.append(s[i])
    else:
        if len(A)==0:
            A.append(s[i])
        elif A[-1]=="S":
            A.pop()
        else:
            A.append(s[i])
print(len(A))
### BUGGY CODE ###

import bisect
n = int(input())
a = sorted(map(int,input().split()))
b = sorted(map(int,input().split()))
c = sorted(map(int,input().split()))
ans = 0
for i in b:
  a_ind = bisect.bisect_left(a,i)
  c_ind = bisect.bisect_right(c,i)
  ans += len(a[:a_ind])*len(c[c_ind:])
print(ans)

### FIXED CODE ###

import bisect
n = int(input())
a = sorted(map(int,input().split()))
b = sorted(map(int,input().split()))
c = sorted(map(int,input().split()))
ans = 0
for i in b:
  a_ind = bisect.bisect_left(a,i)
  c_ind = bisect.bisect_right(c,i)
  ans += a_ind*(n-c_ind)
print(ans)
### BUGGY CODE ###

h, w = map(int, input().split())
ls = [input().strip() for _ in range(h)]
counts = [[[-1] * w for _ in range(h)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        if ls[y][x] == '#':
            counts[0][y][x] = 0
        else:
            if x == 0:
                counts[0][y][x] = 1
            else:
                counts[0][y][x] = counts[0][y][x - 1] + 1
for y in range(h - 1, -1, -1):
    for x in range(w - 1, -1, -1):
        if ls[y][x] == '#':
            counts[1][y][x] = 0
        else:
            if x == w - 1:
                counts[1][y][x] = 1
            else:
                counts[1][y][x] = counts[1][y][x + 1] + 1
for x in range(w):
    for y in range(h):
        if ls[y][x] == '#':
            counts[2][y][x] = 0
        else:
            if y == 0:
                counts[2][y][x] = 1
            else:
                counts[2][y][x] = counts[2][y - 1][x] + 1
for x in range(w - 1, -1, -1):
    for y in range(h - 1, -1, -1):
        if ls[y][x] == '#':
            counts[3][y][x] = 0
        else:
            if y == h - 1:
                counts[3][y][x] = 1
            else:
                counts[3][y][x] = counts[3][y + 1][x] + 1

res = 0
for y in range(h):
    for x in range(w):
        val = -3
        for i in range(4):
            val += counts[i][y][x]
        res = max(res, val)

print(res)

### FIXED CODE ###

h, w = map(int, input().split())
ls = [input().strip() for _ in range(h)]
counts = [[[-1] * w for _ in range(h)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        if ls[y][x] == '#':
            counts[0][y][x] = 0
        else:
            if x == 0:
                counts[0][y][x] = 1
            else:
                counts[0][y][x] = counts[0][y][x - 1] + 1
        yy = h - 1 - y
        xx = w - 1 - x
        if ls[yy][xx] == '#':
            counts[1][yy][xx] = 0
        else:
            if x == 0:
                counts[1][yy][xx] = 1
            else:
                counts[1][yy][xx] = counts[1][yy][xx + 1] + 1

        if ls[y][x] == '#':
            counts[2][y][x] = 0
        else:
            if y == 0:
                counts[2][y][x] = 1
            else:
                counts[2][y][x] = counts[2][y - 1][x] + 1
        yy = h - 1 - y
        xx = w - 1 - x
        if ls[yy][xx] == '#':
            counts[3][yy][xx] = 0
        else:
            if y == 0:
                counts[3][yy][xx] = 1
            else:
                counts[3][yy][xx] = counts[3][yy + 1][xx] + 1

res = 0
for y in range(h):
    for x in range(w):
        val = -3
        for i in range(4):
            val += counts[i][y][x]
        res = max(res, val)

print(res)
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.array([-1 for _ in range(N)])

dp[0] = 0

for i in range(1, N):
    start = max(0, i-K)
    dp[i] = np.min([dp[start:i] + np.abs(h[i] - h[start:i])])

print(dp[-1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

# dp = np.array([-1 for _ in range(N)])
dp = np.zeros(N, dtype=int)

dp[0] = 0

for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

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

from math import gcd
g=[201*[0]for _ in range(201)]
for i in range(1,201):
  for j in range(i,201):
    g[i][j]=gcd(i,j)
ans=0
for i in range(1,201):
  for j in range(1,201):
    for k in range(1,201):
      m=g[min(i,j)][max(i,j)]
      ans+=g[min(k,m)][max(k,m)]
print(ans)


### FIXED CODE ###

def gcd(a,b):
  while b:a,b=b,a%b
  return a
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ans+=gcd(i,gcd(j,k))
print(ans)
### BUGGY CODE ###

import math
import sys

K = int(sys.stdin.readline())
ans = 0

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

print(ans)

### FIXED CODE ###

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

#i<j<k
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            gcd_ij_1 = math.gcd(i, j)
            gcd_ijk_1 = math.gcd(gcd_ij_1, k)
            ans = ans + gcd_ijk_1 * 6

for l in range(1, K):
    for m in range(l+1, K+1):
        gcd_lm_1 = math.gcd(l,m)
        ans = ans + gcd_lm_1 * 6

for n in range(1, K+1):
    ans = ans + n

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

s = input()
number = 0
for i in range(0,len(s)- 3):
    for j in range(i+4,len(s)):
        sum = 0
        for k in range(j-i+1):
            sum = sum + int(s[j- k]) * (10 ** (k))
        if sum % 2019 == 0:
            number = number + 1
print(number)
         

### FIXED CODE ###

s = input()
t = 0
number = 0
#m = [0 for i in range(2019)]
m = [0]*2019
m[0] = 1
a = 1
for i in range(len(s)):
    t = t  +  int(s[len(s) - 1 - i])* a 
    #print(t)
    m[t % 2019] += 1
    a = a * 10
    a = a % 2019
    #print(t%2019)

for j in range(2019):
    #if m[j]>= 2:
    number += (m[j]*(m[j] - 1))//2

print(number)
### BUGGY CODE ###

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

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (l[i] < l[j]+l[k]) and (l[j] < l[i] +l[k]) and (l[k] < l[i] + l[j]):
                a += 1

print(a)

### FIXED CODE ###

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

N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,50):  
        for y in range(x,50):
            for z in range(y,50):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n:
                    if x==y and x==z:
                        s=s+1
                    if x<y and y==z:
                        s=s+3
                    if x==y and y<z:
                        s=s+3              
                    if x<y and y<z:
                        s=s+6    
    print(s)    

### FIXED CODE ###

N=int(input())
ans=[0]*(N+1)
for x in range(1,101):  
    for y in range(1,101):
        for z in range(1,101):
            fn=x**2+y**2+z**2+x*y+y*z+z*x
            if fn>N:
                break
            else:
                ans[fn]=ans[fn]+1
for n in range(1,N+1):
    print(ans[n])
### BUGGY CODE ###

n=int(input())
ans=0
arr=[0]
arr+=list(map(int,input().split()))
arr+=[0]
for i in range(1,n+1):
  tl=0
  tr=0
  for j in range(i-1,-1,-1):
    if arr[j]>arr[i]:
      tl+=1
    else:
      break
  for j in range(i+1,n+1):
    if arr[j]>arr[i]:
      tr+=1
    else:
      break
  ans+=arr[i]*(tl+1)*(tr+1)
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
arr=list(map(int,input().split()))
pos=[0]*(n+1)
for i in range(n):
  pos[arr[i]]=i
l=[i for i in range(n+1)]
r=[i for i in range(n+1)]
for i in range(n,0,-1):
  idx=pos[i]
  tl,tr=l[idx],r[idx]
  ans+=i*(idx-tl+1)*(tr-idx+1)
  l[tr+1]=tl
  r[tl-1]=tr
print(ans)
### BUGGY CODE ###

N = int(input())

def gk(n):
    ans = 0
    while n:
        ans += 1
        n//=10
    return ans

if int(N**(1/2)) ** 2 == N:
    print( gk( int(N**(1/2)) ))
else:
    for i in range( int(N**(1/2)), N+1):
        if N % i == 0:
            print( gk(i) )
            exit(0)



### FIXED CODE ###

N = int(input())

def gk(n):
    ans = 0
    while n:
        ans += 1
        n //= 10
    return ans


ans = float("inf")
for i in range(1, int(N**(1/2))+1):
    if N % i == 0:
        ans = min(ans,gk( N//i)) 
print(ans)
exit(0)


lst = []
for i in range(2,int(N**(1/2))+1):
    if N % i == 0:
        ans = 0
        while N % i == 0:
            ans += 1
            N //= i
        lst.append( (i,ans) )

cand = [1]
while lst:
    p,cnt = lst.pop()
    nl = []
    # for p ==
### BUGGY CODE ###


import sys
sys.setrecursionlimit(10000000)

N, Q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
px = [list(map(int,input().split())) for _ in range(Q)]

tree = [[] for _ in range(N+1)]
for a, b in ab:
  tree[a] += [b]
  #tree[b] += [a]

def isList(item):
  if not item:
    return False
  return isinstance(item, list)

from collections import deque

d = deque()
def f(arr, n):
  global d
  if not arr:
    return
  for pp in arr if type(arr) == list else arr.popleft():
    if isList(tree[pp]):
      d.append(tree[pp])
      counter[pp] += n
    else:
      counter[pp] += n
  if d:
    return f(d, n)

counter = [0] * (N+1)
for p, x in px:
  f(tree[p], x)
  counter[p] += x
print(*counter[1:])

### FIXED CODE ###

import sys

stdin = sys.stdin
na = lambda: map(int, stdin.readline().split())

def main():
  N, Q = na()

  ab = []
  for _ in range(N-1):
    a, b = na()
    ab.append([a, b])
  ab.sort()

  counter = [0] * (N+1)
  for _ in range(Q):
    p, x = na()
    counter[p] += x
  for i in range(N - 1):
    counter[ab[i][1]] += counter[ab[i][0]]
  print(*counter[1:])

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

X,Y,A,B,C = map(int,input().split())

p = sorted(list(map(int,input().split()))) #A
q = sorted(list(map(int,input().split()))) #B
r = sorted(list(map(int,input().split()))) #C

xlist = p[-X:] #X
ylist = q[-Y:] #Y

def main(X,Y,A,B,C):
    for i in range(min(X,Y)):
        if xlist[i] < ylist[i] and min(xlist) < max(r):
            xlist.remove(min(xlist))
            xlist.append(max(r))
            r.pop()
        elif ylist[i] < xlist[i] and min(ylist) < max(r):
            ylist.remove(min(ylist))
            ylist.append(max(r))
            r.pop()
        else:
            continue
    
    print(sum(xlist)+sum(ylist))

main(X,Y,A,B,C)

### FIXED CODE ###

X,Y,A,B,C = map(int,input().split())

p = sorted(list(map(int,input().split()))) #A
q = sorted(list(map(int,input().split()))) #B
r = sorted(list(map(int,input().split()))) #C

xlist = p[-X:] #X
ylist = q[-Y:] #Y

"""
def main(X,Y,xlist,ylist,r):
    for i in range(min(X,Y)):
        if xlist[i] < ylist[i] and min(xlist) < max(r):
            xlist.remove(min(xlist))
            xlist.append(r.pop())
            
        elif ylist[i] < xlist[i] and min(ylist) < max(r):
            ylist.remove(min(ylist))
            ylist.append(r.pop())
            
        elif min(xlist) >= max(r) and min(ylist) >= max(r):
            break
        else:
            continue
    
    print(sum(xlist + ylist))

main(X,Y,xlist,ylist,r)
"""
all_apples = sorted(xlist + ylist + r)
print(sum(all_apples[-(X+Y):]))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
n = len(A)
ans = 0
x = 0
y = 0
for i in range(n - 1):
    B = A[i + 1:n]
    x = sum(B)
    y = (A[i] * x)
    ans += y
ans = ans % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0

x = sum(A)
x = x ** 2
for i in A:
    y = i * i
    x -= y

x = x // 2
x = x % z
print(x)
### BUGGY CODE ###

r=range;x,y,z,k=map(int,input().split())
a,b,c=eval("list(map(int,input().split())), "*3)
ab=sorted([a[i]+b[j]for i in r(x)for j in r(y)],reverse=True)
abc=sorted([ab[i]+c[j]for i in r(min(3000,x*y))for j in r(z)],reverse=True)
print(*[abc[i]for i in r(k)])

### FIXED CODE ###

r=range;x,y,z,k=map(int,input().split())
a,b,c=eval("list(map(int,input().split())), "*3)
ab=sorted([a[i]+b[j]for i in r(x)for j in r(y)],reverse=True)
abc=sorted([ab[i]+c[j]for i in r(min(3000,x*y))for j in r(z)],reverse=True)
print(*[abc[i]for i in r(k)])
### BUGGY CODE ###

from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

def pne(n):
    print(n,end='')

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
n,q= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
gatacca = ["A","C","T","G"]
pa = []
pc = []
for i in range(n-1):
    if a[i] == "A" and a[i+1] == "C":
        pa.append(i)
for i in range(q):
    dna = copy.copy(pa)
    left,right =  (int(i) for i in input().split())
    left-=1.5
    right-=1.5
    dna.append(left)
    dna.append(right)
    dna.sort()
    lp = dna.index(left)
    rp = dna.index(right)

    print(len(dna[lp:rp])-1)


### FIXED CODE ###

from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

def pne(n):
    print(n,end='')

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
n,q= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
gatacca = ["A","C","T","G"]
pa = [0]
pc = []
s = 0
for i in range(n-1):
    if a[i] == "A" and a[i+1] == "C":
        s+=1
    pa.append(s)
for i in range(q):
    left,right =  (int(i) for i in input().split())
    right-=1
    left-=1
    print(pa[right]-pa[left])
### BUGGY CODE ###

from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
ans = sorted([(k,v) for k,v in Counter(S).items() if max(Counter(S).values()) == v], key=lambda x: (-x[1], x[0]))
[print(k[0])for k in ans]

### FIXED CODE ###

from collections import Counter

N = int(input())
c = Counter()
l = 0
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
    if l < c[k]:
        l = c[k]
ans = sorted([k for k, n in c.items() if n==l])
[print(k) for k in ans]
### BUGGY CODE ###

n = input()
dishes = [[], []]
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    # dish.append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1], i))
    dishes[0].append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1], i))
    dishes[1].append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1], i))

# dishes = [copy.deepcopy(dish), copy.deepcopy(dish)]
sorted(dishes[0], key=lambda v: v[0], reverse=True)
sorted(dishes[1], key=lambda v: v[1], reverse=True)

point = [0, 0]
player = 0
while len(dishes[0]) > 0:
    dish = dishes[player].pop(0)

    # remove dish
    dishes[int(not player)].remove(dish)

    point[player] += dish[player + 2]
    player = int(not player)
print(point[0] - point[1])


### FIXED CODE ###

n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] + tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    dish = dishes.pop(0)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])
### BUGGY CODE ###

def solve(x):
    cnt = 1
    while x > 0:
        count = 0
        y = x
        while y > 0:
            count += (y%2==1)
            y >>= 1
        x %= count
        cnt += 1
    return cnt

n = int(input())
x = input()
one = x.count('1')
num = int(x, 2)

up = num%(one+1)
if one == 1:
    down = 0
else:
    down = num%(one-1)
z = 2**(n-1)
for i in range(n):
    if x[i] == '1':
        if one == 1:
            print(0)
            z //= 2
            continue
        s = down - z%(one-1)
        if s < 0:
            s += one-1
    else:
        s = (up + z%(one+1))%(one+1)
    print(solve(s))
    z //= 2

### FIXED CODE ###

def solve(x):
    cnt = 1
    while x > 0:
        x %= bin(x).count('1')
        cnt += 1
    return cnt

n = int(input())
x = input()
one = sum(map(int, list(x)))
num = int(x, 2)

up = num%(one+1)
if one == 1:
    down = 0
else:
    down = num%(one-1)

for i in range(n):
    if x[i] == '1':
        if one == 1:
            print(0)
            continue
        s = (down - pow(2, n-i-1, one-1))%(one-1)
    else:
        s = (up + pow(2, n-i-1, one+1))%(one+1)
    print(solve(s))
### BUGGY CODE ###

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
S =sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

def nibun_insert(lis, item):
  end = len(lis)
  start = 0
  now = (end+start)//2
  while end > start+1:
    if lis[now][0] > item[0]:
      start = 0 + now
      now = (now + end)//2
    else:
      end = 0 + now
      now = (now + start)//2
  return lis[:now+1] + [item] + lis[now+1:]
  

C = sum(cut)
res = min(K - C, 10**6)
length = length[:res+1]
for k in range(res):
  cut[length[0][1]] += 1
  length[0][0] = length[0][0]*cut[length[0][1]]/(cut[length[0][1]]+1)
  if length[0][0] < length[1][0]:
    length = nibun_insert(length[1:], length[0])

   
print(math.ceil(length[0][0]))


### FIXED CODE ###

import math
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
S =sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

def nibun_insert(lis, item):
  end = len(lis)
  start = 0
  now = (end+start)//2
  while end > start+1:
    if lis[now][0] > item[0]:
      start = 0 + now
      now = (now + end)//2
    else:
      end = 0 + now
      now = (now + start)//2
  return deque(lis[:now+1] + [item] + lis[now+1:])
  

C = sum(cut)
res = min(K - C, N)
length = length[:res+1]
length = deque(length)
for k in range(res):
  a = length.popleft()
  cut[a[1]] += 1
  a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
  if a[0] <= length[-1][0]:
    length.append(a)
  elif a[0] >= length[0][0]:
    length.appendleft(a)
  else:
    length = nibun_insert(list(length), list(a))
  length.pop()

print(math.ceil(length.popleft()[0]))
### BUGGY CODE ###

num = int(input())

if num>=1 and num<=200000:
  str_list = []
  kind = 0
  for idx in range(num):
    input_str = input()
    if len(input_str)>10:
      continue
    if input_str not in str_list:
      str_list.append(input_str)
      kind += 1
    else:
      pass
  print(kind)

### FIXED CODE ###

n = int(input())

l = []
for _ in range(n):
    l.append(input())
print(len(set(l)))