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())
dict={}
for i in range(n):
    order,str=input().split()
    if(order=="insert"):
        dict[str]=1
    else:
        if(str in dict):
            print("yes")
        else:
            print("no")

Solution (Python):
int_num=int(input())
ans_list = {}
for i in range(int_num):
    input_list=list(map(str,input().split()))
    if input_list[0] == 'insert':
        ans_list[(input_list[1])] = True
    else:
        if (input_list[1]) in ans_list.keys():
            print('yes')
        else:
            print('no')

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

    dic = {}

    for _ in range(n):
        cmd, key = input().split(' ')

        if 'insert' == cmd:
            dic[key] = key

        if 'find' == cmd:
            if key in dic:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
list_prob = []
dict_prob = {}
for i in range(0,n):
    list_prob.append(list((map(str, input().split()))))
for i in range(0,n):
    if list_prob[i][0] == "insert":
        dict_prob[list_prob[i][1]] = 1
    else:
        try:
            dict_prob[list_prob[i][1]]
            print("yes")
        except KeyError:
            print("no")

Solution (Python):


n=int(input())
a=set()

for i in range(n):
    c,s=input().split()
    if c == 'insert':
        a.add(s)
    else:
        if s in a:
            print('yes')
        else:
            print('no')

Solution (Python):
from sys import stdin


def main():
    h = set()
    _ = int(input())
    for l in stdin:
        cmd, param = l.split()
        if cmd == "insert":
            h.add(param)
        elif param in h:
            print("yes")
        else:
            print("no")


main()

Solution (Python):
from sys import stdin

a = {}

n = int(input())

for _ in range(n):
    com, n = stdin.readline().strip().split()
    if com == 'insert':
        a[n] = 1
    else:
        print('yes') if n in a else print('no')

Solution (Python):
import sys
import collections


sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]


def main():
    N = int(input())
    C = [input().split() for _ in range(N)]

    D = collections.defaultdict(lambda: 0)

    for c in C:
        command, value = c

        if command == "insert":
            D[value] = 1
        else:
            if D[value] == 1:
                print("yes")
            else:
                print("no")


main()

Solution (Python):
import hashlib
from sys import stdin

def insert(v, B):
    key = hashlib.md5(v.encode("utf-8")).hexdigest()
    B[key] = v

def search(v, B):
    key = hashlib.md5(v.encode("utf-8")).hexdigest()
    if key in B:
        return key
    else:
        return 0

def read_and_print_word_dict(n):
    B = {}
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            insert(cmd[1], B)
        elif cmd[0] == 'find':
            res = search(cmd[1], B)
            if res == 0:
                print("no")
            else:
                print("yes")

n = int(input())
read_and_print_word_dict(n)

Solution (Python):
def hashSearch(n):
    l = {}
    res = []
    for x in range(n):
        order = input().split()
        if order[0] == 'insert':
            l[order[1]] = x
        elif order[0] == 'find':
            if order[1] in l:
                res.append('yes')
            else:
                res.append('no')
    print('\n'.join(res))


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

Solution (Python):
import sys


f = sys.stdin
n = ''
d = set()
f.readline()

for line in f:
    cmdarr = line.split()
    if cmdarr[0] == "insert":
        d.add(cmdarr[1])
    else:
        if cmdarr[1] in d:
            print("yes")
        else:
            print("no")

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

Solution (Python):
n = int(input())
cmd = [input().split() for i in range(n)]

data = {}
for v in cmd:
    if v[0][0] == 'i':
        data[v[1]] = True
    else:
        if v[1] in data:
            print('yes')
        else:
            print('no')

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

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

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

Solution (Python):
import sys
d={}
input()
for i in sys.stdin:
    if i[0] == "i":
        d[i[7:]]=0
    else:
        if i[5:] in d:
            print("yes")
        else:
            print("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):
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):
from collections import defaultdict
n = int(input())
d = defaultdict(bool)
for i in range(n):
  q, s = input().split()
  if q=="insert":
    d[s] = True
  elif q=="find":
    if d[s]:
      print("yes")
    else:
      print("no")

Solution (Python):
n = int(input())
h = {}
for _ in range(n):
    cmd,val=input().split(' ')
    if cmd == "insert":
      h[val] = 1
    else:
        if  val in h:
            print("yes")
        else:
            print("no")

Solution (Python):

dic=set({})
for i in range(int(input())):
    a,b=input().split()
    if a=='insert':
        dic.add(b)
    else:
        print('yes' if b in dic else 'no')

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