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

public class C {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    final int INF = Integer.MAX_VALUE / 2;

    void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();

        if (n > m) {
            int tmp = n;
            n = m;
            m = tmp;
        }
        // n < m !!!!
        // n rows m columns

        if (n == 1) {
            out.print(m - (m + 2) / 3);
            return;
        }

        int[][] dp = new int[n * m + 1][1 << (2 * n)];
        for (int i = 0; i < dp.length; i++)
            Arrays.fill(dp[i], INF);

        dp[0][0] = 0;
        for (int i = 0; i < dp.length - 1; i++) {
            int maxNewMask = (1 << Math.min(2 * n, n * m - i)) - 1;
            for (int mask = 0; mask < dp[i].length; mask++)
                if (dp[i][mask] != INF) {
                    //System.err.println(i + " " + mask + " " + dp[i][mask]);
                    if ((mask & 1) == 1) // already covered, skip
                        dp[i + 1][mask >> 1] = Math.min(dp[i + 1][mask >> 1],
                                dp[i][mask]);
                    // place on this tile
                    int newMask = mask >> 1;
                    if (i % n != n - 1)
                        newMask |= 1;
                    newMask |= 1 << (n - 1);
                    newMask &= maxNewMask;
                    dp[i + 1][newMask] = Math.min(dp[i + 1][newMask],
                            dp[i][mask] + 1);

                    if (i % n != n - 1) {// place on next tile
                        newMask = mask >> 1;
                        newMask |= 1;
                        if (i % n != n - 2)
                            newMask |= 2;
                        newMask |= (1 << n);
                        newMask &= maxNewMask;
                        dp[i + 1][newMask] = Math.min(dp[i + 1][newMask],
                                dp[i][mask] + 1);
                    }

                    // place on... 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.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

    static ArrayList<Integer> cols;
    static int ans, n, a[][];

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int tc = sc.nextInt();
        while (tc-- > 0) {
            ans = 0;
            n = sc.nextInt();
            int m = sc.nextInt();
            boolean[] taken = new boolean[m];
            PriorityQueue<Pair> pq = new PriorityQueue<>();
            a = new int[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++) {
                    int cur = sc.nextInt();
                    pq.add(new Pair(i, j, cur));
                    a[i][j] = cur;
                }
            cols = new ArrayList<>();
            while (!pq.isEmpty() && cols.size() < 8) {
                Pair cur = pq.remove();
                if (!taken[cur.j]) cols.add(cur.j);
                taken[cur.j] = true;
            }
            solve(0,new int [cols.size()]);
            out.println(ans);
        }
        out.flush();
        out.close();
    }

    static void solve(int i, int[] p) {
        if (i == cols.size()) {
            int[] max = new int[n];
            for (int k = 0; k < cols.size(); k++) {
                int j = cols.get(k);
                for (int ii = 0; ii < n; ii++) {
                    int idx = (ii + p[k]) % n;
                    max[idx] = Math.max(max[idx], a[ii][j]);
                }
            }
            int poss = 0;
            for (int x : max)
                poss += x;
            ans = Math.max(ans, poss);
            return;
        }
        for (int j = 0; j < n; j++) {
            p[i] = j;
            solve(i + 1, p);
        }
    }


    static class Pair implements Comparable<Pair> {
        int i, j, val;

        public Pair(int i, int j, int val) {
         ... What is the time complexity of the previous code?
targets: np
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class A {
 
	static double[][] a;
	static int N;
	static double[][] memo;
 
	static double[] dp(int alive)
	{
		int count = Integer.bitCount(alive);
		if(count == 1)
		{
			double[] ret = new double[N];
			for(int i = 0; i < N; ++i)
				if((alive & (1<<i)) != 0)
				{
					ret[i] = 1;
					break;
				}
			return memo[alive] = ret;
		}
		if(memo[alive] != null)
			return memo[alive];
		
		double[] ret = new double[N];
		for(int j = 0; j < N; ++j)
			if((alive & (1<<j)) != 0)
			{
				double[] nxt = dp(alive & ~(1<<j));
				for(int i = 0; i < N; ++i)
					ret[i] += die[j][alive] * nxt[i];			
			}
		return memo[alive] = ret;
	}
 
	static double[][] die;
	static void f()
	{
		die = new double[N][1<<N];
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < 1<<N; ++j)
			{
				int count = Integer.bitCount(j);
				if(count <= 1)
					continue;
				double prop = 1.0 / (count * (count - 1) >> 1);
				for(int k = 0; k < N; ++k)
					if((j & (1<<k)) != 0)
						die[i][j] += prop * a[k][i]; 
			}
 
	}
 
	public static void main(String[] args) throws IOException {
 
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
 
		N = sc.nextInt();
		
		a = new double[N][N];
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j)
				a[i][j] = sc.nextDouble();
		memo = new double[1<<N][];
		
		f();
		
		double[] ret = dp((1<<N) - 1);
		for(int i = 0; i < N - 1; ++i)
			out.printf("%.8f ",ret[i]);
		out.printf("%.8f\n", ret[N-1]);
 
		out.flush();
		out.close();
	}
 
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

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

		public double... 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.*;
import java.util.*;

import static java.lang.Math.*;

public class A {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int vis[] = new int[n];
        Arrays.fill(vis, -1);
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (vis[i] != -1) continue;
            c++;
            for (int j = i; j < n; j++) {
                if (vis[j] == -1 && a[j] % a[i] == 0) {
                    vis[j] = c;
                }
            }
        }
        
        pw.println(c);

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
} 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: 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 E implements Runnable {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int t = scn.nextInt();
		while(t-- > 0) {
			int n = scn.nextInt(), m = scn.nextInt();
			int[][] arr = scn.next2DInt(n, m);
			
			int[][] col = new int[m][2];
			for(int j = 0; j < m; j++) {
				int max = 0;
				for(int i = 0; i < n; i++) {
					max = Math.max(max, arr[i][j]);
				}
				col[j][0] = max;
				col[j][1] = j;
			}
			Arrays.parallelSort(col, (o1, o2) -> o2[0] - o1[0]);
			
			int take = Math.min(n, m);
			
			int[][] lol = new int[n][take];
			for(int j = 0; j < take; j++) {
				for(int i = 0; i < n; i++) {
					lol[i][j] = arr[i][col[j][1]];
				}
			}
			
			ans = 0;
			func(lol, 0);
			out.println(ans);
		}
	}
	
	int ans = 0;
	
	void func(int[][] arr, int col) {
		int n = arr.length, m = arr[0].length;
		if(col == m) {
			int rv = 0;
			for(int i = 0; i < n; i++) {
				int mx = 0;
				for(int j = 0; j < m; j++) {
					mx = Math.max(mx, arr[i][j]);
				}
				rv += mx; 
			}
			ans = Math.max(ans, rv);
			return;
		}
		
		for(int rot = 0; rot < n; rot++) {
			int f = arr[0][col];
			for(int j = 1; j < n; j++) {
				arr[j - 1][col] = arr[j][col];
			}
			arr[n - 1][col] = f;
			func(arr, col + 1);
		}
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

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

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new... Complexity:
targets: np
inputs: //Educational Codeforces Round 34
import java.io.*;
import java.util.*;
import java.math.*;

public class TaskD {

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

        int n = fs.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = fs.nextInt();
        }
        
        HashMap<Integer,Integer> h = new HashMap<Integer,Integer>(n);

        BigInteger s = new BigInteger(""+a[0]);
        BigInteger x = new BigInteger("0");
        h.put(a[0], 1);
        for (int i = 1; i < n; i++) {                        
            x = x.add(new BigInteger(""+(((long)i)*((long)a[i]))));
            x = x.subtract(s);
            s = s.add(new BigInteger(""+a[i]));
            Integer q = null;
            q = h.get(a[i]-1);            
            if (q != null) {
                x = x.subtract(new BigInteger(""+q));
            }
            q = h.get(a[i]+1);            
            if (q != null) {
                x = x.add(new BigInteger(""+q));
            }
            q = h.get(a[i]);            
            if (q != null) {
                h.put(a[i], q + 1);
            } else {
                h.put(a[i], 1);
            }
        }

        pw.println(x);

        pw.close();
    }

    static class FastScanner {
        BufferedReader reader;
        StringTokenizer tokenizer;
        FastScanner(InputStream i) {
            reader = new BufferedReader(new InputStreamReader(i));
            tokenizer = new StringTokenizer("");
        }
        String next() throws IOException {
            while(!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException {
            return Long.parseLong(next());
     ... What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C {

    static int MOD = 1_000_000_007;

    public static void main(String[] args) {

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

        int n = in.nextInt();
        char prev = ' ';

        // index, maxNumOfIntents -> count
        int[][] dp = new int[n+1][n+2];

        dp[0][0] = 1;
        for(int i=0;i<n;++i){
            char ch = in.next().charAt(0);
            if(prev == 's'){
                int sum = 0;
                for(int j=n;j>=0;--j){
                    sum = (sum + dp[i-1][j]) % MOD;
                    dp[i][j] = sum;
                }
            }else if(prev == 'f'){
                for(int j=0;j<n;++j){
                    dp[i][j+1] = dp[i-1][j];
                }
            }

            prev = ch;
        }

        int result = 0;
        for(int i=0;i<=n;++i){
            result = (result + dp[n-1][i]) % MOD;
        }


        out.println(result);
        out.close();

    }


    // -----------MyScanner class for faster input----------
    public 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() {
           ... 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.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;

public class D {

    int[][] fast(int n, int m){

        int[][] ans = new int[2][n * m];
        int c = 0;

        for (int left = 1, right = m; left < right; left++, right--) {
            for (int l = 1, r = n; l <= n && r >= 1; l++, r--) {
                ans[0][c] = l;
                ans[1][c++] = left;

                ans[0][c] = r;
                ans[1][c++] = right;
            }
        }

        if (m % 2 == 1) {
            int x = m/2 + 1;
            for(int l = 1, r = n;l < r;l++, r--){
                ans[0][c] = l;
                ans[1][c++] = x;

                ans[0][c] = r;
                ans[1][c++] = x;
                    if(n % 2 == 1 && l + 2 == r){
                        ans[0][c] = l+1;
                        ans[1][c++] = x;
                    }
            }
        }

        if(n == 1 && m % 2 == 1){
            ans[0][c] = 1;
            ans[1][c] = m/2 + 1;
        }

        return ans;
    }

    void stress(){

        for(int i = 3;i<=5;i++){
            for(int j = 2;j<=5;j++){
                int[][] ans = new int[2][];
                try{
                    ans = fast(i, j);
                }catch(Exception e){
                    out.println("ошибка");
                    out.print(i + " " + j);
                    return;
                }

                boolean[][] check = new boolean[i][j];
                for(int c = 0;c<ans[0].length;c++){
                    int x = ans[0][c] - 1;
                    int y = ans[1][c] - 1;
                    check[x][y] = true;
                }

                for(int c = 0;c<i;c++){
                    for(int q = 0;q<j;q++){
                        if(!check[c][q]){
                            out.println(i + " " + j);
                            out.println("точки");
                            for(int w = 0;w<ans[0].length;w++){
 ... 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.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        long r,l;
          r = sc.nextLong();
          l = sc.nextLong();


            if ((r+2)>l) { System.out.print("-1"); return;}
            if ((r % 2) == 0)   {
              System.out.print(r);
                System.out.print(" ");
                System.out.print(r+1);
                System.out.print(" ");
                System.out.print(r+2);return; }
               if((r+3)<=l )
                {  System.out.print(r+1);
                System.out.print(" ");
                  System.out.print(r+2);
                System.out.print(" ");
                  System.out.print(r+3);return; }
             System.out.print("-1");


    }
}
 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: import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
public static void main(String args[]) throws Exception
    {
     
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     int n=Integer.parseInt(br.readLine());
     System.out.println("0 0 "+n);}

}

 What is the time complexity of the previous code?
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.*;
import java.util.*;
 
/**
 * A simple template for competitive programming problems.
 */
public class Solution {
    //InputReader in = new InputReader("input.txt");
    final InputReader in = new InputReader(System.in);
 
    final PrintWriter out = new PrintWriter(System.out);

    int n,m;

    void solve() {
        n = in.nextInt();
        m = in.nextInt();
        int k = in.nextInt();

        int[][] hor = new int[n][m-1];
        int[][] ver = new int[n-1][m];

        for(int i=0; i<n; i++) {
            for(int j=0; j<m-1; j++) {
                hor[i][j] = in.nextInt(); //hor[i][j]=mat[i][j] -> mat[i][j+1]
            }
        }

        for(int i=0; i<n-1; i++) {
            for(int j=0; j<m; j++) {
                ver[i][j] = in.nextInt(); //ver[i][j]= mat[i][j] -> mat[i+1][j]
            }
        }

        int[][] ans = new int[n][m];

        if(k%2==1) {
            for(int i=0; i<n; i++)
                Arrays.fill(ans[i], -1);
        } else {
            for(int dummy=0; dummy<k>>1; dummy++) {
                int[][] newAns = new int[n][m];
                for(int i=0; i<n; i++) {
                    Arrays.fill(newAns[i], Integer.MAX_VALUE);
                    for(int j=0; j<m; j++) {
                        if(isGood(i+1, j)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*ver[i][j] + ans[i+1][j]);
                        }
                        if(isGood(i, j+1)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*hor[i][j] + ans[i][j+1]);
                        }
                        if(isGood(i, j-1)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*hor[i][j-1] + ans[i][j-1]);
                        }
                        if(isGood(i-1, j)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*ver[i-1][j] + ans[i-1][j]);
                        }
                    }
                }
                ans = newAns;
            }
        }

        for(int i=0; i<n; i++) {
    ... Complexity:
targets: cubic
inputs: import java.io.*;
import java.util.*;

public class trafficerules {
 	
 	public static void main(String[] args) throws Exception {
 		if ("Satayev".equals(System.getProperty("user.name"))) {
			long start = System.nanoTime();
			new trafficerules().solve(new FileInputStream("input"));
			System.err.printf("Time elapsed: %d ms.\n", (System.nanoTime()-start)/1000000);
		}
		else
			new trafficerules().solve(System.in);
 	}

 	void solve(InputStream is) throws Exception {
		Scanner in = new Scanner(is);
		
		double a = in.nextDouble(), maxv = in.nextDouble(), s = in.nextDouble(), d = in.nextDouble(), w = in.nextDouble();
		
		if (maxv < w)
			w = maxv;
		
		double t = 0;
		
		// v = at
		// s = att/2
		double t1 = w / a;
		double s1 = a*t1*t1/2;
		double v1 = w;
		if ( s1 < d ) {
			v1 = w;
			
			if (v1 >= maxv)
				t1 += (d-s1)/v1;
			else {
				double tt = (maxv - v1)/a;
				double ss = v1*tt+a*tt*tt/2;
				ss *= 2;
				if (s1 + ss < d)
					t1 += tt*2 + (d-s1-ss)/maxv;
				else {
					ss = (d-s1)/2;
					// ss = v1*t + a*t*t/2;
					double A = a/2;
					double B = v1;
					double C = -ss;
					double D = B*B - 4 * A * C;
					tt = (-B + Math.sqrt(D))/2/A;
					t1 += tt*2;
				}
			}
			
			s1 = d;
		}
		if (s1 > d) {
			s1 = d;
			t1 = Math.sqrt(2*s1/a);
			v1 = a * t1;
		}
		
		t += t1;
		
		double t2 = (maxv - v1) / a;
		double s2 = v1*t2 + a*t2*t2/2;
		double v2 = maxv;
		if (s1 + s2 < s) {
			v2 = maxv;
			t2 += (s-s1-s2)/v2;
		}
		if (s1 + s2 > s) {
			s -= s1;
			// v = v1 + a*t
			// s = v1*t + a*t*t/2
			double A = a/2;
			double B = v1;
			double C = -s;
			double D = B*B - 4*A*C;
			
			t2 = (-B + Math.sqrt(D))/2/A;
		}
		
		t += t2;
		
		System.out.println(t);
 	}

} What is the time complexity of the previous code?
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.*;
import java.util.*;

public class C138B
{

    private static StringTokenizer st;
    
    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }
    
    public static int nextInt()
    {
        return Integer.parseInt(st.nextToken());
    }
    
    public static String next()
    {
        return st.nextToken();
    }
    
    public static long nextLong()
    {
        return Long.parseLong(st.nextToken());
    }
    /**
     * @param args
     */
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];
        nextLine(br);
        for (int i = 0; i < n; i++) a[i] = nextInt();
        
        int bp = 0, fp = 0, count = 0;
        boolean good = false;
        int[] mark = new int[100001];
        for (fp = 0; fp < n; fp++)
        {
            if (mark[a[fp]] == 0)
            {
                count++;
            }
            mark[a[fp]]++;
            if (count == k)
            {
                good = true;
                break;
            }
        }
        if (!good)
        {
            System.out.println("-1 -1");
            return;
        }
        for (bp = 0; bp < fp; bp++)
        {
            if (mark[a[bp]] > 1)
            {
                mark[a[bp]]--;
            }
            else break;
        }
        System.out.println((bp+1) + " " + (fp+1));
    }
    
}
 Complexity:
targets: linear
inputs: // CodeForces Round #914 B train done

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SportMafia {
	
	int n,k;
	int nCand;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String []ss = s.split(" ");
		n = Integer.parseInt(ss[0]);
		k = Integer.parseInt(ss[1]);
	}

	void printRes() {
		System.out.println(nCand);
	}	
	
	private void calculate() {
		// count napitki
		double p;
		p = -1.5 + Math.sqrt(2.25 + 2.0*(n+k));
		nCand = (int)Math.round(n-p);
	}
	
	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(
				new InputStreamReader(System.in));
		SportMafia l = new SportMafia();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}
 What is the time complexity of the previous code?
targets: logn
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.lang.*;
public class CF1003E{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int d = Integer.parseInt(s[1]);
        int k = Integer.parseInt(s[2]);
        StringBuffer sb = new StringBuffer();
        int[] rem = new int[n];
        int[] deg = new int[n];
        int i = 0;
        if(k == 1){
            if(n <= 2){

            }else{
                System.out.println("NO");
                return;
            }
        }
        for(i=0;i<d;i++){
            if(i>=n-1){
                System.out.println("NO");
                return;
            }
            sb.append((i+1) +" " + (i+2)+"\n");
            rem[i] = Math.min(i, d-i);
            deg[i]++;
            if(i+1<n)
            deg[i+1]++;
        }
        if(i<n){
            rem[i] = 0;
            deg[i] = 1;
        }
        i++;
        int j  = 0;
        for(;i<n;i++){
            //For all remaining Nodes
            while(true){
                if(j>=n){
                    System.out.println("NO");
                    return;
                }
                if(rem[j] > 0 && deg[j]<k){
                    deg[j]++;
                    rem[i] = rem[j] - 1;
                    sb.append((j+1)+" "+(i+1)+"\n");
                    deg[i]++;
                    break;
                }else{
                    j++;
                }
            }
        }
        System.out.println("YES");
        System.out.println(sb);
    }
}
 Complexity:
targets: quadratic
inputs: import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;


public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        int[] vertical = new int[n];

        for (int i = 0; i < n; i++) {
            vertical[i] = scanner.nextInt();
        }

        Arrays.sort(vertical);


        ArrayList<Integer> horisontal = new ArrayList<>();
        int amount = 0;
        for (int i = 0; i < m; i++) {
            int x1 = scanner.nextInt(), x2 = scanner.nextInt(), y = scanner.nextInt();
            if (x1 == 1) {
                amount++;
                horisontal.add(x2);
            }
        }

        Collections.sort(horisontal);


        if (amount == 0) {
            System.out.println(0);
            return;
        }


        int minVal = amount, horSize = horisontal.size(), verLen = vertical.length;
        int h = 0, v = 0;

        for (; v < verLen && h < horSize; ) {

           while (h < horSize && horisontal.get(h) < vertical[v]){
               h++;
               amount--;
           }
           minVal = Math.min(minVal, amount + v);

            while (h < horSize && v < verLen && horisontal.get(h) >= vertical[v]){
                minVal = Math.min(minVal, amount + v);
                v++;
            }

        }

        if(horisontal.get(horSize - 1) < 1E9){
            minVal = Math.min(minVal, v);
        }



        System.out.println(minVal);

    }
}
 What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream;
		try {
			inputStream = new FileInputStream("input.txt");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		OutputStream outputStream;
		try {
			outputStream = new FileOutputStream("output.txt");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
	    int maxdist = -1, maxrow = -1, maxcol = -1;
	    int rows = in.ri(), cols = in.ri();
	    int k = in.ri();
	    IntPair[] points = new IntPair[k];
	    for(int i = 0; i < k; i++) points[i] = new IntPair(in.ri(), in.ri());
	    for(int row = 1; row <= rows; row++) {
		    for(int col = 1; col <= cols; col++) {
			    int mindist = Integer.MAX_VALUE;
			    for(int i = 0; i < k; i++)
				    mindist = Math.min(mindist, Math.abs(row - points[i].first) + Math.abs(col - points[i].second));
			    if (mindist > maxdist){
				    maxdist = mindist;
				    maxrow = row;
				    maxcol = col;
			    }
		    }
	    }
	    out.printLine(maxrow, maxcol);
    }
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

	public int read() {
		if (numChars... What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;

public class Task267A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Scanner {

		private final BufferedReader br;
		private String[] cache;
		private int cacheIndex;

		Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			cache = new String[0];
			cacheIndex = 0;
		}

		int nextInt() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Integer.parseInt(cache[cacheIndex++]);
		}

		String next() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return cache[cacheIndex++];
		}

		void close() throws IOException {
			br.close();
		}

	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			int n = sc.nextInt();

			while (n-- > 0) {
				int ai = sc.nextInt();
				int bi = sc.nextInt();
				int retVal = 0;

				while (ai > 0 && bi > 0) {
					if (ai > bi) {
						retVal += ai / bi;
						ai = ai % bi;
					} else {
						retVal += bi / ai;
						bi = bi % ai;
					}
				}
				pw.println(retVal);
			}

			pw.flush();
			sc.close();
		}
	}

} What is the time complexity of the previous code?
targets: constant
inputs: import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.IOException;
import java.util.StringTokenizer;
/*
 * @author Tnascimento 
 */

public class MaeDosDragoes {
	// public static StringTokenizer tokenizer;
	// public static BufferedReader reader;
	public static PrintWriter saida = new PrintWriter(System.out, false);
	// public static String proximo() {
	// 	while (tokenizer == null || !tokenizer.hasMoreElements()) {
	// 		try {
	// 			tokenizer = new StringTokenizer(reader.readLine());
	// 		} catch (RuntimeException e) {
	// 			e.printStackTrace();
	// 		}
	// 	}
	// 	return tokenizer.nextToken();
	// }

	public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(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());
        }
    }



    public static void main(String[] args) {
		FastScanner fastScanner = new FastScanner();
        int proximoInt = fastScanner.nextInt();
        double proximoDouble = fastScanner.nextInt();
        long[] graph = new long[proximoInt];
        for(Integer i = 0; i < proximoInt; i++) {
            for(Integer j =0; j < proximoInt; j++) {
                Integer val = fastScanner.nextInt();
                if (val.equals(1) || i.equals(j)) {
				 graph[i] |= 1L << j;
				}
            }
        }

        int szLeft = proximoInt/2;
        int szRight = proximoInt - szLeft;

        int[] dp = new int[1 << szLeft];
      ... 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: 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.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class C489 {
        int mod = 1000000007;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long x = in.scanLong();
            long k = in.scanLong();
            if (x == 0) {
                out.println(0);
                return;
            }
            long p = CodeX.power(2, k, mod);
            long ans = (2 * p * (x % mod)) % mod;
            ans = (ans + 1) % mod;
            ans = (ans - p + mod) % mod;
            out.println(ans);
        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                 ... Complexity:
targets: logn
inputs: import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class G extends PrintWriter {

    void run() {
        long mod = 1_000_000_000 + 7;
        int n = nextInt();
        int m = nextInt();

        int[] t = new int[n];
        int[] g = new int[n];

        for (int i = 0; i < n; i++) {
            t[i] = nextInt();
            g[i] = nextInt() - 1;
        }

        int k = 1 << n;

        long[][] dp = new long[k][n];

        for (int i = 0; i < n; i++) {
            dp[1 << i][i] = 1;
        }

        for (int mask = 0; mask < k; mask++) {
            if (Integer.bitCount(mask) <= 1) {
                continue;
            }

            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) != 0) {
                    for (int j = 0; j < n; j++) {
                        if ((mask & (1 << j)) == 0 || g[i] == g[j]) {
                            continue;
                        }
                        dp[mask][i] = (dp[mask][i] + dp[mask ^ (1 << i)][j]) % mod;
                    }
                }
            }
        }

        long ans = 0;
        for (int mask = 0; mask < k; mask++) {
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) != 0) {
                    sum += t[i];
                }
            }
            if (sum == m) {

                for (int i = 0; i < n; i++) {
                    if ((mask & (1 << i)) != 0) {
                        ans = (ans + dp[mask][i]) % mod;
                    }
                }

            }

        }

        println(ans);

    }

    boolean skip() {
        while (hasNext()) {
            next();
        }
        return true;
    }

    int[][] nextMatrix(int n, int m) {
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                matrix[i][j] = nextInt();
        return matrix;
    }

    String next() {
        while... What is the time complexity of the previous code?
targets: np
inputs: import java.io.*;
import java.util.*;

public class first
{
	int max(int a1,int a2,int a3)
	{
		int max=a1;
		if(a2>=max)
			max=a2;
		if(a3>=max)
			max = a3;
		return max;	
	}
	
	public static void main(String[] args)
	{
		int num=0;
		
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		int num2 = num/10;
		int num3 = num%10;
		int num4 = (num2/10)*10+num3;
		first fs = new first();
		int result = fs.max(num,num2,num4);
		System.out.println(result);
	}
}	
 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: import java.io.*;
import java.util.*;

public class Solution {
	
	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	static class House implements Comparable<House> {
		int x, a;

		@Override
		public int compareTo(House o) {
			return x - o.x;
		}

		public House(int x, int a) {
			this.x = x;
			this.a = a;
		}
	}
	
	void solve() throws IOException {
		int n = nextInt();
		int t = nextInt();
		House[] hs = new House[n];
		for (int i = 0; i < n; ++i) {
			hs[i] = new House(nextInt(), nextInt());
		}
		Arrays.sort(hs);
		int ans = 2;
		for (int i = 0; i < n - 1; ++i) {
			if (hs[i].a + hs[i + 1].a + 2 * t < 2 * (hs[i + 1].x - hs[i].x)) {
				ans += 2;
			} else if (hs[i].a + hs[i + 1].a + 2 * t == 2 * (hs[i + 1].x - hs[i].x)) {
				ans++;
			}
		}
		out.println(ans);
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		eat("");
		
		solve();
		
		in.close();
		out.close();
	}
	
	private void eat(String str) {
		st = new StringTokenizer(str);
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) throws IOException {
		new Solution();
	}
}
 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.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class e_g14 {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		FastScanner in = new FastScanner(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		
		int T = 1;
		Solver A = new Solver(in, out); 
		
		for(int aa = 0; aa < T; aa++) {
			A.answer(aa + 1);
		}
		
		
		out.close();
	}
	
	static class Solver {
		FastScanner in;
		PrintWriter out;
		
		int n;
		long m;
		
		long [] fact, pow, choose [], dp[];

		public Solver(FastScanner in, PrintWriter out) {
			this.in = in;
			this.out = out;
		}
		
		public void answer(int aa) throws Exception {
			n = in.nextInt();
			m = in.nextLong();
			
			fact = new long [n+5];
			choose = new long [n+5][n+5];
			dp = new long [n+2][n+2];
			pow = new long [n+2];
			
			init();
			
			dp[0][0] = 1;
			for(int i = 0; i <= n; i++) {
				for(int j = 0; j <= i; j++) {
					for(int k = 1; i+k <= n; k++) {
						dp[i+k+1][j+k] += (dp[i][j]*choose[j+k][k]%m)*pow[k-1];
						dp[i+k+1][j+k] %= m;
					}	
				}
			}
			
			
			long ans = 0;
			for(int i = 0; i <= n; i++) {
				ans += dp[n+1][i];
				ans %= m;
			}
			
			out.println(ans);
		}
		
		public void init() {
			fact[0] = 1;
			for(int i = 1; i <= n+4; i++) {
				fact[i] = (i*fact[i-1])%m;
			}
			
			pow[0] = 1;
			for(int i = 1; i <= n+1; i++) {
				pow[i] = (2*pow[i-1])%m;
			}
			
			for(int i = 0; i <= n+4; i++) {
				for(int j = 0; j <= i; j++) {
					choose[i][j] = choose(i, j);
				}
			}
		}
		
		private long choose(int a, int b) {
			long res = (fact[a] * inv((fact[b] * fact[a-b])%m))%m;
			return res;
		}
		
		private long power (long x, long y) {
			long res = 1;
			while(y > 0) {
				if(y%2 == 1) res = (res*x)%m;
				x = (x*x)%m;
				y /= 2;
			}
			return... 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: import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.io.*;

public class Main {
    boolean[] b;
    int[] r;
    ArrayList<ArrayList<Integer>> q;

    public void dfs(int u, int p) {
        for (int i = 0; i < q.get(u).size(); i++) {
            int v = q.get(u).get(i);
            if (v != p) {
                r[v] = r[u] + 1;
                if (b[u]) {
                    b[v] = b[u];
                }
                dfs(v, u);
            }
        }
    }

    public void solve() throws IOException {
        long n = nextLong();
        long s = nextLong();
        long t = 0;
        if(s + 200 < n){
            t = n - s - 200;
        }
        for(long i = s; i <= Math.min(s + 200,n); i++){
            long p = 0;
            long u = i;
            while (u > 0){
                p += u % 10;
                u /= 10;
            }
            if(i - p >= s){
                t++;
            }
        }
        out.print(t);
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

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

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

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception e) {
        }
        new Main().run();
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("lesson.in"));
//            out = new PrintWriter(new... 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: 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 Solution {
    static class Data{
        int x,i;
        Data(int x,int i){
            this.x = x;
            this.i = i;
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        int N = Integer.parseInt(s[0]);
        int K = Integer.parseInt(s[1]);
        s = br.readLine().split("\\s");
        int[] arr = new int[N];
        for(int i=0;i<N;++i) arr[i] = Integer.parseInt(s[i]);
        solve(N,K,arr);   
    }
    
    private static void solve(int N,int K,int[] arr){
       PriorityQueue<Data> pq = new PriorityQueue<Data>(2000,(a,b) -> a.x - b.x == 0 ? b.i - a.i : b.x - a.x);
       for(int i=0;i<arr.length;++i){
           pq.offer(new Data(arr[i],i));
       }
       
       int tot_sum = 0;
       List<Integer> ls = new ArrayList<>();
       Set<Integer> set = new HashSet<>();
       
       for(int i=1;i<=K;++i){
           Data t = pq.poll();
           tot_sum += t.x;
           set.add(t.i);
       }
       int last = -1;
       for(int i =0;i<arr.length;++i){
           if(set.contains(i)){
               K--;
               //System.out.println(i);
               if(K == 0) ls.add(arr.length-last-1);
               else ls.add(i-last);
               last = i;
           }
       }
       
       System.out.println(tot_sum);
       int size = ls.size();
       for(int i=0;i<size;++i){
           System.out.print(ls.get(i) + " ");
       }
    }
} Complexity:
targets: nlogn
inputs: //package Round584;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class typeA {
	public static void main(String[] args) {
		FastReader s = new FastReader();
		int n = s.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=s.nextInt();
		}
		boolean[] arr2  = new boolean[n];
		Arrays.sort(arr);
		for(int i=0;i<arr2.length;i++) {
			arr2[i]=true;
		}
		//arr2[0]=true;
		for(int i=0;i<n-1;i++) {
			for(int j=i+1;j<n;j++) {
					if(arr[j]%arr[i]==0) {
						arr2[j]=false;
					}
				}
			}
		int count=0;
		for(int i=0;i<n;i++) {
			if(arr2[i]==true) {
				count++;
			}
		}
		System.out.println(count);
	}
	static class FastReader 
	
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            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; 
        } 
    } 
	
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: quadratic