codeparrot/codecomplex huggingface dataset:
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskA {

    class Team implements Comparable<Team> {
        int solved = 0;
        int penalty = 0;

        Team(int solved, int penalty) {
            this.solved = solved;
            this.penalty = penalty;
        }

        public int compareTo(Team o) {
            return this.solved == o.solved ? this.penalty - o.penalty : -(this.solved - o.solved);
        }

        public boolean equals(Object obj) {
            if (obj instanceof Team) {
                Team o = (Team) obj;
                return ((this.solved == o.solved) && (this.penalty == o.penalty));
            }
            return false;
        }
    }

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        Team[] teams = new Team[n];
        for (int i = 0; i < n; i++)
            teams[i] = new Team(in.nextInt(), in.nextInt());
        Arrays.sort(teams);

        int[] top = new int[n];
        int[] map = new int[n];
        int cur = -1;
        for (int i = 0; i < n; i++) {
            if (i == 0 || !teams[i].equals(teams[i - 1])) cur = i;
            top[cur]++;
            map[i] = cur;
        }
        out.println(top[map[k - 1]]);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            writer.print(objects[i]);
        }
    }

    public void println(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        int x[] = new int[n];
        for (int i = 0; i < n; i++) {
            int p = in.nextInt(), t = in.nextInt();
            x[i] = (50 - p) * 100 + t;
        }
        Arrays.sort(x);
        int cnt = 0;
        for (int q: x)
            if (q == x[k - 1]) cnt++;
        System.out.println(cnt);
    }

}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution {
    static class Team implements Comparable<Team> {
        int pr;
        int time;
        int id;

        public Team(int P, int T, int I) {
            pr = P;
            time = T;
            id = I;
        }

        @Override
        public int compareTo(Team t) {
            return pr != t.pr ? t.pr - pr : time != t.time ? time - t.time : id - t.id;
        }

    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer st = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(st.nextToken());

        int k = Integer.parseInt(st.nextToken());

        Team[] a = new Team[n];
        int[] c = new int[n + 1];

        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(in.readLine());
            int p = Integer.parseInt(st.nextToken());
            int t = Integer.parseInt(st.nextToken());

            a[i] = new Team(p, t, i);
        }

        Arrays.sort(a);
        int prev = 1;
        c[1]++;

        for (int i = 1; i < n; i++) {
            if (a[i].pr == a[i - 1].pr && a[i].time == a[i - 1].time)
                for (int j = i + 1; j >= prev; j--)
                    c[j] = i + 2 - prev;
            else {
                prev = i + 1;
                c[prev] = 1;
            }
        }

        out.println(c[k]);
        out.close();
    }
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;

public class Teams {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;
    Random rnd;
    
    class Pair implements Comparable<Pair> {
        int a, b;

        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        
        public int compareTo(Pair p) {
            if(a != p.a) {
                return -(a - p.a);
            }
            
            return (b - p.b);
        }
    }

    void solve() throws IOException {
        int n = nextInt(), k = nextInt();
        
        Pair[] ps = new Pair[n];
        
        for(int i = 0; i < n; i++)
            ps[i] = new Pair(nextInt(), nextInt());
        
        Arrays.sort(ps);
        
        int curPlace = 1, res = 0;
        
        int[] places = new int[n];
        
        for(int i = 0; i < n; i++) {
            if(i - 1 >= 0 && ps[i].compareTo(ps[i - 1]) != 0)
                ++curPlace;
            
            places[i] = curPlace;
        }
        
        for(int i = 0; i < n; i++) {
            if(places[i] == places[k - 1])
                ++res;
        }
        
        out.println(res);
    }

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

    public void run() {
        try {
            final String className = this.getClass().getName().toLowerCase();

            try {
                in = new BufferedReader(new FileReader(className + ".in"));
                out = new PrintWriter(new FileWriter(className + ".out"));
            } catch (FileNotFoundException e) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            }

            rnd = new Random();

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(42);
        }
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = in.readLine();

            if (line == null)
                return null;

            st = new StringTokenizer(line);
        }

        return st.nextToken();
    }

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

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

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import sun.reflect.generics.tree.Tree;

import java.io.*;
import java.util.*;

public class A2 {
	static Scanner in; static int next() throws Exception {return in.nextInt();};
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;
	static PrintWriter out;

	public static void main(String[] args) throws Exception {
		in = new Scanner(System.in);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

        int n = next(), k = next()-1;
        int x[] = new int[n];
        for (int i = 0;i < n;i++) x[i] = (100-next())*100+next();
        Arrays.sort(x);
        int res = 0, t = x[k];
        for (int i = 0;i < n;i++) if (t == x[i]) res++;

        out.println(res);


        out.println();
		out.close();
	}
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class A113 {

    public static void main(String[] args) {
        new A113().run();
    }
    
    public void run() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        Team[] teams = new Team[n];
        for (int i = 0; i < teams.length; i++) {
            teams[i] = new Team(in.nextInt(), in.nextInt());
        }
        Arrays.sort(teams);
        int counter = 1;
        int index = k-2;
        while (index >= 0 && teams[index].p == teams[k-1].p && teams[index].t == teams[k-1].t) {
            index--;
            counter++;
        }
        index = k;
        while (index < n && teams[index].p == teams[k-1].p && teams[index].t == teams[k-1].t) {
            index++;
            counter++;
        }
        System.out.println(counter);
    }
    
    private class Team implements Comparable<Team> {
        int p;
        int t;
        
        public Team(int pp, int tt) {
            p = pp; t = tt;
        }

        @Override
        public int compareTo(Team o) {
            if (o.p - this.p == 0)
                return this.t - o.t;
            return o.p - this.p;
        }
    }
}
// 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 codeKNIGHT
 */
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(),k=in.nextInt()-1,i;
        scores a[]=new scores[n];
        for(i=0;i<n;i++)
            a[i]=new scores(in.nextInt(),in.nextInt());
        Arrays.sort(a);
        
        int c=1;
        for(i=k-1;i>=0;i--)
        {
            if(a[i].p==a[k].p&&a[i].t==a[k].t)
                c++;
            else break;
        }
        for(i=k+1;i<n;i++)
        {
            if(a[i].p==a[k].p&&a[i].t==a[k].t)
                c++;
            else break;
        }
        out.println(c);

	}
    class scores implements Comparable<scores>
    {
        int p,t;
        public scores(int p,int t)
        {
            this.p=p;
            this.t=t;
        }
        public int compareTo(scores a)
        {
            if(a.p>this.p)
                return 1;
            if(a.p==this.p&&a.t<this.t)
                return 1;
            return -1;
        }
    }
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.Scanner;
import java.util.Arrays;

public class P166A 
{
	public static void main(String[] args) 
	{
		Scanner myScanner = new Scanner(System.in);
		int n = myScanner.nextInt();
		int k = myScanner.nextInt();
		Team[] queue = new Team[n];
		for (int i = 0; i < n; i++)
		{
			queue[i] = new Team(myScanner.nextInt(), myScanner.nextInt());
		}
		Arrays.sort(queue);
		
		int counter = 0;
		int i = 0;
		int p = -1;
		int t = -1;
		for (; i < k; i++)
		{
			if (p == queue[i].problems && t == queue[i].penalty)
				counter++;
			else
			{
				p = queue[i].problems;
				t = queue[i].penalty;
				counter = 1;
			}
		}
		for (; i < n; i++)
		{
			if (p == queue[i].problems && t == queue[i].penalty)
				counter++;
			else
				break;
		}
		System.out.println(counter);
	}

	static class Team implements Comparable<Team>
	{
		int problems;
		int penalty;
		
		public Team(int problems, int penalty)
		{
			this.problems = problems;
			this.penalty = penalty;
		}
		
		public int compareTo(Team t)
		{
			if (problems > t.problems) return -1;
			else if (problems < t.problems) return 1;
			else if (penalty > t.penalty) return 1;
			else if (penalty < t.penalty) return -1;
			else return 0;
		}
	}
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class A {

    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        Point[] p = new Point[n];
        for (int i = 0; i < n; i++)
            p[i] = new Point(nextInt(), nextInt());
        Arrays.sort(p, new Comparator<Point>() {

            @Override
            public int compare(Point o1, Point o2) {
                if (o1.x == o2.x) return o1.y - o2.y;
                return o2.x - o1.x;
            }
        });
        
        Point cur = p[k - 1];
        int res = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i].x == cur.x && p[i].y == cur.y) res++;
        }
        pl(res);
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            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());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

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

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;


public class A {
	
	
	static class team implements Comparable<team>
	{
		int problems;
		int penalty;
		public team(int problems,int penalty)
		{
			this.penalty=penalty;
			this.problems=problems;
		}
		public int compareTo(team a) {
			if (a.problems==this.problems)
				return this.penalty - a.penalty;
			return a.problems - this.problems;
		}
		
		public boolean igual(team a)
		{
			if (this.problems!=a.problems)
				return false;
			return (this.penalty==a.penalty);
		}
	}
	
	static class Scanner
	{
		BufferedReader rd;
		StringTokenizer tk;
		public Scanner() throws IOException
		{
			rd=new BufferedReader(new InputStreamReader(System.in));
			tk=new StringTokenizer(rd.readLine());
		}
		public String next() throws IOException
		{
			if (!tk.hasMoreTokens())
			{
				tk=new StringTokenizer(rd.readLine());
				return tk.nextToken();
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException
		{
			return Integer.valueOf(this.next());
		}
	}
	
	
	static team[] array=new team[100];
	static int N,K;
	
	public static void main(String args[]) throws IOException
	{
		Scanner sc=new Scanner();
		N=sc.nextInt();
		K=sc.nextInt();
		for(int i=0;i<N;i++)
		{
			array[i]=new team(sc.nextInt(),sc.nextInt());
		}
		Arrays.sort(array,0,N);
		/*
		for(int i=0;i<N;i++)
			System.out.println(array[i].problems);*/
		
		int shared=0;
		for(int i=K-1;i>=0 && array[K-1].igual(array[i]);i--,shared++);
		for(int i=K;i<N && array[K-1].igual(array[i]);i++,shared++);
		System.out.println(shared);
	}

}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class Solution {
	
	class Q implements Comparable<Q> {
		int p, t;
		Q(int q, int w) {
			p = q; t = w;
		}
		@Override
		public int compareTo(Q arg0) {
			if (p == arg0.p) return t - arg0.t; 
			return arg0.p - p;
		}
	}
	
	void solve() throws Exception {
		int n = nextInt();
		int k = nextInt() - 1;
		Q[] a = new Q[n];
		for (int i = 0; i < n; i++) a[i] = new Q(nextInt(), nextInt());
		Arrays.sort(a);
		int ans = 1;
		for (int i = k - 1; i >= 0; i--) if (a[i].compareTo(a[k]) == 0) ans++; else break;
		for (int i = k + 1; i < n; i++) if (a[i].compareTo(a[k]) == 0) ans++; else break;
		out.println(ans);
	}

	public static void main(String[] args) {
		new Solution().run();
	}
	
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null) return null;
			st = new StringTokenizer(s);
		}
		return st.nextToken();
	}
	
	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

	class Team implements Comparable<Team>{
		int p, t;
		public Team(int p, int t) {
			this.p = p;
			this.t = t;
		}
		public int compareTo(Team other) {
			if (this.p != other.p) return other.p - this.p;
			return this.t - other.t;
		}
	}
	
	public void solve() throws IOException {
		int n = nextInt();
		int K = nextInt() - 1;
		Team[] team = new Team[n];
		for (int i = 0; i < n; i++) 
			team[i] = new Team(nextInt(), nextInt());
		
		Arrays.sort(team);
		int ans = -1;
		int pre = 0;
		for (int i = 1; i < n; i++)
			if (team[i].compareTo(team[i - 1]) != 0) {
				if (K >= pre && K < i) {
					ans = i - pre;
					break;
				}
				pre = i;
			}
		if (ans == -1) ans = n - pre;
		writer.println(ans);
	}

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

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("test.inp")));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			//writer = new PrintWriter(new FileOutputStream("test.out"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms");
			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();
	}

}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.*;
import java.io.*;

public class cf166a {
	private static boolean[][] matrix;
	private static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// long l = sc.nextLong();
		// int i = sc.nextInt();
		// String input = sc.nextLine();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		int[] t = new int[n];
		int[] score = new int[n];
		for(int i=0;i<n;i++){
			p[i] = sc.nextInt();
			t[i] = sc.nextInt();
			score[i] = p[i] * 100 + (50 - t[i]);
		}
		boolean[] called = new boolean[n];
		int x = 0;
		boolean check = false;
		while(true){
			int max = 0;
			int y = 0;
			for(int i=0;i<n;i++){
				if(called[i]==false&&score[i]>max){max=score[i];}
			}
			for(int i=0;i<n;i++){
				if(max==score[i]){
					called[i] = true;
					x++;
					y++;
					if(x==k){check=true;}
				}
			}
			if(check){
				System.out.println(y);
				break;
			}
		}
	}
}
// Problem: 166_A. Rank List
// Time complexity: nlogn
import java.util.*;
import java.math.*;

public class Main {
    
    
    public static void main(String[] args) throws Exception{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt() - 1;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            int p = scan.nextInt();
            int t = scan.nextInt();
            arr[i] = -p * 10000 + t;
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] == arr[k]) {
                count++;
            }
        }
        System.out.println(count);
    }
}