Problem:
Set: Search 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).  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$ where the first digits 0 and 1 represent insert and find 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 7
0 1
0 2
0 3
0 2
0 4
1 3
1 10 Sample Output 1 1
2
3
3
4
1
0

Solution (Python):
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))
    else:
        if set([x]).issubset(numset):
            print(1)
        else:
            print(0)

Solution (Python):



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))
	else: print(1 if x in tbl else 0)

Solution (Python):

import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 3
        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:
            self._resize(int(2 ** (math.log2(self.size+1)+1)) - 1)

    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)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()

Solution (Python):


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)

Solution (Python):
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))
    else:
        if b in s:
            print(1)
        else:
            print(0)

Solution (Python):
import sys

s = set()
input()

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

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


resolve()

Solution (Python):
BLACK = True
RED = False


class Vertex:
    def __init__(self, val, color, parent=None, left=None, right=None):
        self.val = val
        self.col = color
        self.p = parent
        self.l = left
        self.r = right


class RedBlcakTree:
    def __init__(self):
        self.nil = Vertex(None, BLACK, None, None, None)    
        self.root = self.nil
        self.size = 0
    

    
    
    
    def inorder_traverse(self, node=None):
        buf = []
        node = self.root if node is None else node
        
        if node != self.nil:
            buf += self.inorder_traverse(node.l)
            buf.append(node.val)
            buf += self.inorder_traverse(node.r)
        return buf
    
    def preorder_traverse(self, node=None):
        buf = []
        node = self.root if node is None else node
        if node != self.nil:
            buf.append(node.val)
            buf += self.preorder_traverse(node.l)
            buf += self.preorder_traverse(node.r)
        return buf

    def postorder_traverse(self, node=None):
        buf = []
        node = self.root if node is None else node
        if node != self.nil:
            buf += self.postorder_traverse(node.l)
            buf += self.postorder_traverse(node.r)
            buf.append(node.val)
        return buf
    
    def __str__(self):
        return '[' + ', '.join(map(str, self.inorder_traverse())) + ']'
    
    def __len__(self):
        return self.size

    
    
    
    
    def find(self, x, node=None, key=lambda x: x):
        '''
        ある部分木のなかで key(val) が x と一致するようなノードを探索する。
        発見したらそのノードを返し、発見できなったら -1 を返す。 (O(lgn))
        Args:
            x (object): 探索したい値
            node (Vertex): 探索を行う部分木の根。デフォルトでは探索木全体の根のノードを指す。
            key (function)
        '''
        node = self.root if node is None else node
        while node != self.nil and key(node.val) != x:
            node = node.l if x < node.val else node.r
        if node == self.nil:
            return -1
        else:
            return node
    
    def min_node(self, node=None):
        '''
        ある部分木のなかで最小のノードを探す (O(lgn))
        '''
        node = self.root if node is None else node
        while node.l != self.nil:
            node = node.l
        return node
    
    def max_node(self, node=None):
        '''
        ある部分木のなかで最大のノードを探す (O(lgn))
        '''
        node = self.root if node is None else node
        while node.r != self.nil:
            node = node.r
        return node
    
    def successor(self, node):
        '''
        中間順木巡回で定まる順序において、ある節点の次節点を決定する。(O(lgn))
        次節点が存在したらそのノードを、存在しなかったら ValueError を返す。
        '''
        arg = node
        if node.r != self.nil:
            return self.min_node(node.r)
        else:
            while node.p != self.nil and node.p.l != node:
                node = node.p
            if node.p == self.nil:
                raise ValueError(f'RedBlackTree.successor(): {arg} is the last node.')
            else:
                return node.p
    
    def predecessor(self, node):
        '''
        中間順木巡回で定まる順序において、ある節点の前節点を決定する。(O(lgn))
        前節点が存在したらそのノードを、存在しなかったら ValueError を返す。
        '''
        arg = node
        if node.l != self.nil:
            return self.max_node(node.l)
        else:
            while node.p != self.nil and node.p.r != node:
                node = node.p
            if node.p == self.nil:
                raise ValueError(f'RedBlackTree.predecessor(): {arg} is the first node.')
            else:
                return node.p


    
    
    
    def _left_rotate(self, node):
        
        
        
        
        

        
                
        
        
        
        

        
        '''
        Args:
            node (Vertex)
        Raises:
            RuntimeError: node ないし回転中心の node.r が self.nil であったとき
        '''
        if node == self.nil or node.r == self.nil:
            raise RuntimeError('RedBlackTree._left_rotate(): cannot rotate with NIL')
        pivot = node.r
        if node.p != self.nil:
            
            if node.p.l == node:
                node.p.l = pivot
            else:
                node.p.r = pivot
        else:
            
            self.root = pivot
        
        pivot.l.p = node
        
        pivot.p = node.p
        node.r = pivot.l
        pivot.l = node
        node.p = pivot
    
    def _right_rotate(self, node):
        if node == self.nil or node.l == self.nil:
            raise RuntimeError('RedBlackTree._right_rotate(): cannot rotate with NIL')
        pivot = node.l
        if node.p != self.nil:
            
            if node.p.l == node:
                node.p.l = pivot
            else:
                node.p.r = pivot
        else:
            
            self.root = pivot
        
        pivot.r.p = node
        
        pivot.p = node.p
        node.l = pivot.r
        pivot.r = node
        node.p = pivot
    
    def _LR_rotate(self, node):
        
        
        

        
        
        
        
        
        

        
        
        
        
        
        
        self._left_rotate(node.l)
        self._right_rotate(node)
    
    def _RL_rotate(self, node):
        self._right_rotate(node.r)
        self._left_rotate(node)

    
    
    
    
    def _transplant(self, u_node, v_node):
        '''
        u_node の親の子供の位置に v_node 以下の部分木がくるように、v_node 部分木を機械的に移し替える。(O(1))
        (u の親が v の親になるわけではない。u 節点はかつての親や子供を参照し続けることに注意。オブジェクトは生き残るのでよしなに属性を書き換えて使用できる -> delete_node())
        なお、この関数では二分探索木条件が保持されるかどうかなどは考慮しない。        
        '''
        
        if u_node.p == self.nil:
            self.root = v_node
        elif u_node.p.l == u_node:
            u_node.p.l = v_node
        else:
            u_node.p.r = v_node
        
        v_node.p = u_node.p
    

    
    
    
    def insert(self, data):
        '''
        値が data であるようなノードを挿入する (O(lgn))
        z は挿入ノードを、y は適切な挿入位置の親ノードの位置を示すトレーラポインタである
        '''
        if self.find(data) == -1:
            self.size += 1
            x = self.root
            y = self.nil
            while x != self.nil:
                y = x
                x = x.l if data < x.val else x.r
            
            z = Vertex(data, RED, y, self.nil, self.nil)
            
            if y == self.nil:
                self.root = z
            elif data < y.val:
                y.l = z
            else:
                y.r = z
            
            self._insert_fixup(z)
    

    def _insert_fixup(self, z):
        '''
        insert により壊れた二色木条件を適切に復活させる。(O(1))
        最初は 2 4 の二色木条件が満たされていない可能性がある。
        ループ終了時には 4 の二色木条件は必ず満たされる。
        そして根が赤色の二色木を緩和二色木というが、この根を黒く彩色することで他の二色機条件が壊れることはない。ただ 2 が満たされるのみ。

        Args:
            z (Vertex): 挿入節点 (最初は赤色)。
        Raises:
            RuntimeError: なぜか二色木条件がすでに壊れている時
        '''
        while z.p.col == RED:
            parent = z.p
            if parent.p.col == RED:
                raise RuntimeError('RedBlackTree._insert_fixup(): color constraints broken')
            if parent.l == z:
                
                if parent.p.l == parent:
                    self._right_rotate(parent.p)
                
                else:
                    self._RL_rotate(parent.p)
                    z = z.r
            else:
                
                if parent.p.l == parent:
                    self._LR_rotate(parent.p)
                    z = z.l
                
                else:
                    self._left_rotate(parent.p)
            z.col = BLACK
            z = z.p
        self.root.col = BLACK
    

    
    
    
    def delete(self, node):
        '''
        赤黒木内の指定された節点を削除する。(O(lgn))
        node 削除後に node がいた位置におさまる節点 x として、
        original_color_of_x は x のもとの色を、
        y は黒が足りていない木の根を表す。
        (以前 x がいた場所 (両方子供あり) or 以前 node がいた場所 (子供は高々片方のみ))
        '''
        self.size -= 1
        x = node
        original_color_of_x = x.col
        
        if node.l == self.nil:
            y = node.r    
            self._transplant(node, node.r)
        
        elif node.r == self.nil:
            y = node.l    
            self._transplant(node, node.l)
        
        
        else:
            x = self.successor(node)
            original_color_of_x = x.col
            y = x.r    
            if x != node.r:
                self._transplant(x, x.r)
                x.r = node.r
                x.r.p = x
            else:
                y.p = x    
            self._transplant(node, x)
            node.l.p = x
            x.l = node.l
            x.col = node.col
        if original_color_of_x == BLACK:
            self._delete_fixup(y)
    
    def _delete_fixup(self, y):
        '''
        delete により壊れた二色木条件を適切に復活させる。(O(1))
        最初は 2 5 の二色木条件が満たされていない可能性がある。(要素数 3 で根が黒、両方の子供が赤であるような根を削除するようなケースで 2 が破られるよ)
        再帰関数処理後には 5 の二色木条件は必ず満たされる。
        そして根が赤色の二色木を緩和二色木というが、この根を黒く彩色することで他の二色機条件が壊れることはない。ただ 2 が満たされるのみ。

        Args:
            y (Vertex): 黒の足りない部分木の根
        '''
        if y != self.root:
            parent = y.p
            original_color_of_p = parent.col
            
            if parent.l == y:
                
                if parent.r.col == RED:
                    
                    self._left_rotate(parent)
                    parent.col = RED
                    parent.p.col = BLACK
                    self._delete_fixup(y)
                
                elif parent.r.l.col == RED:
                    
                    self._RL_rotate(parent)
                    parent.col = BLACK
                    assert(parent.p.r.col == BLACK)
                    
                    parent.p.col = original_color_of_p
                
                elif parent.r.r.col == RED:
                    
                    self._left_rotate(parent)
                    parent.col = BLACK
                    parent.p.r.col = BLACK
                    parent.p.col = original_color_of_p
                
                else:
                    
                    parent.col = BLACK
                    parent.r.col = RED
                    if original_color_of_p == BLACK:
                        self._delete_fixup(parent)
            
            else:
                
                if parent.l.col == RED:
                    
                    self._right_rotate(parent)
                    parent.col = RED
                    parent.p.col = BLACK
                    self._delete_fixup(y)
                
                elif parent.l.r.col == RED:
                    
                    self._LR_rotate(parent)
                    parent.col = BLACK
                    assert(parent.p.l.col == BLACK)
                    
                    parent.p.col = original_color_of_p
                
                elif parent.l.l.col == RED:
                    
                    self._right_rotate(parent)
                    parent.col = BLACK
                    parent.p.l.col = BLACK
                    parent.p.col = original_color_of_p
                
                else:
                    
                    parent.col = BLACK
                    parent.l.col = RED
                    if original_color_of_p == BLACK:
                        self._delete_fixup(parent)
        self.root.col = BLACK


if __name__ == "__main__":
    rb = RedBlcakTree()
    q = int(input())
    for _ in range(q):
        query, num = map(int, input().split())
        if query == 0:
            rb.insert(num)
            print(rb.size)
        else:
            res = rb.find(num)
            print(0) if res == -1 else print(1)

Solution (Python):









import os
import sys




def main():
    q=int(input())
    a=set()
    for _ in range(q):
        command,x=map(int,input().split())

        if command==0:
            a.add(int(x))
            print(len(a))

        else:
            if int(x) in a:
                print(1)
            else:
                print(0)

        


if __name__ == "__main__":
    main()

Solution (Python):
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))
    else:
        print(int(x in S))

Solution (Python):

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

Solution (Python):
S = set()

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

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

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

Solution (Python):
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))
    else:
        print(1 if int(a[1]) in S else 0)

Solution (Python):
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))
    else:
        if y in s:
            print(1)
        else:
            print(0)

Solution (Python):
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))
        else:
            if b in s:print (1)
            else     :print (0)


if __name__ == '__main__':
    main()

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

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

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

    
    else:
        if x in S:
            print(1)
        else:
            print(0)

Solution (Python):
a = set()
for i in range(int(input())):
    b,c = map(int,input().split())
    if b == 0:
        a.add(c)
        print(len(a))
    else:
        print(int(c in a))

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

Solution (Python):
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")
main()

Solution (Python):
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))
    else:
        if query[1] in S:
            print(1)
        else:
            print(0)

Solution (Python):
import sys

s = set()
input()

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

Solution (Python):
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))
    else:
        x={x}
        if S>=x:
            print(1)
        else:
            print(0)

Solution (Python):
def solve():
    from sys import stdin
    f_i = stdin
    
    q = int(f_i.readline())
    d = {}
    ans = []
    cnt = 0
    for i in range(q):
        op, x = map(int, f_i.readline().split())
        if op == 0:
            if d.setdefault(x, '0') == '0':
                d[x] = '1'
                cnt += 1
            ans.append(str(cnt))
        else:
            ans.append(d.setdefault(x, '0'))
    print('\n'.join(ans))

solve()

Solution (Python):
num = int(input())

s = set()
for _ in range(num):
    c, k = [int(x) for x in input().split()]
    
    if c == 0:
        s.add(k)
        print(len(s))
    elif c ==1:
        if k in s:
            print(1)
        else:
            print(0)
    else:
        pass

Solution (Python):

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)) 
    else:
        if tx in st:
            print(1)
        else:
            print(0)

Solution (Python):
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))
        else:
            if (v in int_set):
                print(1)
            else:
                print(0)

Solution (Python):
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))
	else: print(1 if x in tbl else 0)

Solution (Python):

"""
Set - Set: Search
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_7_A&lang=jp

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

Solution (Python):
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))
		else:
			if y in S:
				print("1")
			else:
				print("0")

Solution (Python):
S = set()

q = int(input())


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

    if   command == "0":
        
        S.add(x)
        print(len(S))
    elif command == "1":
        
        if x in S:
            print(1)
        else:
            print(0)
    else:
        raise

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

Solution (Python):
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))
    else: print(1 if x in t else 0)

Solution (Python):
import bisect

S=[]

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

def find(S,x):
    y=bisect.bisect(S,x)
    if y-1>=0 and S[y-1]==x:
        print(1)
    else:
        print(0)

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])
    else:
        find(S,query[1])

Solution (Python):




import sys
input = sys.stdin.readline
import collections

def main():
    tl = {}
    for i in range(int(input())):
        l = list(map(int,input().split()))
        if l[0] == 0:
            tl[l[1]] = 1
            print (len(tl))
        else:
            c = 1 if l[1] in tl else 0
            print (c)
            
if __name__ == '__main__':
    main()

Solution (Python):
import sys
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
s = set()
for i in range(nq):
    q, x = lines[i].split()
    if q == '0':    
        s.add(x)
        ans[i] = str(len(s))
    else:   
        ans[i] = str(int(x in s))

print('\n'.join(ans))

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

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


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

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

Solution (Python):
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))
    else:
        print(1 if x in S else 0)

Solution (Python):
s=set()
for i in range(int(input())):
    a,b=map(int,input().split(" "))
    if a:
        print(1*(b in s))
    else:
        s.add(b)
        print(len(s))

Solution (Python):
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))
  else:
    if q[1] in s:
      print(1)
    else:
      print(0)