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



Sample input:
5
insert A
insert T
insert C
find G
find A


Sample output:
no
yes

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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 ** 30):
        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)
        # print self.hash_array[next_index]
        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()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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] = None
        else:
            if key in dictionary:
                print 'yes'
            else:
              ???print 'no'

        counter += 1


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
dic = []
l = [list(i) for i in input().split]
for i in range(n):
    if l[i][0] == "insert":
        dic.append(l[i][1])
    else:
        if l[i][1] in dic:
            print("yes")
        else:
            print("no")

Submission status: Runtime Error

Solution code:
from collection import deque

D = deque() 
N = int(input())
for i in range(N):
	c, s = input().split()
	if c == "insert":
		d.append(s)
	elif c == "find":
		if (s in d):
			print(Yes)
		else:
			print(No)

Submission status: Runtime Error

Solution code:
from collections import deque

D = deque()
N = int(input())

for i in range(N):
	c, s = input().split()
	if c == "insert":
		d.append(s)
	elif c == "find":
		if (s in d):
			print(Yes)
		else:
			print(No)

Submission status: Runtime Error

Solution code:
from collections import deque

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
dict = []
for i in range(n):
    order = input().split()
    if order[0] == "insert":
        dict.append(order[1])
    else:
        if order[1] in dict:
            print(Yes)

Submission status: Runtime Error

Solution code:
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item


def search(D,k):
    Dc = D[:]
    if D == []:
        return 'no'
    else:
        d = Dc.pop()
        if d == k:
            return 'yes'
        else:
            return search(Dc,k)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

def search(D,k):
    Dc = D[:]
    if Dc == []:
        return 'no'
    else:
        d = Dc.pop()
        if d == k:
            return 'yes'
        else:
            return search(Dc,k)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

    return 0


def search(D,k):
    Dc = D[:]
    if Dc == []:
        return 'no'
    else:
        d = Dc.pop()
        if d == k:
            return 'yes'
        else:
            return search(Dc,k)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import deque

def main():
    n = input()
    D = deque([])
    O = deque([])
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

    return 0


def search(D,k):
    Dc = D[:]
    o = 'no'
    while Dc != []:
        d = Dc.pop()
        if d == k:
            o = 'yes'
            break

    return o


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
d_list = set()

times = int(input())
for i in range(times):
    elm = input().split()
    code = elm[1].replace("A","1")
    code = code.replace("C","2")
    code = code.replace("G","3")
    code = code.replace("T","4")
    if elm[0] == "insert":
        d_list.add(code)
        d_list = sorted(d_list)

    elif elm[0] == "find":
        lower_bound = 0
        upper_bound = len(d_list)-1
        found = False

        while lower_bound <= upper_bound and not found:
            mid = (lower_bound + upper_bound)//2
            if d_list[mid] < code:
                lower_bound = mid + 1
            elif d_list[mid] > code:
                upper_bound = mid - 1
            else:
                found = True
        if found:
            print("yes")
        else:
            print("no")

Submission status: Runtime Error

Solution code:
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")

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??\????????????????????????????°?????????????????????????????£??????????????????????

insert str: ????????? str ??????????????????
find str: ????????? str ?????????????????´??? 'yes'??¨????????????????????´??? 'no'??¨???????????????

??????????????????????????????'A', 'C', 'G', 'T' ???????¨????????????????????§????????????????
1 ??? ?????????????????? ??? 12  n ??? 1,000,000

"""
import sys

# ????´??????¢?????¬????????????
NoVal = -1

# ????????¨????????????
Black = 0
Red = 1

class Node:
    """ ???????????? """

    def __init__(self, pnode, color, value):
        """ ????????????????????? """
        self.P = pnode # ????????????
        self.V = value # ???
        self.C = color # ???
        self.L = NoVal # ??????
        self.R = NoVal # ??????

def Find(r,value):
    """ ????????¨??¢?´¢ """
    if value == r.V:
#        print("Finded p:'{}' v:'{}'".format(r.V, value))
        return True
    if value < r.V: # ?°????????????§??????
        if isinstance(r.L, Node) == True:
#            print("Left Search p:'{}' v:'{}'".format(r.V, value))
            return Find(r.L, value)
    elif value > r.V: # ??§???????????§??????
        if isinstance(r.R, Node) == True:
#            print("Right Search p:'{}' v:'{}'".format(r.V, value))
            return Find(r.R, value)
#    print("Not Exists r:{} v:'{}'".format(r.V, value))
    return False

def Insert(r, value):
    """ ????????¨???????????? """
    if isinstance(r, Node) == False: # ???????????????
#        print("Root Insert '{}'".format(value))
        return Node(NoVal, Black, value) # ????´??????\

    if value == r.V: # ???????????????????????????????????§??????
#        print("Exists p:'{}' v:'{}'".format(r.V, value))
        return NoVal

    if value < r.V: # ?°???????
        if isinstance(r.L, Node) == False: # ??????????????????
            r.L = Node(r, Red, value) # ??????????´??????\
#            print("Left Insert '{}'".format(value))
            return r.L
        else:
#            print("Next Left p'{}' v'{}'".format(r.V, value))
            Insert(r.L, value) # ?????????
    elif value > r.V: # ??§??????
        if isinstance(r.R, Node) == False: # ??????????????????
#            print("Right Insert '{}'".format(value))
            r.R = Node(r, Red, value) # ??????????´??????\
            return r.R
        else:
#            print("Next Right p:'{}' v:'{}'".format(r.V, value))
            Insert(r.R, value) # ?????????

def RotateR(a):
    """ ????????¨???????????¢ a:????????? ?????????:??°????????? """
    b = a.L     # a ???????????? b ??¨??????
    b.P = a.P   # b ????????? a ???????????????
    a.P = b     # a ????????? b ?????????
    a.L = b.R   # a ???????????? b ??????????????????
    a.L.P = a   # a ?????????????????? a ?????????
    b.R = a     # b ???????????? a ?????????
    if b.P != NoVal: # b ??????????´????????????????
       if b.P.L == a: # b ?????????????????? a ??????
            b.P.L = b    # b ?????????????????? b ?????????
       elif b.P.R == a: # b ?????????????????? a ??????
            b.P.R = b    # b ?????????????????? b ?????????
    return b

def RotateL(a):
    """ ????????¨???????????¢ r:????????? """
    b = a.R     # a ???????????? b ??¨??????
    b.P = a.P   # b ????????? a ???????????????
    a.P = b     # a ????????? b ?????????
    a.R = b.L   # a ???????????? b ??????????????????
    a.R.P = a   # a ?????????????????? a ?????????
    b.L = a     # b ???????????? a ?????????
    if b.P != NoVal: # b ??????????´????????????????
       if b.P.L == a: # b ?????????????????? a ??????
            b.P.L = b    # b ?????????????????? b ?????????
       elif b.P.R == a: # b ?????????????????? a ??????
            b.P.R = b    # b ?????????????????? b ?????????
    return b

def Restruct(r):
    """ ????§???? """
    
    if isinstance(r, Node) == False: # ?????§??????
        return
    
    if r.C == Black: # ???????????????????????????????????????
        return

    p = r.P
    if p == NoVal: # ???????????????
        r.C = Black # ???????????????????????????
        return

    if p.C == Red: # ????????????
        if p.P.L == p: # ????????????
            if p.L == r: # ???????????????
                p = RotateR(p) # LL:????????¢
            else: # ???????????????
                RotateL(r) # LR: 1.????????¢
                p = RotateR(p) # LR: 2.????????¢
        else: # ????????????
            if r.P.L == r: # ???????????????
                RotateR(r) # RL: 1.????????¢
                p = RotateL(p) # RL: 2.????????¢
            else: # ???????????????
                p = RotateL(p) ## LR: ????????¢
        if p.C == Red: # ??°???????????????????????°???????????????????§????
            Restruct(p)

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    root = NoVal
    
    for i in cmds:
        if i[0] == "i":
            r = Insert(root, i[7:])
            if isinstance(root, Node) == False:
                root = r
        elif i[0] == "f":
            ret = Find(root, i[5:])
            if ret == True:
                print("yes")
            else:
                print("no")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())

class Hash:
    def __init__(self):
        self.m = 1000003
        self.T = [None] * self.m
    def insert(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if i >0:
            if self.T[j] == None:
                self.T[j] = key
                break
            else:
                i = i + 1
    def search(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.T[j] == key:
                return j
            elif self.T[j] == None:
                return None
            else:
                i += 1
        return self.T[self.h(key)]
    def h(self, key, i):
        ki = self.key2int(key)
        h1 = ki % self.m
        h2 = i * (1 + (ki % (self.m - 1)))
        return (h1 + h2) % self.m
    def key2int(self, key):
        return sum([['A', 'C', 'G', 'T'].index(s) + 1 for s in key])

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

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
import sys
ls = []
line = map(lambda x:x.split(), sys.stdin.readlines())
for i in line:
    if i[0] == "insert":
        ls.append(i[1])
    else:
        print("yes" if i[1] in ls else "no")

Submission status: Runtime Error

Solution code:
def f(s,t):
 #   As="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    As="ACGT"
    if s==t:
        return 0
    else:
        i=0
        while i<4 and s!=As[i]:
            i+=1
        while i<4 and t!=As[i]:
            i+=1
        if i<4:
            return -1
        else:
            return 1
def f3(u,v):
    m=len(u)
    if len(v)<m:
        m=len(v)
    i=0
    while i<m and u[i]==v[i]:
        i+=1
    if i>=m:
        if len(u)==len(v):
            return 0
        elif m==len(u):
            return -1
        else:
            return 1
    else:
        return f(u[i],v[i])
n=int (input ())
D=[]
for i in range(n):
    Od=input (). split ()
    l=len(D)
    gs=Od[1]
    j=0
    ts=0
    if l>0:
        r=1
        r=l%2
        p=1
        l//=2
        j+=l
        ts=f3(gs,D[j])
    #    print(ts)
        while l>1 and ts!=0:#light over
            if ts*p>0 and r==0:
                l-=1
            l//=2
            if ts<0:
                j-=l+1
                p=-1
            else:
                j+=l+1
                p=1
            ts=f3(gs,D[j])
            r=1
            r=l%2
        if ts*p>0 and r==0:
            l-=1
        if l==1 and ts!=0:
            j+=ts
            ts=f3(gs,D[j])
    if Od[0]=="insert":
       # print(gs)
        if ts==-1:
            ts=0
        D.insert(j+ts,gs)
  #      print(D)
    elif ts==0:
        print("yes")
    else:
        print("no")

Submission status: Runtime Error

Solution code:
n = int(raw_input())
L = []

for i in xrange(n):
    a, b = map(raw_input().split())
    if a == "insert":
        L.append(b)
    if a == "find":
        if b in L:
            print "yes"
        else:
            print "no"

Submission status: Runtime Error

Solution code:
n = int(input())
dic = [0]*n

def hash1(x):
    return x % n
def hash2(x):
    return x % (n-1)

for i in range(n):
    line = input().split()
    com = line[0]
    st = str(line[1])
    su = 0
    for i in st:
        if i == 'A':
            su += 1
        elif i == 'C':
            su += 2
        elif i == 'G':
            su += 3
        else:
            su += 4
    if com == 'insert':
        ind = hash1(su)
        while True:
            if dic[ind] == 0:
                dic[ind] = st
                break
            else:
                ind += hash2(su)
    else:
        ind = hash1(su)
        while True:
            if dic[ind] == st:
                print('yes')
                break
            elif dic[ind] == 0:
                print('no')
                break
            else:
                ind += hash2(su)

Submission status: Runtime Error

Solution code:
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")

view raw

Submission status: Runtime Error

Solution code:
import sys


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

    imps = sys.stdin.readlines()

    db = []
    for imp in imps:
        command = imp.split(' ')
        if command[0] == 'insert':
            db.append(command[1])
        else
            if command[1] in db:
                print('yes')
            else:
                print('no')


main()

Submission status: Runtime Error

Solution code:
import sys


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

    imps = sys.stdin.readlines()

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


main()

Submission status: Runtime Error

Solution code:
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 db in k:
            print('yes')
        else:
            print('no')


main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

    def h1(self, key):
        return key % self.length

    def h2(self, key):
        return 1 + (key % (self.length - 1))

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

    def insert(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self[j] is None:
                self[j] = key
                return j
            else:
                i += 1
    
    def search(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            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))

if __name__ == '__main__':

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

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
m = 1e13
NIL = -1

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] == NIL:
            t[j] = key
            return j
        else:
            i += 1

def find(t, key):
    i = 0
    while True:
        j = h(key, i)
        if t[j] == key:
            return j
        elif t[j] == NIL or i >= m:
            return NIL
        else:
            i += 1

def convert(word):
    result = ""
    for i in word:
        if i == "A":
            result += "1"
        elif i == "T":
            result += "2"
        elif i == "G":
            result += "3"
        else:
            result += "4"
    return int(result)


t = [NIL]*m
n = int(input())
for i in range(n):
    com = input().split()
    key = convert(com[1])
    if com[0] == "insert":
        insert(t, key)
    else:
        if find(t, key) != NIL:
            print("yes")
        else:
            print("no")

Submission status: Runtime Error

Solution code:
m = 1e8
NIL = -1

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] == NIL:
            t[j] = key
            return j
        else:
            i += 1

def find(t, key):
    i = 0
    while True:
        j = h(key, i)
        if t[j] == key:
            return j
        elif t[j] == NIL or i >= m:
            return NIL
        else:
            i += 1

def convert(word):
    result = ""
    for i in word:
        if i == "A":
            result += "1"
        elif i == "T":
            result += "2"
        elif i == "G":
            result += "3"
        else:
            result += "4"
    return int(result)


t = [NIL]*m
n = int(input())
for i in range(n):
    com = input().split()
    key = convert(com[1])
    if com[0] == "insert":
        insert(t, key)
    else:
        if find(t, key) != NIL:
            print("yes")
        else:
            print("no")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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()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()

Submission status: Runtime Error

Solution code:
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 = {}
def find(text):
    global dict
    key = getkey(text)
    i = 0
    while i < M:
        h = h3(key, i)
        if dict.get(h) == None:
            break
        elif dict[h] == text:
            return True
        i += 1
    return False

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

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

Submission status: Runtime Error

Solution code:
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 = {}
def find(text):
    global dict
    key = getkey(text)
    i = 0
    while i < M:
        h = h3(key, i)
        if dict.get(h) == None:
            break
        elif dict[h] == text:
            return True
        i += 1
    return False

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

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

Submission status: Runtime Error

Solution code:
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")

Submission status: Runtime Error

Solution code:
n=input()
A={}
for i in range(n):
     x,y=input().split()
     if x=='insert':
         d.add(y)
     else:
         if b in d:
            print('yes')
         else:
            print('no')

Submission status: Runtime Error

Solution code:
n=input()
A={}
for i in range(n):
     x,y=input().split()
     if x=='insert':
         A.add(y)
     else:
         if A in y:
            print('yes')
         else:
            print('no')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in list1:
    print(i

Submission status: Runtime Error

Solution code:
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

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

Submission status: Runtime Error

Solution code:
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

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

Submission status: Runtime Error

Solution code:
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

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

Submission status: Runtime Error

Solution code:
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

def Dictionary(b):
    a=list(map(int,input().split()))
    if(a[0] == "insert"):
        b.append(a[1])
    elif(a[0] == "find"):
        if(a[1] in b):
            print("yes")
        else:
            print("no")

if __name__ == "__main__":
    n=int(input())
    b=[]
    for i in range(n):
        Dictionary(b)

Submission status: Runtime Error

Solution code:
#coding:utf-8
n = int(input())

def converter(string):
    ch_list = ["A", "C", "G", "T"]
    new_string = ""
    for ch in string:
        for i in range(4):
            if ch == ch_list[i]:
                new_string += str(i+1)
    return int(new_string)

    
def sosu(num):
    while True:
        i = 2
        while i <= num ** (1/2) :
            if num % i != 0:
                i += 1

            else:
                num += 1
                i = 2
        break

    return num


def h1(key):
    return key % m

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

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

def insert(T, key):
    i = 0
    while True:
        j = hf(key, i)
        if T[j] == None:
            T[j] = key
            break
        else:
            i += 1

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


m = int(n*1.2)
m = sosu(m)
T = [None for num in range(n)]

cnt = 0
for i in range(n):
    order, string = input().split()
    if order == "insert":
        key = converter(string)
        insert(T,key)
    if order == "find":
        key = converter(string)
        print(search(T, key))