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):

PRIME = 1000231


def main():
    n = int(input())
    d = MyDict()
    for _ in range(n):
        command, v = input().split(' ')
        if command == 'insert':
            d.add(v)
        else:
            if d.find(v):
                print('yes')
            else:
                print('no')




class MyDict:

    def __init__(self, n=PRIME):
        self.n = n
        self.store = [None]*n

    def add(self, v):
        key = self._hash(v)
        while self.store[key] is not None:
            key += 1
        self.store[key] = v

    def find(self, v):
        key = self._hash(v)
        while self.store[key] is not None and self.store[key] != v:
            key += 1
        return self.store[key]

    def _hash(self, v):
        return hash(v) % self.n


if __name__ == '__main__':
    main()

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

Solution (Python):
if __name__ == "__main__":
    inst_num = int(input())
    dictionary = {}

    for _ in range(inst_num):
        operation, value = input().split()
        if "insert" == operation:
            dictionary[value] = 1
        elif "find" == operation:
            if dictionary.get(value):
                print("yes")
            else:
                print("no")
        else:
            pass

Solution (Python):
if __name__ == '__main__':
	n = int(input())
	d = {}
	for i in range(n):
		a,s = map(str,input().split())
		if a == "insert":
			d[s] = 1
		elif a == "find":
			if s in d:
				print("yes")
			else:
				print("no")

Solution (Python):
if __name__ == '__main__':
    n = int(input())

    result = []
    dict_ = {}
    for i in range(n):
        temp = input().split()

        if temp[0][0] == 'i':
            dict_[temp[1]] = True
        else:
            if temp[1] in dict_:
                result.append('yes')
            else:
                result.append('no')
    print('\n'.join(result))

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from collections import deque


mod = 1000000007

if __name__ == "__main__":
    d={}
    n = int(sys.stdin.readline())
    for i in range(n):
        l= list(sys.stdin.readline().split())
        cmd = l[0]
        if len(l)==2:
            text = l[1]
        if cmd == "insert":
            d[text]=1
        elif cmd == "find":
            if text in d:
                print("yes")
            else:
                print("no")

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
dic = set()
for i in range(N):
    op, string = stdin.readline().rstrip().split()
    if op == 'insert':
        dic.add(string)
    elif op == 'find':
        if string in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
M = 1046527  
A = [-1 for i in range(M)]


def str2int(s):
    cnt = 0
    for i in range(len(s)):
        if s[i] == 'A':
            cnt += 1
        elif s[i] == 'T':
            cnt += 2
        elif s[i] == 'C':
            cnt += 3
        elif s[i] == 'G':
            cnt += 4
        cnt *= 4
    return cnt


def h1(k):
    return k % M


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


def h(k, i):
    return (h1(k) + h2(k) * i) % M


def insert(w):
    k = str2int(w)
    i = 0
    while i < M:
        j = h(k, i)
        if A[j] == -1:
            A[j] = w
            break
        i += 1


def find(w):
    k = str2int(w)
    i = 0
    while i < M:
        j = h(k, i)
        if A[j] == -1:
            break
        if A[j] == w:
            return True
        i += 1
    return False


if __name__ == '__main__':
    n = int(raw_input())
    for i in range(n):
        cmd, s = raw_input().split()
        if cmd == "insert":
            insert(s)
        elif cmd == "find":
            if find(s):
                print "yes"
            else:
                print "no"
        else:
            pass

Solution (Python):
d={}
n=int(input())
for i in range(n):
    com,gen=input().split(" ")
    if com=="insert":
        d[gen]=d.get(gen,0)+1
    if com=="find":
        if gen in d:
            print("yes")
        else:
            print("no")

Solution (Python):
def insert(st):
    if st[0]=="A":
        return 0
    elif st[0]=="C":
        return 1
    elif st[0]=="G":
        return 2
    else:
        return 3
 
def finder(li,st):
    serach=insert(st)
    return "yes" if st in li[serach] else "no"
 
n=int(input())
dic=[set() for _ in range(4)]
for i in range(n):
    s,c=input().split()
    if s[0]=="i":
        dic[insert(c)].add(c)
    else:
        print(finder(dic,c))

Solution (Python):
class c:
    def __init__(self):
        self.d = {}

    def insert(self,s):
        self.d[s] = 1

    def find(self,s):
        try:
            if self.d[s]:
                print('yes')
        except KeyError:
            print('no')


n = int(input())
d = c()
for i in range(n):
    s,k = input().split()
    if s == 'insert':
        d.insert(k)
    else:
        d.find(k)

Solution (Python):
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

d=set()
for _ in range(int(input())):
    a,b=input().split()
    if a == 'find':
        if b in d:
            print('yes')
        else:
            print('no')
    else:
        d.add(b)

Solution (Python):
"""
辞書
"""
n = int(input())
s = set()
for _ in range(n):
    com,string = input().split()
    if com == "insert":
        s.add(string)
    elif com == "find":
        flg = string in s
        if flg:
            print("yes")
        else:
            print("no")

Solution (Python):
from collections import deque
n=int(input())
data=set()
ans=deque()
for i in range(n):
    command=input().split()
    if command[0]=="insert":
        data.add(command[1])
    else:
        ans.append("yneos"[1-(command[1] in data)::2])


for i in range(len(ans)):
    print(ans.popleft())

Solution (Python):


n=int(input())
D=set()
for i in range(n):
    order,str=input().split( )
    if order == "insert":
        D.add(str)
    else:
        if str in D:
            print("yes")
        else:
            print("no")

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

for i in range(n):
    command=list(map(str,input().split()))
    if command[0]=='insert':
        dictionary[command[1]]=True
    else:
        if command[1] in dictionary:
            print('yes')
        else:
            print('no')

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

for i in range(n):
    order, str = input().split()
    if order == 'insert':
        str_set.add(str)
    elif order == 'find':
        if str in str_set:
            print('yes')
        else:
            print('no')

Solution (Python):
def main():
    n = int(input())
    d = set()
    for i in range(n):
        c, w = input().split()
        if c == "insert":
            d.add(w)
        else:
            if w in d:
                print("yes")
            else:
                print("no")


if __name__ == '__main__':
    main()

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

dict_ACGT = {}

for _ in range(n):

    command, string = input().split()
    
    if   command == "insert":
        
        dict_ACGT[string] = ""
    elif command == "find":
        
        if string in dict_ACGT:
            print("yes")
        else:
            print("no")
    else:
        raise

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

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

s = set()

for i in range(n):
    
    cmd = input().split()
    
    
    if cmd[0] == 'insert':
        
        s.add(cmd[1])
        
    
    if cmd[0] == 'find':
        if cmd[1] in s:
            print('yes')
        else:print('no')

Solution (Python):
n = int(input())
a = [list(input().split()) for _ in range(n)]

strs = set()

for c, s in a:
    if c == "insert":
        strs.add(s)
    elif c == "find":
        if s in strs:
            print("yes")
        else:
            print("no")

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

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

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

table = {}

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

Solution (Python):
n = int(input())
dict = set()
tmp = set()
for _ in range(n):
  data = list(map(str,input().split()))
  if(data[0][0] == "i"):
    dict.add(data[1])
  elif(data[0][0] == "f"):
    tmp.add(data[1])
    print("yes" if len(dict&tmp) != 0 else "no")
    tmp.clear()

Solution (Python):
n = int(input())
M = 1046527
table = [""]*M
def getKey(str):
    sum = 0
    p = 1
    for i in range(len(str)):
        if str[i] == "A":
            num = 4
        elif str[i] == "T":
            num = 3
        elif str[i] == "G":
            num = 2
        else:
            num = 1
        sum += p*num
        p *= 5
    return sum

for ni in range(n):
    instruction = input().split()
    if instruction[0][0] == "i":
        key = getKey(instruction[1])
        h = key%M
        i = 0
        while table[h] != "" and table[h] != instruction[1]:
             i += 1
             h = (key%M + i *(1 + key%(M-1)) )%M
        table[h] = instruction[1]
    elif instruction[0][0] == "f":
        key = getKey(instruction[1])
        h = key%M
        i = 0
        while table[h] != "" and table[h] != instruction[1]:
             i += 1
             h = (key%M + i *(1 + key%(M-1)) )%M
        if table[h] == instruction[1]:
            print("yes")
        else:
            print("no")

Solution (Python):
if __name__ == '__main__':
    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):
import sys
input = sys.stdin.readline

class Dict:
  def __init__(self, size):
    self.table = [None] * 1046527
    self.table_size = 1046527

  def insert(self, val):
    key = self.get_key(val)
    collision = 0
    while True:
      h = self.generate_hash(key, collision)
      if self.table[h] is None:
        self.table[h] = val
        break
      elif self.table[h] == val:
        break
      collision += 1
  def find(self, val):
    key = self.get_key(val)
    collision = 0
    while True:
      h = self.generate_hash(key, collision)
      if self.table[h] == val: return 1
      elif self.table[h] is None: return 0
      collision += 1

  def get_key(self, val):
    sum, P = 0, 1
    for i in range(len(val)):
      sum += P * self.get_char(val[i])
      P *= 5
    return sum

  def get_char(self, ch):
    if ch == 'A': return 1
    elif ch =='C': return 2
    elif ch =='G': return 3
    elif ch =='T': return 4
    else: return 0

  def generate_hash(self, key, collision):
    h1 = key % self.table_size
    h2 = 1 + key % (self.table_size - 1)
    return (h1 + collision * h2) % self.table_size

def _main():
  N = int(input())
  d = Dict(N)
  commands = [input().split() for _ in range(N)]

  for i in range(N):
    if commands[i][0] == 'insert':
      d.insert(commands[i][1])
    else:
      ans = 'yes' if d.find(commands[i][1]) else 'no'
      print(ans)



if __name__ == '__main__':
  _main()

Solution (Python):
from collections import defaultdict
n = int(input())
dic = defaultdict(int)

for _ in range(n):
  c, v = input().split()
  if c == 'insert':
    dic[v] = 1
  else:
    if dic[v] == 1:
      print('yes')
    else:
      print('no')

Solution (Python):
class Dictionary(object):
    def __init__(self, size):
        self.size = size
        self.a = [None]*size

    def hash(self, x):
        key = hash(x) % self.size
        while self.a[key] and self.a[key] != x:
            key = (key + 10**9+7) % self.size
        return key

    def insert(self, x):
        self.a[self.hash(x)] = x

    def find(self, x):
        return self.a[self.hash(x)] is not None


if __name__ == "__main__":
    import sys
    n = int(input())
    dictionary = Dictionary(n)
    result = []
    for command, s in (l.split() for l in sys.stdin):
        if command == "insert":
            dictionary.insert(s)
        else:
            result.append("yes" if dictionary.find(s) else "no")

    print(*result, sep="\n")

Solution (Python):
from sys import stdin

num = int(input())

dict = {}
for i in range(num):
	cmd = stdin.readline().strip().split()

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

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

for i in range(n):
  ord, char = input().split()
  if ord == 'insert':
    dict.add(char)
  elif ord == 'find':
    if char in dict:
      print('yes')
    else:
      print('no')

Solution (Python):
from collections import*
l=defaultdict(int)
for i in range(int(input())):
    a,b=input().split()
    if a=="insert":
        l[b]=1
    else:
        print(["no","yes"][l[b]==1])

Solution (Python):
n = int(input())
dic = set()
for i in range(n):
    com, x = map(str, input().split())
    if com == 'insert':
        dic.add(x)
    elif com == 'find':
        if x in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
class Dictionary:
    def __init__(self, data={}):
        self.data = data
    def insert(self, x):
        self.data[x] = 0
    def find(self, x):
        if x in self.data:
            return 'yes'
        else:
            return 'no'
n = int(input())
d = Dictionary()
s = [list(input().split()) for i in range(n)]
for i in s:
    if i[0] == 'insert':
        d.insert(i[1])
    else:
        print(d.find(i[1]))

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

l = set()
o = ''
for _ in range(n):
    c = input().split()
    if c[0] == 'insert':
        l.add(c[1])
    elif c[0] == 'find':
        o += ('yes' if c[1] in l else 'no') + "\n"

print(o, end='')

Solution (Python):
num = int(input())
dictionary = {}
for i in range(num):
    com, key = tuple(input().split(' '))
    if com == 'insert':
        dictionary[key] = dictionary.get(key, 0) + 1
    if com == 'find':
        if dictionary.get(key):
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())
h = {}
for i in range(n):
    op, s = input().split()
    if op == "insert":
        h[s] = True
    else:
        if s in h:
            print("yes")
        else:
            print("no")

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

Solution (Python):
import sys
from sys import stdin
input = stdin.readline
 
dic = {}
n = int(input())
for i in range(n):
    s = input()
    if s[0] == 'i': dic[s[7:]] = 1
    else: print("yes" if s[5:] in dic else "no")

Solution (Python):

import bisect
n = int(input().rstrip())
dic = {}
for i in range(n):
    line = input().rstrip().split()
    if line[0] == "insert":
        dic[line[1]] = True
    else:
        if line[1] in dic:
            print("yes")
        else:
            print("no")

Solution (Python):
n = int(input())
s = set()
for i in range(n):
    buff = input().split()
    if buff[0][0] == "i":
        s.add(buff[1])
    else:
        if buff[1] in s:
            print("yes")
        else:
            print("no")

Solution (Python):
import sys
d=set();input()
for c in sys.stdin:
 if"i"==c[0]:d.add(c.split()[1])
 else:print(["no","yes"][c.split()[1]in d])

Solution (Python):
num = int(input())
dict = {}

for i in range(num):
        strList = input().split()
        if strList[0] == "insert":
                dict[strList[1]] = 1
        elif strList[0] == "find":
                if strList[1] in dict:
                        print("yes")
                else:
                        print("no")

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

dic = set()

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

Solution (Python):
import sys

input = sys.stdin.readline

class Dict:
    def __init__(self):
        self.table = [None] * 1046527
        self.table_size = 1046527
    
    def insert(self, key):
        colisions = 0
        while True:
            hash_num = self._calc_hash(self._to_num(key), colisions)
            cand = self.table[hash_num]
            if cand is None:
                self.table[hash_num] = key
                return 0
            elif cand == key:
                return 1
            colisions += 1
    
    def has(self, key):
        colisions = 0
        while True:
            hash_num = self._calc_hash(self._to_num(key), colisions)
            cand = self.table[hash_num]
            if cand == key:
                return True
            elif cand is None or colisions >= self.table_size:
                return False
            else:
                colisions += 1
        return 
    
    def _calc_hash(self, key, colisions):
        hash_1 = key % self.table_size
        hash_2 = 1 + (key % (self.table_size - 1))
        return (hash_1 + colisions * hash_2) % self.table_size
    
    def _to_num(self, str_key):
        sum = 0
        p = 1
        for char in str_key:
            if char == 'A':
                sum += 1 * p
            elif char == 'C':
                sum += 2 * p
            elif char == 'G':
                sum += 3 * p
            elif char == 'T':
                sum += 4 * p
            p *= 5
        return sum

def main_():
    N = int(input())
    commands = [(cmd[0], cmd[1]) for cmd in [input().split() for _ in range(N)]]
    hash_map = Dict()
    for cmd in commands:
        if cmd[0] == 'insert':
            hash_map.insert(cmd[1])
        else:
            ans = 'yes' if hash_map.has(cmd[1]) else 'no'
            print(ans)
            

if __name__ == "__main__":
    main_()

Solution (Python):
import sys
def m():
 d=set();input()
 for i in sys.stdin:
  if"i"==i[0]:d.add(i[7:])
  else:print('yes'if i[5:]in d else'no')
if'__main__'==__name__:m()

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

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
dic = {}
for _ in range(n):
    ope = stdin.readline().rstrip().split()
    if ope[0] == "insert":
        dic[ope[1]] = True
    elif ope[0] == "find":
        if dic.get(ope[1], False):
            print("yes")
        else:
            print("no")

Solution (Python):
import sys

N = int(input())



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

Solution (Python):
def v2i(v):
        v = list(v)
        n = 0
        for i,c in enumerate(v):
            if c == 'A':
                n += 0 + 4 * i
            elif c == 'C':
                n += 1 + 4 * i
            elif c == 'G':
                n += 2 + 4 * i
            elif c == 'T':
                n += 3 + 4 * i
            n *= 4
        n /= 4
        return int(n)



class Dict():

    def __init__(self):
        self.tree = [False] * 4**12

    def find(self,key):
        if self.tree[key] == True:
            print("yes")
        else:
            print("no")
    
    def insert(self,key):
        self.tree[key] = True

    
N = int(input())
D = Dict()
for i in range(N):
    Q,V = input().split()
    if Q == "insert":
        D.insert(v2i(V))
    else:
        D.find(v2i(V))

Solution (Python):


class HashTable(list):
    def __init__(self, length):
        list.__init__(self)
        self.length = length
        self[:] = [None] * length

    def h(self, key, i):
        h1 = key % self.length
        h2 = 1 + (key % (self.length - 1))
        return (h1 + i*h2) % self.length

    def insert(self, key):
        i = 0
        while True:
            h1 = key % self.length
            h2 = 1 + (key % (self.length - 1))
            j = (h1 + i*h2) % self.length
            
            if self[j] is None:
                self[j] = key
                return j
            else:
                i += 1
    
    def search(self, key):
        i = 0
        while True:
            h1 = key % self.length
            h2 = 1 + (key % (self.length - 1))
            j = (h1 + i*h2) % self.length
            
            if self[j] == key:
                return j
            elif self[j] is None or i >= self.length:
                return None
            else:
                i += 1

def getNum(char):
    char2num = str.maketrans("ACGT", "1234")
    return int(char.translate(char2num), 5)

if __name__ == '__main__':

    n = int(input())
    T = HashTable(1046527)
    C = [input().split(" ") for i in range(n)]
    
    for command, char in C:
        num = getNum(char)
        if command[0] == "i":
            T.insert(num)
        else:
            if T.search(num) is None:
                print("no")
            else:
                print("yes")

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    command, value = input().split()
    if command == 'insert':
        dic[value] = True
    else:
        if dic.__contains__(value):
                print("yes")
        else:
            print("no")

Solution (Python):


"""
辞書
"""

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

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

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

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

Solution (Python):
import sys

TABLE_SIZE = 1000000
table = [None] * TABLE_SIZE


def insert(value):
    index = hash(value) % TABLE_SIZE
    values = table[index]
    if not values:
        values = table[index] = []
    values.append(value)


def find(value):
    index = hash(value) % TABLE_SIZE
    values = table[index]
    if not values:
        return False
    return value in values


n = int(sys.stdin.readline())
for _ in range(n):
    command, value = sys.stdin.readline().split()
    if command == 'insert':
        insert(value)
    else:
        print('yes' if find(value) else 'no')

Solution (Python):










def main():
    dic = {}
    for i in range(int(input())):
        l = list(map(str,input().split()))
        if l[0] == 'insert':
            dic[l[1]] = 'yes'
        else:
            try:
                print (dic[l[1]] )
            except:
                print ('no')
if __name__ == '__main__':
   main()

Solution (Python):
if __name__ == '__main__':
	n = int(input())

	dic = set()

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

Solution (Python):



class Dictionary(object):

    def __init__(self, m):
        self.T = [None] * m
        self.m = m

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

    def insert(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if not self.T[j]:
                self.T[j] = key
                return j
            else:
                i += 1
    
    def search(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.T[j] == key:
                return j
            elif not self.T[j] or i >= self.m:
                return 'Not Found'
            else:
                i += 1


if __name__ == "__main__":
    
    
    
    
    
    
    
    
    
    n = int(input())
    orders = []
    for _ in range(n):
        order, chars = input().strip().split()
        orders.append((order, chars))

    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    

    dictionary = {}
    for o in orders:
        order, chars = o
        if order == 'insert':
            dictionary[chars] = 0
        elif order == 'find':
            if chars in dictionary:
                print('yes')
            else:
                print('no')

Solution (Python):

import collections
N = int(input().strip())
q = collections.deque()
for i in range(N):
    order = input().strip().split(" ")
    q.append(order)
dct = set()
while len(q):
    order = q.popleft()
    if order[0] == 'insert':
        newword = order.pop()
        dct.add(newword)
    else:
        word = order.pop()
        if word in dct:
            print("yes")
        else:
            print("no")

Solution (Python):



"""
s in [list]:
-> linear search O(n)
-> TLE
"""


def solve():
    mydict = {}
    n = int(input())
    for _ in range(n):
        ope, s = map(str, input().split())
        if ope == 'insert':
            mydict[s] = True
        elif ope == 'find':
            if s in mydict:
                print('yes')
            else:
                print('no')


if __name__ == '__main__':
    solve()

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

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

for _ in range(n):
    order, value = input().split()
    if order == "insert":
        dic[value] = 1
    elif order == "find":
        if value in dic:
            print("yes")
        else:
            print("no")
    else:
        print("invalid order")

Solution (Python):

n=int(input())
dict=set()
for i in range(n):
    ope, key=input().split()
    if ope == "insert":
        dict.add(key)
    elif ope == "find":
        print("yes" if key in dict else "no")

Solution (Python):
from collections import deque
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


DICTIONARY={}
num_query=int(input())

for loop in range(num_query):
    input_str=input().split()
    if input_str[0]=='insert':
        DICTIONARY[input_str[1]]=True
    else:
        if DICTIONARY.__contains__(input_str[1]):
            print("yes")
        else:
            print("no")

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

for i in range(n):
    cmd,num = input().split()
    if   cmd == 'insert':
        dic[num] = i
    elif cmd == 'find':
        if dic.__contains__(num):
            ans_list.append('yes')
        else:
            ans_list.append('no')

for ans in ans_list:
    print(ans)

Solution (Python):
n=int(input())
dic={}
for x in range(n):
    s=list(map(str,input().split()))
    if(s[0]=="insert"):
        dic[s[1]]=True
    elif(s[0]=="find"):
       if(dic.get(s[1])==True):
           print("yes")
       else:
        print("no")

Solution (Python):
m = 1046527
H = [""] * m


def str_to_nume(word):
    ans = ""
    for _ in word:
        if _ == "A":
            ans += ("1")
        elif _ == "C":
            ans += ("2")
        elif _ == "G":
            ans += ("3")
        elif _ == "T":
            ans += ("4")
    return ans


def convert_type(word):
    
    
    return int(str_to_nume(word))


def hash1(key):
    return key % m


def hash2(key):
    '''hash1で衝突したとき用
    '''
    return 1 + key % (m-1)


def find(str_key):
    key = convert_type(str_key)
    for i in range(m):
        h = (hash1(key) + i * hash2(key)) % m
        if H[h] == str_key:
            return 1
        elif len(H[h]) == 0:
            return 0
    return 0


def insert(str_key):
    key = convert_type(str_key)
    for i in range(m):
        h = (hash1(key) + i * hash2(key)) % m
        if H[h] == str_key:
            return 1
        elif len(H[h]) == 0:
            H[h] = str_key
            return 0
    return 0


sols = []
n = int(input())

for i in range(n):
    col = input().split()
    if col[0] == "insert":
        insert(col[1])
    else:
        if find(col[1]) == 1:
            sols.append("yes")
        else:
            sols.append("no")
for _ in sols:
    print(_)