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

import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


D = set()
N = int(input())
for _ in range(N):
    cmd, string = input().split()
    if cmd == "insert":
        D.add(string)
    elif cmd == "find":
        print("yes" if string in D else "no")

Solution (Python):
import sys

def main():
    """ MAIN """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    D = {}
    for i in cmds:
        if i[0] == "i":
            D[i[7:]] = 1
        elif i[0] == "f":
            if i[5:] in D:
                print("yes")
            else:
                print("no")

if __name__ == '__main__':
    main()

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

for _ in range(n):
    q, X = input().split()
    if q == "insert":
        dic[X] = 1
    else:
        if X in dic.keys():
            print("yes")
        else:
            print("no")

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

for i in xrange(n):
    a, b = raw_input().split()
    if a == "insert":
        dic[b] = True
    elif a == "find":
        if b in dic:
            print "yes"
        else:
            print "no"

Solution (Python):
import sys
input()
r = sys.stdin.readlines()
d = {}
 
for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')

Solution (Python):
from collections import defaultdict
n = int(input())
dic = defaultdict(lambda: 0)
for _ in range(n):
    com = input().split(' ')
    if com[0]=='insert':
        dic[com[1]] = 1
    else:
        if com[1] in dic:
            print('yes')
        else:
            print('no')

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

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

Solution (Python):
import sys
n = int(input())
dic =set()

t = sys.stdin.readlines()

for i in t:
    i,op = i.split()
    if i == 'insert':
        dic.add(op)    
    else:
        if op in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
def ALDS1_4C():
    D = {}
    for i in range(int(input())):
        cmd, key = input().split()
        if cmd == 'insert':
            D[key]='yes'
        else:
            print(D.get(key, 'no'))

if __name__ == '__main__':
    ALDS1_4C()

Solution (Python):

import sys


class Hash(object):
    def __init__(self, size):
        self._array = [None] * size
        self._size = size

    def _hash(self, key):
        return key % self._size

    def insert(self, key, value):
        j = self._hash(key)
        if self._array[j] is None:
            self._array[j] = [value]
        else:
            self._array[j].append(value)

    def find(self, key, value):
        j = self._hash(key)
        if self._array[j] is None:
            return False
        elif value in self._array[j]:
            return True
        else:
            return False


def stoi(s):
    ret = 0
    p = 1
    ctoi = {"A": 1, "C": 2, "G": 3, "T": 4}
    for c in s:
        ret += ctoi[c] * p
        p *= 7
    return ret


def dictionary(lst):
    h = Hash(1046527)
    ret = []
    for val in lst:
        if val[0] == "insert":
            h.insert(stoi(val[1]), val[1])
        elif val[0] == "find":
            if h.find(stoi(val[1]), val[1]):
                ret.append("yes")
            else:
                ret.append("no")
        else:
            raise ValueError
    return ret


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    n = int(lst.pop(0)[0])
    print("\n".join(dictionary(lst)))

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


    for i in range(n):
        command, string = input().split()
        if (command == 'insert'):
            d.add(string)
        elif (command == 'find'):
            if string in d:
                print('yes')
            else:
                print('no')

if __name__ == "__main__":
    main()

Solution (Python):
def insert(string, hash_list):
    hali = hash_list
    if string not in hali:
        hali[string] = 1
    return hali


def find(string, hash_list):
    hali = hash_list
    return string in hali



n = int(input())
words = {}
operate = [list(input().split()) for i in range(n)]

for i in operate:
    if i[0] == "insert":
        insert(i[1], words)
    elif i[0] == "find":
        if find(i[1], words):
            print("yes")
        else:
            print("no")

Solution (Python):
import sys
n = int(input())
d = {}
for op in sys.stdin.readlines():
    op = op.split()
    if op[0] == 'insert':
        d[op[1]] = 1  
    elif op[0] == 'find':
        if op[1] in d:
            print('yes')
        else:
            print('no')

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

for i in xrange(n):
	line = raw_input().split()
	cmd = line[0]
	ope = line[1]
	if cmd == "insert":
		dic[ope] = 1
	else:
		try:
			dic[ope] == 1
		except:
			print("no")
		else:
			print("yes")

Solution (Python):
import sys
 
if __name__ == '__main__':
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
 
    D = {}
    for i in cmds:
        if i[0] == "i":
            D[i[7:]] = 1
        elif i[0] == "f":
            if i[5:] in D:
                print("yes")
            else:
                print("no")

Solution (Python):


def solve():
    num_lines = int(raw_input())

    s = set()
    for i in xrange(num_lines):
        command, target = raw_input().split(" ")

        if command[0] == "i":
            s.add(target)
            continue

        if target in s:
            print "yes"
        else:
            print "no"


if __name__ == "__main__":
    solve()

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

s = set()
for _ in range(n):
    inst = input().split()
    if inst[0] == "insert":
        s.add(inst[1])
    else:
        if inst[1] in s:
            print("yes")
        else:
            print("no")

Solution (Python):
import sys
 
n = int(input())
dic = {}
input_ = sys.stdin.readlines()
 
for i in input_:
    c, s = i.split()
    if c == 'insert':
        dic[s] = 0
    else:
        if s in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys


def main():
    _ = int(input())

    imps = sys.stdin.readlines()

    db = {}
    for imp in imps:
        c, k = imp.split(' ')
        if c == 'insert':
            db[k] = 0
        elif k in db:
            print('yes')
        else:
            print('no')


main()

Solution (Python):
import sys
readline = sys.stdin.readline
SET = set()
for _ in range(int(readline())):
    c, s = readline().split()
    if c == "insert":
        SET.add(s)
    elif c == "find":
        print("yes" if s in SET else "no")

Solution (Python):
import sys
readline = sys.stdin.readline
SET = set()
input()
for s in sys.stdin:
    if s[0] == "i":
        SET.add(s[7:])
    elif s[0] == "f":
        print("yes" if s[5:] in SET else "no")

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):
def get_char_value(char):
    if char == "C":
        return 1;
    if char == "A":
        return 2;
    if char == "G":
        return 3;
    if char == "T":
        return 4;

def get_string_value(string):
    s = 0;
    p = 1;
    for char in string:
        s += p * get_char_value(char);
        p *= 5;
    return s;

def h1(value, M):
    return value % M;

def h2(value, M):
    return 1 + value % (M - 1);

def insert(dic, M, string):
    value = get_string_value(string);
    h1_value = h1(value, M);
    h2_value = h2(value, M);
    i = 0;
    while True:
        index = (h1_value + i * h2_value) % M;
        if dic[index] == string:
            break;
        elif dic[index] is None:
            dic[index] = string;
            break;
        i += 1;

def find(dic, M, string):
    value = get_string_value(string);
    h1_value = h1(value, M);
    h2_value = h2(value, M);
    i = 0;
    while True:
        index = (h1_value + i * h2_value) % M;
        if dic[index] == string:
            return True;
        elif dic[index] is None:
            return False;
        i += 1;

M = 1046527;
dic = [None for i in range(M)];
count = int(input());
for i in range(count):
    command = input().split();
    if command[0] == "insert":
        insert(dic, M, command[1]);
    elif command[0] == "find":
        if find(dic, M, command[1]):
            print("yes");
        else:
            print("no");

Solution (Python):
class dictionary:

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

    def insert(self, s):
        self._d.add(s)

    def find(self, s):
        if s in self._d:
            print("yes")
        else:
            print("no")


if __name__ == '__main__':

    dd = dictionary()

    n = int(input())
    for _ in range(n):
        args = input().split()
        if args[0] == "insert":
            dd.insert(args[1])
        elif args[0] == "find":
            dd.find(args[1])

Solution (Python):
import collections

hoge = collections.defaultdict(lambda: 'no')
num = int(input())

for _ in range(num):
    command, key = input().split()
    if command == 'insert':
        hoge[key] = 'yes'
    else:
        print(hoge[key])

Solution (Python):
d=set()
for _ in[0]*int(input()):
 c,g=input().split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
d=set()
for _ in[0]*int(input()):
 c,g=input().split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
d=set()
for _ in[0]*int(input()):
 c,g=input().split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
d=set()
for _ in[0]*int(input()):
 c,g=input().split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
d={}
for _ in[0]*int(input()):
 c,g=input().split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d=set()
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d=set()
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d=set()
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d=set()
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d|=set([g])
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
input()
for e in sys.stdin:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 c,g=e.split()
 if'i'==c[0]:d[g]=0
 else:print(['no','yes'][g in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'i'==e[0]:d[e[7:]]=0
 else:print(['no','yes'][e[5:]in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'i'==e[0]:d[e[7:]]=0
 else:print(['no','yes'][e[5:]in d])

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print(['no','yes'][e[5:]in d])
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print(['no','yes'][e[5:]in d])
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:
  print('yes'if e[5:]in d else'no')
 else:
  d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:
  print('yes'if e[5:]in d else'no')
 else:
  d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:
  print('yes'if e[5:]in d else'no')
 else:
  d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:
  print('yes'if e[5:]in d else'no')
 else:
  d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:
  print('yes'if e[5:]in d else'no')
 else:
  d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

Solution (Python):
import sys
d={}
for e in sys.stdin.readlines()[1:]:
 if'f'==e[0]:print('yes'if e[5:]in d else'no')
 else:d[e[7:]]=0

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

Solution (Python):



import sys

_dict = dict()

n = int(sys.stdin.readline())
for i in range(n):
    cmd, word = sys.stdin.readline().split()
    if cmd == 'insert':
        _dict[word] = True
    elif cmd == 'find':
        if word in _dict:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
def m():
 d={}
 for e in sys.stdin.readlines()[1:]:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={}
 for e in sys.stdin.readlines()[1:]:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={}
 for e in sys.stdin.readlines()[1:]:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={};input()
 for e in sys.stdin:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={};input()
 for e in sys.stdin:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={};input()
 for e in sys.stdin:
  if'f'==e[0]:print('yes'if e[5:]in d else'no')
  else:d[e[7:]]=0
if'__main__'==__name__:m()

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

d = set()

for i in range(n):
    com = input().split()
    if com[0] == "insert":
        d.add(com[1])
    else:
        print("yes" if com[1] in d else "no")

Solution (Python):
dic = set()
n = int(input())
for i in range(n):
    cmd, val = input().split()
    if cmd == "insert":
        dic.add(val)
    elif cmd == "find":
        print("yes" if val in dic else "no")
    else:
        print("wrong command")

Solution (Python):
n = int(input())
D = set([])
for i in range(n):
    A,X = input().split()
    if A[0] == "i":
        D.add(X)
    else:
        if X in D:
            print("yes")
        else:
            print("no")

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

for i in range(n):
    com = input().split()
    if com[0] == "insert":
        d.add(com[1])
    else:
        print("yes" if com[1] in d else "no")

Solution (Python):

d = {}
N = int(input())

for _ in range(N):
    ope, s = map(str, input().split())
    if ope == 'insert':
        d[s] = 0
    elif ope == 'find':
        if s in d.keys():
            print('yes')
        else:
            print('no')

Solution (Python):
import sys 


class Tree:
    def __init__(self):
        self.children = {}
        self.end = False

    def __contains__(self, key):
        if len(key) == 0:
            return self.end

        k, *rest = key 
        if k not in self.children:
            return False

        return rest in self.children[k]

    def add(self, key):
        if len(key) > 0:
            k, *rest = key 
            if k not in self.children:
                self.children[k] = self.__class__()

            self.children[k].add(rest)
        else:
            self.end = True


class Dictionary:
    def __init__(self):
        self.tree = Tree()

    def insert(self, word):
        self.tree.add(word)

    def find(self, word):
        return word in self.tree


def run():
    _ = int(input())  
    words = Dictionary()

    for command in sys.stdin:

        if command.startswith('insert'):
            words.insert(command[7:])
        elif command.startswith('find'):
            if words.find(command[5:]):
                print('yes')
            else:
                print('no')
        else:
            raise ValueError()


if __name__ == '__main__':
    run()

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    cmd, string = input().split()
    if cmd == "insert":
        d[string] = True
    else:
        try:
            if d[string]:
                print("yes")
        except:
            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:
        print('yes'*(val in d) or 'no')

Solution (Python):
n = int(input())
o = {""}
for i in range(n):
    a = len(o)
    op, ob = map(str, input().split())
    if op == "find":
        o.add(ob)
        if len(o) > a:
            print("no")
            o.discard(ob)
        else:
            print("yes")
    else:
        o.add(ob)

Solution (Python):
import sys
def m():
 d={};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d[e[7:]]=0
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={0};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d|={e[7:]}
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={0};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d|={e[7:]}
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={0};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d|={e[7:]}
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={0};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d|={e[7:]}
if'__main__'==__name__:m()

Solution (Python):
import sys
def m():
 d={};input()
 for e in sys.stdin:
  if'f'==e[0]:print(['no','yes'][e[5:]in d])
  else:d[e[7:]]=0
if'__main__'==__name__:m()

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

Solution (Python):

"""
Created on Mon Apr 30 13:14:10 2018
ALDS1-4c  implementation with dictionary
@author: maezawa
"""

n = int(input())
a = dict([])
for s in range(n):
    cmd, word = input().split()
    if cmd == 'insert':
        a[word]=''
    else:
        if word in a:
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())
a = {}
for i in range(n):
    x,m = input().split()
    if x[0] =='i':a[m] = 0
    else:
        if m in a:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

M = 1046527
def h1(key):
    return key % M

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

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

word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4}
def getkey(text):
    sum = 0
    p = 1
    for c in text:
        sum += p*word_dic[c]
        p *= 5
    return sum

dict = [None for i in range(M)]
def find(text):
    key = getkey(text)
    i = 0
    while i < M:
        h = h3(key, i)
        if dict[h] == None:
            break
        elif dict[h] == text:
            return True
        i += 1
    return False

def insert(text):

    key = getkey(text)
    i = 0
    while i < M:
        j = h3(key, i)
        if dict[j] == None:
            dict[j] = text
            break
        else:
            i += 1

n = int(input())
operations = sys.stdin.readlines()
for ope in operations:
    op, text = ope.rstrip().split(' ')
    if op == 'insert':
        insert(text)
    elif op == 'find':
        rst = find(text)
        if rst:
            print('yes')
        else:
            print('no')

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

for i in range(n):
    com = input().split()
    c = com[0]

    if com[1] in dic:
        if c[0] == 'f': ans.append("yes")
        else: pass

    else:
        if c[0] == 'i': dic[ com[1] ] = i
        else: ans.append("no")


for i in ans: print(i)

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

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

strs = {}

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

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

    s_set = set()
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            s_set.add(order[1])
        else:
            if order[1] in s_set:
                print("yes")
            else:
                print("no")


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
dic={}
a=[]
b=[]
for i in range(n):
	tmp1,tmp2=input().split()
	a.append(tmp1)
	b.append(tmp2)

for i in range(n):
	if a[i]=='insert':
		dic[b[i]]=1
	else:
		if b[i] in dic:
			print("yes")
		else:
			print("no")

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

Solution (Python):

n = int(input())
d = set()
for i in range(n):
    x = input()
    if x[0] == "i":
        d.add(x[7:])
    else :
        if(x[5:] in d) : print("yes")
        else : print("no")

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

Solution (Python):
n=int(input())
list={}
list1=[]
for i in range(n):
    a,b=map(str,input().split())
    if a=="insert":
        list.setdefault(b,i)
    if a=="find":
        if b in list:
            list1.append("yes")
        else:
            list1.append("no")

for i in list1:
    print(i)

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

for i in ans:
	print(i)

Solution (Python):

n = int(input())
box = set()

for _ in range(n):
    tmp,mozi= input().split()
    
    if tmp == "find":
        if mozi in box:
            print("yes")
        else:
            print("no")
    else:
        box.add(mozi)

Solution (Python):
n = int(input())
d = set()
for i in range(n):
    x = input()
    if x[0] == "i":
        d.add(x[7:])
    else :
        if(x[5:] in d) : print("yes")
        else : print("no")

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    x = input()
    if x[0] == "i":
        d[x[7:]] = 1
    else :
        if(x[5:] in d.keys()) : print("yes")
        else : print("no")

Solution (Python):
n=int(input())
dict={}
for i in range(n):
    str=input()
    if str[0]=="i":
        dict.update({str[7:]:1})
    else:
        if str[5:] in dict:
            print("yes")
        else:
            print("no")

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

Solution (Python):
import sys

n = int(input())
dct = set()

for line in sys.stdin:

    cmd, val = line.strip().split()

    if cmd == 'insert':
        dct.add(val)

    else:
        if val in dct:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

n = int(input())
htable = [0 for _ in range(16777216)]


def to_int(s):
    if s == 'A':
        return 1
    elif s == 'C':
        return 2
    elif s == 'G':
        return 3
    else:
        return 4


def to_hash(string):
    h = 0
    for i, s in enumerate(string):
        ints = to_int(s)
        h += 4**i * ints

    return h


def insert(string):
    h = to_hash(string)
    htable[h] = 1


def find(string):
    h = to_hash(string)
    if htable[h]:
        print('yes')
    else:
        print('no')


for line in sys.stdin:
    cmd, string = line.strip().split()

    if cmd == 'insert':
        insert(string)

    else:
        find(string)

Solution (Python):



def get_key(_str):
    key = 0
    for i in range(len(_str)):
        if _str[i] == 'A': key += 1
        elif _str[i] == 'C': key += 2
        elif _str[i] == 'G': key += 3
        elif _str[i] == 'T': key += 4
        key *= 5
    return key
    
def main():
    n = int(input())
    dict = {}
    for i in range(n):
        command = input().split()
        if command[0][0] == 'i':
            dict[get_key(command[1])] = command[1]
        else:
            key = get_key(command[1])
            if key in dict: print('yes')
            else: print('no')
    
if __name__ == "__main__":
    main()

Solution (Python):
import sys

htable = [0] * 16777216


def to_int(s):
    if s == 'A':
        return 1
    elif s == 'C':
        return 2
    elif s == 'G':
        return 3
    else:
        return 4


def to_hash(string):
    h = 0
    for i, s in enumerate(string):
        ints = to_int(s)
        h += 4**i * ints

    return h


def insert(string):
    h = to_hash(string)
    htable[h] = 1


def find(string):
    h = to_hash(string)
    if htable[h]:
        print('yes')
    else:
        print('no')


if __name__ == '__main__':

    n = int(input())

    for line in sys.stdin:
        cmd, string = line.strip().split()

        if cmd == 'insert':
            insert(string)

        else:
            find(string)

Solution (Python):
import sys
n = int(input())
input_lines = [input() for i in range(n)]
char_set = set()
for i in range(n):
    line = input_lines[i].split()
    if line[0] == 'insert':
        char_set.add(line[1])
    elif line[0] == 'find' and line[1] in char_set:
        print('yes')
    else:
        print('no')

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


def main():
    n = int(input())
    d = set()
    for _ in range(n):
        op, s = input().split()
        if op == 'insert':
            d.add(s)
        else:
            if s in d:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    main()