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

Solution code:
n = int(input())

s = set()

for i in range(n):
    c, num = input().split()

    if c == 'insert':
        s.add(num)
    elif c == 'find':
        if {num}<=s:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


class Dictionary:
    def __init__(self):
        self.dict = defaultdict(lambda:False)
    
    def insert(self, x):
        self.dict[x] = True
        
    def find(self, x):
        if self.dict[x]:
            print("yes")
        else:
            print("no")
            
            
def main():
    Dict = Dictionary()
    
    n = int(input())
    for i in range(n):
        op, key = input().split()
        if op == "find":
            Dict.find(key)
        else:
            Dict.insert(key)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
dic = {}

for _ in range(int(input())):
    
    cmd, word = input().split()
    
    if cmd == 'insert':
        dic[word] = 1

    elif cmd == 'find':
        if dic.__contains__(word):
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
N = int(input())

d = {}
for _ in range(N):
    op, value = input().split()
    if op == 'insert':
        d[value] = value
    elif op == 'find':
        if value in d.keys():
            print('yes')
        else:
            print('no')
    else:
        raise Exception

# print(d.keys())

Submission status: Accepted

Solution code:
n = int(input())

data = {}

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

Submission status: Accepted

Solution code:
n = int(input())
dic = set()
for i in range(n):
    operation, string = input().split()
    if operation == "insert":
        dic.add(string)
    else:
        print("yes" if string in dic else "no")

Submission status: Accepted

Solution code:
n = int(input())
commands = []
for i in range(n):
    command, key = input().split(" ")
    commands.append((command, key))

dic = {}
for command in commands:

    if command[0] == "insert":
        dic[command[1]] = ""
    elif command[0] == "find":
        print("yes") if command[1] in dic else print("no")

Submission status: Accepted

Solution code:
def dictionary():
    n = int(input())
    dic = {}
    for i in range(n):
        line = input().split()
        order, key = line[0], line[1]
        if order == "insert":
            dic[key] = i
        else:
            if key in dic:
                print("yes")
            else:
                print("no")

if __name__ == "__main__":
    dictionary()

Submission status: Accepted

Solution code:
d = {}
n = int(input())
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        d[command[1]] = 0
    elif command[0] == 'find':
        if command[1] in d:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
n = int(input())

dict = {}
ans = []
for i in range(n):
  cmd, key = input().split(" ")
  if cmd == "insert":
    dict[key] = "yes"
    continue
  
  if cmd == "find":
    if dict.get(key) is None:
      ans.append("no")
    else:
      ans.append(dict[key])

for a in ans:
  print(a)

Submission status: Accepted

Solution code:
#処理回数
p_number = int(input())
acgt_disc = {}

#処理の実行
for i in range(p_number):
    a,b = input().split()
    if a[0] == "i":
        acgt_disc[b] = 0
    else:
        if b in acgt_disc:
            print("yes")
        else:
            print("no")

Submission status: Accepted

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

    for _ in range(n):
        com, para = input().split()

        if com == "insert":
            d.add(para)

        elif com == "find":
            if  para in d:
                print("yes")
            else:
                print("no")

main()

Submission status: Accepted

Solution code:
n = int(input())
S = set()
ans = []
for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        S.add(cmd[1])
    elif cmd[0] == 'find':
        if cmd[1] in S:
            ans.append('yes')
        else:
            ans.append('no')
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
#  dictionary

import sys

my_dict = dict()
n = int(input())

for i in range(n):
    query,value = sys.stdin.readline().split()
    if query == "insert":
        my_dict[value] = True
    elif query == "find":
        if value in my_dict:
            print("yes")
        else:
            print("no")

Submission status: Accepted

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

class HashTable:
    def __init__(self, capacity):
        capacity = 2**capacity
        self.table = [None]*capacity
        self.mask = capacity - 1
    
    def insert(self, data):
        node = Node(data)
        remainder = hash(data) & self.mask
        node.next, self.table[remainder] = self.table[remainder], node
    
    def find(self, data):
        remainder = hash(data) & self.mask
        node = self.table[remainder]
        while node:
            if node.data == data:
                return True
            node = node.next
        return False      

    
if __name__ == "__main__":
    n = int(input())
    dictionary = HashTable(20)
    for _ in range(n):
        operation, string = input().split()
        if operation == "insert":
            dictionary.insert(string)
            continue
        print("yes" if dictionary.find(string) else "no")

Submission status: Accepted

Solution code:
n = int(input())
s = set()
for _ in range(n):
	a,b = input().split()
	if a=="insert":
		s.add(b)
	else:
		print("yes" if b in s else "no")

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
  command, key = input().split()
  if command == "insert":
    dic[key] = True
  elif command == "find":
    if dic.get(key, False):
      print("yes")
    else:
      print("no")

Submission status: Accepted

Solution code:
# ライブラリのインポート
#import re #正規表現
import sys
#import heapq
#import collections
#import math

def main():
    s = set()
    for inst in sys.stdin:
        if inst[0] == 'f': print('yes' if inst[5:] in s else 'no')
        else: s.add(inst[7:])
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
dic=set()
for i in range(n):
    st=input().split()
    if st[0] == 'insert':
        dic.add(st[1])
        
    if st[0]== 'find':
        if st[1] in dic:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
# Dictionary

def main():
  n = int(input())
  commands= [input().split() for _ in range(n)]
  dictionary = {}
  
  for command in commands:
    if command[0] == 'insert':
      dictionary[command[1]] = True
    else: # find
      if command[1] in dictionary:
        print('yes')
      else:
        print('no')

main()

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    a, b = input().split()
    if a == "insert":
        dic[b] = 0
    else:
        if b in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
"""
17D8101031C 杉山　祥吾 ID:keisei334 python
"""

n=int(input())

dic=set()

for i in range(n):
    Command, Key = input().split()
    if Command=="insert":
        dic.add(Key)
    else:
        if Key in dic:
            print("yes")
        else:
            print("no")

"""実行結果

"""

Submission status: Accepted

Solution code:
n = int(input())

d = dict()
for _ in range(n):
    op, key = input().split()
    if op == 'insert':
        d[key] = None
    elif op == 'find':
        ans = 'yes' if key in d else 'no'
        print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d={}
for i in range(n):
    inst,val=input().split()
    if(inst=="insert"):
        d[val]=True
    elif(inst=="find"):
        if(d.get(val, False)):
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
dic = {}
n = int(input())
for _ in range(n):
    command = input().split(' ')
    opecode = command[0]
    operand = command[1]
    if opecode == 'insert':
        dic[operand] = operand
    elif opecode == 'find':
        if dic.get(operand) != None:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
N=int(input())

#set():集合でリストとは異なり要素は順番をもたず、重複した要素は取り除かれます。

D=set()
a=[]
b=[]

for i in range(N):
    A,B=input().split()
    #print(A,B)
    #A,B=input().split() これがinsert AAA ならA=insert B=AAA
    a.append(A)
    b.append(B)

for i in range(N): 
    if a[i]=="insert":
        D.add(b[i])
    elif a[i]=="find":
        if b[i] in D:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline

    dic = set()
    n = int(input())
    ans = []
    for a in range(n):
        s = input()
        if "\n" in s:
            s = s[:-1]
        if s[0] == "i":
            dic.add(s[7:])
        else:
            ans.append("yes" if s[5:] in dic else "no")
    print("\n".join(ans))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
num_s, *D,  = [s.split() for s in open(0)]
num_s = int(num_s[0])
dic = {}

for d in D:
    if d[0] == "insert":
        dic[d[1]] = 1
    else:
        if d[1] in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
hash_table = {}
n = int(input())
for _ in range(n):
    order, text = input().split()
    if order == "insert":
        hash_table[text] = 1
    elif order == "find":
        print("yes" if text in hash_table else "no")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n = int(input())

	dictionary = set()

	for i in range(n):
		Command, Key = input().split()
		if Command == "insert":
			dictionary.add(Key)
		else:
			if Key in dictionary:
				print("yes")
			else:
                            print("no")

Submission status: Accepted

Solution code:
"""
hash法を構成する
"""
class Dictionary():
    def __init__(self):
        self.MEMO = {'A':1, 'G':2, 'C':3, 'T':4}
        SIZE = 13
        POW = [1]*SIZE 
        for i in range(1, 13):
            POW[i] = POW[i-1]*4
        self.POW = POW
        self.DICT = [False]*POW[12]
    
    def makekey(self, value):
        l = len(value)
        key = -1 #アルファベットを数値に変換する準備
        for i in range(l):
            key += self.MEMO[value[i]]*self.POW[i]
        return key #このkeyの最大値は2**24-1
    
    def insert(self, value):
        key = self.makekey(value)
        self.DICT[key] = True
    
    def find(self, value): 
        key = self.makekey(value)
        if self.DICT[key] == False: #停止条件
            print('no')
        else:
            print('yes')

n = int(input())

d = Dictionary() 

for i in range(n):
    command, tmp_str = map(str, input().split())
    if command[0] == "i":
        d.insert(tmp_str)
    else:
        d.find(tmp_str)

Submission status: Accepted

Solution code:
d = set()
n = int(input())
for i in range(n):
    order, s = input().split(" ")
    if order == 'insert':
        d.add(s)

    elif order == 'find':
        if s in d:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
import sys

d = {'A': 0, 'C': 1, 'G': 2, 'T': 3}

the_hash = [None for _ in 'ACGT']

def insert(s):
    h = the_hash
    for c in s:
        if h[d[c]] is None:
            h[d[c]] = [None, None, None, None, False]
        h = h[d[c]]
    h[4] = True

def find(s):
    h = the_hash
    for c in s:
        if h[d[c]] is None:
            return False
        else:
            h = h[d[c]]
    else:
        return h[4]

n = int(input())
for _ in range(n):
    command, s = sys.stdin.readline().split()
    if command[0] == 'i':    # insert
        insert(s)
    elif find(s):   # find
        print('yes')
    else:
        print('no')

Submission status: Accepted

Solution code:
#dictionary
dict = set()
n = int(input())
for i in range(n):
    line = input().split()
    if line[0] == "insert":
        dict.add(line[1])
    elif line[0] == "find":
        if line[1] in dict:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
# ALDS1_4_C: Dictionary
n = int(input())
cmds = [input().split() for _ in range(n)]
dictionary = {}
for cmd in cmds:
    if cmd[0] == "insert":
        dictionary[cmd[1]] = None
    elif cmd[0] == "find":
        if cmd[1] in dictionary.keys():
            print("yes")
        else:
            print("no")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

str_dict = {}
for _ in range(0, n):
    command, str = input().split(' ')
    if command == 'insert':
        str_dict[str] = True
    elif command == 'find':
        if str in str_dict:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
import sys

def m():
    d={}
    input()
    for e in sys.stdin:
        if'f'==e[0]:
            print('yes' if e[5:] in d else 'no')
        else:
            d[e[7:]] = 0
            
if'__main__'==__name__:
    m()

Submission status: Accepted

Solution code:
n = int(input())

Dic = {}

ans = "no"

for i in range(n):
  order, word = input().split()
  if order == "insert":
    Dic[word] = i
  else:
    if word in Dic.keys():
      ans = "yes"
    else:
      ans = "no"
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a={}
res=[]
for i in range(n):
    order, value =input().split()
    if order == 'insert':
        a[value]= i
    elif order =='find':
        if a.__contains__(value):
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
import sys
from sys import stdin
input = stdin.readline

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    res = set()
    n_order = int(input())
    for i in range(n_order):
        order = input().split()
        if 'insert' == order[0]: 
            res.add(order[1])
        elif 'find' == order[0]:
            if order[1] in res: print('yes')
            else : print('no')

Submission status: Accepted

Solution code:
n = int(input())
st =set()
order, str = "",""
res = []
for i in range(n):
    order, str = input().split()
    if order == "insert":
        st.add(str)
    else:
        if str in st:print("yes")
        else:print("no")

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(3**12)

SIZE = 13
POW = [1]*SIZE

for i in range(1,SIZE):
    POW[i] = POW[i-1]*4

N = int(input())
memo = {'A':1,'G':2,'C':3,'T':4}
DICT = [False]*POW[12]

def getNUM(tmp_str):
    global POW,memo
    ret = -1
    for i in range(len(tmp_str)):
        ret += memo[tmp_str[i]]*POW[i]
    return ret


for _ in range(N):
    command,tmp_str = map(str,input().split())
    if command[0] == 'i':
        DICT[getNUM(tmp_str)] = True
    else:
        if DICT[getNUM(tmp_str)]:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


class HashTable:
    def __init__(self):
        self.Max = 1046527
        self.hashTable = [""] * self.Max
        
    def getChar(self, ch):
        if ch == "A":
            return 1
        elif ch == "G":
            return 2
        elif ch == "C":
            return 3
        elif ch == "T":
            return 4
        else:
            return 0
    
    def getKey(self, str):
        charList = list(str)
        sum = 0
        p = 1
        for ch in charList:
            sum += p * self.getChar(ch)
            p *= 5
        return sum

    def hash1(self, key):
        return key % self.Max
        
    def hash2(self, key):
        return key % (self.Max - 1)

    def find(self, str):
        key = self.getKey(str)
        i = 0
        while True:
            h = (self.hash1(key) + i * self.hash2(key)) % self.Max
            if str == self.hashTable[h]:
                return True
            elif len(self.hashTable[h]) == 0:
                return False
            i += 1
        return False

    def insert(self, str):
        key = self.getKey(str)
        i = 0
        while True:
            h = (self.hash1(key) + i * self.hash2(key)) % self.Max
            if str == self.hashTable[h]:
                return True
            elif len(self.hashTable[h]) == 0:
                self.hashTable[h] = str
                return False
            i += 1
        return False
        

hTable = HashTable()

lenA = int(input())
A = []
for i in range(lenA):
    tmp = list(input().split())
    A.append(tmp)

for i in range(lenA):
    if A[i][0] == "insert":
        hTable.insert(A[i][1])
    elif A[i][0] == "find":
        if hTable.find(A[i][1]):
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
coms = ['insert', 'find']
_, *D = open(0).read().split()
S = set()
for c, s in zip(*[iter(D)]*2):
    if coms.index(c) == 0:
        S.add(s)
    else:
        print('yes' if s in S else 'no')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    worddict = {}
    for _ in range(n):
        common, word = input().split(' ')
        if common == 'insert':
            worddict[word] = 1
        else:
            if word in worddict:
                print('yes')
            else:
                print('no')

Submission status: Accepted

Solution code:
import sys
  
dic = {}

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

for _ in range(n):
    command, c = stdin.readline().split()
    if command == 'insert':
        dic[c] = 1
    elif command == 'find':
        if c in dic:
            sys.stdout.write('yes\n')
        else:
            sys.stdout.write('no\n')

sys.stdout.flush()

Submission status: Accepted

Solution code:
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    d=set()
    for _ in range(n):
        o,w=input().split()
        if o=="insert":d.add(w)
        else:
            if w in d:
                print("yes")
            else:
                print("no")

main()

Submission status: Accepted

Solution code:
dic = {}
n = int (input())
for i in range(n):
    cmd, w = input().split()
    if cmd == "insert":
        dic[w]=1
    elif cmd == "find":
        if w in dic.keys():
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
#coding: utf-8

D = dict()
n = int(input())
for i in range(n):
    S = input().split()
    if S[0] == 'insert':
        D[S[1]] = True
    else:
        if S[1] in D:
            print('yes')
        else:
            print('no')

Submission status: Accepted

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

for _ in range(n):
    command, l = input().split()
    
    if command == "insert":
        dic.add(l)
    elif command == "find":
        if l in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
def main():
	n = int(input())
	dic = {}
	for _ in range(n):
		s = input()
		if s[0] == "i":
			dic[s[7:]] = 0
		else:
			if s[5:] in dic:
				print("yes")
			else:
				print("no")
main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
hashMap = {}
for i in range(n):
    inputL = input().split()
    if inputL[0] == 'insert':
        hashMap[inputL[1]] = 1
    else:
        if inputL[1] in hashMap:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
n = int(input())
list = {}
for i in range(n):
	command, item = input().split()
	if command == "find":
		if item in list:
			print("yes")
		else:
			print("no")
	else:
		list[item] = 0

Submission status: Accepted

Solution code:
dic ={}


n = int(input())

for _ in range(n):
    com, word = input().split()
    
    if com =="insert":
        dic[word] = True
    elif com =='find':
        print("yes" if word in dic else "no")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 24 00:11:24 2019

@author: iwao_yuuki
"""

import math

n = int(input(""))

D = {}
Ans = []

for i in range(n):
    cm,text = input().split()

    if cm == "insert":
        D[text] = 1
    if cm == "find":
        if text in D.keys():
                Ans.append("yes")
        else:
            Ans.append("no")

for i in Ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())

l={}
ans=[]

for i in range(n):
    ope,let=input().split()

    if ope=='insert':
        l[let]=0
    else:
        if let in l:
            ans.append("yes")
        else:
            ans.append("no")

for h in ans:
    print(h)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
d = set()
ans = []

for i in range(int(input())):
    str1, str2 = input().split()
    if (str1 == 'insert'):
        d.add(str2)
    else :
        if(str2 in d):
            ans.append('yes')
        else:
            ans.append('no')

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
#17D8104026C 宮地拓海 Air_conditioner123 Python

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

Submission status: Accepted

Solution code:
n=int(input())
dic={}
j=0
for i in range(n):
    order,str=input().split()
    if order=="insert":
        j+=1
        dic.setdefault(str,j)
    else:
        if str in dic.keys():
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
dict={}
n=int(input())
cnt=0
ans=[]
for i in range(n):
    str=list(input().split())
    if str[0]=='insert':
        dict[str[1]]=cnt
        cnt+=1

    if str[0]=='find':
        if str[1] in dict:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    record = set()
    n = int(input())
    for _ in range(n):
        order, string = input().split()
        if order == 'insert':
            record.add(string)
        else:
            assert order == 'find', '输入错误'
            if string in record:
                print('yes')
            else:
                print('no')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 学籍番号 17D8101029G 石塚 博之 ID: mcatpolo 言語: python3

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

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

    

    if com[0] == "insert":
        dic.add(com[1])

    else:
        if com[1] in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
n = int(input())
d = set()

for _ in range(n):
	command, value = input().split()

	if command == "find":
		s = "yes" if value in d else "no"
		print(s)
		continue

	d.add(value)

Submission status: Accepted

Solution code:
n=int(input())
key=set()
j=0
c=0
for i in range(n):
    a,b=input().split()
    if a=='insert':
        key.add(b)
        j=j+1
    if a=='find':
        c=0
        if b in key:
            print("yes")
        else: print("no")

Submission status: Accepted

Solution code:
n = int(input())

set1 = set()
set2 = set()

str = list()

for i in range(0, n):
    str1,str2 = input().split()
    if str1[0] == 'i':
        set1.add(str2)
    if str1[0] == 'f':
        set2.add(str2)
        set3 = set1 & set2
        if set3 == set():
            str.append('no')
        else:
            str.append('yes')
        set2.clear()

for i in range(0, len(str)):
    print(str[i])

Submission status: Accepted

Solution code:
dict = {}
n = int(input())
cnt = 0
ans = []
for i in range(n):
    str = list(input().split())
    if str[0] == 'insert':
        dict[str[1]] = cnt
        cnt += 1
    
    if str[0] == 'find':
        if str[1] in dict:
            print("yes")
        else:
            print("no")

Submission status: Accepted

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

for i in range (n):
    s,a=input().split()
    if s=="insert":
        dic.add(a)
    elif s=="find":
        if a in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
n=int(input())

s=set()
command=[]

for i in range(n):
  c=input().split()
  command.append(c)


for i in range(n):

  if command[i][0]=="insert":
    s.add(command[i][1])
  else:
    if command[i][1] in s:
      print("yes")
    else:
      print("no")

Submission status: Accepted

Solution code:
element_count = int(input())
dic = set()
for i in range(element_count):
    instruction = input().split()
    if instruction[0]=="insert":
        dic.add(instruction[1])
    elif instruction[0]=="find":
        if instruction[1] in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
num = int(input())

count = 0
dict1 = {}
for i in range(num):
    command, word = map(str,input().split())
    
    if command == "insert":
        dict1[word] = i
    
    else:
        if (word in dict1.keys()) == True:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
n=int(input())
dict ={}
for i in range(n):
    c=input()
    if c[:6]=="insert":
        dict[(c[7:])]=True
    elif c[:4]=="find":
        if dict.get(c[5:])==True:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
A=set()
n=int(input())

Ans=set()
for i in range(n):    
    command,x=input().split()
    if command == "insert":
        A.add(x)
    elif command == "find":
        
        if x in A:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
a={}
n=int(input())
for i in range(n):
    s=list(input().split())
    if s[0]=='insert':
        a[s[1]]=0
    elif s[0]=='find':
        if s[1] in a:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
n = int(input())
dic = set()
for i in range(n):
    key, value = input().split()
    if key == "insert":
        dic.add(value)
    else:
        if value in dic:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
d = {}
n = int(input())
for _ in range(n):
    s = input().split()
    if s[0] == "insert":
        d[s[1]] = 0
    elif s[0] == "find":
        if d.get(s[1]) == 0:
            print("yes")
        else:
            print("no")

Submission status: Accepted

Solution code:
def main():
    d = set()
    N = int(input())
    for i in range(N):
        S = input().split()
        if S[0] == 'insert':
            d.add(S[1])
        elif S[0] == 'find':
            if S[1] in d:
                print("yes")
            else:
                print("no")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for _ in range(n):
    instruction, str = input().split()
    if instruction == 'insert':
        dic[str] = '_'
    
    else:
        if str in dic:
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
n = int(input())
o = [input().split(" ") for _ in range(n)]

def func(n, o):
    dic = {}
    for i in range(n):
        if o[i][0] == "insert":
            dic[o[i][1]] = 1
        else:
            print("yes" if o[i][1] in dic else "no")

func(n, o)

Submission status: Accepted

Solution code:
n = int(input())
x = {}
for i in range(n):
    a = input().split()
    if a[0] == 'insert':
        x[a[1]] = 1
    else:
        if a[1] in x.keys():
            print('yes')
        else:
            print('no')

Submission status: Accepted

Solution code:
if __name__ == "__main__":
	d = {}
	n = int(input())
	for _ in range(n):
		command = input().split()
		if command[0] == "insert":
			d[command[1]] = ''
		if command[0] == "find":
			if command[1] in d:
				print("yes")
			else:
				print("no")