Problem:

Set: Delete

  For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.

  
insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.

  
find($x$): Report the number of $x$ in $S$ (0 or 1).

  
delete($x$): Delete $x$ from $S$.

Input

  The input is given in the following format.

$q$
$query_1$
$query_2$
:
$query_q$

Each query $query_i$ is given by

0 $x$

or

1 $x$

or

2 $x$

  where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.

Output

  For each insert operation, print the number of elements in $S$.

  For each find operation, print the number of specified elements in $S$.

Constraints

  
$1 \leq q \leq 200,000$

  
$0 \leq x \leq 1,000,000,000$

Sample Input 1

8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2

Sample Output 1

1
2
3
1
0
1
3



Sample input:
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2


Sample output:
1
2
3
1
0
1
3

Submission status: Wrong Answer

Solution code:

import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 1
        self.keys = [None] * self.size

    def add(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                self.keys[k] = key
                self.count += 1
                break
            elif self.keys[k] == key:
                break
        else:
            raise RuntimeError('set is full')

        if self.count > self.size // 2:
            size = int(2 ** (math.log2(self.size+1)+1)) - 1
            self._resize(size)

    def delete(self, key):
        i = self._hash(key)
        while self.keys[i] is not None and self.keys[i] != key:
            i = (i + 1) % self.size

        for j in range(self.size):
            k1 = (i + j) % self.size
            k2 = (i + j + 1) % self.size
            if self.keys[k2] is None:
                self.keys[k1] = None
                self.count -= 1
                break
            elif k2 == self._hash(self.keys[k2]):
                self.keys[k1] = None
                self.count -= 1
                break
            else:
                self.keys[k1] = self.keys[k2]

        if self.count <= self.size // 4:
            size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
            self._resize(size)

    def __contains__(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                return False
            elif self.keys[k] == key:
                return True
        raise RuntimeError('set is full')

    def _hash(self, key):
        return key % self.size

    def _resize(self, size):
        old_keys = self.keys
        self.count = 0
        self.size = size
        self.keys = [None] * self.size

        for key in old_keys:
            if key is None:
                continue
            self.add(key)


def run():
    q = int(input())
    s = LinearProbingIntSet()

    for _ in range(q):
        command, value = [int(x) for x in input().split()]
        if command == 0:
            s.add(value)
            print(s.count)
        elif command == 1:
            if value in s:
                print(1)
            else:
                print(0)
        elif command == 2:
            s.delete(value)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:

import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 1
        self.keys = [None] * self.size

    def add(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                self.keys[k] = key
                self.count += 1
                break
            elif self.keys[k] == key:
                break
        else:
            raise RuntimeError('set is full')

        if self.count > self.size // 2:
            size = int(2 ** (math.log2(self.size+1)+1)) - 1
            self._resize(size)

    def delete(self, key):
        i = self._hash(key)
        while self.keys[i] is not None and self.keys[i] != key:
            i = (i + 1) % self.size

        if self.keys[i] != key:
            return

        for j in range(self.size):
            k1 = (i + j) % self.size
            k2 = (i + j + 1) % self.size
            if self.keys[k2] is None:
                self.keys[k1] = None
                self.count -= 1
                break
            elif k2 == self._hash(self.keys[k2]):
                self.keys[k1] = None
                self.count -= 1
                break
            else:
                self.keys[k1] = self.keys[k2]

        if self.count <= self.size // 4:
            size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
            self._resize(size)

    def __contains__(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                return False
            elif self.keys[k] == key:
                return True
        raise RuntimeError('set is full')

    def _hash(self, key):
        return key % self.size

    def _resize(self, size):
        old_keys = self.keys
        self.count = 0
        self.size = size
        self.keys = [None] * self.size

        for key in old_keys:
            if key is None:
                continue
            self.add(key)

def run():
    q = int(input())
    s = LinearProbingIntSet()

    for _ in range(q):
        command, value = [int(x) for x in input().split()]
        if command == 0:
            s.add(value)
            print(s.count)
        elif command == 1:
            if value in s:
                print(1)
            else:
                print(0)
        elif command == 2:
            s.delete(value)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Submission status: Time Limit Exceeded

Solution code:

import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 1
        self.keys = [None] * self.size

    def add(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                self.keys[k] = key
                self.count += 1
                break
            elif self.keys[k] == key:
                break
        else:
            raise RuntimeError('set is full')

        if self.count > self.size // 2:
            size = int(2 ** (math.log2(self.size+1)+1)) - 1
            self._resize(size)

    def delete(self, key):
        i = self._hash(key)
        while self.keys[i] is not None and self.keys[i] != key:
            i = (i + 1) % self.size

        if self.keys[i] != key:
            return
        self.keys[i] = None
        self.count -= 1

        i = (i + 1) % self.size
        while self.keys[i] is not None:
            k, self.keys[i] = self.keys[i], None
            self.count -= 1
            self.add(k)
            i = (i + 1) % self.size

        if self.count <= self.size // 4:
            size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
            self._resize(size)

    def __contains__(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                return False
            elif self.keys[k] == key:
                return True
        raise RuntimeError('set is full')

    def _hash(self, key):
        return key % self.size

    def _resize(self, size):
        old_keys = self.keys
        self.count = 0
        self.size = size
        self.keys = [None] * self.size

        for key in old_keys:
            if key is None:
                continue
            self.add(key)


def run():
    q = int(input())
    s = LinearProbingIntSet()

    for _ in range(q):
        command, value = [int(x) for x in input().split()]
        if command == 0:
            s.add(value)
            print(s.count)
        elif command == 1:
            if value in s:
                print(1)
            else:
                print(0)
        elif command == 2:
            s.delete(value)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
numset = set([])
q = int(input())
for i in range(q):
    query, x = list(map(int, input().split(' ')))
    if query == 0:
        numset.add(x)
        print(len(numset))
    elif query == 1:
        if set([x]).issubset(numset):
            print(1)
        else:
            print(0)
    else:
        if set([x]).issubset(numset):
            numset.remove(x)

Submission status: Accepted

Solution code:
# AOJ ITP2_7_B: Set: Delete
# Python3 2018.6.24 bal4u

tbl = set()
q = int(input())
for i in range(q):
	a = input().split()
	x = int(a[1])
	if a[0] == '0':
		tbl.add(x)
		print(len(tbl))
	elif a[0] == '1': print(1 if x in tbl else 0)
	else:
		if x in tbl: tbl.remove(x)

Submission status: Accepted

Solution code:
# coding=utf-8

Q = int(input())

S = set()

for i in range(Q):
    qtype, number = map(int, input().split())
    if qtype == 0:
        S.add(number)
        print(len(S))
    elif qtype == 1:
        if number in S:
            print(1)
        else:
            print(0)
    elif qtype == 2:
        try:
            S.remove(number)
        except KeyError:
            pass

Submission status: Accepted

Solution code:

import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 1
        self.keys = [None] * self.size

    def add(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                self.keys[k] = key
                self.count += 1
                break
            elif self.keys[k] == key:
                break
        else:
            raise RuntimeError('set is full')

        if self.count > self.size // 2:
            size = int(2 ** (math.log2(self.size+1)+1)) - 1
            self._resize(size)

    def delete(self, key):
        i = self._hash(key)
        while self.keys[i] is not None and self.keys[i] != key:
            i = (i + 1) % self.size

        if self.keys[i] != key:
            return
        self.keys[i] = None
        self.count -= 1

        i = (i + 1) % self.size
        while self.keys[i] is not None:
            key = self.keys[i]
            if i != self._hash(key):
                self.keys[i] = None
                self.count -= 1
                self.add(key)
            i = (i + 1) % self.size

        if self.count <= self.size // 4:
            size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
            self._resize(size)

    def __contains__(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                return False
            elif self.keys[k] == key:
                return True
        raise RuntimeError('set is full')

    def _hash(self, key):
        return (key * 13) % self.size

    def _resize(self, size):
        old_keys = self.keys
        self.count = 0
        self.size = size
        self.keys = [None] * self.size

        for key in old_keys:
            if key is None:
                continue
            self.add(key)


def run():
    q = int(input())
    s = LinearProbingIntSet()

    for _ in range(q):
        command, value = [int(x) for x in input().split()]
        if command == 0:
            s.add(value)
            print(s.count)
        elif command == 1:
            if value in s:
                print(1)
            else:
                print(0)
        elif command == 2:
            s.delete(value)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
n=int(input())
s=set()
for i in range(n):
    a,b=map(int,input().split())
    if a==0:
        s.add(b)
        print(len(s))
    elif a==1:
        if b in s:
            print(1)
        else:
            print(0)
    else:
        if b in s:
            s.remove(b)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
from random import randrange


q = int(input())
queries = [list(map(int, input().split())) for i in range(q)]

set_ = set()

for category, x in queries:
    if category == 0:
        set_.add(x)
        print(len(set_))
    elif category == 1:
        print(int(x in set_))
    else:
        if x in set_:
            set_.remove(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	set_delete
# CreatedDate:  2020-07-15 11:57:08 +0900
# LastModified: 2020-07-15 12:06:49 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    q = int(input())
    S = set()
    for _ in range(q):
        command = input().split()
        if command[0] == '0':
            S.add(int(command[1]))
            print(len(S))
        elif command[0] == '1':
            if int(command[1]) in S:
                print(1)
            else:
                print(0)
        else:
            S.discard(int(command[1]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
readline = open(0).readline
writeline = open(1, 'w').writelines

s = set()


def insert(x):
    s.add(x)
    ans.append("%d\n" % len(s))


def find(x):
    ans.append("%d\n" % (x in s))


C = [insert, find, s.discard].__getitem__
Q = int(readline())
ans = []

for _ in range(Q):
    t, x = map(int, readline().split())
    C(t)(x)

writeline(ans)

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input())
    ans = set()
    for _ in range(n):
        q, x = [int(i) for i in input().split()]
        if q == 0:
            ans.add(x)
            print(len(ans))
        elif q == 1:
            if x in ans:
                print(1)
            else:
                print(0)
        else:
            if x in ans:
                ans.remove(x)


resolve()

Submission status: Accepted

Solution code:
S = set()
q = int(input())
for i in range(q):
    c, x = map(int, input().split())
    if c == 0:
        S.add(x)
        print(len(S))
    elif c == 1:
        print(int(x in S))
    else:
        S.discard(x)

Submission status: Accepted

Solution code:
#空リスト作成と標準入力
s = set()
for _ in range(int(input())):
    a,b = map(int,input().split())
    try:
        #セットbを入れセットの長さを出力する
        if a == 0:
            s.add(b)
            print(len(s))
            
        #セットの中にbがあるなら1ないなら0を出力する
        elif a == 1:print(1 if b in s else 0)
        
        #セットからbを消す
        elif a == 2:s.remove(b)
    except KeyError:
        pass

Submission status: Accepted

Solution code:
S = set()

for i in range(int(input())):
    order,value = map(int,input().split())

    if order == 0:
        S.add(value)
        print(len(S))
    elif order == 1:
        print(1 if value in S else 0)
    else:
        S.discard(value)

Submission status: Accepted

Solution code:
q = int(input())
se = set()
while q:
    q -= 1
    op, x = map(int, input().split())
    if op == 1:
        print(+(x in se))
    elif op == 0:
        se.add(x)
        print(len(se))
    else:
        se.discard(x)

Submission status: Accepted

Solution code:
S = set()
q = int(input())
for i in range(q):
    a = input().split()
    if a[0] == "0":
        S.add(int(a[1]))
        print(len(S))
    elif a[0] == "1":
        print(1 if int(a[1]) in S else 0)
    else:
        if int(a[1]) in S:
            S.remove(int(a[1]))

Submission status: Accepted

Solution code:
q = int(input())
s = set()
for i in range(q):
    x, y = map(int, input().split())
    if x == 0:
        s.add(y)
        print(len(s))
    elif x == 1:
        print(1) if y in s else print(0)
    else:
        s.discard(y)

Submission status: Accepted

Solution code:
def main():
    m = int(input())
    s = set()
    for _ in range(m):
        a,b = map(int,input().split())
        if a == 0:
            s.add(b)
            print (len(s))
        elif a == 1:
            if b in s:print (1)
            else     :print (0)
        elif b in s:s.remove(b)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q = int(input())
S = set([])

for i in range(q):
    query, x = list(map(int, input().split()))

    # insert
    if query == 0:
        S.add(x)
        print(len(S))

    # find
    elif query == 1:
        if x in S:
            print(1)
        else:
            print(0)

    # delete
    else:
        if x in S:
            S.remove(x)

Submission status: Accepted

Solution code:
s = set()
for _ in range(int(input())):
	q,x = map(int, input().split())
	if q==0:
		s.add(x)
		print(len(s))
	elif q==2:
		s.discard(x)
	else:
		print("1" if x in s else "0")

Submission status: Accepted

Solution code:
def main():
    q = int(input())
    s = set()

    for _ in range(q):
        op, x = map(int, input().split())

        if op == 0:
            s.add(x)
            print(len(s))
        elif op == 1:
            if x in s:
                print("1")
            else:
                print("0")
        elif op == 2:
            s.discard(x)
main()

Submission status: Accepted

Solution code:
S=set()

q=int(input())

for _ in range(q):
    query=[int(i) for i in input().split(" ")]
    if query[0]==0:
        S.add(query[1])
        print(len(S))
    elif query[0]==1:
        if query[1] in S:
            print(1)
        else:
            print(0)
    else:
        if query[1] in S:
            S.remove(query[1])

Submission status: Accepted

Solution code:
import sys

s = set()
input()

for q in sys.stdin:
    q = q.split()
    if q[0] == '0':
        s.add(q[1])
        print(len(s))
    elif q[0] == '1':
        print(int(q[1] in s))
    else:
        s.discard(q[1])

Submission status: Accepted

Solution code:
S=set()
n=int(input())
for i in range(n):
    q,x=map(int,input().split())
    if q==0:
        if x in S:
            print(len(S))
        else:
            S.add(x)
            print(len(S))
    elif q==1:
        x={x}
        if S>=x:
            print(1)
        else:
            print(0)
    else:
            S.discard(x)

Submission status: Accepted

Solution code:
n = int(input())

s = set()
for _ in range(n):
    c, k = [int(x) for x in input().split()]
    if c == 0:
        s.add(k)
        print(len(s))
        continue
    if c == 1:
        if k in s:
            print(1)
        else:
            print(0)
        continue
    if c==2:
        s.discard(k)

Submission status: Accepted

Solution code:
q = int(input( ))
st = set()
for i in range(q):
    cmmd,tx = map(int, input().split( ))
    if cmmd == 0:
        st.add(tx) 
        print(len(st)) 
    elif cmmd == 1 :
        if tx in st:
            print(1)
        else:
            print(0)
    else:
        if tx in st:
            st.remove(tx)

Submission status: Accepted

Solution code:
from typing import Set


if __name__ == "__main__":
    int_set: Set[int] = set()
    num_query = int(input())

    for _ in range(num_query):
        op, v = map(lambda x: int(x), input().split())
        if (0 == op):
            int_set.add(v)
            print(len(int_set))
        elif (1 == op):
            if (v in int_set):
                print(1)
            else:
                print(0)
        else:
            if (v in int_set):
                int_set.remove(v)

Submission status: Accepted

Solution code:
tbl = set()
q = int(input())
for i in range(q):
	a = input().split()
	x = int(a[1])
	if a[0] == '0':
		tbl.add(x)
		print(len(tbl))
	elif a[0] == '1': print(1 if x in tbl else 0)
	else:
		if x in tbl: tbl.remove(x)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Set - Set: Delete
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_7_B&lang=jp

"""
s = set()
for _ in range(int(input())):
    q, x = input().split()
    if q == '0':
        s.add(x)
        print(len(s))
    elif q == '1':
        print(int(x in s))
    else:
        s.discard(x)

Submission status: Accepted

Solution code:
readline = open(0).readline
writelines = open(1, 'w').writelines
s = set()
def insert(x):
    s.add(x)
    ans.append("%d\n" % len(s))
def find(x):
    ans.append("%d\n" % (x in s))
 
C = [insert, find, s.discard].__getitem__
Q = int(readline())
ans = []
for _ in range(Q):
    t, x = map(int, readline().split())
    C(t)(x)
writelines(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	n = int(input())
	S = set()

	for _ in range(n):
		x,y = map(int,input().split())
		if x == 0:
			S.add(y)
			print(len(S))
		elif x == 1:
			if y in S:
				print("1")
			else:
				print("0")
		else:
			S.discard(y)

Submission status: Accepted

Solution code:
S = set()

q = int(input())


for _ in range(q):
    
    command, *list_num = input().split()
    x = int(list_num[0])

    if   command == "0":
        # insert(x)
        S.add(x)
        print(len(S))
    elif command == "1":
        # find(x)
        if x in S:
            print(1)
        else:
            print(0)
    elif command == "2":
        if x in S:
            S.remove(x)
    else:
        raise

Submission status: Accepted

Solution code:
n = int(input())
s = set()
for _ in range(n):
    a, b = map(int,input().split())
    if a == 0:
        s.add(b)
        print(len(s))
    elif a == 1:
        if b in s:
            print(1)
        else:
            print(0)
    else:
        if b in s:
            s.remove(b)

Submission status: Accepted

Solution code:
t = set()
q = int(input())

for i in range(q):
    a = input().split()
    x = int(a[1])
    if a[0] == '0':
        t.add(x)
        print(len(t))
    elif a[0] == '1': print(1 if x in t else 0)
    else:
        if x in t: t.remove(x)

Submission status: Accepted

Solution code:
import bisect

S=[]

def insert(S,count,x):
    y=bisect.bisect_left(S,x)
    if y>=count or S[y]!=x:
        S.insert(y,x)
        count+=1
    print(count)
    return S,count

def find(S,x):
    y=bisect.bisect_left(S,x)
    if y<count and S[y]==x:
        judge=1
    else:
        judge=0
    return judge,y

q=int(input())
count=0
for i in range(q):
    query=list(map(int,input().split()))
    
    if query[0]==0:
        S,count=insert(S,count,query[1])
    elif query[0]==1:
        print(find(S,query[1])[0])
    else:
        if find(S,query[1])[0]==1:
            S.pop(find(S,query[1])[1])
            count-=1

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_7_B&lang=jp
#  Set: Delete: python3
#  2018.12.02 yonezawa

import sys
input = sys.stdin.readline
import collections

def main():
    tl = {}
    for i in range(int(input())):
        l = list(map(int,input().split()))

        #insert
        cmd = l[0]
        if cmd == 0:
            tl[l[1]] = 1
            print (len(tl))
        #find
        elif cmd == 1:
            c = 1 if l[1] in tl else 0
            print (c)
        #delete
        elif cmd == 2:
            d = l[1]
            try:
                tl.pop(d)
            except KeyError:
                None
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
s = {}
for i in range(nq):
    q, x = lines[i].split()
    if q == '0':    # insert x
        s[x] = ''
        ans[i] = str(len(s))
    elif q == '1':   # find x
        ans[i] = str(int(x in s))
    else:           # delete x
        if x in s:
            del s[x]

[print(x) for x in ans if x]

Submission status: Accepted

Solution code:
q = int(input())

num = set()
for _ in range(q):
    query, x = map(int, input().split())
    if query == 0:
        num.add(x)
        print(len(num))
    elif query == 1:
        if x in num:
            print(1)
        else:
            print(0)
    else:
        if x in num:
            num.remove(x)

Submission status: Accepted

Solution code:
readline = open(0).readline
writelines = open(1, 'w').writelines
s = set()
def insert(x):
    s.add(x)
    ans.append("%d\n" % len(s))
def find(x):
    ans.append("%d\n" % (x in s))

C = [insert, find, s.discard].__getitem__
Q = int(readline())
ans = []
for _ in range(Q):
    t, x = map(int, readline().split())
    C(t)(x)
writelines(ans)

Submission status: Accepted

Solution code:
S = set()
for _ in [0]*int(input()):
    q, x = input().split()
    if q == "0": S.add(x); print(len(S))
    elif q == "1": print(1 if x in S else 0)
    elif x in S: S.remove(x)

Submission status: Accepted

Solution code:
n = int(input())
S = set()
for i in range(n):
    query, x = map(int, input().split())
    if query == 0:
        S.add(x)
        print(len(S))
    elif query == 1:
        print(1 if x in S else 0)
    else:
        S.discard(x)

Submission status: Accepted

Solution code:
s=set()
for i in range(int(input())):
    a,b=map(int,input().split(" "))
    if a==1:
        print(1*(b in s))
    elif a==0:
        s.add(b)
        print(len(s))
    elif a==2:
        s.discard(b)

Submission status: Accepted

Solution code:
n = int(input())
s = set()
for i in range(n):
  q = list(map(int, input().split()))
  if q[0]==0:
    s.add(q[1])
    print(len(s))
  elif q[0]==1:
    if q[1] in s:
      print(1)
    else:
      print(0)
  else:
    if q[1] in s:
      s.remove(q[1])

Submission status: Runtime Error

Solution code:
numset = set([])
q = int(input())
for i in range(q):
    query, x = list(map(int, input().split(' ')))
    if query == 0:
        numset.add(x)
        print(len(numset))
    elif query == 1:
        if set([x]).issubset(numset):
            print(1)
        else:
            print(0)
    else:
        numset.remove(x)

Submission status: Runtime Error

Solution code:
# coding=utf-8

Q = int(input())

S = set()

for i in range(Q):
    qtype, number = map(int, input().split())
    if qtype == 0:
        S.add(number)
        print(len(S))
    if qtype == 1:
        if number in S:
            print(1)
        else:
            print(0)
    if qtype == 2:
        S.remove(number)

Submission status: Runtime Error

Solution code:
# coding=utf-8

Q = int(input())

S = set()

for i in range(Q):
    qtype, number = map(int, input().split())
    if qtype == 0:
        S.add(number)
        print(len(S))
    elif qtype == 1:
        if number in S:
            print(1)
        else:
            print(0)
    elif qtype == 2:
        S.remove(number)