codeparrot/codecomplex huggingface dataset:
// Problem: 169_A. Chores
// 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(),a=in.nextInt(),b=in.nextInt(),i,c=0;
        int ar[]=new int[n];
        for(i=0;i<n;i++)
            ar[i]=in.nextInt();
        Arrays.sort(ar);
        out.println(ar[b]-ar[b-1]);
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.security.SecureRandom;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
    
    
    
    
    public void solve() throws Exception {
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long h[] = new long[n];
        
        for (int i = 0;i < n; ++ i) {
            h[i] = sc.nextLong();
        }
        Arrays.sort(h);
        long l = h[n - a];
        long r = h[n - a - 1];
        out.println(l - r);
    }
    
    
    
    
    /*--------------------------------------------------------------*/
    
    static String filename = "";
    static boolean fromFile = false;
    
    BufferedReader in;
    PrintWriter out;
    FastScanner sc;
    
    public static void main(String[] args) {
        new Thread(null, new Solution(), "", 1 << 25).start();
    }
   
    public void run() {
        try {
            init();
            solve();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }
    
    void init() throws Exception {
        if (fromFile) {
            in = new BufferedReader(new FileReader(filename+".in"));
            out = new PrintWriter(new FileWriter(filename+".out"));
        } else {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        sc = new FastScanner(in);
    }
}

class FastScanner {
    
    BufferedReader reader;
    StringTokenizer strTok;
    
    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }
    
    public String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            strTok = new StringTokenizer(reader.readLine());
        }
        
        return strTok.nextToken();
    }
    
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    
    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }
    
    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(nextToken());
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class test {

    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int n = kb.nextInt();
        int a = kb.nextInt();
        int b = kb.nextInt();
        int array[] = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = kb.nextInt();
        }
        Arrays.sort(array);
        int k = 0;
        int t1 = 0;
        int t2 = 0;
        for (int i = 0; i < b; i++) {
            t1= array[i];
            if(i<n-1){
                t2=array[i+1];
                k=t2-t1;
            }
            else k=0;
        }
        System.out.println(k);

    }
}
// Problem: 169_A. Chores
// 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 @zhendeaini6001
 */
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 a = in.nextInt();
        int b = in.nextInt();
        int[] input = IOUtils.readIntArray(in, n);
        Arrays.sort(input);
        int x = input[b-1];
        int y = input[b];
        out.println(y - x);
    }
}

class IOUtils {

    public static int[] readIntArray(Scanner in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.nextInt();
        return array;
    }

    }
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class VkR2A{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));

        int nm[] = toIntArray();
        int n = nm[0];
        int a = nm[1];
        int b = nm[2];
        nm=toIntArray();
        Arrays.sort(nm);
        int k=nm[b-1];
        int res=nm[b]-k;
        System.out.println(res);

    }


    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args)throws Exception {
        File _=new File("chores.in");
        BufferedReader br=_.exists()? new BufferedReader(new FileReader(_)):new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        String str;
        
        st=new StringTokenizer(br.readLine());
        int n,a,b;
        n=Integer.parseInt(st.nextToken());
        a=Integer.parseInt(st.nextToken());
        b=Integer.parseInt(st.nextToken());
        
        ArrayList<Integer> chores=new ArrayList<Integer>();
        int k;
        st=new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) {
            k=Integer.parseInt(st.nextToken());
            chores.add(k);
        }
        Collections.sort(chores);
        
        System.out.println(chores.get(b)-chores.get(b-1));
        
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class problemA {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] hs = new int[n];
        for(int i = 0; i < n; i++){
            hs[i] = sc.nextInt();
        }
        Arrays.sort(hs);
        System.out.println(hs[b]-hs[b-1]);
    }
}
// Problem: 169_A. Chores
// 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(), a = next(), b = next();
        int h[] = new int[n];

        for (int i = 0;i < n;i++) h[i] = next();

        Arrays.sort(h);

        int res = h[b] - h[b-1];

        out.println(res);

        out.println();
		out.close();
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ProblemA {

    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] data = s.readLine().split(" ");
        int n =  Integer.valueOf(data[0]);
        int a =  Integer.valueOf(data[1]);
        int b =  Integer.valueOf(data[2]);

        long[] h = new long[n];
        String[] line = s.readLine().split(" ");
        for (int i = 0 ; i < n ; i++) {
            h[i] = Integer.valueOf(line[i]);
        }
        Arrays.sort(h);
        
        System.out.println(h[b] - h[b-1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class Train_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int [] h = new int[n]; 
        for (int i = 0; i < n; i++) {
            h[i]  = sc.nextInt(); 
        }
        Arrays.sort(h);
        System.out.println(h[n-a] - h[b-1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
   private static IO io;

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

   private void run() throws IOException {
       io = new IO(System.getProperty("ONLINE_JUDGE")!=null);
       solve();
       io.flush();
   }
   
   private void solve() throws IOException {
       int n = io.nI(), a = io.nI(), b = io.nI(), h[] = new int[n], i;
       for(i = 0; i<n; i++)h[i] = io.nI(); Arrays.sort(h);
       io.wln(h[b]-h[b-1]);
   }//2.2250738585072012e-308
   
   private int gcd(int a, int b) {
       while(b>0) b^=a^=b^=a%=b;
       return a;
   }
   
   @SuppressWarnings("unused")
   private class IO{
       StreamTokenizer in; PrintWriter out; BufferedReader br; Reader reader; Writer writer;
       public IO(boolean oj) throws IOException{
           Locale.setDefault(Locale.US);
           reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
           writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
           br = new BufferedReader(reader);
           in = new StreamTokenizer(br);
           out = new PrintWriter(writer);
       }
       public void wln(){out.println();}
       public void wln(int arg){out.println(arg);}
       public void wln(long arg){out.println(arg);}
       public void wln(double arg){out.println(arg);}
       public void wln(String arg){out.println(arg);}
       public void wln(boolean arg){out.println(arg);}
       public void wln(char arg){out.println(arg);}
       public void wln(float arg){out.println(arg);}
       public void wln(Object arg){out.println(arg);}
       public void w(int arg){out.print(arg);}
       public void w(long arg){out.print(arg);}
       public void w(double arg){out.print(arg);}
       public void w(String arg){out.print(arg);}
       public void w(boolean arg){out.print(arg);}
       public void w(char arg){out.print(arg);}
       public void w(float arg){out.print(arg);}
       public void w(Object arg){out.print(arg);}
       public void wf(String format, Object...args){out.printf(format, args);}
       public void flush(){out.flush();}
       public int nI() throws IOException {in.nextToken(); return(int)in.nval;}
       public long nL() throws IOException {in.nextToken(); return(long)in.nval;}
       public String nS() throws IOException {in.nextToken(); return in.sval;}
       public double nD() throws IOException {in.nextToken(); return in.nval;}
       public float nF() throws IOException {in.nextToken(); return (float)in.nval;}
       public void wc(char...a){for(char c : a){in.ordinaryChar(c);in.wordChars(c, c);}}
       public void wc(char c1, char c2){in.ordinaryChars(c1, c2); in.wordChars(c1, c2);}
   }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class SolA {

	private static InputReader in;
	private static PrintWriter out;

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

		run();
		out.close();
	}

	public static void run() {
		int n = in.readInt();
		int a = in.readInt();
		int b = in.readInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = - in.readInt();
		}
		Arrays.sort(h);
		
		int base = -h[a-1];
		int base1 = -h[a];
		out.print(-(base1 - base));
		
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuffer res = new StringBuffer();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;
    
    public long result = 0;
    public int k = 0;

    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 void solve() throws NumberFormatException, IOException {
        int n = nextInt();
        int a = nextInt();
        int b = nextInt();
        
        int[] ar = new int[n];
        
        for(int i=0;i<n;i++){
            ar[i] = nextInt();
        }
        
        Arrays.sort(ar);
        
        out.println(ar[b]-ar[b-1]);
    }

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

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++)
            ar[i] = in.nextInt();
        Arrays.sort(ar);
        int x1 = ar[b-1];
        int x2 = ar[b];
        System.out.println(x2-x1);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn

import java.util.Arrays;
import java.util.Scanner;

public class CF_Chores {

    
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        
        long ar[] = new long[n];
        for (int i = 0; i < n; i++) {
            ar[i]=s.nextLong();
        }
        Arrays.sort(ar);
        
        long ret = 0;
//      System.out.println(Arrays.toString(ar));
        if(ar[b]==ar[b-1])
            System.out.println("0");
        else {
            ret = ar[b]-ar[b-1];
            System.out.println(ret);
        }
        
    }

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
	{
	public static void main(String args[])	throws IOException
		{
		Scanner c=new Scanner(System.in);
		int n=c.nextInt();
		int a=c.nextInt();		//higher
		int b=c.nextInt();		//lower
		int C[]=new int[n];
		for(int i=0;i<n;i++) 
			C[i]=c.nextInt();
		Arrays.sort(C);
		//System.out.println(Arrays.toString(C));
		int petya=C[n-a];
		System.out.println((C[n-a]-C[n-a-1]));
		}
	}

//must declare new classes here
// Problem: 169_A. Chores
// Time complexity: nlogn


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

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;
	
	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}
	
	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}
	
	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}
	
	long nl() throws IOException 
	{
		return Long.parseLong(ns());
	}
	
	double nd() throws IOException 
	{
		return Double.parseDouble(ns());
	}
		
	String ns() throws IOException 
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens()) 
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}
	
	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}
		
	

	//Main Code starts Here
	int totalCases, testNum;	
	int n,a,b;
	long arr[];

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			if(!input())
				break;
			solve();
		}
	}

	void solve() throws IOException
	{
		Arrays.sort(arr);
		long x1 = arr[b-1];
		long x2 = arr[b];
		
		System.out.println(x2-x1);
	}

	boolean input() throws IOException
	{
		n = ni();
		a = ni();
		b = ni();
		arr = new long[n];
		for(int i = 0;i<n;i++)
		{
			arr[i] = nl();
		}
		return true;
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }
        Arrays.sort(ar);
        if (ar[b-1] == ar[b ]) {
            System.out.println(0);
        } else {
            System.out.println(ar[b ] - ar[b-1]);
        }
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;


public class Solution
{
    public static void main(String[] args) throws IOException
    {
        new Solution().run();
    }
    StreamTokenizer in; 
    Scanner ins;
    PrintWriter out;
    
    int nextInt() throws IOException
    {
        in.nextToken();      
        return (int)in.nval;
    }
   

    void run() throws IOException
    {

        if(System.getProperty("ONLINE_JUDGE")!=null)
        {
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            ins = new Scanner(System.in);
            out = new PrintWriter(System.out);
        }
        else
        {           
            in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));             
            ins = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        }
        int n = nextInt(),a = nextInt(),b = nextInt();
        b--;
        int [] A = new int[n];
        for(int i = 0; i < n ;i++)
        {
            A[i] = nextInt();
        }
        Arrays.sort(A);
        if(A[b] == A[b+1])
            out.print(0);
        else
            out.print(A[b+1]- A[b]);
        out.close();
    }
    
    
    class Team implements Comparable
    {
        public int p,t;
        public int compareTo(Object obj)
        {
            Team a = (Team) obj;
            if(p>a.p || p==a.p && t<a.t)                          
                return -1;
            else                
                if(p==a.p && t==a.t)
                    return 0;
                else
                    return 1;
        }
        
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();
        int x[] = new int[n];
        for (int i=0; i<n; i++) x[i]=input.nextInt();
        Arrays.sort(x);
        int y[] = new int[n];
        for (int i=0; i<n; i++) y[i]=x[n-i-1];
        System.out.println(y[a-1]-y[a]);
    }
}