Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(stdinput())

    d = MyDict()

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            d.insert(value)
        elif cmd == 'find':
            if d.find(value):
                print('yes')
            else:
                print('no')

class MyDict():
    def __init__(self):
        self.E = []
    
    def insert(self, value):
        self.E.append(value)
    
    def find(self, value):
        return value in self.E

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Fixed submission:
def main():
    n = int(stdinput())

    st = [None] * (4**12)

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            st[get_hash(value)] = 1
        elif cmd == 'find':
            if st[get_hash(value)] == 1:
                print('yes')
            else:
                print('no')

CODES = {'A' : 1, 'C' : 2, 'G' : 3, 'T' : 4}
def get_hash(s):
    base = 1
    h = 0
    for c in s:
        code = CODES[c]
        h += code * base
        base *= 4
    return h

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(stdinput())

    d = MyDict()

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            d.insert(value)
        elif cmd == 'find':
            if d.find(value):
                print('yes')
            else:
                print('no')

class MyDict():
    def __init__(self):
        self.stacks = {
            'A': [],
            'C': [],
            'G': [],
            'T': []
        }
    
    def insert(self, value):
        self.stacks[value[0]].append(value)
    
    def find(self, value):
        return value in self.stacks[value[0]]

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Fixed submission:
def main():
    n = int(stdinput())

    st = [None] * (4**12)

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            st[get_hash(value)] = 1
        elif cmd == 'find':
            if st[get_hash(value)] == 1:
                print('yes')
            else:
                print('no')

CODES = {'A' : 1, 'C' : 2, 'G' : 3, 'T' : 4}
def get_hash(s):
    base = 1
    h = 0
    for c in s:
        code = CODES[c]
        h += code * base
        base *= 4
    return h

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(stdinput())

    d = MyDict()

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            d.insert(value)
        elif cmd == 'find':
            if d.find(value):
                print('yes')
            else:
                print('no')


class MyDict():
    def __init__(self):
        self.stacks = {
            'A': [],
            'C': [],
            'G': [],
            'T': []
        }
    
    def insert(self, value):
        st = self.stacks[value[0]]
        st.append(value[1:])
        self.stacks[value[0]] = sorted(st)
    
    def find(self, value):
        st = self.stacks[value[0]]
        return binary_search(st, len(st), value[1:])

def binary_search(S, n, t):
    left = 0
    right = n - 1
    while left <= right:
        mid = (left + right) // 2
        if S[mid] == t:
            return True
        elif S[mid] > t:
            right = mid - 1
        else:
            left = mid + 1
    
    return False

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Fixed submission:
def main():
    n = int(stdinput())

    st = [None] * (4**12)

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            st[get_hash(value)] = 1
        elif cmd == 'find':
            if st[get_hash(value)] == 1:
                print('yes')
            else:
                print('no')

CODES = {'A' : 1, 'C' : 2, 'G' : 3, 'T' : 4}
def get_hash(s):
    base = 1
    h = 0
    for c in s:
        code = CODES[c]
        h += code * base
        base *= 4
    return h

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(stdinput())

    d = MyDict()

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            d.insert(value)
        elif cmd == 'find':
            if d.find(value):
                print('yes')
            else:
                print('no')


class MyDict():
    def __init__(self):
        self.stacks = {
            1: [], 2: [], 3: [], 4: [], 5: [],
            6: [], 7: [], 8: [], 9: [], 10: [],
            11: [], 12: []
        }
    
    def insert(self, value):
        st = self.stacks[len(value)].append(value)
    
    def find(self, value):
        st = self.stacks[len(value)]
        return value in st

def binary_search(S, n, t):
    left = 0
    right = n - 1
    while left <= right:
        mid = (left + right) // 2
        if S[mid] == t:
            return True
        elif S[mid] > t:
            right = mid - 1
        else:
            left = mid + 1
    
    return False

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    


Fixed submission:
def main():
    n = int(stdinput())

    st = [None] * (4**12)

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            st[get_hash(value)] = 1
        elif cmd == 'find':
            if st[get_hash(value)] == 1:
                print('yes')
            else:
                print('no')

CODES = {'A' : 1, 'C' : 2, 'G' : 3, 'T' : 4}
def get_hash(s):
    base = 1
    h = 0
    for c in s:
        code = CODES[c]
        h += code * base
        base *= 4
    return h

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')