codeparrot/codecomplex huggingface dataset:
// Problem: 166_A. Rank List
// Time complexity: nlogn
//package round113;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni(), k = ni();
		int[][] d = new int[n][2];
		for(int i = 0;i < n;i++){
			d[i][0] = ni();
			d[i][1] = ni();
		}
		
		Arrays.sort(d, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				if(a[0] - b[0] != 0)return -(a[0] - b[0]);
				return a[1] - b[1];
			}
		});
		
		int b;
		for(b = k-1;b >= 0 && d[k-1][0] == d[b][0] && d[k-1][1] == d[b][1];b--);
		b++;
		int a;
		for(a = k-1;a < n && d[k-1][0] == d[a][0] && d[k-1][1] == d[a][1];a++);
		a--;
		out.println(a-b+1);
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new A().run();
	}
	
	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}
	
	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}
	
	
	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author hheng
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int k = in.nextInt();
        Team[] t = new Team[N];
        for (int i=0; i<N; i++) t[i] = new Team(in.nextInt(), in.nextInt());
        Arrays.sort(t);
        int p_k = t[k-1].p, t_k = t[k-1].t;
        int count = 0;
        for (int i=0; i<N; i++) if (t[i].p==p_k && t[i].t ==t_k) count++;
        out.println(count);
	}
}

class Team implements Comparable<Team>{
    int p, t;
    Team(int a, int b) { p=a; t=b;}
    public int compareTo(Team g) {
        if (p < g.p) return 1;
        if (p > g.p) return -1;
        if (t < g.t) return -1;
        if (t > g.t) return 1;
        return 0;
    }
    
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        solver.solve();
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public class result implements Comparable{
        public int t = 0;
        public int p = 0;
        
        public result(int p,int t){
            this.t = t;
            this.p = p;
        }

        @Override
        public int compareTo(Object o) {
            result r = (result)o;
            int out = r.p-p;
            if (out==0) out = t-r.t;
            return out;
        }
        
        
    }
    
    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();
        int k = nextInt();
        
        result[] table = new result[n];
        
        for (int i=0;i<n;i++){
            int p = nextInt();
            int t = nextInt();
            
            table[i] = new result(p,t);
        }
        
        Arrays.sort(table);
        
        int result = 1;
        k--;
        
        for (int i=k-1;i>=0 && table[i].p==table[k].p && table[i].t==table[k].t;i--){
            result++;
        }
        for (int i=k+1;i<n && table[i].p==table[k].p && table[i].t==table[k].t;i++){
            result++;
        }
        out.println(result);
    }

    public void close() {
        out.flush();
        out.close();
    }

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class A{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> v = new TreeSet<Integer>();
        for(int i=0;i<n;i++) v.add(sc.nextInt());
        Iterator<Integer> it = v.iterator();
        it.next();
        it.remove();
        System.out.println(v.isEmpty() ? "NO" : v.iterator().next());
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.Scanner;

public class Seq2 {

    static void metod() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        int min = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] < min)
                min = a[i];
        }
        
        int min2 = min;
        boolean t = false;
        for (int i = 0; i < a.length; i++) {
            if (a[i] != min) {
                if (!t) {
                    min2 = a[i];
                    t = true;
                } else {
                    if (min2 > a[i])
                        min2 = a[i];
                }
            }
        }

        System.out.println((min == min2) ? "NO" : min2);        
    }

    public static void main(String[] args) {
        Seq2.metod();
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    private static Parser in;
    private static PrintWriter out;
    
    public static void main(String[] args) {
        in = new Parser(System.in);
        out = new PrintWriter(System.out);
        
        int n= in.nextInt();
        int min = 101;
        boolean b = false;
        int pmin = 101;
        int t= 0 ;
        for(int i=0; i<n; i++){
            t = in.nextInt();
            
            if (t<min){if(min != pmin)b=true; if(b) pmin = min;  min = t;  continue;}
            if (t>min && t<pmin){b=true; pmin = t;  continue;}
            if (t>min && !b){b=true; pmin = t;  continue;}
            //if (b){if(t<pmin){pmin = t; continue;}}
            //out.print(min);
            //out.print(pmin);
        }
        if (b) System.out.println(pmin); else System.out.println("NO");
        //out.flush();
    }
}


class Parser {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;
 
    public Parser(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
    }
    public String nextString(int size) { 
        byte[] ch = new byte[size];
        int point = 0;
        try {
            byte c = read();
            while (c == ' ' || c == '\n' || c=='\r')
                c = read();
            while (c != ' ' && c != '\n' && c!='\r') {
                ch[point++] = c;
                c = read();
            }
        } catch (Exception e) {}
        return new String(ch,0,point);
        }
    public int nextInt() { 
    int ret = 0;
    boolean neg;
    try {
        byte c = read();
        while (c <= ' ')
            c = read();
        neg = c == '-';
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
            c = read();
        } while (c > ' ');
    
    if (neg) return -ret;
    } catch (Exception e) {}
    return ret;
    }
    public long nextLong() { 
        long ret = 0;
        boolean neg;
        try {
            byte c = read();
            while (c <= ' ')
                c = read();
            neg = c == '-';
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');
        
        if (neg) return -ret;
        } catch (Exception e) {}
        return ret;
        }
    private void fillBuffer() {
        try {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        } catch (Exception e) {}
        if (bytesRead == -1) buffer[0] = -1;
    }
 
    private byte read() {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class A
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        
        int[] a = new int[n];
        
        for(int i=0;i < n;i++)
            a[i] = scan.nextInt();
            
        Arrays.sort(a);
        
        int min = a[0];
        
        for(int i=1;i < n;i++)
        {
            if(a[i] > min)
            {
                System.out.println(a[i]);
                return;
            }
        }
        
        System.out.println("NO");
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class A {
    public static void main(String[] args) throws IOException {
        new A().run();
    }

    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    private void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n = nextInt();
        Set<Integer> set = new TreeSet<Integer>();

        for (int i = 0; i < n; i++) {
            set.add(nextInt());
        }
        set.remove(set.iterator().next());
        PrintWriter pw = new PrintWriter(System.out);
        if (set.isEmpty()) {
            pw.println("NO");
        } else {
            pw.println(set.iterator().next());
        }
        pw.close();
    }

    int nextInt() throws IOException {
        while (!st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.io.*;
public class Main{

        BufferedReader in;
        StringTokenizer str = null;
        PrintWriter out;

        private String next() throws Exception{
                if (str == null || !str.hasMoreTokens())
                        str = new StringTokenizer(in.readLine());
                return str.nextToken();
        }
        
        private int nextInt() throws Exception{
                return Integer.parseInt(next());
        }
        
        private long nextLong() throws Exception{
                return Long.parseLong(next());
        }
        
        private double nextDouble() throws Exception{
                return Double.parseDouble(next());
        }

        public void run() throws Exception{
                in = new BufferedReader(new InputStreamReader(System.in));//new FileReader();
                out = new PrintWriter(System.out);//new File();
                int n = nextInt();
                HashSet<Integer> hs = new HashSet<Integer>();
                for(int i=0;i<n;i++) hs.add(nextInt());
                if (hs.size() == 1){
                  out.println("NO");
                  out.close();
                  return;
                }
                int a[] = new int[hs.size()];
                int yk = 0;
                for(int i:hs) a[yk++] = i;
                Arrays.sort(a);
                out.println(a[1]);
                out.close();
        }

        public static void main(String args[]) throws Exception{
                new Main().run();
        }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*; 
 
public class Main{ 
        public static void main(String[] args){ 
                Scanner sc = new Scanner(System.in); 
                int n = sc.nextInt(); 
                TreeSet<Integer> set = new TreeSet<Integer>(); 
 
                for(int i=0;i<n;i++){ 
                        set.add(sc.nextInt()); 
                } 
 
                if(set.size() >= 2) 
                        System.out.println(set.toArray()[1]); 
                else 
                        System.out.println("NO"); 
        } 
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class VtoraiaStat implements Runnable {

    boolean isLocalMode = false;


    private void doJob() throws Exception {
       int n  = nextInt();
        int[] r = new int[n];
        for(int i =0;i<n;i++){
            r[i]=nextInt();
        }

        Arrays.sort(r);
        int m = r[0];
        for(int i=0;i<n;i++){
            if(r[i]!=m){
                writer.write(""+r[i]);
                return;
            }
        }
        writer.write("NO");
    }


    public static void main(String[] args) {
        new VtoraiaStat().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(getReader());
            tokenizer = null;
            writer = new PrintWriter(System.out);
            //do job
            doJob();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }


    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public Reader getReader() throws FileNotFoundException {
        if (isLocalMode) {
            return new FileReader("input.txt");
        } else {
            return new InputStreamReader(System.in);
        }
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int iTotTerm, i, j, iSml = 0, iPos = 0;
        iTotTerm = Integer.parseInt(br.readLine());
        String seq[];
        seq = br.readLine().split(" ");
        int iSeq[] = new int[iTotTerm];
        for (i = 0; i < iTotTerm; i++) {
            iSeq[i] = Integer.parseInt(seq[i]);
        }
        for (i = 0; i < iTotTerm; i++) {
            iSml = iSeq[i];
            iPos = i;
            for (j = i; j < iTotTerm; j++) {
                if (iSeq[j] < iSml) {
                    iSml = iSeq[j];
                    iPos = j;
                }
            }
            iSeq[iPos] = iSeq[i];
            iSeq[i] = iSml;
            if (i != 0 && iSeq[i - 1] != iSeq[i]) {
                break;
            }
        }
        if (iSml != iSeq[0]) {
            System.out.print(iSml);
        } else {
            System.out.print("NO");
        }
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String []args){
		Scanner cin = new Scanner( System.in );
		int n  = cin.nextInt();
		int [] num = new int [ n ];
		
		for (int i=0; i<n; i++)
			num[i] = cin.nextInt();
		
		Arrays.sort( num );
		
		int i = 0;
		while ( i < n ){
			if ( num[i] != num[0] ) break;
			i++;
		}
		
		if ( i == n ) System.out.println("NO");
		else System.out.println(num[i]);
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.lang.*;
import java.io.*;

public class Blah
{
    public static void main(String args[])
    {
	Scanner c = new Scanner(System.in);
	String number = c.nextLine();
	int i = Integer.parseInt(number);
	if (i == 1)
	    {
		System.out.println("NO");
		return;
	    }
	String line = c.nextLine();
	String[] arr = line.split(" ");
	int[] array = new int[i];
	for (int j = 0; j < i; j++)
	    {
		array[j] = Integer.parseInt(arr[j]);
	    }
        int min = array[0];
	int second = 0;
	boolean thing = false;
	for (int j = 0; j < i; j++)
	    {
		if (!thing && array[j] > min)
		    {
			second = array[j];
			thing = true;
		    }
		if (array[j] < min)
		    {
			second = min;
			min = array[j];
			thing = true;
		    }
		else if (thing && array[j] > min && array[j] < second)
		    second = array[j];
	    }
	if (!thing)
	    System.out.println("NO");
	else
	    System.out.println(second);
	return;	     
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.Scanner;


public class prob1 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		if(n == 1)
		{
//			throw new RuntimeException();
			int m = input.nextInt();
			System.out.println("NO");
//			System.out.println(input.next());
			return;
		}
		int[] num = new int[n];
		boolean flag  = false;
		for(int i = 0; i < n; i++)
		{
			num[i] = input.nextInt();
			if(num[i] != num[0])
				flag = true;
		}
		if(!flag)
		{
			System.out.println("NO");
			return;
		}
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++)
			if(num[i] < min)
				min = num[i];
		int min2 = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++)
			if(num[i] <= min2 && num[i] > min)
				min2 = num[i];
		System.out.println(min2);
		
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
//package codeforces.br22;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * User: Kandy
 * Date: 29.06.2010
 * Time: 21:07:24
 */
public class ProblemA {
    public void solve() {
        boolean oj = true;

        try {
            Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("A.in");
            Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("A.out");
            BufferedReader br = new BufferedReader(reader);
            StreamTokenizer st = new StreamTokenizer(reader);
            PrintWriter out = new PrintWriter(writer);

            MyTokenizer tok = new MyTokenizer(br.readLine());
            int n = (int)tok.getNum();
            tok =new MyTokenizer(br.readLine());
            List<Integer> a = new ArrayList<Integer>();
            for(int i=0;i<n;i++) {
                int r = (int)tok.getNum();
                if (!a.contains(r)) {
                    a.add(r);
                }
            }
            Collections.sort(a);
            if (a.size() < 2) {
                out.printf("NO");
            } else {
                out.printf("%d", a.get(1));
            }

            br.close();
            out.close();
            reader.close();
            writer.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
        finally {
        }
    }


    public static void main(String[] args) {
        ProblemA f = new ProblemA();
        f.solve();
    }

    private class MyTokenizer {
        private String s;
        private int cur;

        public MyTokenizer(String s) {
            this.s = s;
            cur = 0;
        }

        public void skip() {
            while (cur < s.length() && (s.charAt(cur) == ' ' || s.charAt(cur) == '\n')) {
                cur++;
            }
        }

        public double getNum() {
            skip();
            String snum = "";
            while (cur < s.length() && (s.charAt(cur) >= '0' && s.charAt(cur) <= '9' || s.charAt(cur) == '.' || s.charAt(cur) == '-')) {
                snum += s.charAt(cur);
                cur++;
            }
            return Double.valueOf(snum);
        }

        public String getString() {
            skip();
            String s2 = "";
            while (cur < s.length() && (((s.charAt(cur) >= 'a' && s.charAt(cur) <= 'z')) || ((s.charAt(cur) >= 'A' && s.charAt(cur) <= 'Z')))) {
                s2 += s.charAt(cur);
                cur++;
            }
            return s2;
        }

        public char getCurrentChar() throws Exception {
            if (cur < s.length())
                return s.charAt(cur);
            else
                throw new Exception("Current character out of string length");
        }

        public void moveNextChar() {
            if (cur < s.length())
                cur++;
        }

        public boolean isFinished() {
            return cur >= s.length();
        }
    }
}