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: Wrong Answer

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

    repo = []
    for i in range(n):
        line = input()
        if line[0] == 'i':
            if line[7:10] not in repo:
                repo.append(line.split()[1])
        elif line[0] == 'f':
            if line[5:8] in repo:
                print('Yes')
            else:
                print('No')
    return


main()

Submission status: Wrong Answer

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

    repo = []
    for i in range(n):
        line = input()
        if line[0] == 'i':
            if line[7:10] not in repo:
                repo.append(line.split()[1])
        elif line[0] == 'f':
            if line[5:8] in repo:
                print('yes')
            else:
                print('no')
    return


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = "a"
for i in range(n):
    s = input().split()
    if s[0] == "insert":
        A += str(s[1])
    else:
        if str(s[1]) in A:
            print("yes")
        else:
            print("no")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = []
for i in range(n):
    s = input().split()
    if s[0] == "insert":
        A.append(str(s[1]))
    else:
        if str(s[1]) in A:
            print("yes")
            A.remove(str(s[1]))
        else:
            print("no")
    print(A)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = []
for i in range(n):
    s = input().split()
    if s[0] == "insert":
        A.append(str(s[1]))
    else:
        if str(s[1]) in A:
            print("yes")
            A.remove(str(s[1]))
        else:
            print("no")

Submission status: Wrong Answer

Solution code:
def BinarySearch(A, n, key):
    left = 0
    right = n
    mid	= 0
    while left < right:
        mid = (left+right)/2
        if A[mid] == key:
            return 1
        elif A[mid] > key:
            right = mid
        else:
            left = mid + 1
    return mid

if __name__ == "__main__":
    n = int(raw_input())
    dic = []
    num	= 0
    for i in range(n):
        t = raw_input().split()
        if t[0] == "insert":
            dic.insert(BinarySearch(dic, num, t[1]), t[1])
            num	+= 1
        if t[0] == "find":
            if(BinarySearch(dic, num, t[1])):
                print("yes")
            else:
                print("no")

Submission status: Wrong Answer

Solution code:
def BinarySearch(A, n, key):
    left = 0
    right = n
    mid	= 0
    while left < right:
        mid = (left+right)/2
        if A[mid] == key:
            return -1
        elif A[mid] > key:
            right = mid
        else:
            left = mid + 1
    return mid + 1

if __name__ == "__main__":
    n = int(raw_input())
    dic = []
    num	= 0
    for i in range(n):
        t = raw_input().split()
        if t[0] == "insert":
            dic.insert(BinarySearch(dic, num, t[1]), t[1])
            num	+= 1
        if t[0] == "find":
            if(BinarySearch(dic, num, t[1])<0):
                print("yes")
            else:
                print("no")

Submission status: Wrong Answer

Solution code:
def BinarySearch(A, n, key):
    left = 0
    right = n
    mid	= 0
    while left < right:
        mid = (left+right)/2
        if A[mid] == key:
            return -1
        elif A[mid] > key:
            right = mid
        else:
            left = mid + 1
    return left

if __name__ == "__main__":
    n = int(raw_input())
    dic = []
    num	= 0
    for i in range(n):
        t = raw_input().split()
        if t[0] == "insert":
            dic.insert(BinarySearch(dic, num, t[1]), t[1])
            num	+= 1
        if t[0] == "find":
            if(BinarySearch(dic, num, t[1])<0):
                print("yes")
            else:
                print("no")

Submission status: Wrong Answer

Solution code:
class TrieTree:
    def __init__(self):
        self.flag = 0
        self.next = [None, None, None, None]

def judge(c):
    if c == "A":
        return 0
    elif c == "C":
        return 1
    elif c == "G":
        return 2
    else:
        return 3

def find(key, trie):

    if(len(key)>=1):
        index = judge(key[0])
        if(trie.next[index]!=None):
            find(key[1:], trie.next[index])
        else:
            print("no")
    else:
        if(trie.flag):
            print("no")
        else:
            print("yes")

def insert(key, trie):
    if(len(key)>=1):
        index = judge(key[0])
        if(trie.next[index]!=None):
            insert(key[1:], trie.next[index])
        else:
            trie.next[index] = TrieTree()
            insert(key[1:], trie.next[index])
    else:
        trie.flag = 1

if __name__ == "__main__":

    root = TrieTree()
    n = raw_input()

    for i in (n):
        com = raw_input().split()
        if(com[0][0] == "i"):
            insert(com[1], root)
        else:
            find(com[1], root)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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( "yes" )
		else:
			output.append( "no" )

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

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
d = ""
for i in range(n):
    p,q = map(str,raw_input().split())
    if p == "insert":
        d += q
    elif p == "find":
        r = d.find(q)
        if(r >= 0):
            print "yes"
        else:
            print "no"

Submission status: Wrong Answer

Solution code:
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(l,key,i)
        if (T[h] is None ):
            T[h] = key
            return h
        else:
            i += 1

def search(T,key):
    l = len(T)
    i = 0
    while True:
        h = hash(l,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]*4444
n = int(input())


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

### convert key to num(1~4)
    tmp_key = ''
    for x in list(d[1]):
        tmp_key += dict[x]

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

Submission status: Wrong Answer

Solution code:
n=input()
dict_list=[]
for i in range(n):
	command=raw_input().split()
	if command[0]=='insert':
		dict_list.append(command[1])
	else :
		if command[1] in dict_list:
			print("Yes")
		else :
			print("No")

Submission status: Wrong Answer

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


d = [False]*16777220

def hash(s):
    ret = 0
    i = 0
    for dg in s:
        if dg == 'A':
            ret += 0 * 10**i
        elif dg == 'C':
            ret += 1 * 10**i
        elif dg == 'G':
            ret += 2 * 10**i
        elif dg == 'T':
            ret += 3 * 10**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:
    if c[0] == 'i':
        insert(d,c[7:])
    else:
        find(d,c[5:])

Submission status: Wrong Answer

Solution code:
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)
    print s,h
    d[h] = True

def find(d,s):
    h = hash(s)
    print s,h
    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:])

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n):
    com,str = [str, raw_input().split()]
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
        else:
          print 'no'

Submission status: Wrong Answer

Solution code:
count = 0
n = input()

for i in range(n):
  com,str = [str, raw_input().split()]
  if com == 'insert':
    dic[count] = str
    count += 1
  elif com == 'find':
    for j in range(count-1):
      if dic[j] == str:
        print 'yes'
      else:
        print 'no'

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n):
    com,str = [str, raw_input().split()]
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes\n'
        else:
          print 'no\n'

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = [str, raw_input().split()]
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
        else:
          print 'no'

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = [str, raw_input().split()]
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print "yes"
        else:
          print "no"

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = (str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
        else:
          print 'no'

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = (str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        else:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = (str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():


          print 'no'

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com,str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com, strn = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = strn
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == strn:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com, str = [str(x) for x in raw_input().split()]
    if com == 'insert':
      dic[count] = strn
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

 print "aaa"

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n-1):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = int(input())

  for i in range(n-1):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(0,n):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(0,n):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(0,count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-2:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()

  for i in range(n):
    com, str = map(raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-2:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def insert(S, string):
    S.append(string)

def find(S, string):
    cnt = 0
    for i in range(len(S)):
        cnt = cnt + 1
        if S[i] == string:
            print 'yes'
            break
        elif cnt == len(S):
            print 'no'

n = input()

S = []

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

Submission status: Wrong Answer

Solution code:
def insert(S, string):
    S.append(string)

def find(S, string):
    cnt = 0
    for i in range(len(S)):
        cnt = cnt + 1
        if S[i] == string:
            print 'yes'
            break
        elif cnt == len(S) or cnt == 0:
            print 'no'

n = input()

S = []

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

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()
  dic = []

  for i in range(n-1):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
def main():

  count = 0
  n = input()
  dic = []

  for i in range(n):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Submission status: Wrong Answer

Solution code:
A = []
n = input()

for i in range(n):
    command = raw_input().split()

    if command[0] == 'insert':
        A.insert(0, command[1])
    elif command[0] == 'find':
        if A.count(command[1]) != 0:
            print "Yes"
        else:
            print "No"

Submission status: Wrong Answer

Solution code:
import sys

class dictionary:
    def __init__(self):
        self.lst = [None] * 4 ** 12

    def insert(self, key):
        hash = self.toHash(key)
        self.lst[hash] = 1

    def find(self, key):
        hash = self.toHash(key)
        if self.lst[hash] is not None:
            return True
        else:
            return False

    def toHash(self, key):
        key = key.replace("A", "0")
        key = key.replace("C", "1")
        key = key.replace("G", "2")
        key = key.replace("T", "3")
        return int(key)

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"

Submission status: Wrong Answer

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

def sort(a, left, right):
    if left < right:
        mid = (left+right)/2
        pivot = a[mid]
        a[mid] = a[left]
        p = left
        for i in range(left+1, right+1):
            if a[i] < pivot:
                p = p+1
                p, i = i, p
        a[left] = a[p]
        a[p] = pivot
        sort(a, left, p-1)
        sort(a, p+1, right)

def search(a, target):
    lo = 0
    hi = len(a)-1
    while lo <= hi:
        mid = (lo+hi)/2
        if target <= a[mid]:
            hi = mid-1
        if target >= a[mid]:
            lo = mid+1
    if lo == hi+2:
        return True
    else:
        return False

n = int(raw_input())
dic = []
for i in range(n):
    com, s = map(str, raw_input().split())
    if com == "insert":
        dic.append(s)
    elif com == "find":
        sort(dic, 0, len(dic)-1)
        if search(dic, s):
            print "yes"
        else:
            print "no"

Submission status: Wrong Answer

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

def sort(a, left, right):
    if left < right:
        mid = (left+right)/2
        pivot = a[mid]
        a[mid] = a[left]
        p = left
        for i in range(left+1, right+1):
            if a[i] < pivot:
                p = p+1
                p, i = i, p
        a[left] = a[p]
        a[p] = pivot
        sort(a, left, p-1)
        sort(a, p+1, right)

def search(a, target):
    lo = 0
    hi = len(a)-1
    while lo <= hi:
        mid = (lo+hi)/2
        if target <= a[mid]:
            hi = mid-1
        if target >= a[mid]:
            lo = mid+1
    if lo == hi+2:
        return True
    else:
        return False

n = int(raw_input())
dic = []
for i in range(n):
    com, s = map(str, raw_input().split())
    if com == "insert":
        dic.append(s)
        sort(dic, 0, len(dic)-1)
    elif com == "find":
        if search(dic, s):
            print "yes"
        else:
            print "no"

Submission status: Wrong Answer

Solution code:
class Node:
    def __init__(self,v):
        self.v = v
        self.next = None

class Dictionary:
    def __init__(self,l=100000):
        self.l = l
        self.values = []
        for i in range(l):
            self.values.append(None)

    def insert(self,x):
        h = hash(x) % self.l
        if self.values[h] == None:
            self.values[h] = Node(x)
        else:
            self.values[h].next = Node(x)

    def find(self,x):
        h = hash(x)%self.l
        n = self.values[h]
        while n != None:
            if n.v == x:
                return True
            n = n.next
        return False


d = Dictionary()
n = int(raw_input())
ops = []
for _ in range(n):
    op,s = raw_input().split(' ')
    ops.append((op,s))

for op,s in ops:
    if op[0] == 'i':
        d.insert(s)
    else:
        if d.find(s):
            print 'yes'
        else:
            print 'no'

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
l = deque()

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

Submission status: Wrong Answer

Solution code:
n=input()

d=[]
for x in xrange(n):
    cmd = raw_input().split()
    
    print cmd[0]
    
    if cmd[0] == "insert":
        d.append(cmd[1])
    elif cmd[0] == "find":
        print "yes" if cmd[1] in d else "no"

Submission status: Wrong Answer

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp
#??????
if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = []
    for c, s in input_list:
        if c == "insert":
            l.append(s)
        else:
            if s in c:
                print("yes")
            else:
                print("no")

Submission status: Wrong Answer

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

print(t)

Submission status: Wrong Answer

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 ** 20):
        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)
        while True:
            if (self.hash_array[next_index] is None) or (collision_number > self.hash_size):
                return None
            elif self.hash_array[next_index] == data:
                return True
            else:            
                collision_number +=1

    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():
    hash_table = HashTable()
    input_size = int(raw_input())
    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: Wrong Answer

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 ** 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)
        if collision_number != 0:
            print 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()

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
#5.4
n = int(input())
strs = [];

for i in range(0, n):
    tmp = list(input().split())
    if tmp[0] == 'insert':
        strs.append(tmp[1])
    elif tmp[0] == 'find':
        if strs.count([tmp[1]]) > 0:
            print('yes')
        else:
            print('no')

Submission status: Wrong Answer

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):
    if D == []:
        return 'no'
    else:
        d = D.pop()
        if d == k:
            return 'yes'
        else:
            return search(D,k)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
dic = {}
n = int(input())
for i in range(n):
    op, key = input().split()
    print(op, key)