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

H, W, K = map(int, input().split())
s = []
for _ in range(H):
    *row, = map(int, input())
    s.append(row)

ret = H * W
for bits in range(1 << (H - 1)):
    # 水平カットで生成される2枚目以降の開始行
    # 0行目は確定で, 残りのカットを調べる
    # 次の変換が必要
    # [0,H) -> [1,H]

    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + (1 if (bits >> j) & 1 else 0)
    # group = [0,0,1,1,1,2,...]

    ctr = [0] * H
    add_v = [0] * H
    c = 0
    cut = bin(bits).count('1')
    while c < W:
        need_cut = False
        for r in range(H):
            g = group[r]
            add_v[g] += s[r][c]
            if ctr[g] + add_v[g] > K:
                need_cut = True
                break

        if need_cut:
            ctr = [0] * H
            add_v = [0] * H
            cut += 1
            continue

        for r in range(H):
            g = group[r]
            ctr[g] += add_v[g]
            add_v[g] = 0
        c += 1

    ret = min(ret, cut)

print(ret)


### FIXED CODE ###

H, W, K = map(int, input().split())
s = []
for _ in range(H):
    *row, = map(int, input())
    s.append(row)

ret = H * W
for bits in range(1 << (H - 1)):
    # 水平カットで生成される2枚目以降の開始行
    # 0行目は確定で, 残りのカットを調べる
    # 次の変換が必要
    # [0,H) -> [1,H]

    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + (1 if (bits >> j) & 1 else 0)
    # group = [0,0,1,1,1,2,...]

    ctr = [0] * H
    add_v = [0] * H
    c, pc = 0, -1
    cut = bin(bits).count('1')
    while c < W:
        need_cut = False
        for r in range(H):
            g = group[r]
            add_v[g] += s[r][c]
            if ctr[g] + add_v[g] > K:
                need_cut = True
                break

        if need_cut:
            if pc == c:
                cut = H * W
                break
            ctr = [0] * H
            add_v = [0] * H
            cut += 1
            pc = c
            if cut >= ret:
                break
            continue

        for g, _add_v in enumerate(add_v):
            ctr[g] += _add_v
        add_v = [0] * H
        pc = c
        c += 1

    ret = min(ret, cut)

print(ret)
### BUGGY CODE ###

import copy
H,W,K=map(int,input().split())
S=[]
for _ in range(H):
    S.append([int(x) for x in list(input())])

ans=(H-1)+(W-1)

for i in range(2**(H-1)):
    check=[0]*H
    for j in range(H-1):
        if ((i>>j)&1):
            check[j+1]=check[j]+1
        else:
            check[j+1]=check[j]
    
    g=check[H-1]+1
    A=[0]*g
    c=0
    f=0
    for j in range(W):
        B=[0]*g
        for k in range(H):
            if S[k][j]==1:
                B[check[k]]+=1
            if B[check[k]]>K:
                c=10**4
                f=1
                break
        if f:
            break
        #print("AB",A,B)
        for l in range(g):
            if B[l]==0:
                continue
            elif A[l]+B[l]>K:
                c+=1
                A=copy.copy(B)
                break
            else:
                A[l]+=B[l]
    ans=min(ans,c+g-1)

print(ans)




### FIXED CODE ###

import copy
H,W,K=map(int,input().split())
S=[]
for _ in range(H):
    S.append([int(x) for x in list(input())])

ans=(H-1)+(W-1)

for i in range(2**(H-1)):
    check=[0]*H
    for j in range(H-1):
        if ((i>>j)&1):
            check[j+1]=check[j]+1
        else:
            check[j+1]=check[j]
    
    g=check[H-1]+1
    A=[0]*g
    c=0
    f=0
    for j in range(W):
        B=[0]*g
        for k in range(H):
            if S[k][j]==1:
                B[check[k]]+=1
            if B[check[k]]>K:
                c=10**4
                f=1
                break
        if f:
            break
        #print("AB",A,B)
        for l in range(g):
            if A[l]+B[l]>K:
                c+=1
                A=copy.copy(B)
                break
            else:
                A[l]+=B[l]
    ans=min(ans,c+g-1)

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

def digits (n):
    digits = []
    while n != 0:
        r = n % 10
        digits.append(r)
        n = n // 10 
    return digits

def check (n):
    sum = 0
    for i in digits (n):
        sum += i
    return sum % 9 == 0

n = int(input())
result = check(n)

if result == True:
    result = "Yes"
else:
    result = "No"
print(result)

### FIXED CODE ###

n = int(input())
result = n % 9

if result == 0:
    result = "Yes"
else:
    result = "No"
print(result)
### BUGGY CODE ###

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    if 0 in inlis:
        ans = 0
    else:
        ans = 1
    for i in inlis:
        ans *= i
        #print(ans)
        if ans > 10 ** 18:
            ans = -1
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    inlis = list(map(int, input().split()))
    if 0 in inlis:
        ans = 0
    else:
        ans = 1
        for i in inlis:
            ans *= i
            #print(ans)
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,Q = II()
a,b = Line(N-1)
p,x = Line(Q)

for i in range(N-1):
    a[i] -= 1
    b[i] -= 1

for i in range(Q):
    p[i] -= 1


#深さ優先探索
def dfs(pt,v):
    '''
    input
        pt: 各点との結合場所を格納した2次元配列　pt=[[1, 2, 3], [0], [5, 0], [6, 0], [6], [2], [3, 4]]
        v: 初期点 v=0

    output
        d: 初期点からの距離を格納した配列 d=[0, 1, 1, 1, 3, 2, 2]
    '''
    n=len(pt)
    d=[-1]*n
    check_visited = [False]*n
    check_visited[v] = True
    S = [v]
    d[v] = 0
    while S:
        v1 = S.pop()
        for i in pt[v1]:
            if check_visited[i] == False:
                check_visited[i] = True
                d[i] = d[v1] + 1
                S.append(i)
    return d


pt = [[] for _ in range(N)]
for i in range(N-1):
    pt[a[i]].append(b[i])
    pt[b[i]].append(a[i])
d = dfs(pt,0)

parent = defaultdict(list)
for i in range(N-1):
    if d[a[i]]>d[b[i]]:
        parent[a[i]].append(b[i])
    else:
        parent[b[i]].append(a[i])

val = [0]*N
for i in range(Q):
    val[p[i]] += x[i]

for i in range(N):
    now = i
    ans = 0
    while now != 0:
        ans += val[now]
        now = parent[now][0]
    print(val[0]+ans)

### FIXED CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,Q = II()
a = [0]*(N-1)
b = [0]*(N-1)
p = [0]*Q
x = [0]*Q

for i in range(N-1):
    a1,b1 = II()
    a[i] = a1-1
    b[i] = b1-1

for i in range(Q):
    p1,x1 = II()
    p[i] = p1-1
    x[i] = x1


parent = defaultdict(list)
for i in range(N-1):
    parent[b[i]].append(a[i])

val = [0]*N
for i in range(Q):
    val[p[i]] += x[i]

for i in range(1,N):
    val[i] += val[parent[i][0]]

print(*val)
### BUGGY CODE ###

n, k = [int(x) for x in input().split()]
seq = [int(x) for x in input().split()]
dp = [0]*n
k = min(k, n)
for i in range(1, k):
    dp[i] = abs(seq[i] - seq[0])
# print(dp)
for i in range(k, n):
    a = dp[i-1] + abs(seq[i] - seq[i-1])
    for j in range(k-1):
        a = min(a, dp[i-2-j] + abs(seq[i] - seq[i-2-j]))
    dp[i] = a
# print(dp)
print(dp[-1])

### FIXED CODE ###

n, k = [int(x) for x in input().split()]
seq = [int(x) for x in input().split()]
dp = [0]*n
k = min(k, n)
for i in range(1, k):
    dp[i] = abs(seq[i] - seq[0])
# print(dp)
for i in range(k, n):
    a = dp[i-1] + abs(seq[i] - seq[i-1])
    for j in range(k-1):
        a = min(a, dp[i-2-j] + abs(seq[i] - seq[i-2-j]))
    dp[i] = a
# print(dp)
print(dp[-1])
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(map(int, list(input())))
mod = 2019
lens = len(S)
mods = [0]*lens
cum = 0
for i in range(lens):
    s = S[-i-1]
    cum += s*(10**i)
    cum %= mod
    mods[i] = cum
mods += [0]
from collections import Counter
c = Counter(mods)

ans = 0
for num, cnt in c.most_common():
    if cnt<2:
        break
    ans += cnt*(cnt-1)//2
print(ans)

### FIXED CODE ###

S = list(input())[::-1]
L = len(S)
from collections import defaultdict

mod = 2019
t = 0
dic = defaultdict(int)
ans = 0
for l in range(L):
    t += pow(10, l, mod)*int(S[l])%mod
    t %= mod
    ans += dic[t]
    dic[t] += 1
    if t==0:
        ans += 1

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

def sub_c():
    n = int(input())
    a_list = list(map(int, input().split()))

    a_tuple_list = []
    for i, a in enumerate(a_list):
        temp = (a, i)
        a_tuple_list.append(temp)
    a_tuple_list.sort()

    ret = ''
    for t in a_tuple_list:
        ret += str(t[1]+1) + ' '
    print(ret)


if __name__ == '__main__':
    sub_c()


### FIXED CODE ###

def sub_c():
    n = int(input())
    a_list = list(map(int, input().split()))

    a_tuple_list = []
    for i, a in enumerate(a_list):
        temp = (a, i)
        a_tuple_list.append(temp)
    a_tuple_list.sort()

    ret = ''
    for t in a_tuple_list:
        ret += str(t[1]+1) + ' '
    print(ret)


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

n = int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(1,n):
    for j in range(n-i):
        if j+i>n-1:
            break
        if A[j]+A[j+i]==i:
            cnt+=1
print(cnt)

### FIXED CODE ###

n = int(input())
A=list(map(int,input().split()))
cnt=0
B=[]
C=[]
for i,a in enumerate(A):
    B.append(A[i]+i)
    C.append(A[i]-i)
from collections import Counter
Bd=dict(Counter(B))
Cd=dict(Counter(C))
cnt=0
for k in Bd.keys():
    try:
        cnt+=Bd[k]*Cd[-k]
    except KeyError:
        continue
print(cnt)
### BUGGY CODE ###

import sys

# n = 10 ** 5
# データ読み込み関係
n = int(input())

a = list(map(int, input().split(' ')))

l = [0] * n

# 基本的な状況のリストを作成
for i in range(n):
    l[i] = abs((n - 1 - i) - i)

possible = True

# 報告状況が実現可能か確認
for e in l:
    if e in a:
        a.remove(e)
    else:
        possible = False
        break

if(possible == False):
    print(0)
    sys.exit()

multiCount = int(n / 2)

print(2 ** multiCount % (10 ** 9 + 7))

### FIXED CODE ###

import sys

# n = 10 ** 5
# データ読み込み関係
n = int(input())

a = list(map(int, input().split(' ')))

record = {}

possible = True

# 状況が実現可能か確認
for e in a:
    if(e in record.keys()):
        record[e] += 1
        if(record[e] == 2):
            if(e == 0):
                possible = False
                break
        if(record[e] == 3):
            possible = False
            break
    else:
        record[e] = 1

if(possible == False):
    print(0)
    sys.exit()

multiCount = int(n / 2)

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

N = input()
A = input().split()
if '0' in A:
  print(0)
else:
  a = 1
  for i in A:
    a *= int(i)
  if a > 10**18:
      print(-1)
  else:
    print(a)

### FIXED CODE ###

N = input()
A = input().split()
if '0' in A:
  print(0)
else:
  a = 1
  for i in A:
    a *= int(i)
    if a > 10**18:
        print(-1)
        exit()
  else:
    print(a)
### BUGGY CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
dp=[[float('inf')]*2 for i in range(keta+1)]
dp[0]=[0,1]

for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
# dp=[[float('inf')]*2 for i in range(keta+1)]
dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            for i in range(N):
                if x != int(S[i]):
                    continue
                for j in range(i+1, N):
                    if y != int(S[j]):
                        continue
                    for k in range(j+1, N):
                        if z != int(S[k]):
                            continue
                        ans += z == int(S[k])
                        break
                    break
                break
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            for i in range(N):
                if x != int(S[i]):
                    continue
                for j in range(i+1, N):
                    if y != int(S[j]):
                        continue
                    for k in range(j+1, N):
                        if z != int(S[k]):
                            continue
                        ans += z == int(S[k])
                        break
                    break
                break
print(ans)
### BUGGY CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from collections import defaultdict

N,Q = map(int,input().split())
task = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x)) # xで止まらなくなる
  task.append((s-x,1,x)) # xで止まる

for i in range(Q):
  d = int(input())
  task.append((d,2,i)) # 止まる位置を答える
answer = [-1]*Q

task.sort()

# 引っかかってる場所の管理
se = set()
se_hp = [] # heapで最小値を先頭に保つ

# 小さい時刻から順に見ていく
for a,b,c in task:
  if not b: # b == 0
    se.remove(c)
  elif b&1: # b == 1
    se.add(c)
    heappush(se_hp,c)
  else: # b == 2
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

print('\n'.join(map(str,answer)))


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])
### BUGGY CODE ###

N = int(input())
A = [int(x) for x in input().split()]

DA = []
for v in A:
    d = 0
    while v & 1 == 0:
        v = v << 2
        d += 1
    DA.append(d)

print(min(DA))


### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]

DA = []
for v in A:
    d = 0
    while v%2 == 0:
        v //= 2
        d += 1
    DA.append(d)

print(min(DA))
### BUGGY CODE ###

N = int(input())
T = [int(input()) for _ in range(N)]

pnmax = {}

def pn(A):
	a = A
	for n in range(2, A + 1):
		if a == 1:
			return
		c = 0
		while not a % n:
			c += 1
			a //= n
		if 0 < c:
			if not n in pnmax:
				pnmax[n] = c
			else:
				pnmax[n] = max(pnmax[n], c)

for t in T:
	pn(t)

r = 1
for k, v in pnmax.items():
	r *= k ** v

#print(pnmax)
print(r)


### FIXED CODE ###

N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a, b):
	if not a % b:
		return b
	else:
		return gcd(b, a % b)

l = T[0]
for n in range(1, N):
	l = l * T[n] // gcd(l, T[n])

print(l)
### BUGGY CODE ###

S = input()
N = len(S)

ans_set1 = set()
ans_set2 = set()

for i in range(N+1):
    for j in range(i+3,N+1):
        if int(S[i:j]) % 673 == 0:
            ans_set1.add((i,j))

for i,j in ans_set1:
    if int(S[i:j]) % 3 == 0:
        ans_set2.add((i,j))

print(len(ans_set2))


### FIXED CODE ###

def cal(S):
    N = len(S)
    num,cnt = 0,0
    mod = 2019
    rem = [0 for _ in range(mod)]
    for i in range(N):
        num = (num + int(S[N-1-i]) * pow(10,i,mod)) % mod
        rem[num] += 1

    output = rem[0] * (rem[0] + 1) // 2
    for i in range(1,mod):
        output += rem[i] * (rem[i]-1) // 2

    return output

def main():
    S = input()

    print(cal(S))

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

s = input()
length=len(s)
l = int(len(s)/2)
def erase_01_10(moji):
  moji = moji.replace('01','').replace('0011','').replace('000111','').replace('00001111','').replace('0000011111','')
  moji = moji.replace('10','').replace('1100','').replace('111000','').replace('11110000','').replace('1111100000','')
  return moji
for i in range(l):
  if s == erase_01_10(s):
    break
  s = erase_01_10(s)
print(length-len(s))


### FIXED CODE ###

s = input()
length=len(s)
#print(s.count('0'))
#print(s.count('1'))
m=min(s.count('0'),s.count('1'))
print(2*m)
### BUGGY CODE ###

from collections import defaultdict as dd
import queue
import numpy as np
import sys
input = sys.stdin.readline
N, M, K = map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(M)]
cd = [tuple(map(int,input().split())) for _ in range(K)]
dic = dd(list)
for (a,b) in ab:
    dic[str(a)].append(b)
    dic[str(b)].append(a)
seen = set()
def BFS(dic,node):
    cc = set()
    q = queue.Queue()
    q.put(node)
    cc.add(node)
    while not q.empty():
        now_node = q.get()
        cc.add(now_node)
        target = set(dic[str(now_node)]) - cc
        for tgt in target:
            q.put(tgt)
    return cc
c_comp=np.zeros((N),dtype='int32')
len_ls = []
var = 1
for i in range(1,N+1):
    if c_comp[i-1] == 0:
        # 連結判定
        tmp = BFS(dic,i)
        c_comp[np.array(list(tmp))-1] = var
        len_ls.append(len(tmp)-1)
        var += 1
        # seen = seen & set(tmp)
        #c_comp.append(list(tmp))

#uf = [0]*N
#for i,ls in enumerate(c_comp):
#    for val in ls:
#        uf[int(val)-1] = i
for (a,b) in cd:
    if c_comp[a-1] == c_comp[b-1]:
        dic[str(a)].append(str(b))
        dic[str(b)].append(str(a))
res = [0]*N
"""
for ls in c_comp:
    leng = len(ls)-1
    for idx in ls:
        res[int(idx)-1] = leng - len(dic[idx])
"""
for i in range(N):
    res[i] = len_ls[c_comp[i]-1] - len(dic[str(i+1)])
print(*res)


### FIXED CODE ###

from collections import defaultdict as dd
import queue
import sys
input = sys.stdin.readline
N, M, K = map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(M)]
cd = [tuple(map(int,input().split())) for _ in range(K)]
dic = dd(list)
for (a,b) in ab:
    dic[str(a)].append(b)
    dic[str(b)].append(a)
uf = [-1]*N
def BFS(ufid, dic, node):
    leng = -1
    q = queue.Queue()
    q.put(node)
    while not q.empty():
        now_node = q.get()
        if uf[now_node-1] > 0:
            continue
        leng += 1
        uf[now_node-1] = ufid
        target = [val for val in dic[str(now_node)] if uf[val-1]==-1]
        for tgt in target:
            q.put(tgt)
            uf[tgt-1] = 0
    return leng

len_ls = []
var = 1
for i in range(N):
    if uf[i] == -1:
        # 連結判定
        leng = BFS(var, dic, i+1)
        len_ls.append(leng)
        var += 1
for (a,b) in cd:
    if uf[a-1] == uf[b-1]:
        dic[str(a)].append(b)
        dic[str(b)].append(a)
res = [len_ls[uf[i]-1] - len(dic[str(i+1)]) for i in range(N)]
print(*res)
### BUGGY CODE ###

N = int(input())

name = []
num = []

max_temp = 1

for _ in range(N):
    temp = input()
    if not temp in name:
        name.append(temp)
        num.append(1)
    else:
        x = name.index(temp)
        num[x] += 1
        if num[x] > max_temp:
            max_temp = num[x]
            
        
output = []

for i in range(len(num)):
    if num[i] == max_temp:
        output.append(name[i])
        
output.sort()

for i in range(len(output)):
    print(output[i])

### FIXED CODE ###

# coding cell (SUBMIT ONLY THIS CELL)

N = int(input())

counter = {}

for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})

m = max(counter.values())
        
ans = []    

for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()

for i in ans:
    print(i)
### BUGGY CODE ###

# const
M = 1046527

def h1(key):
    return key % M

def h2(key):
    return 1 + (key % (M-1))

def hash(key ,i):
    return (h1(key) + i*h2(key)) % M

def conv_str_to_num(str):
    converted = 0
    s_list = list(str)
    for (i,c) in enumerate(s_list):
        if c == 'A':
            n = 1
        elif c == 'C':
            n = 2
        elif c == 'G':
            n = 3
        elif c == 'T':
            n = 4
        else:
            n = 0

        converted += 5**i * n

    return converted



class hashTable(object):
    def __init__(self, arg):
        self.T = [""] * arg

    def insert(self, s):
        key = conv_str_to_num(s)
        i = 0
        while True:
            h = hash(key, i)
            if self.T[h] == "":
                self.T[h] = s
                break
            i += 1

    def find(self, s):
        key = conv_str_to_num(s)
        i = 0
        while True:
            h = hash(key, i)
            if self.T[h] == s:
                return 1
            elif self.T[h] == "":
                return 0

            i += 1
        return 0


if __name__ == '__main__':
    h_t = hashTable(M)
    n = int(input())
    for _ in range(n):
        op, s = input().split()
        if op == "insert":
            h_t.insert(s)
        else:
            tmp = h_t.find(s)
            if tmp == 1:
                print("yes")
            else:
                print("no")

### FIXED CODE ###

def hash1(m, key):
    return key % m

def hash2(m, key):
    return 1 +  key % (m - 1)

def hash(m, key, i):
    return (hash1(m, key) + i * hash2(m, key) ) % m

def insert(T, key):
    i = 0
    l = len(T)
    while True:
        h = hash(1046527,key,i)
        if (T[h] == None ):
            T[h] = key
            return h
        elif (T[h] == key):
            return h
        else:
            i += 1

def search(T,key):
    l = len(T)
    i = 0
    while True:
        h = hash(1046527,key,i)
        if(T[h] == key):
            return h
        elif(T[h] is None or h >= l):
            return -1
        else:
            i += 1

def find(T, key):
    a = search(T,key)
    if(a == -1):
        print('no')
    else:
        print('yes')

dict = {'A' : '1', 'C' : '2', 'G' : '3', 'T' : '4'}
data = []
T = [None]*1046527
n = int(input())


while n > 0:
    st = input()
    d = list(st.split())

### convert key to num(1~4)
    tmp_key = ''
    for x in list(d[1]):
        tmp_key += dict[x]

    data.append([d[0],int(tmp_key)])
    n -= 1
for com in data:
    if(com[0] == 'insert'):
        insert(T,com[1]) 
    else:
        find(T,com[1])