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 = 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):
n=input()

d=set()
for x in xrange(n):
    cmd, st = map(str, raw_input().split())
    
    if cmd == "insert":
        d.add(st)
    elif cmd == "find":
        print 'yes' if st in d else 'no'

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

Solution (Python):
import sys

n = int(input())
s = set()
for i in range(n):
    ins = input().split()
    if ins[0] == "insert":
        s.add(ins[1])
    elif ins[0] == "find":
        if ins[1] in s:
            print("yes")
        else:
            print("no")

Solution (Python):




import sys


def h1(key):
    return key % m


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


def h(key, i):
    return (h1(key) + i * h2(key)) % m


def insert(T, key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == 'NULL':
            T[j] = key
            return j
        else:
            i += 1


def search(T, key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == key:
            print('yes')
            return j
        elif T[j] == 'NULL' or i >= m:
            print('no')
            return 'NULL'
        else:
            i += 1


def str_to_key(_str):
    _length = len(_str)
    _sum, p = 0, 1
    for i in range(_length):
        _sum += p * (ord(_str[i]) - 64)
        
        p *= 5

    
    
    
    return _sum


def action(command, content):
    key = str_to_key(content)
    if command[0] == 'i':
        insert(T=T, key=key)
    elif command[0] == 'f':
        search(T=T, key=key)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    m = 1046527
    length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    T = ['NULL' for _ in range(m)]
    for command, content in command_list:
        action(command=command, content=content)

Solution (Python):




import sys


def h1(key):
    return key % m


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


def h(key, i):
    return (h1(key) + i * h2(key)) % m


def insert(key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == 'NULL':
            T[j] = key
            return j
        else:
            i += 1


def search(key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == key:
            print('yes')
            return j
        elif T[j] == 'NULL' or i >= m:
            print('no')
            return 'NULL'
        else:
            i += 1


def str_to_key(_str):
    _length = len(_str)
    _sum, p = 0, 1
    for i in range(_length):
        _sum += p * (ord(_str[i]) - 64)
        
        p *= 5

    
    
    
    return _sum


def action(command, content):
    key = str_to_key(content)
    if command[0] == 'i':
        insert(key=key)
    elif command[0] == 'f':
        search(key=key)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    m = 1046527
    length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    T = ['NULL' for _ in range(m)]
    for command, content in command_list:
        action(command=command, content=content)

Solution (Python):




import sys


def h1(key):
    return key % m


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


def h(key, i):
    return (h1(key) + i * h2(key)) % m


def insert(key):
    i = 0
    while True:
        j = h(key, i)
        if not T[j]:
            T[j] = key
            return j
        else:
            i += 1


def search(key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == key:
            print('yes')
            return j
        elif not T[j] or i >= m:
            print('no')
            return None
        else:
            i += 1


def str_to_key(_str):
    _length = len(_str)
    _sum, p = 0, 1
    for i in range(_length):
        _sum += p * (ord(_str[i]) - 64)
        
        p *= 5

    
    
    
    return _sum


def action(command, content):
    key = str_to_key(content)
    if command[0] == 'i':
        insert(key=key)
    elif command[0] == 'f':
        search(key=key)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    m = 1046527
    length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    T = [None] * m
    for command, content in command_list:
        action(command=command, content=content)

Solution (Python):



ARRY_SIZE = 1000003

def hash1(key):
	return key % (ARRY_SIZE)

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

def hash_combo(key, i):
	return (hash1(key) + i * hash2(key)) % ARRY_SIZE

def insert(arr,key):
	i = 0

	while True:
		j = hash_combo(key, i)
		if arr[j] == "":
			arr[j] = key
			return True
		else:
			i +=  1

def find(arr, key):
	i = 0
	while True:
		j = hash_combo(key,i)
		if arr[j] == key:
			return True
		elif arr[j] == "" or i >= ARRY_SIZE:
			return False
		else:
			i += 1

def getKey(pre_key):
	key =[]
	for pk in pre_key:
		if pk == "A":
			key.append(1)
		elif pk == "C":
			key.append(2)
		elif pk == "G":
			key.append(3)
		else:
			key.append(4)
	return int("".join(map(str,key)))
		
	


def main():
	N = int(raw_input())
	cmd = [raw_input().split() for _ in range(N)]
	dic = [""] * ARRY_SIZE

	for i in range(N):
		if cmd[i][0] == "insert":
			insert(dic, getKey(cmd[i][1]))
		elif cmd[i][0] == "find":
			if find(dic, getKey(cmd[i][1])):
				print "yes"
			else:
				print "no"





if __name__ == '__main__':
	main()

Solution (Python):


if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = set([])
    for c, s in input_list:
        if c == "insert":
            l.add(s)
        else:
            if s in l:
                print("yes")
            else:
                print("no")

Solution (Python):


if __name__ == "__main__":
    n_line = int(input())
    l = set([])
    for i in range(n_line):
        input_line = input().split()
        if input_line[0] == "insert":
            l.add(input_line[1])
        else:
            if input_line[1] in l:
                print("yes")
            else:
                print("no")

Solution (Python):


if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = set([])
    for c, s in input_list:
        if c == "insert":
            l.add(s)
        else:
            if s in l:
                print("yes")
            else:
                print("no")

Solution (Python):
def use_dictionary(commands):
    d = {}
    for cmd, word in commands:
        if cmd == 'insert':
            d[word] = True
        elif cmd == 'find':
            if word in d:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    
    commands = []
    
    
    
    
    
    
    num = int(input())
    for i in range(num):
        commands.append([x for x in input().split(' ')])

    
    use_dictionary(commands)

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

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

Solution (Python):



''' ?????? '''


class Dictionary(object):
    """ Dictionary """

    def __init__(self):
        self.dict = {}

    def insert(self, x):
        self.dict[x] = 0

    def find(self, x):
        if x in self.dict.keys():
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    N = int(input())

    d = Dictionary()

    for _ in range(N):
        command, key = list(input().split())
        if command == 'insert':
            d.insert(key)
        elif command == 'find':
            d.find(key)

Solution (Python):
class Dictionary_class:
    def __init__(self):
        self.dic = set()

    def insert(self, str):
        self.dic.add(str)

    def find(self, str):
        if str in self.dic:
            return True
        else:
            return False

n = int(input())
answer = ""
dic = Dictionary_class()
for i in range(n):
    instruction = input().split()
    if instruction[0] == "insert":
        dic.insert(instruction[1])
    elif instruction[0] == "find":
        if dic.find(instruction[1]):
            answer += "yes\n"
        else:
            answer += "no\n"
print(answer, end = "")

Solution (Python):

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

for i in range(n):
    cmd = input().split()

    if cmd[0] == "insert":
        dic.add(cmd[1])
    else:
        print("yes" if cmd[1] in dic else "no")

Solution (Python):
import sys

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

for i in range(n):
    cmd = sys.stdin.readline().split()

    if cmd[0] == "insert":
        dic.add(cmd[1])
    else:
        print("yes" if cmd[1] in dic else "no")

Solution (Python):
d={}
for _ in range(int(input())):
    a,b=input().split()
    if a=='find':
        if b in d:print('yes')
        else:print('no')
    else:d[b]=0

Solution (Python):
t = set()
m = int(input())
for i in range(m):
    cmd, key = input().split()
    if cmd == "insert":
        t.add(key)
    else:
        if key in t:
            print("yes")
        else:
            print("no")

Solution (Python):
import sys

def h1(key):
    return key % M

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

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

def my_insert(dic, key):
    i = 0

    while 1:
        j = H(key, i)
        if dic[j] is None:
            dic[j] = key
            return j
        else:
            i += 1

def my_search(dic, key):
    i = 0

    while 1:
        j = H(key, i)
        if dic[j] == key:
            return True
        elif dic[j] is None or i >= M:
            return False
        else:
            i += 1

def str2int(s):
    res = s

    res = res.replace("A", "1")
    res = res.replace("C", "2")
    res = res.replace("G", "3")
    res = res.replace("T", "4")

    return int(res)

M = 1000003
dic = [None] * M

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

for k in range(n):
    cmd, s = sys.stdin.readline().split()

    if cmd == "insert":
        my_insert(dic, str2int(s))
    else:
        print("yes" if my_search(dic, str2int(s)) else "no")

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

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

Solution (Python):
dic = {}

for i in range(int(input())):
  cmd, arg = input().split()
  if cmd == "insert":
    dic[arg] = 0
  else:
    if arg in dic:
      print("yes")
    else:
      print("no")

Solution (Python):
import sys
from collections import ChainMap
input()
rp = sys.stdin.readlines()
cm = ChainMap()

for i in rp:
    if i[0] == 'i':
        cm[i[7:]] = 0
    else:
        if i[5:] in cm:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys

input()
rp = sys.stdin.readlines()
cm = {}

for i in rp:
    if i[0] == 'i':
        cm[i[7:]] = 0
    else:
        if i[5:] in cm:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
input()
rl = sys.stdin.readlines()
d = {}

for i in rl:
    
    if i[0] == 'i':
    
        d[i[7:]] = 0
        
    else:
        if i[5:] in d:
        
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
input()
rl = sys.stdin.readlines()
d = {}

for i in rl:
    c, s = i.split()
    
    if c[0] == 'i':
        
        d[s] = 0
    else:
        
        if s in d:
            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:
        print('yes' if i[5:] in d else '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):
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):
import sys


fin = sys.stdin

n = int(fin.readline())
d = {}

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

Solution (Python):
import sys
n = int(input())
command = sys.stdin.readlines()
Q = {}
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q[b] = 0
    else:
        if b in Q.keys():
            print("yes")
        else:
            print("no")

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

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

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")

Solution (Python):


def input_converter(key_string):
    key_string = key_string.replace('A', '1')
    key_string = key_string.replace('T', '2')
    key_string = key_string.replace('C', '3')
    key_string = key_string.replace('G', '4')
    return int(key_string)


class HashTable(object):
    def __init__(self, hash_size = 2 ** 26):
        self.hash_size = hash_size
        self.hash_array = [None] * self.hash_size

    def insert_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        while self.hash_array[next_index] is not None:
            collision_number += 1
            next_index = self.hash_function(key, collision_number)
        
        self.hash_array[next_index] = data

    def search_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        next_data = self.hash_array[next_index]
        while True:
            if (next_data is None) or (collision_number > self.hash_size):
                return False
            elif next_data == data:
                return True
            else:            
                collision_number +=1
                next_index = self.hash_function(key, collision_number)
                next_data = self.hash_array[next_index]

    def hash_function(self, key, collision_number):
        def h1(key):
            return key % self.hash_size
    
        def h2(key):
            return key % (self.hash_size - 1)

        return (h1(key) + collision_number * h2(key)) % self.hash_size


def main():
    input_size = int(raw_input())
    hash_table = HashTable()
    counter = 0
    while counter < input_size:
        command, key = raw_input().split(' ')
        if command == 'insert':
            hash_table.insert_value(key, input_converter(key))
        else:
            if hash_table.search_value(key, input_converter(key)):
                print 'yes'
            else:
                print 'no'
        counter += 1


if __name__ == '__main__':
    main()

Solution (Python):


def input_converter(key_string):
    key_string = key_string.replace('A', '1')
    key_string = key_string.replace('T', '2')
    key_string = key_string.replace('C', '3')
    key_string = key_string.replace('G', '4')
    return int(key_string)


class HashTable(object):
    def __init__(self, hash_size = 2 ** 26):
        self.hash_size = hash_size
        self.hash_array = [None] * self.hash_size

    def insert_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        while self.hash_array[next_index] is not None:
            collision_number += 1
            next_index = self.hash_function(key, collision_number)
        self.hash_array[next_index] = data

    def search_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        next_data = self.hash_array[next_index]
        while True:
            if (next_data is None) or (collision_number > self.hash_size):
                return False
            elif next_data == data:
                return True
            else:            
                collision_number +=1
                next_index = self.hash_function(key, collision_number)
                next_data = self.hash_array[next_index]

    def hash_function(self, key, collision_number):
        def h1(key):
            return key % self.hash_size
    
        def h2(key):
            return key % (self.hash_size - 1)

        return (h1(key) + collision_number * h2(key)) % self.hash_size


def main():
    input_size = int(raw_input())
    hash_table = HashTable()
    counter = 0
    while counter < input_size:
        command, key = raw_input().split(' ')
        if command == 'insert':
            hash_table.insert_value(key, input_converter(key))
        else:
            if hash_table.search_value(key, input_converter(key)):
                print 'yes'
            else:
              print 'no'
        counter += 1


if __name__ == '__main__':
    main()

Solution (Python):


def main():
    dictionary = {}
    input_num = int(raw_input())
    counter = 0
    while counter < input_num:
        command, key = raw_input().split(' ')
        if command == 'insert':
            dictionary[key] = True
        else:
            if key in dictionary:
                print 'yes'
            else:
              print 'no'

        counter += 1


if __name__ == '__main__':
    main()

Solution (Python):


def main():
    dictionary = {}
    input_num = int(raw_input())
    counter = 0
    while counter < input_num:
        command, key = raw_input().split(' ')
        if command[0] == 'i':
            dictionary[key] = True
        else:
            if key in dictionary:
                print 'yes'
            else:
              print 'no'

        counter += 1


if __name__ == '__main__':
    main()

Solution (Python):


def main():
    dictionary = {}
    input_num = int(raw_input())
    counter = 0
    while counter < input_num:
        command, key = raw_input().split(' ')
        if command[0] == 'i':
            dictionary[key] = True
        else:
            if key in dictionary:
                print 'yes'
            else:
              print 'no'

        counter += 1


if __name__ == '__main__':
    main()

Solution (Python):


dictionary = {}
input_num = int(raw_input())
counter = 0
while counter < input_num:
    command, key = raw_input().split(' ')
    if command[0] == 'i':
        dictionary[key] = None
    else:
        if key in dictionary:
            print 'yes'
        else:
            print 'no'

    counter += 1

Solution (Python):


dictionary = {}
input_num = int(raw_input())
counter = 0
while counter < input_num:
    command, key = raw_input().split(' ')
    if command == 'insert':
        dictionary[key] = None
    else:
        if key in dictionary:
            print 'yes'
        else:
            print 'no'

    counter += 1

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

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

Solution (Python):
n = input()
dictInProb = set()
for i in range(int(n)):
    cmdAndStr = list(input().split())
    if cmdAndStr[0] == "insert":
        dictInProb.add(cmdAndStr[1])
    elif cmdAndStr[0] == "find":
        if cmdAndStr[1] in dictInProb:
            print("yes")
        else:
            print("no")
    else: pass

Solution (Python):
from collections import deque

D = set()
N = int(input())

for i in range(N):
	c, s = input().split()
	if c == "insert":
		D.add(s)
	elif c == "find":
		if (s in D):
			print("yes")
		else:
			print("no")

Solution (Python):
command_num = int(input())
dict = set([])

for i in range(command_num):
    in_command, in_str = input().rstrip().split(" ")
    
    if in_command == "insert":
        dict.add(in_str)
    elif in_command == "find":
        if in_str in dict:
            print("yes")
        else:
            print("no")

Solution (Python):
if __name__ == '__main__':
    try:
        n = int(raw_input())
    except:
        print 'the first input must be integer value!'
        exit()

    genoms = set([])
    answers = []
    for _ in range(n):
        values = raw_input().split()
        order = values[0]
        genom = values[1]
        if order == "insert":
            genoms.add(genom)
        else:
            
            answers.append('yes' if genom in genoms else 'no' )

    
    

    for answer in answers:
        print answer

Solution (Python):


N=int(input())
dict={}
for i in range(N):
    a,b=input().split()
    if a=="insert":
        dict[b]=i
    else:
        if b in dict:
            print("yes")
        else:
            print("no")

Solution (Python):
from collections import deque

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

Solution (Python):


import sys
import os


N = int(sys.stdin.readline())
lines = sys.stdin.readlines()
d = {}
for s in lines:
    command, word = s.split()
    if command == 'insert':
        d[word] = True
    elif command == 'find':
        if word in d.keys():
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())
l = {}
for _ in range(n):
    ss = input().split()
    order, string = ss[0], ss[1]
    if order == "insert":
        l[string] = 1
    else:
        print('yes' if string in l else 'no')

Solution (Python):
from collections import deque
dictionary = set()
for making in range(int(input())) :
    action = input().split()
    if action[0] == 'insert' : dictionary.add(action[1])
    else : 
        if action[1] in dictionary : print('yes')
        else : print('no')

Solution (Python):
import sys

num = int(input())
dic = set()

for i in range(num):
    order = sys.stdin.readline().split()

    if order[0] == 'insert':
        dic.add(order[1])
    else:
        if order[1] in dic:
            print('yes')
        else:
            print('no')

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

Solution (Python):
dic = {}

n = int(input())

for i in range(n):
    op, key = input().split()
    h_key = hash(key) 
    if op == "insert":
        dic[h_key] = 1
    else:
        if h_key in dic:
            print("yes")
        else:
            print("no")

Solution (Python):
m = 2000003

def MyHash(k,i):
    return (k%m+i*(1+(k%m)))%m

def main():
    n = input()
    T = ['']*2000003
    O = []
    for i in range(n):
        c, k = raw_input().split()
        i = 0
        if c == 'insert':
            k_hashed = hash(k)
            while True:
                j = MyHash(k_hashed,i)
                if T[j] == '':
                    T[j] = k
                    break
                else:
                    i += 1
        else:
            O.append(search(T,k))

    for item in O:
        print item

    return 0


def search(T,k):
    k_hashed = hash(k)
    i = 0
    while True:
        j = MyHash(k_hashed,i)
        if T[j] == k:
            o = 'yes'
            break
        elif T[j] == '':
            o = 'no'
            break
        else:
            i += 1

    return o


if __name__ == "__main__":
    main()

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

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

if __name__ == '__main__':
	dictionary()

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

Solution (Python):


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

for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        dic.add(cmd[1])
    else:
        if cmd[1] in dic:
            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):
N = int(input())
d = {}
for i in [None]*N:
    a, b = input().split()
    if a == "insert":
        d[b] = 1
    else:
        print("yes" if b in d else "no")

Solution (Python):
import sys

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    inp = sys.stdin.readlines()
    lis = set()
    for i in range(n):
        com = inp[i].split()
        if com[0] == "insert":
            lis.add(com[1])
        elif com[1] in lis:
            print("yes")
        else:
            print("no")

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

dic = {}

for _ in range(n):
    command = input().split(" ")
    if command[0] == "insert":
        dic[command[1]] = 1
    else:
        if command[1] in dic:
            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
 
 
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())
d = {}
for i in range(n):
    cmd, s = input().split()
    if cmd == "insert":
        d.update([(s, 0)])
    else:
        if s in d:
            print("yes")
        else:
            print("no")

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

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

	for _ in range(n):
		order, code = input().split()
		if order == 'insert':
			dictionary.add(code)
		elif order == 'find':
			if code in dictionary:
				print('yes')
			else:
				print('no')
		else:
			raise Exception('InputError')

if __name__ == '__main__':
	main()

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

	for _ in range(n):
		order, code = input().split()
		if order == 'insert':
			dictionary[code] = 1
		elif order == 'find':
			if code in dictionary:
				print('yes')
			else:
				print('no')
		else:
			raise Exception('InputError')

if __name__ == '__main__':
	main()

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


dictionary = dict()
for i in range(n):
	command,data = input().split()
	
	if command == 'insert':
		dictionary[data] = 1
	else:
		if data in dictionary:
			print('yes')
		else:
			print('no')

Solution (Python):
dic=set()
n=int(input())
cmd=[list(input().split()) for i in range(n)]
for c, l in cmd:
    if c=="insert":
        dic.add(l)
    if c=="find":
        if l in dic:
            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:
        print('yes'*(val in d)or'no')

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

for i in range(n):
    op, st = input().split()
    if op == 'insert':
        h[st] = 'yes'
    else:
        print (h.get(st, 'no'))

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

def makeHash(letter):
    if letter == 'A':
        return 1
    elif letter == 'C':
        return 2
    elif letter == 'G':
        return 3
    elif letter == 'T':
        return 4
    return 0

dict = {}
for i in range(n):
    command, word = raw_input().split()
    key = 0
    if command == 'insert':
         dict[word] = 1
    elif command == 'find':
        if word in dict: 
            print 'yes'
        else:
            print 'no'

Solution (Python):
from collections import defaultdict

d = defaultdict(lambda: 0)

N = int(input())

for _ in range(N):
    ord, str = input().split()
    if ord == 'insert':
        d[str] = 1
    else:
        if str in d:
            print('yes')
        else:
            print('no')

Solution (Python):
import sys
input()
dic = {}
line = map(lambda x:x.split(), sys.stdin.readlines())
for i in line:
    if i[0] == "insert":
        dic[i[1]] = None
    else:
        print("yes" if i[1] in dic else "no")

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

Solution (Python):
dic = {}
line = []
for i in range(int(input())):
    line.append(input().split())
for i in line:
    if i[0][0] == "i":
        dic[i[1]] = None
    else:
        print("yes" if i[1] in dic else "no")

Solution (Python):
n = int(input())
  
s = set()
for i in range(n):
    c, m = input().split()
    if c[0] == 'i':
        s.add(m)
    elif c[0] == 'f':
        if m in s:
            print('yes')
        else:
            print('no')

Solution (Python):
n = int(input())
  
l = []
s = {}
for i in range(n):
    c, m = input().split()
    if c[0] == 'i':
        s[m] = 0
    elif c[0] == 'f':
        if m in s:
            l.append('yes')
        else:
            l.append('no')
print(*l,sep='\n')