codeparrot/codecomplex huggingface dataset:
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author oleksiys
 */
public class A {
    public static void main(String [] args){
        try(Scanner s = new Scanner(System.in)){
            final int n = s.nextInt();
            final int m = s.nextInt();
            final int k = s.nextInt();
            final int [] a = new int [n];
            for (int i = 0; i < a.length; ++i){
                a[i] = s.nextInt();
            }
            Arrays.sort(a);
            int i = a.length - 1;
            int available = k;
            int filters = 0;
            while (available < m && i >= 0){
                available -= 1;
                available += a[i];
                filters++;
                i--;
            }
            if (available < m){
                System.out.println(-1);
            }else{
                System.out.println(filters);
            }
        }
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class A {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok = new StringTokenizer("");

	void solve() throws IOException {
		int n = readInt();
		int m = readInt();
		int k = readInt();
		int[] a = readArr(n);
		Arrays.sort(a);
		for(int i = 0; i <= n; i++){
			int curR = k;
			for(int j = n-1; j >= n-i; j--){
				curR += a[j];
			}
			curR -= i;
			if(curR >= m){
				out.println(i);
				return;
			}
		}
		out.println(-1);
	}

	void init() throws FileNotFoundException {
		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	int[] readArr(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = readInt();
		}
		return res;
	}

	long[] readArrL(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = readLong();
		}
		return res;
	}

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

	public void run() {
		try {
			long t1 = System.currentTimeMillis();
			init();
			solve();
			out.close();
			long t2 = System.currentTimeMillis();
			System.err.println("Time = " + (t2 - t1));
		} catch (Exception e) {
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
//package codeforces.contests.cf159;

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

public class ProblemA {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    int[] readInts() throws IOException {
        String[] strings = reader.readLine().split(" ");
        int[] ints = new int[strings.length];
        for(int i = 0; i < ints.length; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        return ints;
    }

    void solve() throws IOException {
        int[] tt = readInts();
        int n = tt[0];
        int m = tt[1];
        int k = tt[2];
        int[] a = readInts();
        Arrays.sort(a);
        for(int i = 0, j = a.length - 1; i < j; i++, j--) {
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
        int ix = 0;
        while(k < m && ix < n) {
            k += a[ix++] - 1;
        }
        if(k < m) {
            writer.println(-1);
        }
        else {
            writer.println(ix);
        }
        writer.flush();
    }

    public static void main(String[] args) throws IOException {
        new ProblemA().solve();
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;


public class Round159ProblemA {

	public static void main(String[] args) {
		Reader r = new Reader();
		int filters = r.nextInt();
		int devices = r.nextInt();
		int sockets = r.nextInt();
		
		List<Integer> filtery = new ArrayList<>();
		for (int i = 0; i < filters; i++) {
			filtery.add(r.nextInt()-1);
		}
		
		//System.out.println(filtery);
		
		if(devices <= sockets){
			System.out.println(0);
			return;
		}else{
			Collections.shuffle(filtery);
			Collections.sort(filtery);
			devices -= sockets;
			int act = filtery.size()-1;
			int result = 0;
			while(devices > 0){
				//System.out.println(devices + " " + act);
				if(act < 0){
					System.out.println(-1);
					return;
				}
				devices -= filtery.get(act);
				act--;
				result++;
			}
			System.out.println(result);
		}
	}

	static class Reader {
		StreamTokenizer in;

		public Reader() {
			in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
					System.in)));
		}

		public int nextInt() {
			try {
				in.nextToken();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return (int) in.nval;
		}

		public long nextLong() {
			try {
				in.nextToken();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return (long) in.nval;
		}

		public String next() {
			try {
				in.nextToken();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return in.sval;
		}
	}
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner sc = new Scanner(System.in);
        int numSupply = sc.nextInt();
        int dev = sc.nextInt();
        int socket = sc.nextInt();
        int[] sockInSu = new int[numSupply];
        for (int i = 0; i< sockInSu.length; i++) {
            sockInSu[i] = sc.nextInt();
        }
        
        Arrays.sort(sockInSu);
        
        if (socket >= dev) {
            System.out.println(0);
        }else {
            int count = 0;
            for (int i = sockInSu.length-1; i >= 0; i--) {
                socket+= sockInSu[i]-1;
                count++;
                if (socket >= dev) {
                    System.out.println(count);
                    break;
                }
            }
            if (socket < dev)
                System.out.println(-1);
        }
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;

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

   StreamTokenizer in;
   PrintWriter out;

   int nextInt() throws IOException
   {
      in.nextToken();
      return (int)in.nval;
   }
   long nextLong() throws IOException
   {
      in.nextToken();
      return (long)in.nval;
   }
   void run() throws IOException
   {
     // in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
     // out = new PrintWriter(new FileWriter("output.txt"));
      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    out = new PrintWriter(new OutputStreamWriter(System.out));
      solve();
      out.flush();
   }

   void solve() throws IOException
   {
      int N=nextInt();
      int m=nextInt();
      int k=nextInt();
     //  System.out.println("k "+k);
      ArrayList<Integer> ts= new ArrayList<Integer>();
       for (int i = 0; i < N; i++) {
           ts.add(nextInt());
       }
       int count=0,pos=0;
       Collections.sort(ts);
       int jj=ts.size()-1;
      while(m>k){
         
      if((jj<0)||(k==0))
      {pos=1;break;}
      else{
        //  System.out.println(k);
      k+=ts.get(jj) -1;
      jj--;
      count++;
      }
      
      }
      if(pos==0)
           out.println(count);
      else
           out.println("-1");
      
   }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;


public class A {
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens())
				tk=new StringTokenizer(br.readLine());
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	public static void main(String args[]) throws NumberFormatException, IOException{
		Scanner sc=new Scanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		int K=sc.nextInt();
		int[] array=new int[N];
		for(int i=0;i<N;i++)
			array[i]=sc.nextInt();
		Arrays.sort(array);
		int val=K;
		int index=N - 1;
		while(index>=0 && val<M){
			val--;
			val+=array[index];
			index--;
		}
		if (val<M)
			System.out.println("-1");
		else
			System.out.println((N - 1) - index);
	}

}
// Problem: 257_A. Sockets
// 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
 */
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 m = in.nextInt();
		int k = in.nextInt();
		int[] fs = IOUtils.readIntArray(in, n);
		Arrays.sort(fs);
		int ptr = fs.length - 1;
		int res = 0;
		while (ptr >= 0 && k < m) {
			k += fs[ptr--] - 1;
			res++;
		}
		if (k < m) out.println(-1);
		else out.println(res);
	}
}

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: 257_A. Sockets
// Time complexity: nlogn

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

/**
 *
 * @author Natasha
 */
public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int produzeni = in.nextInt();
        int devices = in.nextInt();
        int stekovi = in.nextInt();
        int [] filter = new int[produzeni];
        for(int i = 0; i<produzeni; i++){
            filter[i] = in.nextInt();
        }
        Arrays.sort(filter);
        int filt_no = filter.length-1;
        if(devices<=stekovi) {
            System.out.println("0");
            return;
        }
        int used = 0;
        while(devices>stekovi){
            try{
            stekovi+=filter[filt_no--]-1;
            }
            catch(Exception e){
                System.out.println("-1");
                return;
            }
        }
        
        System.out.println(filter.length - filt_no-1);
        
        
        
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt(), m = input.nextInt(), k = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++)
        data[i] = input.nextInt();
    Arrays.sort(data);
    m -= k;
    int at = n-1;
    int count = 0;
    while(at>=0 && m>0)
    {
        count++;
        m++;
        m -= data[at];
        at--;
    }
    if(m>0)
        System.out.println(-1);
    else
        System.out.println(count);
}
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class TaskA {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new TaskA().solve(in, out);
		in.close();
		out.close();
	}
	
	private void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		int answer = 0;
		int counter = k;
		int[] a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = in.nextInt();
		Arrays.sort(a);
		int[] b = Arrays.copyOf(a, a.length);
		for (int i = 0; i < n; ++i) 
			a[i] = b[n - i - 1];
		for (int i = 0; i < n; ++i) {
			if (counter < m) {
				counter += a[i] - 1;
				++answer;
			} else
				break;
		}
		if (counter < m)
			out.println("-1");
		else
			out.println(answer);
	}

}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class round159A {
    static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer st = new StringTokenizer("");

    static int nextInt() throws Exception {
        return Integer.parseInt(next());
    }

    static String next() throws Exception {
        while (true) {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            st = new StringTokenizer(s);
        }
    }

    public static void main(String[] args) throws Exception {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        int[] supply = new int[n];
        for (int i = 0; i < n; ++i)
            supply[i] = nextInt();
        if (m <= k) {
            System.out.println(0);
        } else {
            int have = k;
            Arrays.sort(supply);
            for(int i = n - 1 ; i >= 0 ; --i){
                have--;
                have += supply[i];
                if(have >= m){
                    System.out.println(n - i);
                    return;
                }
            }
            System.out.println(-1);
        }
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class ProblemA {
    InputReader in; PrintWriter out;
    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        Arrays.sort(a);
        int d = k;
        int cur = n - 1;
        int ans = 0;
        while (d < m && cur >= 0) {
            d += a[cur] - 1;
            cur--;
            ans++;
        }
        if (d >= m)
            out.println(ans);
        else
            out.println("-1");
    }
    
    ProblemA(){
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        try {
            if (oj) {
                in = new InputReader(System.in);
                out = new PrintWriter(System.out);
            }
            else {
                Writer w = new FileWriter("output.txt");
                in = new InputReader(new FileReader("input.txt"));
                out = new PrintWriter(w);
            }
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
        solve();
        out.close();
    }
    public static void main(String[] args){
        new ProblemA();
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
    
    public InputReader(FileReader fr) {
        reader = new BufferedReader(fr);
        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());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }

}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	void solve() throws Exception {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int a [] = new int [n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if (k >= m) {
			out.println(0);
			return;
		}
		int sum = k;
		for (int j = n - 1; j >= 0; j--) {
			sum--;
			sum += a[j];
			if (sum >= m) {
				out.println((n - j));
				return;
			}
		}
		out.println(-1);
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Solution(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

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());
	}

}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;


public class A {
    
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int so[]= new int[n];
        for(int i=0;i<n;i++) so[i]=in.nextInt();
        Arrays.sort(so);
        if(m<=k) {
            System.out.println("0");
            return;
        }
        int sum=0;
        int socUsed=0;
        int cont=0;
        for(int i=n-1;i>=0;i--){
            cont++;
            sum+=so[i]; 
            if(sum>=m || sum+(k-1)>=m){
                System.out.println(cont);
                return;
            }   
            sum--;  
        }   
        System.out.println("-1");
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

    void run() throws IOException {
        int n = ni();
        int m = ni();
        int k = ni();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni() - 1;
        Arrays.sort(a);
        int ans = 0;
        if (m > k) {
            m -= k - 1;
            for (int i = n - 1; i >= 0; i--) {
                ans++;
                m -= a[i];          
                if (m < 2)
                    break;

            }
            if (m > 1)
                ans = -1;
        }
        pw.print(ans);
    }

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

    int ni() throws IOException {
        return Integer.parseInt(next());
    }

    String nl() throws IOException {
        return br.readLine();
    }

    PrintWriter pw;
    BufferedReader br;
    StringTokenizer st;

    public static void main(String[] args) throws IOException {
        long timeout = System.currentTimeMillis();
        boolean CF = System.getProperty("ONLINE_JUDGE") != null;
        PrintWriter _pw = new PrintWriter(System.out);
        BufferedReader _br = new BufferedReader(CF ? new InputStreamReader(System.in) : new FileReader(new File("in.txt")));
        new A(_br, _pw).run();
        if (!CF) {
            _pw.println();
            _pw.println(System.currentTimeMillis() - timeout);
        }
        _br.close();
        _pw.close();
    }

    public A(BufferedReader _br, PrintWriter _pw) {
        br = _br;
        pw = _pw;
    }
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {
	int n, m, k;
	int[] a;
	
	void run()throws IOException{
//		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(new InputStreamReader(System.in));
		n = sc.nextInt();
		m = sc.nextInt();
		k = sc.nextInt();
		a = new int[n];
		for(int i=0;i<n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		
		if(m<=k){
			System.out.println(0);
			return;
		}
		
		int cnt = k;
		int ind = a.length-1;
		int ret = 0;
		while(cnt<m && ind>=0){
			cnt += a[ind]-1;
			--ind;
			ret++;
			
		}
		
		if(cnt>=m) System.out.println(ret);
		else System.out.println(-1);
	}

	public static void main(String[] args)throws IOException {
		new A().run();
	}
}
// Problem: 257_A. Sockets
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class CF159DIV2 {
	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		Arrays.sort(a);
		for (int i = 0; i < a.length / 2; i++) {
			int tmp = a[i];
			a[i] = a[n - i - 1];
			a[n - i - 1] = tmp;
		}
		int need = m;
		int have = k;
		int ans = 0;
		int it = 0;
		while (have < need) {
			have += a[it++] - 1;
			ans++;
			if (it >= n) break;
		}
		if (have >= need) {
			out.println(ans);
		} else {
			out.println(-1);
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF159DIV2().runIO();
	}
}