Problem:
Score : 300 points

Problem Statement

There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.

Constraints

1≤N≤10^5

1≤a_i,b_i≤10^5

1≤K≤b_1…+…b_n

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K
a_1 b_1
:
a_N b_N

Output

Print the K-th smallest integer in the array after the N operations.

Sample Input 1

3 4
1 1
2 2
3 3

Sample Output 1

3

The resulting array is the same as the one in the problem statement.

Sample Input 2

10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Sample Output 2

1

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Numerics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    public void calc()
    {
        int n = cin.nextInt(), k = cin.nextInt();
        //var sw = new System.Diagnostics.Stopwatch(); sw.Start();//入力の待ち時間も計測してしまうのを避けるためこのタイミング

        int[][] ab = new int[n][];
        
        for (int i = 0; i < n; i++)
        {
            ab[i] = new int[2];
            ab[i][0] = cin.nextInt();
            ab[i][1] = cin.nextInt();
        }
        tekitoucomparer2 cp = new tekitoucomparer2();
        Array.Sort(ab, cp);

        
        //for (int i = 0; i < n; i++)
        //{
        //    ShowL($"a:{ab[i][0]} b:{ab[i][1]}  sorted");

        //}
        //sw.Stop();
        //ShowL($"time: {sw.ElapsedMilliseconds } msec");

        BigInteger count = 0;
        int index = 0;
        while(count < k)
        {
            count += ab[index++][1];
        }
        ShowL(ab[--index][0]);
        Console.Read();
    }

    class tekitoucomparer2 : IComparer<int[]>
    {
        //public int Compare(object x, object y)
        //{
        //    int[] a = (int[])x;
        //    int[] b = (int[])y;
        //    return a[0] - a[1];
        //}
        public int Compare(int[] x, int[] y)
        {
            return x[0] - y[0];
        }
    }
    


    void ShowL(string s)
    {
        Console.WriteLine(s);
    }
    void ShowL(int i) { Console.WriteLine($"{i}"); }
    
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}