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 in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var set = new Set<int>();
        var q = Input.num;
        var res = new List<int>();
        while (q-- > 0)
        {
            var qx = Input.ar;
            if (qx[0] == 0)
            { set.Insert(qx[1]); res.Add(set.Count); }
            else res.Add(ToInt32(set.Contains(qx[1])));
        }
        if(res.Count!=0)
            WriteLine(string.Join("\n", res));
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}public class Set<T> where T:IComparable<T>
{
    class Node
    {
        public T Key { get; set; }
        public Node parent;
        public Node left;
        public Node right;
        public bool isRed;
        public Node(T Key = default(T),Node parent=null, Node left = null, Node right = null, bool isRed = false)
        {
            this.Key = Key;
            this.parent = parent;
            this.left = left;
            this.right = right;
            this.isRed = isRed;
        }
    }
    public int Count { get; private set; }
    public bool IsMulti { get; }
    private Node root;
    private Node NIL;
    public Set(bool isMulti=false)
    {
        IsMulti = isMulti;
        NIL = new Node();
        NIL.parent = NIL;
        NIL.left = NIL;
        NIL.right = NIL;
        root = NIL;
    }
    
    private void LeftRotate(Node x)
    {
        var y = x.right;
        x.right = y.left;
        if (!ReferenceEquals(y.left, NIL))
            y.left.parent = x;
        y.parent = x.parent;
        if (ReferenceEquals(x.parent, NIL))
            root = y;
        else if (ReferenceEquals(x.parent.left, x))
            x.parent.left = y;
        else x.parent.right = y;
        y.left = x;
        x.parent = y;
    }

    private void RightRotate(Node x)
    {
        var y = x.left;
        x.left = y.right;
        if (!ReferenceEquals(y.right, NIL))
            y.right.parent = x;
        y.parent = x.parent;
        if (ReferenceEquals(x.parent, NIL))
            root = y;
        else if (ReferenceEquals(x.parent.left, x))
            x.parent.left = y;
        else x.parent.right = y;
        y.right = x;
        x.parent = y;
    }

    public void Insert(T value)
        => Insert(new Node(value, NIL, NIL, NIL,true));
    private void Insert(Node val)
    {
        var y = NIL;
        var x = root;
        while (!ReferenceEquals(x, NIL))
        {
            y = x;
            if (!IsMulti&&val.Key.CompareTo(x.Key) == 0) return;
            else if (val.Key.CompareTo(x.Key) == -1)
                x = x.left;
            else x = x.right;
        }
        Count++;
        val.parent = y;
        if (ReferenceEquals(y, NIL))
            root = val;
        else if (val.Key.CompareTo(y.Key) == -1)
            y.left = val;
        else y.right = val;

        while (val.parent.isRed)
            if (ReferenceEquals(val.parent.parent.left, val.parent))
            {
                var py = val.parent.parent.right;
                if (py.isRed)
                {
                    val.parent.isRed = false;
                    py.isRed = false;
                    val.parent.parent.isRed = true;
                    val = val.parent.parent;continue;
                }
                else if (ReferenceEquals(val, val.parent.right))
                {
                    val = val.parent;
                    LeftRotate(val);
                }
                    val.parent.isRed = false;
                        val.parent.parent.isRed = true;
                    RightRotate(val.parent.parent);
                
            }
            else
            {
                var py = val.parent.parent.left;
                if (py.isRed)
                {
                    val.parent.isRed = false;
                    py.isRed = false;
                    val.parent.parent.isRed = true;
                    val = val.parent.parent;continue;
                }
                else if (ReferenceEquals(val, val.parent.left))
                {
                    val = val.parent;
                    RightRotate(val);
                }
                    val.parent.isRed = false;
                        val.parent.parent.isRed = true;
                    LeftRotate(val.parent.parent);
                
            }
        root.isRed = false;
    }

    public bool Contains(T value)
    {
        var x = root;
        while (!ReferenceEquals(x, NIL))
            if (value.CompareTo(x.Key) == 0) return true;
            else if (value.CompareTo(x.Key) == 1) x = x.right;
            else x = x.left;
        return false;
    }
}