Muennighoff/xP3x-sample huggingface dataset:
inputs: import java.io.*;
import java.util.*;

public class Main {

    private static void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();

        List<List<Integer>> g = new ArrayList<>(n + 1);
        for (int i = 0; i < n + 1; i++) {
            g.add(new LinkedList<>());
        }

        int degree1 = 0, degree2 = 0, root = 0;
        for (int i = 0; i < n - 1; i++) {
            int a = in.nextInt();
            int b = in.nextInt();

            g.get(a).add(b);
            g.get(b).add(a);

            if (g.get(a).size() > degree1) {

                if (a == root) {
                    degree1 = g.get(a).size();
                } else {
                    degree2 = degree1;
                    degree1 = g.get(a).size();
                    root = a;
                }

            } else if (g.get(a).size() > degree2) {
                degree2 = g.get(a).size();
            }

            if (g.get(b).size() > degree1) {

                if (b == root) {
                    degree1 = g.get(b).size();
                } else {
                    degree2 = degree1;
                    degree1 = g.get(b).size();
                    root = b;
                }

            } else if (g.get(b).size() > degree2) {
                degree2 = g.get(b).size();
            }
        }

        if (degree2 > 2) {
            out.print("No");
        } else {
            out.println("Yes");

            List<Integer> leaves = new LinkedList<>();
            for (int i = 1; i <= n; i++) {
                if (i != root) {
                    if (g.get(i).size() == 1) {
                        leaves.add(i);
                    }
                }
            }

            out.println(leaves.size());
            for (int i : leaves) {
                out.println(root + " " + i);
            }
        }
    }

    private static void shuffleArray(int[] array) {
        int index;
        Random random = new Random();
        for (int i = array.length - 1; i > 0; i--) {
            index =... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Random;
import java.util.TreeSet;

/**
 * Actual solution is at the top, in class Solver
 */
final public class Main implements Runnable {
	private static String[] args;

	public static void main(String[] args) {
		Main.args = args;
		new Thread(null, new Main(), "MyRunThread", 1 << 27).start();
	}

	//@Override
	public void run() {
		long time_beg = -1;
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (args.length > 0 && args[0].equals("outside")) {
			time_beg = System.currentTimeMillis();
			try {
				inputStream = new FileInputStream("IO/in.txt");
//				outputStream = new FileOutputStream("IO/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		} else {
			try {
//				inputStream = new FileInputStream("IO/in.txt");
//				outputStream = new FileOutputStream("IO/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		}

		Solver s = new Solver();
		s.in = new InputReader(inputStream);
		s.out = new OutputWriter(outputStream);
		if (args.length > 0 && args[0].equals("outside")) {
			s.dout = new DebugWriter(s.out);
		}

		s.solve();

		if (args.length > 0 && args[0].equals("outside")) {
			s.dout.printFormat("*** Total time: %.3f ***\n", (System.currentTimeMillis() - time_beg) / 1000.0);
		}

		s.out.close();
	}
}


final class Solver {
	InputReader in;
	OutputWriter out;
	DebugWriter dout;

	public void solve() {
		int n = in.readInt();
		int k = in.readInt();


		TreeSet<Integer> q = new TreeSet<Integer>();
		int[] mas = new int[n];
		for (int i = 0; i... What is the time complexity of the previous code?
targets: nlogn
inputs: import java.util.*;

public class TaskA {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a);

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }

        int take = 0, num = 0;

        for (int i = n - 1; i > -1; i--) {
            num++;
            take += a[i];
            sum -= a[i];
            if (take > sum) {
                break;
            }
        }

        System.out.println(num);
    }
}
 What is the time complexity of the previous code?
targets: nlogn
inputs: import java.util.*;
import java.util.Map.Entry;
import java.io.*;
public class Main {
	public static class node implements Comparable<node> {
		int l,r;
		node(){}
		node(int l,int r) {
			this.l=l;
			this.r=r;
		}
		@Override
		public int compareTo(node rhs) {
			return r-rhs.r;
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		StringTokenizer sa=new StringTokenizer(in.readLine());
		int n=Integer.parseInt(sa.nextToken());
		sa=new StringTokenizer(in.readLine());
		int[] a=new int[n];
		TreeMap<Integer,ArrayList<node>> mp=new TreeMap();
		for (int i=0;i<n;++i) a[i]=Integer.parseInt(sa.nextToken());
		for (int i=0;i<n;++i) {
			int tmp=0;
			for (int j=i;j<n;++j) {
				tmp+=a[j];
				if (!mp.containsKey(tmp)) {
					ArrayList t=new ArrayList();
					t.add(new node(i,j));
					mp.put(tmp,t);
				} else {
					ArrayList<node> t=mp.get(tmp);
					int left=0,right=t.size()-1,res=t.size();
					while (left<=right) {
						int mid=(left+right)>>1;
						if (t.get(mid).r>=i) {
							res=mid;
							right=mid-1;
						} else left=mid+1;
					}
					if (res==t.size()) t.add(new node(i,j));
					else if (t.get(res).r>j) t.set(res,new node(i,j));
				}
			}
		}
		int res=0;
		for (Entry<Integer,ArrayList<node>> entry:mp.entrySet())
			res=Math.max(res,entry.getValue().size());
		out.println(res);
		for (Entry<Integer,ArrayList<node>> entry:mp.entrySet())
			if (entry.getValue().size()==res) {
				ArrayList<node> tmp=entry.getValue();
				for (int i=0;i<tmp.size();++i)
					out.printf("%d %d\n",tmp.get(i).l+1,tmp.get(i).r+1);
				out.flush();
				return;
			}
	}
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: quadratic
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class StrangeAddition {

	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		sc = new StringTokenizer(br.readLine());
		int tc = nxtInt();
		while (tc-- > 0) {
			int a = nxtInt();
			int b = nxtInt();
			int ans = 0;
			while (a != b) {
				if (a == 0 || b == 0)
					break;
				if (a > b) {
					int div = a / b;
					a -= b * div;
					ans += div;
				} else {
					int div = b / a;
					b -= a * div;
					ans += div;
				}
			}
			out.println(ans + (a == b ? 1 : 0));
		}
		br.close();
		out.close();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));

	static StringTokenizer sc;

	static String nxtTok() throws IOException {
		while (!sc.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return null;
			sc = new StringTokenizer(s.trim());
		}
		return sc.nextToken();
	}

	static int nxtInt() throws IOException {
		return Integer.parseInt(nxtTok());
	}

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}
} What is the time complexity of the previous code?
targets: constant
inputs: import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.*;
 
public class ExplorerSpace {
	
	private static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public MyScanner() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }

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

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

	    long nextLong() {
	        return Long.parseLong(next());
	    }

	    double nextDouble() {
	        return Double.parseDouble(next());
	    }

	    String nextLine(){
	        String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	    }

	 }
	
    
	public static long[][][] dp; 
	
	public static boolean valid(int i, int j, int n, int m)
	{
		return i>=0 && i<n &&j>=0 && j<m;
	}
	
	public static void solution(int n, int m, int k, int[][] h, int[][] v)
			
	{
		if(k%2==1)
		{
			for(int i = 0; i<n; i++)
			{
				for(int j = 0; j<m; j++)
				   out.print(-1+" ");
				
				out.println();
				
			}
			
			return;
		}
		
		dp = new long[n][m][k/2+1];
		
		for(int t = 1; t<=k/2; t++)
		{
			for(int i = 0; i<n; i++)
			{
				for(int j = 0; j<m; j++)
				{
					dp[i][j][t] = Long.MAX_VALUE;
						
				}
			}
		}
		
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<m; j++)
			{
				dp[i][j][0] = 0;
					
			}
		}
		
		
		for(int t = 1; t<=k/2; t++)
		{
			for(int i = 0; i<n; i++)
			{
				for(int j = 0; j<m; j++)
				{
					if(valid(i,j+1,n,m))
						dp[i][j][t] = Math.min(dp[i][j][t], h[i][j] + dp[i][j+1][t-1]); 
				
					if(valid(i,j-1,n,m))
						 dp[i][j][t] = Math.min(dp[i][j][t],... What is the time complexity of the previous code?
targets: cubic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. //package round429;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni();
		int[] a = na(n);
		for(int i = 0;i < n;i++){
			int v = a[i];
			for(int j = 2;j*j <= v;j++){
				while(v % (j*j) == 0){
					v /= j*j;
				}
			}
			a[i] = v;
		}
		
		Arrays.sort(a);
		int[] f = new int[n];
		int p = 0;
		for(int i= 0;i < n;i++){
			if(i > 0 && a[i] != a[i-1]){
				p++;
			}
			f[p]++;
		}
		f = Arrays.copyOf(f, p+1);
		int mod = 1000000007;
		
		int[][] fif = enumFIF(1000, mod);
		long[] res = countSameNeighborsSequence(f, fif, mod);
		long ans = res[0];
		for(int v : f){
			ans = ans * fif[0][v] % mod;
		}
		
		out.println(ans);
	}
	
	public static int[][] enumFIF(int n, int mod) {
		int[] f = new int[n + 1];
		int[] invf = new int[n + 1];
		f[0] = 1;
		for (int i = 1; i <= n; i++) {
			f[i] = (int) ((long) f[i - 1] * i % mod);
		}
		long a = f[n];
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		invf[n] = (int) (p < 0 ? p + mod : p);
		for (int i = n - 1; i >= 0; i--) {
			invf[i] = (int) ((long) invf[i + 1] * (i + 1) % mod);
		}
		return new int[][] { f, invf };
	}

	
	public static long[] countSameNeighborsSequence(int[] a, int[][] fif, int mod)
	{
		int n = a.length;
		
		int bef = a[0];
		int aft = a[0];
		long[] dp = new long[bef];
		dp[bef-1] = 1;
		for(int u = 1;u < n;u++){
			int v = a[u];
			aft += v;
			long[][] ldp = new long[bef][aft];
			for(int i = 0;i < dp.length;i++){
				ldp[i][0] = dp[i];
			}
			
			for(int i = 0;i < v;i++){
				long[][] ndp = new long[bef][aft];
				for(int j = 0;j < bef;j++){
					for(int k = 0;j+k < aft;k++){
						if(ldp[j][k] == 0)continue;
						// XX -> XCX
						if(j > 0){
							ndp[j-1][k] += ldp[j][k] *... Complexity:
targets: cubic
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class c {
    class IO {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st;
        Random rnd = new Random();;
        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());
        }
    }
    
    void run() throws IOException{
        IO read=new IO();
        int n=read.nextInt();
        int a[]=new int[n],b[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=b[i]=read.nextInt();
        Arrays.sort(b);
        int cnt=0;
        for(int i=0;i<n;i++)
            if(a[i]!=b[i])
                cnt++;
        if(cnt==0||cnt==2)
            read.out.println("YES");
        else
            read.out.println("NO");
        read.out.close();
    }
    public static void main(String[] args) throws IOException {
        new c().run();
    }
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: nlogn
inputs: import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayDeque;
import java.util.Arrays;


public class Main {
	private static StreamTokenizer in;
	private static PrintWriter out;
	
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}
	
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}
	
	public static void main(String[] args) throws Exception {
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(System.out);
		
		int n = nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++)
			a[i] = nextInt();
		Arrays.sort(a);
		int u = a[0];
		for (int i=0; i<n; i++)
			if (a[i]>u) {
				out.println(a[i]);
				out.flush();
				return;
			}
		out.println("NO");
		out.flush();
	}
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: nlogn
inputs: import java.io.*;
import java.util.*;
import java.lang.*;
import static java.lang.Math.*;

// _ h _ r _ t r _
// _ t _ t _ s t _




public class TaskA implements Runnable {
    long m = (int)1e9+7;
    PrintWriter w;
    InputReader c;
    final int MAXN = (int)1e6 + 100;
    public void run() {
        c = new InputReader(System.in);
        w = new PrintWriter(System.out);

        int n = c.nextInt(), hamming_distance = 0;
        char[] s = c.next().toCharArray(), t = c.next().toCharArray();
        HashMap<Character, HashSet<Character>> replace = new HashMap<>();
        HashMap<Character, Integer> map = new HashMap<>();

        for(int i=0;i<n;++i) if(s[i] != t[i]) {
            HashSet<Character> temp;
            if(replace.containsKey(s[i])){
                temp = replace.get(s[i]);
                temp.add(t[i]);
            } else {
                temp = new HashSet<>();
                temp.add(t[i]);
            }
            map.put(s[i],i);
            replace.put(s[i], temp);
            hamming_distance++;
        }

        int l = -1, r = -1;
        boolean global_check = false;
        for(int i=0;i<n;i++) if(s[i] != t[i]) {
            if(replace.containsKey(t[i])) {
                HashSet<Character> indices = replace.get(t[i]);
                int ind = map.get(t[i]);
                l = i + 1;
                r = ind + 1;
                if (indices.contains(s[i])) {
                    hamming_distance -= 2;
                    global_check = true;
                    break;
                }
            }
            if(global_check) break;
        }

        if(!global_check && l!=-1) hamming_distance--;
        else if(global_check){
            for(int i=0;i<n;i++) {
                if(t[i] == s[l-1] && s[i] == t[l-1]){
                    r = i + 1;
                    break;
                }
            }
        }
        w.println(hamming_distance);
        w.println(l+" "+r);

        w.close();
    }
    static long gcd(long a, long b) {
        if (b == 0)
          ... What is the time complexity of the previous code?
targets: linear
inputs: import java.util.Scanner;

public class Training {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long index = in.nextLong();
        if (index < 10) {
            //one digit
            System.out.println(index);
        } else if (index < 190) {
            //two digits
            solve(2, index, 10, 10);

        } else if (index < 2890) {
            //three digits 
            solve(3, index, 190, 100);

        } else if (index < 38890) {
            //four digits 
            solve(4, index, 2890, 1000);

            //start changing ------------------------------------------------------------
        } else if (index < 488890) {
            //five digits 
            solve(5, index, 38890, 10000);

        } else if (index < 5888890) {
            //six digits 
            solve(6, index, 488890, 100000);

        } else if (index < 68888890) {
            //seven digits 
            solve(7, index, 5888890, 1000000);

        } else if (index < 788888890) {
            //eight digits 
            solve(8, index, 68888890, 10000000);

        } else if (index < 8888888890l) {
            //nign digits 
            solve(9, index, 788888890, 100000000);

        } else if (index < 98888888890l) {
            //ten digits 
            solve(10, index, 8888888890l, 1000000000);

        } else {
            solve(11, index, 98888888890l, 10000000000l);

        }

    }

    static void solve(int length, long index, long lastPoint, long num) {
        String s = "";
        num += (index - lastPoint) / length;
        s += num;
        int mod = (int) ((index - lastPoint) % length);
        System.out.println(s.charAt(mod));
    }

}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: logn
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ACodehorsesTShirts {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                String ch = in.next();
                if (map.containsKey(ch)) {
                    map.put(ch, map.get(ch) + 1);
                } else {
                    map.put(ch, 1);
                }
            }
            int s = n;
            for (int i = 0; i < n; i++) {
                String ch = in.next();
                if (map.containsKey(ch)) {
                    if (map.get(ch) == 1) {
                        map.remove(ch);
                    } else {
                        map.put(ch, map.get(ch) - 1);
                    }
                    s--;
                }
            }
            out.println(s);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

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

        public String next() {
            while (st == null || !st.hasMoreElements())... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.Scanner;
public class LuckyDivision {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        
        if( n % 4==0 ||
            n % 7==0 ||
            n % 47==0 ||
            n % 74==0 ||
            n % 447==0 ||
            n % 474==0 ||
            n % 477==0 ||
            n % 744==0 ||
            n % 774==0 ||
            n % 777==0
        )
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}
 Complexity:
targets: constant
inputs: import java.io.*;
import java.util.*;

public class LectureSleep {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);


    public static void main(String[] args) {
        int n = r.nextInt(); // duration of lecture
        int k = r.nextInt(); // number of minutes keep mishka awake
        int[] theorems = new int[n+1];
        for(int i = 1; i <= n; i++){
            theorems[i] = r.nextInt();
        }
        int[] mishka = new int[n+1];
        for(int i = 1; i <= n; i++){
            mishka[i] = r.nextInt();
        }
        int[] sums = new int[n+1];
        for(int i = 1; i <= n; i++){
            if(mishka[i] == 0){
                sums[i] = sums[i-1] + theorems[i];
            } else{
                sums[i] = sums[i-1];
            }
        }
        int max = 0;
        for(int i = 1; i <= n-k+1; i++){
            int sum = sums[i+k-1] - sums[i-1];
            max = Math.max(max, sum);
        }
        int totalSum = 0;
        for(int i = 1; i <= n;... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
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 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 cnt = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (k >= m) {
                System.out.println(cnt);
                return;
            }
            cnt++;
            k += A[i] - 1;
        }
        if (k >= m)
            System.out.println(cnt);
        else
            System.out.println(-1);
    }
}
 Complexity:
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class C {

	private static double r, EPS=1e-10;
	
	public static void solve(FastScanner fs) {	
		int n=fs.nextInt();
		r=fs.nextInt();
		int[] xCoords=fs.readArray(n);
		
		ArrayList<Point> placed=new ArrayList<>();
		for (int x:xCoords) {
			double maxY=r;
			for (Point p:placed)
				maxY=Math.max(maxY, getNewY(p, x));
			placed.add(new Point(x, maxY));
		}
		for (Point p:placed) {
			System.out.printf("%.9f ", p.y);
		}
		
	}
	
	private static double getNewY(Point circleCenter, int x) {
		double dx=Math.abs(x-circleCenter.x);
		if (dx>r+r)
			return 0;
		if (dx<EPS)
			return circleCenter.y+r+r;
		double hypot=r+r;
		return circleCenter.y+Math.sqrt(hypot*hypot-(double)dx*dx);
	}

	
	static class Point {
		double x;
		double y;
		public Point(double x, double y) {
			this.x=x;
			this.y=y;
		}
 	}
	
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner = new FastScanner(System.in);
		solve(scanner);
	}
	

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n)... Complexity:
targets: quadratic
inputs: import java.io.*;
import java.util.StringTokenizer;

/**
 * CodeForces Round 5D. Follow Traffic Rules
 * Created by Darren on 14-9-14.
 */
public class Main {
    Reader in = new Reader(System.in);
    PrintWriter out = new PrintWriter(System.out);

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

    int a, v;
    int l, d, w;

    void run() throws IOException {
        a = in.nextInt();
        v = in.nextInt();
        l = in.nextInt();
        d = in.nextInt();
        w = in.nextInt();

        double totalTime = 0.0;
        if (v >= w) {
            if (w*w >= 2*a*d) {
                double x = Math.sqrt(2*a*d);
                totalTime = x / a;
                if ((v*v-x*x) >= 2*a*(l-d))
                    totalTime += (-2*x+Math.sqrt(4*x*x+8*a*(l-d))) / (2*a);
                else
                    totalTime += (v-x)/(1.0*a) + (l-d-(v*v-x*x)/(2.0*a))/v;
            } else {
//                totalTime = (-2*w+Math.sqrt(4*w*w+8*a*(l-d))) / (2*a);
                if (2*v*v-w*w <= 2*a*d) {
                    totalTime = v / (1.0*a) + (v-w) / (1.0*a) + (d-(2*v*v-w*w)/(2.0*a)) / v;
                } else {
                    double x = Math.sqrt((2*a*d+w*w)/2.0);
                    totalTime = x / a + (x-w) / a;
                }
                if ((v*v-w*w) >= 2*a*(l-d))
                    totalTime += (-2*w+Math.sqrt(4*w*w+8*a*(l-d))) / (2*a);
                else
                    totalTime += (v-w)/(1.0*a) + (l-d-(v*v-w*w)/(2.0*a))/v;
            }
        } else {
            if (v*v >= 2*a*l)
                totalTime = Math.sqrt(l*2.0/a);
            else
                totalTime = v / (1.0*a) + (l-v*v/(2.0*a)) / v;
        }

        out.printf("%.10f", totalTime);
        out.flush();
    }

    void solve() throws IOException {

    }

    static class Reader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(new... What is the time complexity of the previous code?
targets: constant
inputs: import java.io.*;
import java.util.*;
 

public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));
		//Scanner skek = new Scanner(System.in);
		PrintWriter outkek = new PrintWriter(System.out);
		
		String[] input = kek.readLine().split(" ");
		int N = Integer.parseInt(input[0]), M = Integer.parseInt(input[1]);
		boolean[][] connected = new boolean[N + 1][N];
		long[][] walks = new long[1 << N][N];
		long res = 0;
		
		for(int i = 0; i < M; i++){
			input = kek.readLine().split(" ");
			int A = Integer.parseInt(input[0]) - 1, B = Integer.parseInt(input[1]) - 1;
			connected[A][B] = connected[B][A] = true;
		}
		
		for(int i = 0; i < N; i++){
			walks[1 << i][i] = 1;
		}
		
		for(int i = 1; i < 1 << N; i++){
			int temp = (int) (Math.log(i & -(i)) / 0.6931471805599453);
			for(int j = 0; j < N; j++){
				if(((1 << j) & i) > 0 && j != temp){
					for(int k = 0; k < N; k++){
						if(connected[k][j]){
							walks[i][j] += walks[i ^ (1 << j)][k];
						}
					}
					
					int count = 0, track = i;
					while(track > 0){
						if(track % 2 == 1){
							count++;
						}
						track /= 2;
					}
					
					
					if(count >= 3 && connected[temp][j]){
						res += walks[i][j];
					}
				}
			}
		}
		
		outkek.println(res / 2);
		kek.close();
		outkek.close();
	}	
	
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np
inputs: import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class cf2 {
	static final double EPS = 1e-9;

  public static void main(String[] args) throws IOException {
	 Scanner sc = new Scanner(System.in);
	
	 //rec
	 int xr1=sc.nextInt(), yr1=sc.nextInt(), xr2=sc.nextInt(),yr2=sc.nextInt();
	 int xr3=sc.nextInt(), yr3=sc.nextInt(), xr4=sc.nextInt(),yr4=sc.nextInt();
	
	 Point pr1 = new Point(xr1, yr1);
	 Point pr2 = new Point(xr2, yr2);
	 Point pr3 = new Point(xr3, yr3);
	 Point pr4 = new Point(xr4, yr4);
	 
	 LineSegment lr1 = new LineSegment(pr1, pr2);
	 LineSegment lr2 = new LineSegment(pr2, pr3);
	 LineSegment lr3 = new LineSegment(pr3, pr4);
	 LineSegment lr4 = new LineSegment(pr4, pr1);
	 
	 //diamond
	 int xd1=sc.nextInt(), yd1=sc.nextInt(), xd2=sc.nextInt(),yd2=sc.nextInt();
	 int xd3=sc.nextInt(), yd3=sc.nextInt(), xd4=sc.nextInt(),yd4=sc.nextInt();
	 
	 Point p1 = new Point(xd1, yd1);
	 Point p2 = new Point(xd2, yd2);
	 Point p3 = new Point(xd3, yd3);
	 Point p4 = new Point(xd4, yd4);
	 
	 Point [] pt = new Point [5];
	 pt[0]=p1;  pt[1]=p2;  pt[2]=p3;  pt[3]=p4;  pt[4]=p1;
	 Polygon pg = new Polygon(pt);
	 
	 if(pg.inside(pr1)||pg.inside(pr2)||pg.inside(pr3)||pg.inside(pr4)) {
		 System.out.println("YES");
		 return;
	 }
	
	 
	 LineSegment ld1 = new LineSegment(p1, p2);
	 LineSegment ld2 = new LineSegment(p2, p3);
	 LineSegment ld3 = new LineSegment(p3, p4);
	 LineSegment ld4 = new LineSegment(p4, p1);
	 
	 Rectangle rec = new Rectangle(new Point(Math.min(Math.min(xr3,xr4),Math.min(xr1,xr2)), Math.min(Math.min(yr3,yr4),Math.min(yr1,yr2))), 
			 new Point(Math.max(Math.max(xr3,xr4),Math.max(xr1,xr2)), Math.max(Math.max(yr3,yr4),Math.max(yr1,yr2))) );
	 
	 if(rec.contains(p1)||rec.contains(p2)||rec.contains(p3)||rec.contains(p4)) {
		 System.out.println("YES");
	     return;
	 }
	 
	... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: constant
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pttrung
 */
public class B {

    static Senator[] data;

    public static void main(String[] args) {
        Scanner in = new Scanner(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int k = in.nextInt();
        int A = in.nextInt();
        data = new Senator[n];
        for (int i = 0; i < n; i++) {
            data[i] = new Senator(in.nextInt(), in.nextInt());
        }
        out.println(cal(0, new int[n], A, k));

        out.close();
    }

    public static double cal(int index, int[] num, int A, int left) {
        if (index == data.length - 1) {
            int dif = (100 - data[index].loyal)/10;
            dif = left >= dif? dif:left;
            num[index] =  dif;
           
            double result = 0;
            for (int k = 0; k < (1 << num.length); k++) {
                double val = 1;
                double total = 0;
                for (int i = 0; i < num.length; i++) {
                    if (((1 << i) & k) != 0) {
                        val *= ((double)(data[i].loyal + 10*num[i])/100);
                    } else {
                        val *= ((double)(100 - (data[i].loyal + 10*num[i]))/100);
                        total += data[i].level;
                    }
                }
                if (countBit(k) > num.length / 2) {
                    result += val;
                } else {
                    result += val * ((double) A / (A + total));
                }
            }
//           // if(result >= 1){
//                for(int i : num){
//                    System.out.print(i + " ");
//                }
//                System.out.println("\n" + result);
//            //}
            return result;
        } else {
            double result = 0;
         ... Complexity:
targets: np
inputs: 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]);
    }
} What is the time complexity of the previous code?
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.awt.Point;

public class CodeForces {
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private final long MOD = 1000000009;

    long power(long a, long b)
    {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                res *= a;
                if (res >= MOD)
                    res %= MOD;
            }
            a *= a;
            if (a >= MOD)
                a %= MOD;
            b >>= 1;
        }
        return res;
    }

    void runCase(int caseNum) throws IOException {
        long n = nextLong();
        long m = nextLong();
        long k = nextLong();

        if (n - m >= n / k) {
            System.out.println(m);
            return;
        }
        long res = 0;
        long rem = (k - 1) * (n - m);
        m -= rem;
        long bound = m / k;
        res = (power(2, bound + 1) + MOD - 2) % MOD;
        res *= k;
        res %= MOD;
//        for (long i = 0; i < bound; ++i) {
//            res += k;
//            res <<= 1;
//            if (res >= MOD)
//                res %= MOD;
//        }
        res += rem;
        res += m % k;
        res %= MOD;
        System.out.println(res);
    }


    public static void main(String[] args) throws IOException {
        if (ONLINE_JUDGE){
            System.out.println();
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(System.out);
            //out = new PrintWriter("output.txt");
        }
        new CodeForces().runIt();
        out.flush();
        out.close();
        return;
    }

    static BufferedReader in;
    private StringTokenizer st;
    static PrintWriter out;

    static int pos;
    static String curInput = "";

    String next() throws IOException {
        while... Complexity:
targets: logn
inputs: import java.io.*;
import java.util.StringTokenizer;

public class TaskB {

    void run() {
        FastReader in = new FastReader(System.in);
//        FastReader in = new FastReader(new FileInputStream("input.txt"));
        PrintWriter out = new PrintWriter(System.out);
//        PrintWriter out = new PrintWriter(new FileOutputStream("output.txt"));


        long n = in.nextLong();
        long k = in.nextLong();

        long a = 1;
        long b = -(2 * n + 3);
        long c = n * n + n - 2 * k;

        long d = b * b - 4 * a * c;
        long ans1 = (-b + (long) Math.sqrt(d)) / 2;
        long ans2 = (-b - (long) Math.sqrt(d)) / 2;

        if (ans1 >= 0 && ans1 <= n) {
            out.println(ans1);
        } else {
            out.println(ans2);
        }


        out.close();
    }

    class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

        Long nextLong() {
            return Long.parseLong(next());
        }

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(nextLine());

            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }


    public static void main(String[] args) {
        new TaskB().run();
    }
}
 What is the time complexity of the previous code?
targets: logn
inputs: import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;

public class D {
    static LinkedList<Integer>[] E;
    static int[] M;
    static boolean[] visited;
    static int n;
    static int center;

    public static boolean match(int x) {
        if (visited[x])
            return false;
        visited[x] = true;
        for (int y : E[x])
            if (y != center && (M[y] == -1 || match(M[y]))) {
                M[y] = x;
                return true;
            }
        return false;
    }

    public static int maxMatch() {
        int res = 0;
        Arrays.fill(M, -1);
        for (int i = 0; i < n; i++) {
            Arrays.fill(visited, false);
            if (i != center && match(i))
                res++;
        }
        return res;
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        n = in.readInt();
        int m = in.readInt();
        E = new LinkedList[n];
        M = new int[n];
        boolean[][] C = new boolean[n][n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++)
            E[i] = new LinkedList<Integer>();
        for (int i = 0; i < m; i++) {
            int x = in.readInt() - 1;
            int y = in.readInt() - 1;
            C[x][y] = true;
            E[x].add(y);
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int res = 0;
            int all = 0;
            for (int j = 0; j < n; j++)
                if (j != i) {
                    all += E[j].size();
                    if (!C[i][j])
                        res++;
                    if (!C[j][i])
                        res++;
                    else
                        all--;
                }
            if (!C[i][i])
                res++;
            center = i;
            int match = maxMatch();
            res += (all - match) + (n - match - 1);
            min = Math.min(min,... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: cubic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;
 
 
public class Main {
 
 
	public static void main(String[] args) throws Exception{
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int n = Integer.parseInt(ana.nextToken()) ; 
		
		int t[]= new int[101] ; 
		ArrayList<Integer> v = new ArrayList<>() ; 
		ana = new StringTokenizer(jk.readLine()) ;
		for(int i=0 ; i<n ;i++)
		{
			
			int y = Integer.parseInt(ana.nextToken()) ;
			t[y]=1 ; 
			v.add(y) ; 
		}
		Collections.sort(v);
		int c= 0; 
		for(int ele : v)
		{
			if(t[ele]==1)
			{
				
				for(int i=ele ; i<=100 ; i+=ele)
				{
					t[i]=2 ; 
				}
				c++ ; 
			}
		
		}
		out.println(c);
		
 
 
 
 
 
 
 
 
		out.flush();
	}
} Complexity:
targets: quadratic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Div1_429C {

	static final long MOD = 1_000_000_007;
	static long[] fact = new long[305];
	static long[] iFact = new long[305];
	static final long I304 = 904487323;

	public static void main(String[] args) throws IOException {
		fact[0] = 1;
		for (int i = 1; i < 305; i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		iFact[304] = I304;
		for (int i = 303; i >= 0; i--) {
			iFact[i] = iFact[i + 1] * (i + 1) % MOD;
		}

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int len = Integer.parseInt(reader.readLine());
		long[] groups = new long[len + 1];
		int[] gSizes = new int[len + 1];
		int nG = 0;

		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		iLoop:
		for (int i = 0; i < len; i++) {
			long nxt = Integer.parseInt(inputData.nextToken());
			for (int j = 1; j <= nG; j++) {
				if (isSquare(nxt * groups[j])) {
					gSizes[j]++;
					continue iLoop;
				}
			}
			groups[++nG] = nxt;
			gSizes[nG] = 1;
		}

		long[][] dp = new long[nG + 1][len];

		dp[0][0] = 1;

		int fTotal = 0;
		for (int fG = 0; fG < nG; fG++) {
			for (int fB = 0; fB < len; fB++) {
				if (dp[fG][fB] == 0) {
					continue;
				}
				int nGSize = gSizes[fG + 1];
				for (int nS = 1; nS <= Math.min(nGSize, fTotal + 1); nS++) {
					for (int nBR = 0; nBR <= Math.min(fB, nS); nBR++) {
						long nW = dp[fG][fB] * fact[nGSize] % MOD * comb(nGSize - 1, nS - 1) % MOD * comb(fB, nBR) % MOD
								* comb(fTotal + 1 - fB, nS - nBR) % MOD;
						dp[fG + 1][fB - nBR + nGSize - nS] = (dp[fG + 1][fB - nBR + nGSize - nS] + nW) % MOD;
					}
				}
			}
			fTotal += gSizes[fG + 1];
		}
		printer.println(dp[nG][0]);
		printer.close();
	}

	static long comb(int a, int b)... Complexity:
targets: cubic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
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);
        TaskE2 solver = new TaskE2();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++) {
            solver.solve(i, in, out);
        }
        out.close();
    }

    static class TaskE2 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int[][] a = in.readIntTable(n, m);
            int[][] id = new int[n + 1][1 << n];
            int[][] val = new int[n + 1][1 << n];
            ArrayUtils.fill(id, m);
            int[] sum = new int[1 << n];
            int[] low = new int[1 << n];
            boolean[] base = new boolean[1 << n];
            int[] vv = new int[1 << n];
            for (int i = 1; i < (1 << n); i++) {
                low[i] = Integer.bitCount(Integer.lowestOneBit(i) - 1);
                int current = i;
                base[i] = true;
                vv[i] = i;
                for (int j = 0; j < n; j++) {
                    current = current << 1;
                    current += current >> n;
                    current -= (current >> n) << n;
                    if (current < i) {
                        base[i] = false;
              ... Complexity:
targets: np