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())
A = [input() for i in range(N)]

D = {}
for row in A:
    order, key = row.split()
    if order[0] == "i":
        D[key] = 1
    else:
        if key in D.keys():
            print("yes")
        else:
            print("no")

Solution (Python):
n = int(input())
s = {2}
s.remove(2)
for i in range(n):
    order = list(map(str, input().split()))
    if (order[0][0] == 'i'):
        s.add(order[1])
    else:
        if order[1] in s:
            print('yes')
        else:
            print('no')

Solution (Python):

import sys

htable = [0] * 4 ** 12


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




n = int(input())

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

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

Solution (Python):
n = int(input())
mydict = {}
answer_list = []

for i in range(n) :
    query, wd = input().split()
    
    if query == "insert" :
        mydict[wd] = 1
    else :
        if wd in mydict.keys() : answer_list.append("yes")
        else : answer_list.append("no")
        
for i in answer_list :
    print(i)

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

added_strings = set()
for i in range(n):
    com, s = input().split()
    if com == 'insert':
        added_strings.add(s)
    elif com == 'find':
        print('yes' if (s in added_strings) else 'no')

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

Solution (Python):
import sys
n = int(input())
d = set()
for i in sys.stdin:
    c, s = i.split()
    if c == 'insert':
        d.add(s)
    else:
        print('yes' if s in d else 'no')

Solution (Python):
n = int(input())
dic = set()
for i in range(n):
    x = input()
    if 'insert' in x:
        dic.add(x.strip('insert '))
    else :
        if x.strip('find ') in dic:
            print('yes')
        else :
            print('no')

Solution (Python):
import sys

def main():
    lines = sys.stdin.readlines()
    n = int(lines[0])

    repo = {}
    for i in range(1, n + 1):
        command, acgt = lines[i].split()
        if command[0] == 'i':
            if acgt not in repo:
                repo[acgt] = 0
        elif command[0] == 'f':
            if acgt in repo:
                print('yes')
            else:
                print('no')
    return


main()

Solution (Python):
def main():
    dictionary = set()
    for _ in range(int(input())):
        command = input().split()
        if command[0] == 'insert':
            dictionary.add(command[1])
        else:
            print('yes' if command[1] in dictionary else 'no')


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
data = {}
for _ in range(n):
    key = input()
    if key[0] == 'i':
        data.setdefault(key[7:], '0')
    else:
        if key[5:] in data:
            print('yes')
        else:
            print('no')

Solution (Python):
order_num = int(input())
jisho = {}
for _i in range(order_num):
    order, key = input().split()
    if order == 'insert':
        jisho[key] = ''
    elif order == 'find':
        try:
            jisho[key]
            print('yes')
        except KeyError:
            print('no')

Solution (Python):
n = int(input())
dict = set()
for _ in range(n):
    c, s = input().split()
    if c == 'insert':
        dict.add(s)
    else:
        print(('no', 'yes')[s in dict])

Solution (Python):


n = int(input())
d = set()
for _ in range(n):
    cmd, data = input().split()
    if cmd == 'insert':
        d.add(data)
    else:
        if data in d:
            print("yes")
        else:
            print("no")

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

Solution (Python):
N=int(input())
dic={}
for _ in range(N):
    c,s=input().split()
    if c=="insert":
        dic[s]=True
    else:
        print("yes" if s in dic else "no")

Solution (Python):
h={}
for _ in range(input()):
    a,b=raw_input().split()
    if a[0]=="f":
        print "yes" if b in h else "no"
    else:
        h[b]=1

Solution (Python):
n = input()
a = set()

for x in xrange(n):
	(i, f) = map(str, raw_input().split())
	if i == "insert":
		a.add(f)
	else:
		if f in a:
			print "yes"
		else:
			print "no"

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

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

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

Solution (Python):
se = set([])
n = int(raw_input())
for i in range(n):
    order, string = raw_input().split()
    if order == 'insert':
        se.add(string)
    elif order == 'find':
        if string in se:
            print 'yes'
        else:
            print 'no'

Solution (Python):
n = input()
table =	set()

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

Solution (Python):
n = int( raw_input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		try:
			dic[ word ]
			output.append( "yes" )
		except KeyError:
			output.append( "no" )

print( "\n".join( output ) )

Solution (Python):
n = int( input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		try:
			dic[ word ]
			output.append( "yes" )
		except KeyError:
			output.append( "no" )

print( "\n".join( output ) )

Solution (Python):
n = int( raw_input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if not dic.get( word ):
			output.append( "no" )
		else:
			output.append( "yes" )

print( "\n".join( output ) )

Solution (Python):
n = int( input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if not dic.get( word ):
			output.append( "no" )
		else:
			output.append( "yes" )

print( "\n".join( output ) )

Solution (Python):
n = int( raw_input( ) )
dic = {}
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if not dic.get( word ):
			print( "no" )
		else:
			print( "yes" )

Solution (Python):
n = int( raw_input( ) )
dic = {}
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if word in dic:
			print( "yes" )
		else:
			print( "no" )

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

Solution (Python):
n = int(raw_input())
d = {}
for i in range(n):
    p,q = map(str,raw_input().split())
    if p == "insert":
        d[q] = 1
    elif p == "find":
        if(q in d):
            print "yes"
        else:
            print "no"

Solution (Python):
n = int(raw_input())
d = set()
for i in range(n):
    p,q = map(str,raw_input().split())
    if p == "insert":
        d.add(q)
    elif p == "find":
        if(q in d):
            print "yes"
        else:
            print "no"

Solution (Python):
n = int(input())
d = set()
for _ in range(n):
    command = input()
    if 'i' == command[0]:
        _, word = command.split()
        d.add(word)
    else:
        _, word = command.split()
        print('yes' if word in d else 'no')

Solution (Python):
n=int(raw_input())
a={}
for i in range(n):
	inst,key=raw_input().split()
	if inst=='insert': 
		a.update({key:i})
	elif inst=='find': 
		if a.has_key(key)==True:
			 print 'yes'
		else:print 'no'

Solution (Python):
import sys

n = int(input())
dic = set()
for i in range(n):
    s = sys.stdin.readline()
    if s[0] == "i":
        dic.add(s[7:])
    else:
        print('yes' if s[5:] in dic else 'no')

Solution (Python):
n = int(raw_input())
d = {}
for i in xrange(n):
    L = raw_input().split()
    if L[0] == 'insert':
        d[hash(L[1])] = L[1]
    else:
        if d.has_key(hash(L[1])):
            print 'yes'
        else:
            print 'no'

Solution (Python):
count=int(raw_input())
l=set()
for i in xrange(count):
	a,b=raw_input().split()
	if a=='insert':
		l.add(b)
	elif b in l:
		print 'yes'
	else:
		print 'no'

Solution (Python):
import sys


def main():
    orders = sys.stdin.readlines()[1:]
    dna_set = set()
    for order in orders:
        command, dna = order.split(" ")
        if command == "insert":
            dna_set.add(dna)
        elif command == "find":
            if dna in dna_set:
                print("yes")
            else:
                print("no")


if __name__ == "__main__":
    main()

Solution (Python):


n = int(input())
dic = set()
for i in range(n):
    cmd, word = input().split()
    if cmd == "find":
        if word in dic:
            print("yes")
        else:
            print("no")
    else:
        dic.add(word)

Solution (Python):




def process(commands):
    d = set()
    for c in commands:
        cpair = c.split()
        if cpair[0] == "insert":
            d.add(cpair[1])
        elif cpair[0] == "find":
            r = "yes" if cpair[1] in d else "no"
            print(r)


def main():
    n = int(input())
    commands = [input() for i in range(n)]
    process(commands)


if __name__ == "__main__":
    main()

Solution (Python):
n = input()

dict_ = set()
for _ in xrange(n):
    cmd, str_ = raw_input().split()
    if cmd == "insert":
        dict_.add(str_)
    elif cmd == "find":
        if str_ 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 == "find":
        if key in dic:
            print("yes")
        else:
            print("no")
    else:
        dic.add(key)

Solution (Python):
class Dictionary:
    def __init__(self):
        self.elements = set()
    def insert(self, x):
        self.elements.add(x)
    def find(self, y):
        if y in self.elements:
            print('yes')
        else:
            print('no')

import sys

n = int(sys.stdin.readline())

simple_dict = Dictionary()

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        simple_dict.find(operation[5:])

Solution (Python):
n = int(raw_input().strip())
commands = []
for i in range(n):
    commands.append(raw_input().strip())


d = [False]*67108870

def hash(s):
    ret = 0
    i = 0
    for dg in s:
        if dg == 'A':
            ret += 0 * 4**i
        elif dg == 'C':
            ret += 1 * 4**i
        elif dg == 'G':
            ret += 2 * 4**i
        elif dg == 'T':
            ret += 3 * 4**i
        i += 1
    return ret

def insert(d,s):
    h = hash(s)
    d[h] = True

def find(d,s):
    h = hash(s)
    if d[h]: print 'yes'
    else: print 'no'

for c in commands:
    c += 'C'
    if c[0] == 'i':
        insert(d,c[7:])
    else:
        find(d,c[5:])

Solution (Python):
class HashTable:
    def __init__(self, size = 1000003):
        self.size = size
        self.hash_table = [None] * size

    def _gen_key(self, val):
        raw_hash_val = hash(val)
        h1 = raw_hash_val % self.size
        h2 = 1 + (raw_hash_val % (self.size - 1))
        for i in range(self.size):
            candidate_key = (h1 + i * h2) % self.size
            if not self.hash_table[candidate_key] or self.hash_table[candidate_key] == val:
                return candidate_key

    def insert(self, val):
        key = self._gen_key(val)
        self.hash_table[key] = val

    def search(self, val):
        key = self._gen_key(val)
        if self.hash_table[key]:
            return True
        else:
            return False


import sys

n = int(sys.stdin.readline())

simple_dict = HashTable()

ans = ''

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        if simple_dict.search(operation[5:]):
            ans += 'yes'
        else:
            ans += 'no'
        ans += '\n'

print(ans, end = '')

Solution (Python):
class HashTable:
    def __init__(self, size = 1000003):
        self.size = size
        self.hash_table = [None] * size

    def _gen_key(self, val):
        raw_hash_val = hash(val)
        h1 = raw_hash_val % self.size
        h2 = 1 + (raw_hash_val % (self.size - 1))
        for i in range(self.size):
            candidate_key = (h1 + i * h2) % self.size
            if not self.hash_table[candidate_key] or self.hash_table[candidate_key] == val:
                return candidate_key

    def insert(self, val):
        key = self._gen_key(val)
        self.hash_table[key] = val

    def search(self, val):
        key = self._gen_key(val)
        if self.hash_table[key]:
            print('yes')
        else:
            print('no')


import sys

n = int(sys.stdin.readline())

simple_dict = HashTable()

ans = ''

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        simple_dict.search(operation[5:])

Solution (Python):
class HashTable:
    def __init__(self, size = 1000003):
        self.size = size
        self.hash_table = [None] * size

    def _gen_key(self, val):
        raw_hash_val = hash(val)
        h1 = raw_hash_val % self.size
        h2 = 1 + (raw_hash_val % (self.size - 1))
        for i in range(self.size):
            candidate_key = (h1 + i * h2) % self.size
            if not self.hash_table[candidate_key] or self.hash_table[candidate_key] == val:
                return candidate_key

    def insert(self, val):
        key = self._gen_key(val)
        self.hash_table[key] = val

    def search(self, val):
        key = self._gen_key(val)
        if self.hash_table[key]:
            return True
        else:
            return False


import sys

n = int(sys.stdin.readline())

simple_dict = HashTable()

ans = ''

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        if simple_dict.search(operation[5:]):
            ans += 'yes'
        else:
            ans += 'no'
        ans += '\n'

print(ans, end = '')

Solution (Python):



se = set()
n = int(input())
tmp = [input().split() for i in range(n)]


for i in tmp:
    cmd, v = i
    if cmd == "find":
        if v in se:
            print("yes")
        else:
            print ("no")
    else:
        se.add(v)

Solution (Python):
N = int(input())
dictionary = dict()
for i in range(N):
    command, string = input().split()
    if command == "insert":
        dictionary[string] = True
    elif dictionary.get(string) == None:
        print("no")
    else:
        print("yes")

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

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

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

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

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

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

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


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


    tmp_key = ''
    for x in list(d[1]):
        tmp_key += dict[x]

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

Solution (Python):
l, n, r = set(), int(input()), str.maketrans('ACGT', '1234')

for _ in range(n):
    opr, word = input().split()
    word = int(word.translate(r), base=5)
    if opr.startswith('i'):
        l.add(word)
    else:
        print('yes' if word in l else 'no')

Solution (Python):
dic=dict()
n = int(input())
for i in range(n):
    a = input()
    t=a.split()
    if t[0] == "insert":
        dic[t[1]] = True
    else:
        if t[1] in dic:
            print("yes")
        else:
            print("no")

Solution (Python):
def insert(S, string):
    S.add(string)

def find(S, string):
    if string in S:
        print 'yes'
    else:
        print 'no'

n = input()

S = set()

for i in range(n):
    tmp1, tmp2  = map(str, raw_input().split())
    if tmp1 == 'insert':
        insert(S, tmp2)
    elif tmp1 == 'find':
        find(S, tmp2)
    else:
        print 'error!'

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

Solution (Python):
M = 1046527
L = 14
H = [""] * M

def getChar(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 getKey(strings):
    Sum = 0
    p = 1
    for i in xrange(len(strings)):
        Sum += p * getChar(strings[i])
        p *= 5

    return Sum

def h1(key):
    return key % M

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

def find(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            return 0
        else:
            i += 1
    return 0

def insert(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            H[h] = strings
            return 0
        else:
            i += 1
    return 0

def main():
    n = input()
    for i in xrange(n):
        com = raw_input().split()
        if com[0][0] == 'i':
            insert(com[1])
        else:
            if find(com[1]):
                print 'yes'
            else:
                print 'no'
    return 0

main()

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

for _ in range(n):
    cmd, arg = input().split()
    if cmd == "insert":
        dictionary.add(arg)
    elif cmd == "find":
        if arg in dictionary:
            print("yes")
        else:
            print("no")

Solution (Python):
def f():
    return raw_input()
def f2():
    return raw_input().split()

dic = {}
n = int(f())
for i in range(n):
    c1, c2 = f2()
    if c1 == 'insert':
        dic[c2] = 548
    elif c1 == 'find':
        if dic.has_key(c2):
            print 'yes'
        else:
            print 'no'

Solution (Python):
import sys

class HashTable:
    def __init__(self):
        self.table = [None] * 4
        self.flag = False

class Dictionary:
    def __init__(self):
        self.hashTable = HashTable()

    def insert(self, key):
        table = self.hashTable
        for c in key:
            hash = self.toHash(c)
            if table.table[hash] is None:
                table.table[hash] = HashTable()
            table = table.table[hash]
        table.flag = True

    def find(self, key):
        table = self.hashTable
        for c in key:
            hash = self.toHash(c)
            if table.table[hash] is None:
                return False
            table = table.table[hash]
        if table.flag:
            return True
        else:
            return False

    def toHash(self, key):
        if key == "A":
            return 0
        elif key == "C":
            return 1
        elif key == "G":
            return 2
        else:
            return 3

if __name__ == "__main__":
    dic = Dictionary()
    lines = sys.stdin.readlines()
    del lines[0]
    for command in lines:
        key = command.split()[1]
        if command[0] == "i":
            dic.insert(key)
        else:
            if dic.find(key):
                print "yes"
            else:
                print "no"

Solution (Python):
n = int(input())
arr = {}
for i in range(n):
		cmd = input()
		if cmd[0] == "i":
			arr[cmd[7::]] = 0
		else:
			print("yes" if cmd[5:] in arr else "no")

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


n = int(raw_input())
dic = set()
for i in range(n):
    com, s = map(str, raw_input().split())
    if com == "insert":
        dic.add(s)
    elif com == "find":
        if s in dic:
            print "yes"
        else:
            print "no"

Solution (Python):
import sys
dic = set()
L = sys.stdin.readlines()

for Ins in L[1:]:
    ins, op = Ins.split()
    if ins == 'insert':
        dic.add(op)
    if ins == 'find':
        print('yes' if op in dic else 'no')

Solution (Python):
M = 1046527
L = 14
H = [""] * M
 
def getChar(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 getKey(strings):
    Sum = 0
    p = 1
    for i in xrange(len(strings)):
        Sum += p * getChar(strings[i])
        p *= 5
 
    return Sum
 
def h1(key):
    return key % M
 
def h2(key):
    return 1 + (key % (M-1))
 
def find(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            return 0
        else:
            i += 1
    return 0
 
def insert(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            H[h] = strings
            return 0
        else:
            i += 1
    return 0
 
def main():
    n = input()
    for i in xrange(n):
        com = raw_input().split()
        if com[0][0] == 'i':
            insert(com[1])
        else:
            if find(com[1]):
                print 'yes'
            else:
                print 'no'
    return 0
 
main()

Solution (Python):
n=int(input())
d = {}
for _ in range(n):
    op,s = input().split()
    if   op == 'insert': d[s] = 'yes'
    elif op == 'find'  : print(d.get(s,'no'))

Solution (Python):
n = input()
dic = set([])
for i in xrange(n):
    order = raw_input().split()
    if order[0][0] == 'i':
        dic.add(order[1])
    else:
        print "yes" if order[1] in dic else "no"

Solution (Python):
import sys

dict = {}
n = int(input())
l = []
line = map(lambda x:x.split(), sys.stdin.readlines())
s = ""
for (c,arg) in line:
    if c == "insert":
        dict[arg] = 0
    elif c == "find":
        if arg in dict:
            s += "yes\n"
        else:
            s += "no\n"
print(s,end="")

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

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

Solution (Python):

sample_input = list(range(4))
sample_input[0] = '''6
insert AAA
insert AAC
find AAA
find CCC
insert CCC
find CCC'''
sample_input[1] = '''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_input[2] = '''20
find CTT
find TAG
insert AA
insert CTC
find G
insert TGT
find AAC
find TTG
insert AA
insert TTG
insert G
insert A
insert GG
insert C
insert TT
find T
insert C
find GG
find G
insert CG'''
sample_input[3]='''15
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
find CC
insert T
find TTT
find T
find A'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        


class ACGTDictNode (object):
    
    def __init__(self):
        self.A = None    
        self.C = None
        self.G = None
        self.T = None
        self.has_end = False
    
    
    def add_if_none(self, acgt):
        if acgt == 'A':
            if self.A is not None:
                return self.A
            else:
                self.A = ACGTDictNode()
                return self.A
        elif acgt == 'C':
            if self.C is not None:
                return self.C
            else:
                self.C = ACGTDictNode()
                return self.C
        elif acgt == 'G':
            if self.G is not None:
                return self.G
            else:
                self.G = ACGTDictNode()
                return self.G
        elif acgt == 'T':
            if self.T is not None:
                return self.T
            else:
                self.T = ACGTDictNode()
                return self.T
        else:
            assert False
            
            
    def get(self, acgt):
        if acgt == 'A':
            return self.A
        elif acgt == 'C':
            return self.C
        elif acgt == 'G':
            return self.G
        elif acgt == 'T':
            return self.T
        else:
            assert False
            
    
    def add_end(self):
        self.has_end = True

        

class ACGTDict (object):
    
    def __init__(self):
        self.tree = ACGTDictNode()
        
        
    def insert(self, string):
        node = self.tree
        for c in string:
            node = node.add_if_none(c)
        node.add_end()
            
    
    def find(self, string):
        node = self.tree
        for c in string:
            node = node.get(c)
            if node is None:
                return False
        return node.has_end
        
        

dict = ACGTDict()
num_of_commands = int(input())
for n in range(num_of_commands):
    input_str = input()
    command, data = input_str.split(' ')
    if command == 'insert':
        dict.insert(data)
    else:
        if dict.find(data):
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
dic = set()
L = sys.stdin.readlines()

for Ins in L[1:]:
    ins, op = Ins.split()
    if ins == 'insert':
        dic.add(op)
    if ins == 'find':
        print('yes' if op in dic else 'no')

Solution (Python):
import sys

n = int(input())
dic = {}

for i in range(n):
    c, s = sys.stdin.readline().split()
    if c == 'insert':
        dic[s] = 0
    else:
        if s in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

n = int(input())
dic = set()

for i in range(n):
    c, s = sys.stdin.readline().split()
    if c == 'insert':
        dic.add(s)
    else:
        if s in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

n = int(input())
dic = set()
input_ = [x.split() for x in sys.stdin.readlines()]

for c, s in input_:
    if c == 'insert':
        dic.add(s)
    else:
        if s in dic:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

n = int(input())
dic = {}
input_ = [x.split() for x in sys.stdin.readlines()]

for c, s in input_:
    if c == 'insert':
        dic[s] = 0
    else:
        if s in dic:
            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):
num = int(input())
sets = {}
for n in range(num):
    temp = input()
    if temp[0] == 'i':
        sets[temp.split(' ')[1]] = 0
    else:
        if temp.split(' ')[1] in sets:
            print("yes")
        else:
            print("no")

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

Solution (Python):
dict = {}
n = int(raw_input())
for _ in xrange(n):
  com, word = raw_input().split()
  if com == "insert":
    dict[word] = True
  else:
    if word in dict:
      print "yes"
    else:
      print "no"

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

dic = {}
for i in range(n):
    inst, c = input().split()
    if inst[0] == 'i':
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 0
    else:
        if c in dic:
            print('yes')
        else:
            print('no')

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

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

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

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

Solution (Python):


def main():
    n = input()
    dic = {}
    for i in xrange(n):
        command, ope = raw_input().split()
        if command == "insert":
            dic[ope] = 1
        elif command =="find":
            if ope in dic:
                print "yes"
            else:
                print "no"

if __name__ == '__main__':
    main()