Problem:
Search III Your task is to write a program of a simple dictionary which implements the following instructions:  insert str : insert a string str in to the dictionary  find str : if the distionary contains str , then print ' yes ', otherwise print ' no '  Input In the first line n , the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format. Output Print yes or no for each find instruction in a line. Constraints  A string consists of ' A ', ' C ', ' G ', or ' T '  1 ≤ length of a string ≤ 12   n ≤ 1000000  Sample Input 1 5
insert A
insert T
insert C
find G
find A Sample Output 1 no
yes Sample Input 2 13
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
insert T
find TTT
find T Sample Output 2 yes
no
no
yes
yes
yes Notes Template in C

Solution (Python):
n=int(input())
answer=[]
d={}
for i in range(n):
    cmd,word=input().split()
    if cmd=="insert":
        d[word]=True
    
    else:
        if word in d:
            print("yes")

        else:
            print("no")

Solution (Python):
from collections import deque, defaultdict
import sys
import math

if __name__ == '__main__':
    n = int(input())
    s = defaultdict(int)
    for _ in range(n):
        a, b = input().split()
        if a == 'insert':
            s[b] += 1
        else:
            if s[b]:
                print('yes')
            else:
                print('no')

Solution (Python):
import time

n = int(input())


S = set()
for i in range(0,n):
	lst = list(input().split())
	if lst[0] == 'insert':
		S.add(lst[1])
	elif lst[0] == 'find':
		if lst[1] in S:
			print('yes')
		else:
			print('no')

Solution (Python):
def insert(dic,text):
  dic[text] = 1

def find(dic,text):
  if text in dic:
    print('yes')
  else:
    print('no')
    
num = int(input())
d = {}
while num > 0:
  ope , s = input().split()
  if ope == 'insert':
    insert(d,s)
  elif ope == 'find':
    find(d,s)  
  num -= 1

Solution (Python):
import sys

D = {}
input()
for line in sys.stdin:
    if line[0] == "f":
        print('yes' if line[5:] in D else 'no')
    else:
        D[line[7:]] = 0

Solution (Python):



hash_list = {}

if __name__ == "__main__":
    n = int(input())

    for _ in range(n):
        command, arg = input().split()

        if command == 'insert':
            hash_list[arg] = 1
        else:
            print('yes' if arg in hash_list else 'no')

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    req = input().split()
    if(req[0] == "insert"):
        dic[req[1]] = i
    elif(req[0] == "find"):
        if(req[1] in dic):
               print("yes")
        else:
               print("no")

Solution (Python):
a = int(input())

d = {}
for i in range(a):
    o,v = input().split()
    if o == 'insert':
        d[v] = v
    elif o == 'find':
        if v in d:
            print('yes')
        else:
            print('no')

Solution (Python):
def readinput():
    n=int(input())
    commands = []
    for i in range(n):
        command=input().split()
        commands.append(command)
    return n, commands

def main(n,commands):
    d = dict()
    for cmd in commands:
        if(cmd[0]=='insert'):
            d[cmd[1]]=cmd[1]
        elif(cmd[0]=='find'):
            if(cmd[1] in d):
                print('yes')
            else:
                print('no')

if __name__=='__main__':
    n,commands=readinput()
    main(n,commands)

Solution (Python):
n = int(input())

values = {}
for _ in range(n):
  command, value = input().split()

  if command[0] == 'i':
    values[value] = value
  if command[0] == 'f':
    if value in values:
      print ('yes')
    else:
      print ('no')

Solution (Python):
n = int(input())
index = set()

for _ in range(n):
    command, string = input().split()
    if command == "insert":
        index.add(string)
    else:
        if string in index:
            print("yes")
        else:
            print("no")

Solution (Python):

import sys
from sys import stdin
input = stdin.readline

n = int(input())
D = {}
for i in range(n):
    s = input()
    if s[0] == "i":
        D[s[7:]] = 11111111111111111111111111111111111
    else:
        print("yes" if s[5:] in D else "no")

Solution (Python):
from sys import stdin

def main():
    a = set()
    _ = int(stdin.readline())
    for command,value in (line.split() for line in stdin.readlines()):
        if command == "insert":
            a.add(value)
        else:
            print("yes" if value in a else "no")

main()

Solution (Python):
n = int(input())
dict = set()
for i in range(n):
  a,b = input().split()
  if a=="insert":
    dict.add(b)
  else:
    if b in dict:
      print("yes")
    else:
      print("no")

Solution (Python):
n = int(input())
order = [''] * n
st = [''] * n
for i in range(n):
    order[i], st[i] = map(str, input().split())

dic = {}
for i in range(n):
    if order[i] == 'insert':
        dic.setdefault(st[i], 0)
    else:
        if st[i] in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

n = int(sys.stdin.readline())
d = {}

for i in range(n):
	op, NA = sys.stdin.readline().split()
	if op == "insert":
		d[NA] = 0
	else:
		if NA in d:
			print("yes")
		else:
			print("no")

Solution (Python):
n=int(input())
D=set()
for i in range(n):
    command,str_=input().split()
    if command=='insert':
        D.add(str_)
    elif command=='find':
        if str_ in D:
            print('yes')
        else:
            print('no')

Solution (Python):
a = {}

n = int(input())

for i in range(n):
  cmd, val = input().split()
  if cmd == 'insert':
    a[val] = val
  elif cmd == 'find':
    print('yes' if val in a else 'no')

Solution (Python):
n = int(input())
d = set()
for i in range(n):
    cmd, val = input().split()
    if cmd == 'insert':
        d.add(val)
    else:
        print('yes'*(val in d)or'no')

Solution (Python):
n = int(input())
lst = []

for i in range(n):
	tmp = input().split()
	lst.append(tmp)
	
d = {}

for i in range(n):
	if lst[i][0] == 'insert':
		d[lst[i][1]] = d.get(lst[i][1], 0) + 1
	elif lst[i][0] == 'find':
		print('yes') if lst[i][1] in d else print('no')

Solution (Python):
n = int(input())
myDict = {}

for i in range(n):
    cmd,key = input().split()
    if cmd == "insert":
        myDict.setdefault(key,key)
    else:
        if key in myDict.keys():
            print("yes")
        else:
            print("no")

Solution (Python):
mp = {}
for _ in range(int(input())):
    op, x = input().split()
    if op == "insert":
        mp[x] = True
    else:
        print(['no', 'yes'][x in mp])

Solution (Python):


dic = set()
def insert(s):
    dic.add(s)
def find(s):
    if s in dic:
        print("yes")
    else:
        print("no")
i = int(input())
for c in range(i):
    op,s = map(str,input().split())
    if op == "insert":
        insert(s)
    elif op == "find":
        find(s)

Solution (Python):
n = int(input())
s = set([])
for i in range(n):
    cmd, str1 = input().split()
    if cmd == "insert":
        s.add(str1)
    else:
        if str1 in s:
            print("yes")
        else:
            print("no")

Solution (Python):
N = int(input())

dic = {}
for i in range(N):
    com, s = input().split()
    if com == 'insert':
        dic[s] = True
    elif com == 'find':
        print('yes' if s in dic else 'no')

Solution (Python):
"""
n=int(input())
s=[int(x) for x in input().split()]
q=int(input())
t=[int(x) for x in input().split()]

c=0
for i in t:
    if i in s:
        c+=1
print(c)
"""
"""
n=int(input())
s=[int(x) for x in input().split()]
q=int(input())
t=[int(x) for x in input().split()]

a=0
for i in range(q):
    L=0
    R=n-1
    while L<=R:
        M=(L+R)//2
        if s[M]<t[i]:
            L=M+1
        elif s[M]>t[i]:
            R=M-1
        else:
            a+=1
            break
print(a)
"""


n=int(input())
d={}
for i in range(n):
    command,words=input().split()
    if command=='find':
        if words in d:
            print('yes')
        else:
            print('no')
    else:
        d[words]=0

Solution (Python):
class Dict(object):
    def __init__(self, size):
        self.dict = [None for _ in range(size)]
        self.size = size

    def h1(self, key):
        return key % self.size

    def h2(self, key):
        return 1 + (key % (self.size-1))

    def h(self, key, i):
        return (self.h1(key) + i * self.h2(key)) % self.size

    def insert(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.dict[j] == None:
                self.dict[j] = key
                break
            else:
                i += 1

    def find(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.dict[j] == key:
                return 1
            elif self.dict[j] == None or i >= self.size:
                return 0
            else:
                i += 1


def get_key(table, word):
    return int(word.translate(table))


if __name__ == "__main__":
    import sys
    input = sys.stdin.readline 

    table = str.maketrans({
        "A": "1",
        "C": "2",
        "G": "3",
        "T": "4"
    })

    m = 1046527
    d = Dict(m)

    n = int(input())

    for _ in range(n):
        command = input()
        if command[0] == 'i':
            d.insert(get_key(table, command[7:]))
        else:
            if d.find(get_key(table, command[5:])):
                print('yes')
            else:
                print('no')

Solution (Python):
n = int(input())

d = {}
for i in range(n):
    order,string = input().split()
    if order == "insert":
        d[string] = 1
    else:
        try:
            if d[string] :
                print("yes")
        except:
            print("no")

Solution (Python):
N = int(input())

a = set([])
for i in range(N):
    S = input()
    if S[0] == "i":
        a.add(S[7:])
        
    else:
        print("yes" if S[5:] in a else "no")

Solution (Python):

def main():
    s = set()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0] == 'insert':s.add(com[1])
        else :
            if com[1] in s:print('yes')
            else          :print('no')


if __name__ == '__main__':
    main()

Solution (Python):
def insert(cnt, data):
    T[str(data)] = cnt


cnt = 0
T = {}
n = int(input())
for i in range(n):
    Order, data_S = input().split()
    if Order[0] =="i":
        insert(cnt, data_S)
        cnt +=1

    else:
        if str(data_S) in T:
            print("yes")
        else:
            print("no")

Solution (Python):
n = int(input())
S = {}

ans = []
for i in range(n):
	order = input().split()
	if order[0] == "insert":
		S[order[1]] = 0
	elif order[0] == "find":
		if order[1] in S:
			ans.append("yes")
		else:
			ans.append("no")

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

Solution (Python):
from sys import stdin
import math

class hash():
    def __init__(self,n):
        self.n=1000003
        self.memo=[None]*self.n
    def madekey(self,key):
        if key=='A':return '1'
        elif key=='C':return '2'
        elif key=='G':return '3'
        elif key=='T':return '4'
    def getkey(self,KEY):
        key=""
        for S in KEY:
            key=key+self.madekey(S)
        return int(key)
    def h1(self,key):
        return key%self.n
    def h2(self,key):
        return (key%(self.n-1))+1
    def insert(self,S):
        key=self.getkey(S)
        h1 = self.h1(key)
        h2 = self.h2(key)
        for i in range(0,self.n+1):
            j=(h1+(i*h2)) % self.n
            if self.memo[j] is None:
                self.memo[j]=S
                break

    def search(self,S):
        key = self.getkey(S)
        h1 = self.h1(key)
        h2 = self.h2(key)
        for i in range(0,self.n+1):
            j = (h1+(i*h2)) % self.n
            if self.memo[j] ==S:
                return 'yes'
            elif self.memo[j] is None or i ==self.n:
                return 'no'
n=list(map(int,(stdin.readline().strip().split())))
dic=hash(n)
for _ in range(n[0]):
    S =list(stdin.readline().strip().split())
    if S[0]=='insert':
        dic.insert(S[1])
    elif S[0]=='find':
        print(dic.search(S[1]))

Solution (Python):
n = int(input())
mydic = {}
for _ in range(n):
    s,t = input().split()
    if s == "insert":
        mydic[t] = 1
    else:
        if t in mydic.keys():
            print("yes")
        else:
            print("no")

Solution (Python):
n = int(input())

l = set()

for _ in range(n):
    command, s = input().split()
    if command == "insert":
        l.add(s)
    else:
        if s in l:
            print("yes")
        else:
            print("no")

Solution (Python):
n = int(input())
my_dict = {}

for i in range(n):
  order, key = input().split(' ')
  if order == 'insert':
    my_dict[key] = True
  elif order== 'find':
    if key in my_dict.keys():
      print('yes')
    else:
      print('no')

Solution (Python):

from collections import defaultdict

N = int(input())
S = [(input().split()) for _ in range(N)]

d = defaultdict(bool)

for c, v in S:
    if c == 'insert':
        d[v] = True
    else:
        print('yes' if v in d else 'no')

Solution (Python):



def main():
    d = set()
    for l in open(0).readlines()[1:]:
        o, k = l.split()
        if o == "insert":
            d.add(k)
            continue
        if k in d:
            print("yes")
        else:
            print("no")

main()

Solution (Python):
DICT = {}
N = int(input())
for loop in range(N):
    com,str = input().split()
    if com == "insert":
        DICT[str] = True

    elif com == "find":
        if DICT.__contains__(str):
            print("yes")
        else:
            print("no")

Solution (Python):
import sys
n = int(sys.stdin.readline())
b = 20000000
a = [None]*b
def getC(c):
    if c == "A": t = 1
    elif c == "C": t = 2
    elif c == "G": t = 3
    elif c == "T": t = 4
    return t
def getK(s):
  ret = 0
  for c in s:
    ret = ret*5 + getC(c)
  return ret
def hash1(key):
  return key % b
def hash2(key):
  return 1 + key % (b-1)
def find(key):
  
  i = 0
  j = (hash1(key)+i*hash2(key))%b
  while a[j]:
    if a[j] == key:
      return True
    i += 1
    j = (hash1(key)+i*hash2(key))%b
  return False
def insert(key):
  i = 0
  j = (hash1(key)+i*hash2(key))%b
  while a[j]:
    i += 1
    j = (hash1(key)+i*hash2(key))%b
  if a[j] == None:
    a[j] = key
for i in range(n):
  q,s = sys.stdin.readline().split()
  if q[0]=="i":
    insert(getK(s))
  else:
    if find(getK(s)):
      print("yes")
    else:
      print("no")

Solution (Python):
N=int(input())
h_num=10000
L=[[] for x in range(h_num)]
def string_to_hash(S):
    S_num=0
    i=0
    for s in S:
        i+=1
        if s=='A':
            S_num+=1*i
        elif s=='C':
            S_num+=10*i
        elif s=='G':
            S_num+=100*i
        elif s=='T':
            S_num+=1000*i
    return(S_num%h_num)

for n in range(N):
    cmd , str_ = input().split()
    h=string_to_hash(str_)
    if cmd=='insert':
        L[h].append(str_)
    elif cmd== 'find':
        L_temp=L[h]
        if str_ in L_temp:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())

m = 1046527

H = [None]*m

table = str.maketrans({
'A':'1',
'C':'2',
'G':'3',
'T':'4',
})



def getChar(string):
    return int(string.translate(table))



def h1(key):
    return key % m

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

def find(string):
    i = 0
    key = getChar(string)
    while True:
        h = (h1(key) + i*h2(key))%m
        if H[h] == string:
            return 1
        elif H[h] is None:
            return 0
        else:
            i += 1

def insert(string):
    i = 0
    key = getChar(string)
    while True:
        h = (h1(key) + i*h2(key))%m
        if H[h] is None:
            H[h] = string
            break
        else:
            i += 1

for _ in range(n):
    com, string = input().split()
    if com[0] == 'i':
        insert(string)
    else:
        if find(string):
            print('yes')
        else:
            print('no')

Solution (Python):
class Dictonary:

    def __init__(self):
        self.d = set()

    def insert(self, s: str):
        if s not in self.d:
            self.d.add(s)

    def find(self, s: str):
        if s in self.d:
            print('yes')
        else:
            print('no')

d = Dictonary()
n = int(input())

for _ in range(n):
    cmd, s = input().split()
    if cmd == 'insert':
        d.insert(s)
    elif cmd == 'find':
        d.find(s)

Solution (Python):




DICT_SIZE = 1000003
REHASH = 10007
DICT = [None] * DICT_SIZE


def hash_value(S):
    M = 257
    val = 0
    for c in S:
        val = (val * M + ord(c)) % DICT_SIZE
    return val


def insert(s):
    h = hash_value(s)
    while DICT[h] is not None:
        if DICT[h] == s:
            return
        h = (h + REHASH) % DICT_SIZE
    DICT[h] = s


def find(s):
    h = hash_value(s)
    while True:
        if DICT[h] is None:
            return 'no'
        elif DICT[h] == s:
            return 'yes'
        h = (h + REHASH) % DICT_SIZE


if __name__ == "__main__":

    n = int(input())

    for _ in range(n):
        cmd, s = input().split()
        if cmd == 'insert':
            insert(s)
        else:
            print(find(s))

Solution (Python):
n = int(input())
lst = [input().split() for i in range(n)]
dict = {}
for op, s in lst:
    if op == 'insert':
        dict[s] = 1
    if op == 'find':
        try:
            if dict[s] == 1:
                print('yes')
        except:
            print('no')

Solution (Python):
M = 1046527

def charToKey(a):
    if a == "A":
        return 1
    elif a == "C":
        return 2
    elif a == "G":
        return 3
    elif a == "T":
        return 4
    else:
        return 0

def strToKey(s):
    sum = 0
    coef = 1
    for c in s:
        key = charToKey(c)
        sum += coef * key
        coef *= 5
    return sum

def hash1(key):
    return key % M

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

def insert(A, value):
    key = strToKey(value)
    for i in range(M):
        hash = (hash1(key) + i * hash2(key)) % M
        if A[hash] == value:
            return
        elif A[hash] is None:
            A[hash] = value
            return
    return

def find(A, value):
    key = strToKey(value)
    for i in range(M):
        hash = (hash1(key) + i * hash2(key)) % M
        if A[hash] == value:
            return True
        elif A[hash] is None:
            return False
    return False

if __name__ == "__main__":
    A = [None for i in range(M)]

    N = int(input())
    for i in range(N):
        command, value = input().split()
        if command == "insert":
            insert(A, value)
        else:
            if (find(A, value)):
                print("yes")
            else:
                print("no")

Solution (Python):
keys = set()
n = int(input())
for i in range(n):
    order, string = input().split()
    if order == "insert":
        keys.add(string)
    elif order == "find":
        if string in keys:
            print("yes")
        else:
            print("no")

Solution (Python):
def hash(v):
    return v % 100001

def insert(hashTable, value):
    key = hash(value)
    if hashTable[key] == None:
        hashTable[key] = [value]
    else:
        hashTable[key].append(value)

def find(hashTable, value):
    key = hash(value)
    if hashTable[key] == None:
        return False
    else:
        for val in hashTable[key]:
            if val == value:
                return True
    return False

def convert(string):
    res = ''
    for s in string:
        res += str(ord(s))
    return int(res)

n = int(input())
hashTable = [None] * 10**6
for i in range(n):
    com, val = input().split()
    val = convert(val)
    if com == 'insert':
        insert(hashTable, val)
    else:
        print('yes') if find(hashTable, val) else print('no')

Solution (Python):
n = int(input())
S = set()
for _ in range(n):
    op, arg = input().split()
    if op == "insert":
        S.add(arg)
    elif arg in S:
        print("yes")
    else:
        print("no")

Solution (Python):
n = int(input())
dic = {}
res = []

for i in range(n):
    com = input().split()
    if com[0] == "insert":
        dic[com[1]] = i
    elif com[0] == "find":
        if com[1] in dic:
            res.append("yes")
        else:
            res.append("no")
            
for i in res:
    print(i)

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
t = {}
for i in range(n):
    c, s = input().split()
    if c[0] == "i":
        t[s] = 0
    else:
        print('yes' if s in t else 'no')

Solution (Python):
n = int(input())
t = set()
for i in range(n):
    c, s = input().split()
    if c == "insert":
        t.add(s)
    elif s in t:
        print("yes")
    else:
        print("no")

Solution (Python):
N = int(input())

comm_list = [input().split() for _ in  range(N)]

dictionary = set()

for comm, v in comm_list:
    if comm == 'insert':
        dictionary.add(v)
    elif comm == 'find':
        if v in dictionary:
            print('yes')
        else:
            print('no')
    else:
        raise

Solution (Python):
dic={}
N=int(input())
for i in range(N):
    a,b=input().split()
    if a=="insert":
        dic[b]=1
    else:
        try:
            if dic[b]:
                print('yes')
        except:
            print('no')

Solution (Python):
class MyDict:
    def __init__(self, max):
        self.max = max
        self.pow = [1] * (self.max + 1)
        for i in range(1, self.max + 1):
            self.pow[i] = self.pow[i - 1] * 4
        self.d = [False] * (self.pow[-1])
        
    def __hash(self, val):
        l = len(val)
        h = -1
        for i in range(l):
            if val[i] == 'A':
                h += (1*self.pow[i])
            elif val[i] == 'C':
                h += (2*self.pow[i])
            elif val[i] == 'G':
                h += (3*self.pow[i])
            elif val[i] == 'T':
                h += (4*self.pow[i])
        return h
    
    def insert(self, x):
        key = self.__hash(x)
        self.d[key] = True
    
    def find(self, x):
        key = self.__hash(x)
        return self.d[key]
        

n = int(input())
dic = MyDict(12)

for _ in range(n):
    cmd, x = input().split()
    
    if cmd == 'insert':
        dic.insert(x)
    elif cmd == 'find':
        print('yes') if dic.find(x) else print('no')

Solution (Python):
n = int(input())

s = set()

for i in range(n):
    c, num = input().split()

    if c == 'insert':
        s.add(num)
    elif c == 'find':
        if {num}<=s:
            print('yes')
        else:
            print('no')

Solution (Python):
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


class Dictionary:
    def __init__(self):
        self.dict = defaultdict(lambda:False)
    
    def insert(self, x):
        self.dict[x] = True
        
    def find(self, x):
        if self.dict[x]:
            print("yes")
        else:
            print("no")
            
            
def main():
    Dict = Dictionary()
    
    n = int(input())
    for i in range(n):
        op, key = input().split()
        if op == "find":
            Dict.find(key)
        else:
            Dict.insert(key)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = set()
for i in range(0, N):
    x, y = map(str, input().split())
    if x == 'insert':
        A.add(y)
    else:
        if y in A:
            print('yes')
        else:
            print('no')

Solution (Python):
dic = {}

for _ in range(int(input())):
    
    cmd, word = input().split()
    
    if cmd == 'insert':
        dic[word] = 1

    elif cmd == 'find':
        if dic.__contains__(word):
            print('yes')
        else:
            print('no')

Solution (Python):
N = int(input())

d = {}
for _ in range(N):
    op, value = input().split()
    if op == 'insert':
        d[value] = value
    elif op == 'find':
        if value in d.keys():
            print('yes')
        else:
            print('no')
    else:
        raise Exception

Solution (Python):
n = int(input())

data = {}

for i in range(n):
    command = input().split()
    
    if command[0] == "insert":
        data[command[1]] = ''
    elif command[0] == "find":
        if command[1] in data:
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())
dic = set()
for i in range(n):
    operation, string = input().split()
    if operation == "insert":
        dic.add(string)
    else:
        print("yes" if string in dic else "no")

Solution (Python):
n = int(input())
commands = []
for i in range(n):
    command, key = input().split(" ")
    commands.append((command, key))

dic = {}
for command in commands:

    if command[0] == "insert":
        dic[command[1]] = ""
    elif command[0] == "find":
        print("yes") if command[1] in dic else print("no")

Solution (Python):
def dictionary():
    n = int(input())
    dic = {}
    for i in range(n):
        line = input().split()
        order, key = line[0], line[1]
        if order == "insert":
            dic[key] = i
        else:
            if key in dic:
                print("yes")
            else:
                print("no")

if __name__ == "__main__":
    dictionary()

Solution (Python):
d = {}
n = int(input())
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        d[command[1]] = 0
    elif command[0] == 'find':
        if command[1] in d:
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())

dict = {}
ans = []
for i in range(n):
  cmd, key = input().split(" ")
  if cmd == "insert":
    dict[key] = "yes"
    continue
  
  if cmd == "find":
    if dict.get(key) is None:
      ans.append("no")
    else:
      ans.append(dict[key])

for a in ans:
  print(a)

Solution (Python):

p_number = int(input())
acgt_disc = {}


for i in range(p_number):
    a,b = input().split()
    if a[0] == "i":
        acgt_disc[b] = 0
    else:
        if b in acgt_disc:
            print("yes")
        else:
            print("no")

Solution (Python):
def main():
    n = int(input())
    d = set()

    for _ in range(n):
        com, para = input().split()

        if com == "insert":
            d.add(para)

        elif com == "find":
            if  para in d:
                print("yes")
            else:
                print("no")

main()

Solution (Python):
n = int(input())
S = set()
ans = []
for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        S.add(cmd[1])
    elif cmd[0] == 'find':
        if cmd[1] in S:
            ans.append('yes')
        else:
            ans.append('no')
for a in ans:
    print(a)

Solution (Python):


import sys

my_dict = dict()
n = int(input())

for i in range(n):
    query,value = sys.stdin.readline().split()
    if query == "insert":
        my_dict[value] = True
    elif query == "find":
        if value in my_dict:
            print("yes")
        else:
            print("no")

Solution (Python):
class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

class HashTable:
    def __init__(self, capacity):
        capacity = 2**capacity
        self.table = [None]*capacity
        self.mask = capacity - 1
    
    def insert(self, data):
        node = Node(data)
        remainder = hash(data) & self.mask
        node.next, self.table[remainder] = self.table[remainder], node
    
    def find(self, data):
        remainder = hash(data) & self.mask
        node = self.table[remainder]
        while node:
            if node.data == data:
                return True
            node = node.next
        return False      

    
if __name__ == "__main__":
    n = int(input())
    dictionary = HashTable(20)
    for _ in range(n):
        operation, string = input().split()
        if operation == "insert":
            dictionary.insert(string)
            continue
        print("yes" if dictionary.find(string) else "no")

Solution (Python):
n = int(input())
s = set()
for _ in range(n):
	a,b = input().split()
	if a=="insert":
		s.add(b)
	else:
		print("yes" if b in s else "no")

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
  command, key = input().split()
  if command == "insert":
    dic[key] = True
  elif command == "find":
    if dic.get(key, False):
      print("yes")
    else:
      print("no")

Solution (Python):


import sys




def main():
    s = set()
    for inst in sys.stdin:
        if inst[0] == 'f': print('yes' if inst[5:] in s else 'no')
        else: s.add(inst[7:])
    

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
dic=set()
for i in range(n):
    st=input().split()
    if st[0] == 'insert':
        dic.add(st[1])
        
    if st[0]== 'find':
        if st[1] in dic:
            print('yes')
        else:
            print('no')

Solution (Python):


def main():
  n = int(input())
  commands= [input().split() for _ in range(n)]
  dictionary = {}
  
  for command in commands:
    if command[0] == 'insert':
      dictionary[command[1]] = True
    else: 
      if command[1] in dictionary:
        print('yes')
      else:
        print('no')

main()

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    a, b = input().split()
    if a == "insert":
        dic[b] = 0
    else:
        if b in dic:
            print("yes")
        else:
            print("no")

Solution (Python):
"""
17D8101031C 杉山　祥吾 ID:keisei334 python
"""

n=int(input())

dic=set()

for i in range(n):
    Command, Key = input().split()
    if Command=="insert":
        dic.add(Key)
    else:
        if Key in dic:
            print("yes")
        else:
            print("no")

"""実行結果

"""

Solution (Python):
n = int(input())

d = dict()
for _ in range(n):
    op, key = input().split()
    if op == 'insert':
        d[key] = None
    elif op == 'find':
        ans = 'yes' if key in d else 'no'
        print(ans)

Solution (Python):
n=int(input())
d={}
for i in range(n):
    inst,val=input().split()
    if(inst=="insert"):
        d[val]=True
    elif(inst=="find"):
        if(d.get(val, False)):
            print("yes")
        else:
            print("no")

Solution (Python):
dic = {}
n = int(input())
for _ in range(n):
    command = input().split(' ')
    opecode = command[0]
    operand = command[1]
    if opecode == 'insert':
        dic[operand] = operand
    elif opecode == 'find':
        if dic.get(operand) != None:
            print('yes')
        else:
            print('no')

Solution (Python):
N=int(input())



D=set()
a=[]
b=[]

for i in range(N):
    A,B=input().split()
    
    
    a.append(A)
    b.append(B)

for i in range(N): 
    if a[i]=="insert":
        D.add(b[i])
    elif a[i]=="find":
        if b[i] in D:
            print("yes")
        else:
            print("no")

Solution (Python):
import sys
def main():
    input = sys.stdin.readline

    dic = set()
    n = int(input())
    ans = []
    for a in range(n):
        s = input()
        if "\n" in s:
            s = s[:-1]
        if s[0] == "i":
            dic.add(s[7:])
        else:
            ans.append("yes" if s[5:] in dic else "no")
    print("\n".join(ans))

if __name__ == "__main__":
    main()