Muennighoff/xP3x-sample huggingface dataset:
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;

/**
 * 2013.07.27 No.1 235A LCM Challenge
 * 数论 n%2 == 0?     n%3 == 0?
 * @author Administrator * 
 */

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        if (n < 3)
            System.out.println(n);
        else if (n % 2 != 0)
            System.out.println((long)n * (n - 1) * (n - 2));
        else if(n % 3 != 0)
            System.out.println((long)n * (n - 1) * (n - 3));
        else 
            System.out.println((long)(n - 1) * (n - 2) * (n - 3));
        in.close();
        

    }
}  Complexity:
targets: constant
inputs: import java.io.*;
import java.util.*;
import java.math.*;

public class Main  {
    
    Scanner in;
    PrintWriter out;
    
    static class House implements Comparable <House>{
        int len;
        int pos;
        
        House(Scanner in){
            pos = in.nextInt() * 2;
            len = in.nextInt() * 2;         
        }
        
        public int compareTo(House arg0) {
            return this.pos-arg0.pos;
        }
        
    }
            
    void solve(){
        int n = in.nextInt();
        int size = in.nextInt();
        House []h = new House[n];
        for (int i = 0; i < h.length; i++){
            h[i] = new House(in);
        }
        Arrays.sort(h);
        int ans = 2;
        for (int i = 0; i < h.length - 1; i++){
            int next = i + 1;
            int sz = h[next].pos - h[i].pos - (h[next].len + h[i].len) / 2;
            if (sz == size * 2) {
                ans ++;
            } else if (sz > size * 2) {
                ans += 2;
            }
        }
        out.println(ans);
    }
    
    public void run(){
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        
        try {
            solve();
        } finally {
            out.close();
        }
    }
    
    void asserT(boolean e){
        if (!e){
            throw new Error();
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
} What is the time complexity of the previous code?
targets: nlogn
inputs: import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
    void solve() {
        int n=ni(),m=ni();
        int a[][]=new int[n+1][m+1];
        for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=ni();

        if(n==1){
            int mn=Integer.MAX_VALUE;
            for(int i=1;i<m;i++) mn=Math.min(mn,Math.abs(a[1][i]-a[1][i+1]));
            pw.println(mn) ;
            return ;
        }
        mn1=new int[n+1][n+1];
        mn2=new int[n+1][n+1];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){

                if(i==j) continue;

                mn1[i][j]=mn2[i][j]=Integer.MAX_VALUE;
                for(int k=1;k<=m;k++){
                    mn1[i][j]=Math.min(mn1[i][j],Math.abs(a[i][k]-a[j][k]));
                   // if(i==3 && j==4) pw.println(a[i][k]+" "+a[j][k]);
                }
                for(int k=1;k<m;k++){
                    mn2[i][j]=Math.min(mn2[i][j],Math.abs(a[i][k+1]-a[j][k]));
                }
                //if(m==1) mn2[i][j]=0;

            }
        }
      //  pw.println(mn1[3][4]);
        dp=new int[17][1<<16][17];
        for(int i=1;i<17;i++) for(int j=0;j<(1<<16);j++) Arrays.fill(dp[i][j],-1);

        int ans=0;
        for(int i=1;i<=n;i++){
            ans=Math.max(ans,go(2,1<<(i-1),i,i,n));
        }
        pw.println(ans);

    }
    int mn1[][],mn2[][];
    int dp[][][];
    int go(int i,int mask,int prev,int first,int n){
        if(i>n){
       //   if(mn2[first][prev]==0)  pw.println(prev+" "+first+" "+mn2[first][prev]);
            return mn2[first][prev];
        }
       if(dp[first][mask][prev]!=-1) return dp[first][mask][prev];
        int cc=0;
        for(int k=1;k<=n;k++){
            if((mask&(1<<(k-1)))==0){
                cc=Math.max(cc,Math.min(mn1[prev][k],go(i+1,mask|(1<<(k-1)),k,first,n)));
               //if(mn1[prev][k]==0)  pw.println(mn1[prev][k]+" "+prev+" "+k);
            }
        }
        dp[first][mask][prev]=cc;
        return cc;
    }



    long M= (long)1e9+7;
... What is the time complexity of the previous code?
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.BufferedReader;
import java.io.InputStreamReader;


public class Main {

    
    public static void main(String[] args)throws java.lang.Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String s = br.readLine();
     int max = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i+1; j < s.length(); j++) {
                if(s.substring(i+1).contains(s.substring(i,j)))
                    max = Math.max(max, j-i);

            }}
            System.out.println(max);



    
    }

}
 Complexity:
targets: cubic
inputs: import java.io.*;
import java.util.*;

public class a{
    static BufferedReader br;
    static PrintWriter pw;
    static int N, M, K;
    static ArrayList<Integer> graph[][];
    public static void main(String args[]) throws IOException{
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken());
        M = Integer.parseInt(st.nextToken());
        K = Integer.parseInt(st.nextToken());
        if(K % 2 == 1){
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    pw.print("-1 ");
                }
                pw.println();
            }
            br.close(); pw.close();
            return;
        }
        graph = new ArrayList[N][M];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                graph[i][j] = new ArrayList<Integer>();
            }
        }
        for(int i = 0; i < N; i++){
            st = new StringTokenizer(br.readLine());
            for(int j = 0; j < M-1; j++){
                int w = Integer.parseInt(st.nextToken());
                graph[i][j].add(w);
            }
        }
        for(int i = 0; i < N; i++){
            graph[i][M-1].add(0);
        }
        for(int i = 0; i < N-1; i++){
            st = new StringTokenizer(br.readLine());
            for(int j = 0; j < M; j++){
                int w = Integer.parseInt(st.nextToken());
                graph[i][j].add(w);
            }
        }
        K /= 2;
        for(int i = 0; i < M; i++) graph[N-1][i].add(0);
        long ans[][][] = new long[K+1][N][M];
        for(int i = 0; i < N; i++){
            Arrays.fill(ans[0][i], 0);
        }
        for(int i = 1; i <= K; i++){
            for(int x = 0; x < N; x++){
                for(int y = 0; y < M; y++){
                    long cur = (long)1e17;
                    if(x < N-1){
                        cur =... 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. import java.io.*;
import java.util.*;

public final class PythonIndentation
{
	public static void main(String[] args)
	{
		new PythonIndentation(System.in, System.out);
	}

	static class Solver implements Runnable
	{
		static final int MOD = (int) 1e9 + 7;
		int n;
		char[] arr;
		long[][] dp;
		BufferedReader in;
		PrintWriter out;

		void solve() throws IOException
		{
			n = Integer.parseInt(in.readLine());
			arr = new char[n];
			dp = new long[n + 1][n + 1];

			for (int i = 0; i < n; i++)
				arr[i] = in.readLine().charAt(0);

			for (int i = 0; i <= n; i++)
				Arrays.fill(dp[i], -1);

			dp[0][0] = 1;

			if (arr[0] == 's')
				out.println(find(1, 0));
			else
				out.println(find(1, 1));
		}

		long find(int curr, int backIndents)
		{
			if (backIndents < 0)
				return 0;

			if (curr == n)
				return 1;

			if (dp[curr][backIndents] != -1)
				return dp[curr][backIndents];

			long ans;

			if (arr[curr] == 's')
				ans = find(curr + 1, backIndents);
			else
				ans = find(curr + 1, backIndents + 1);

			if (arr[curr - 1] != 'f')
				ans = CMath.mod(ans + find(curr, backIndents - 1), MOD);

			return dp[curr][backIndents] = ans;
		}

		public Solver(BufferedReader in, PrintWriter out)
		{
			this.in = in;
			this.out = out;
		}

		@Override public void run()
		{
			try
			{
				solve();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	static class CMath
	{
		static long mod(long number, long mod)
		{
			return number - (number / mod) * mod;
		}

	}

	private PythonIndentation(InputStream inputStream, OutputStream outputStream)
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
		PrintWriter out = new PrintWriter(outputStream);
		Thread thread = new Thread(null, new Solver(in, out), "PythonIndentation", 1 << 29);

		try
		{
			thread.start();
			thread.join();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				in.close();
			}
			catch (IOException... 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.util.Scanner;

public class A015 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), t = in.nextInt();
		int[] centers = new int[n], sides = new int[n];
		for (int x = 0; x < n; x++) {
			centers[x] = in.nextInt();
			sides[x] = in.nextInt();
		}
		int count = 0;

		big: for (int x = -4000; x <= 4000; x++) {
			boolean touch = false;
			for (int i = 0; i < n; i++) {
				int d = 2*centers[i] - x;
				d = d > 0 ? d : -d;
				int s = t + sides[i];
				if (s == d) {
					touch = true;
				} else if (s > d) {
					continue big;
				}
			}
			if (touch)
				count++;
		}
		System.out.println(count);
	}
}
 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.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

	final static int mod = 1_000_000_007;

	public static void main(String[] args) throws Exception {

		STDIN scan = new STDIN();
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = scan.nextInt();
		boolean even = true;
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			for(int j = 0; j < i; j++)
				if(a[i] < a[j]) even = !even;
		}
		int q = scan.nextInt();
		while(q-- > 0) {
			int l = scan.nextInt(), r = scan.nextInt();
			int len = r - l + 1;
			int permutations = len * (len - 1) / 2;
			if(permutations % 2 != 0) even = !even;
			pw.println(even ? "even" : "odd");
		}
		
		pw.flush();
	}
		
	static class STDIN {
		BufferedReader br;
		StringTokenizer st;

		public STDIN() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}

		boolean hasNext() throws Exception {
			if (!st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.hasMoreTokens();
		}

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

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

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

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

		String nextLine() throws Exception {
			return br.readLine();
		}
	}
} Complexity:
targets: quadratic
inputs: /*(c) gorlum0 [at] gmail.com*/
import java.io.*;
import java.util.*;
import java.math.*;

public class E
{
    int bitcount(int x) {
        int c = 0;
        for ( ; x != 0; c++)
            x &= x-1;
        return c;
    }

    boolean bit(int x, int i)
    {
        if (i < 0) return false;
        return (x>>i & 1) == 1 ? true : false;
    }

    int solve(int n, int m)
    {
        if (m > n) { int x = m; m = n; n = x; }
        int maxmask = 1<<m;

        int[][][] dp = new int[n+1][maxmask][maxmask];
        for (int i = 0; i <= n; i++)
            for (int j = 0; j < maxmask; j++)
                for (int k = 0; k < maxmask; k++)
                    dp[i][j][k] = inf;
        for (int i = 0; i < maxmask; i++)
            dp[0][0][i] = bitcount(i);

        for (int i = 1; i <= n; i++)
            for (int b = 0; b < maxmask; b++)
                for (int c = 0; c < maxmask; c++)
                    for (int a = 0; a < maxmask; a++) {
                        boolean nospider = false;
                        for (int j = 0; j < m; j++)
                            if (not(bit(a,j) || bit(c,j) || bit(b,j-1) || bit(b,j) || bit(b,j+1))) {
                                nospider = true;
                                break;
                            }
                        if (nospider) continue;

                        dp[i][b][c] = Math.min(dp[i][b][c], dp[i-1][a][b] + bitcount(c));
                    }
        int res = inf;
        for (int b = 0; b < maxmask; b++)
            res = Math.min(res, dp[n][b][0]);
        return n*m - res;
    }

    void main() throws IOException {
        int n;
        while ((n = nextInt()) != EOF) {
            int m = nextInt();
            out.println(solve(n, m));
        }
    }

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

    // ======================================================================

    int inf = (int) 1e9;
    final int EOF = -1;

    boolean not(boolean p) { return !p; }

    int sqr(int x) { return x*x;... What is the time complexity of the previous code?
targets: np
inputs: //package pack;

import java.util.*;

public class first
{
	public static long power(long x, long y, long p)
    {
        long res = 1;
        x = x % p; 
        while (y > 0)
        {	if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res;
    }
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long k=sc.nextLong();
		long mod=1000000007;
		if(k==0 || x==0)
			System.out.println((2*x)%mod);
		else
		{	long answer=1;
			answer+=(power(2,k,mod))*(((2*x)-1)%mod);
			System.out.println(answer%mod);
		}
	}
} What is the time complexity of the previous code?
targets: logn
inputs: import java.util.*;
import java.io.*;
public class B {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                   ... What is the time complexity of the previous code?
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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int inv = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    if (a[j] > a[i]) {
                        inv++;
                    }
                }
            }
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                int s = (r - l + 1) * (r - l) / 2;
                inv = (inv + s) % 2;
                out.println(inv % 2 == 0 ? "even" : "odd");
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null ||... Complexity:
targets: quadratic
inputs: import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Task {

	private static final boolean readFromFile = false;
	
	public static void main(String args[]){
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FileOutputStream fileOutputStream;
		FileInputStream fileInputStream;
		if (readFromFile){
			try{
				fileInputStream = new FileInputStream(new File("input.txt"));
				fileOutputStream = new FileOutputStream(new File("output.txt"));
			}catch (FileNotFoundException e){
				throw new RuntimeException(e);
			}
		}
		PrintWriter out = new PrintWriter((readFromFile)?fileOutputStream:outputStream);
		InputReader in = new InputReader((readFromFile)?fileInputStream:inputStream);
		
		Solver s = new Solver(in,out);
		s.solve();
		
		out.close();
	}
}

class Solver{
	InputReader in;
	PrintWriter out;
	
	public void solve(){
		String s = in.nextLine();
		for (int len=s.length()-1;len>=1;len--)
			for (int i=0;i<s.length()-len+1;i++)
				for (int j=i+1;j<s.length()-len+1;j++)
					if (s.substring(i,i+len).equals(s.substring(j,j+len))){
						out.println(len);
						return;
					}
		out.println(0);
	}

		
	Solver(InputReader in, PrintWriter out){
		this.in=in;
		this.out=out;
	}
}

class InputReader{
	private BufferedReader buf;
	private StringTokenizer tok;
	
	InputReader(InputStream in){
		tok = null;
		buf = new BufferedReader(new InputStreamReader(in));
	}
	
	InputReader(FileInputStream in){
		tok = null;
		buf = new BufferedReader(new InputStreamReader(in));
	}
	
	public String next(){
		while (tok==null || !tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(buf.readLine());
			}catch (IOException e){
				throw new... 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 static java.util.Arrays.sort;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class SecondOrderStatistics implements Runnable
{
  public static void main(String[] args) throws Exception
  {
    new SecondOrderStatistics().run();
  }

  private void solve() throws Exception
  {
    int n = nextInt();
    SortedSet<Integer> sset = new TreeSet<Integer>();
    for (int i = 0; i < n; i++)
    {
      int a = nextInt();
      sset.add(a);
    }

    if (sset.size() < 2)
      out.println("NO");
    else
    {
      Integer v[] = (Integer[]) sset.toArray(new Integer[sset.size()]);
      sort(v);
      out.println(v[1]);
    }
  }

  // -------------- Input/Output routines below ---------------//
  private BufferedReader in;
  PrintWriter out;
  StringTokenizer tokenizer;

  public void run()
  {
    // String problem = this.getClass().getName();
    try
    {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new BufferedOutputStream(System.out));
      solve();
      out.flush();
      in.close();
      out.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      // System.exit(1);
    }
  }

  String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(in.readLine());
    }
    return tokenizer.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());
  }

} Complexity:
targets: nlogn
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;

public class R111_D2_A {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        int n = in.readInt();
        int[] inp = new int[n];
        for (int i = 0; i < inp.length; i++) {
            inp[i] = in.readInt();
        }
        Arrays.sort(inp);
        int sum1 = 0;
        int res = 0;
        for (int i = inp.length - 1; i >= 0; i--) {
            sum1 += inp[i];
            res++;
            int sum2 = 0;
            for (int j = 0; j < i; j++) {
                sum2 += inp[j];
            }
            if (sum1 > sum2) {
                break;
            }
        }
        System.out.println(res);
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1000];
        private int curChar, numChars;

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

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

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                 ... 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.Scanner;
import java.util.TreeMap;

/**
 *
 * @author camoroh13
 */
public class Solution {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
 //       Scanner sc = new Scanner(new FileInputStream("/home/camoroh13/NetBeansProjects/JavaApplication1/src/input.txt"));
        int n = sc.nextInt();
        int t = sc.nextInt();
//        int[][] h = new int[n][2];
        TreeMap<Integer, Integer> h = new TreeMap<Integer, Integer>();
        for (int i=0; i < n; i++) {
            int key = sc.nextInt();
            h.put(key, sc.nextInt());
        }

        int ans = 2;
        Integer lastKey = h.firstKey();
        Integer last = h.get(lastKey);
        h.remove(lastKey);
        for (int i=1; i < n; i++) {
            int key = h.firstKey();
            int val = h.get(key);
            //System.out.println(Math.abs(key-val*1.0/2 - (lastKey + last*1.0/2)) + "-" + key + "-"+val);
            if (Math.abs(key-val*1.0/2 - (lastKey + last*1.0/2)) == t) {
                ans++;
            } else if (Math.abs(key-val*1.0/2 - (lastKey + last*1.0/2))  > t) {
                ans += 2;
            }
            lastKey = key;
            last = val;
            h.remove(lastKey);
        }

        System.out.println(ans);
        
        sc.close();
    }


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

public class LightItUp {

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 StringTokenizer st = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int previous = 0;
		int array[] = new int[n+1];
		int answer = 0;
		
		StringTokenizer st1 = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++){
			array[i] = Integer.parseInt(st1.nextToken());
			if(i % 2 == 0){
				answer += (array[i] - previous);
			}
			previous = array[i];
		}
		
		if(n % 2 == 0){
			answer += (m - previous);
		}
		previous = m;
		int max = Integer.MAX_VALUE;
		
		while(n-- != 0){
			int temp = array[n];
			if(n%2 == 0){
				array[n] = array[n+1] - (previous - array[n]);
			}
			else{
				array[n] = array[n+1] + (previous - array[n]);
			}
			previous = temp;
			max = Math.min(max, array[n]);
		}
		if(max>=-1){
			System.out.println(answer);
		}
		else{
			System.out.println(answer - (max+1));
		}

	}

}
 Complexity:
targets: linear
inputs: import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.util.*;

import static java.lang.System.gc;
import static java.lang.System.out;

public class Main {

    Scanner scanner = new Scanner(System.in);

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


    void solve() {

        int n = scanner.nextInt();
        scanner.nextLine();
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();


        int ans = 0;
        boolean a[] = new boolean[30];
        boolean b[] = new boolean[30];

        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                ans ++;
                a[s1.charAt(i)  - 'a'] = true;
                b[s2.charAt(i)  - 'a'] = true;
            }
        }
        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i) && a[s2.charAt(i) - 'a'] && b[s1.charAt(i) - 'a']) {
                for (int j = i + 1; j < n; j ++) {
                    if (s1.charAt(i) == s2.charAt(j) && s1.charAt(j) == s2.charAt(i)) {
                        out.println(ans - 2);
                        out.println((i + 1) + " " + (j + 1));
                        return;
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i) && (a[s2.charAt(i) - 'a'] || b[s1.charAt(i) - 'a'])) {
                for (int j = i + 1; j < n; j ++) {
                    if (s1.charAt(j) != s2.charAt(j) && (s1.charAt(i) == s2.charAt(j) || s1.charAt(j) == s2.charAt(i))) {
                        out.println(ans - 1);
                        out.println((i + 1) + " " + (j + 1));
                        return;
                    }
                }
            }
        }

        out.println(ans);
        out.println(-1 + " " + -1);
    }
} What is the time complexity of the previous code?
targets: quadratic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. // package Practice1.CF35;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class CF035C {
    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(new File("input.txt")/*System.in*/);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
//        pair[] arr = new pair[n];
        Queue<pair> q = new LinkedList<>();
        PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        boolean[][] visited = new boolean[n][m];
        for (int i = 0; i < k; i++) {
            int x = s.nextInt() - 1;
            int y  = s.nextInt() - 1;
            visited[x][y] = true;
            pair p = new pair(x,y);
//            arr[i] = p;
            q.add(p);
        }

        q.add(null);
        int[] dx = {0,0,1,-1};
        int[] dy = {1,-1,0,0};
        int ansX = q.peek().x;
        int ansY = q.peek().y;
        while(true){
            if(q.peek() == null){
                q.poll();
                q.add(null);
            }
            pair p = q.poll();
            if(p == null){
                break;
            }
            for (int i = 0; i < 4; i++) {
                if(isValid(p.x + dx[i],p.y+dy[i],n,m) && !visited[p.x + dx[i]][p.y+dy[i]]){
                    q.add(new pair(p.x + dx[i],p.y+dy[i]));
                    ansX = p.x + dx[i];
                    ansY = p.y + dy[i];
                    visited[ansX][ansY] = true;
                }
            }
        }
        out.println((ansX+1) + " " + (ansY+1));
        out.close();

    }

    public static boolean isValid(int x, int y,int n, int m){
        return x >= 0 && x < n && y >= 0 && y < m;
    }

    private static class pair{
        int x;
        int y;

        public pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}
 Complexity:
targets: cubic
inputs: import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class C {
	static final long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		long[][] dp = new long[N][N];
		dp[0][0] = 1L;
		for(int i = 0; i < N-1; i++) {
			char oper = sc.next().charAt(0);
			if(oper == 'f') {
				dp[i+1][0] = 0L;
				for(int j = 1; j < N; j++) {
					dp[i+1][j] = dp[i][j-1];
				}
			}
			else {
				dp[i+1][N-1] = dp[i][N-1];
				for(int j = N-2; j >= 0; j--) {
					dp[i+1][j] = (dp[i+1][j+1] + dp[i][j]) % MOD;
				}
			}
		}
		long res = 0;
		for(int i = 0; i < N; i++) {
			res += dp[N-1][i];
			res %= MOD;
		}
		out.println(res);
		out.flush();
	}

	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

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

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

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

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
} What is the time complexity of the previous code?
targets: quadratic
inputs: import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class codeforces {

    public static long cnt = 0;

    public static void f(int g1, int g2, int g3, int last) {
        if (g1 == 0 && g2 == 0 && g3 == 0) cnt++;
        if (g1 > 0 && last != 1) f(g1 - 1, g2, g3, 1);
        if (g2 > 0 && last != 2) f(g1, g2 - 1, g3, 2);
        if (g3 > 0 && last != 3) f(g1, g2, g3 - 1, 3);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(scan.readLine());
        int n = Integer.parseInt(st.nextToken());
        int t = Integer.parseInt(st.nextToken());
        int T[] = new int[n];
        int G[] = new int[n];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(scan.readLine());
            T[i] = Integer.parseInt(st.nextToken());
            G[i] = Integer.parseInt(st.nextToken());
        }
        long ans = 0;
        for (int mask = 1; mask < (1 << n); mask++) {
            int sum = 0;
            int g1 = 0;
            int g2 = 0;
            int g3 = 0;

            for (int i = 0; i < n; i++) {
                if (((1 << i) & mask) > 0) {
                    sum += T[i];
                    if (G[i] == 1) g1++;
                    if (G[i] == 2) g2++;
                    if (G[i] == 3) g3++;
                }
            }
            cnt = 0;
            if (sum == t) f(g1, g2, g3, -1);
            for (long i = 1; i <= g1; i++) cnt *= i;
            for (long i = 1; i <= g2; i++) cnt *= i;
            for (long i = 1; i <= g3; i++) cnt *= i;
            ans += cnt;
        }
        System.out.println(ans % 1000000007);
    }
} 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.*;
import java.util.*;

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

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

		int n = next();
		int t = 2*next();

		int[] x = new int[n];
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = 2* next() + 2000;
			a[i] = next();
		}

		int[] srt = new int[n];
		for (int i = 0; i < n; i++) srt[i] = 10000 * x[i] + a[i];
		Arrays.sort(srt);
		for (int i = 0; i < n; i++) {
			x[i] = srt[i] / 10000;
			a[i] = srt[i] % 10000;
		}

		int answ = 2;
		for (int i = 0; i < n - 1; i++) {
			if (x[i + 1] - x[i] > a[i] + a[i + 1] + t) answ++;
			if (x[i + 1] - x[i] >= a[i] + a[i + 1] + t) answ++;
		}

		out.println(answ);

		out.close();
	}
} Complexity:
targets: nlogn
inputs: import java.io.*;
import java.math.*;
import java.util.*;


 public class Main {
	private InputStream is;
	private PrintWriter out;
	int time = 0, dp[][], DP[][], start[], parent[], end[], val[], black[], MOD = (int)(1e9+7), arr[], arr1[];
	int MAX = 10000000, N, K, p;
	ArrayList<Integer>[] amp, amp1;
	boolean b[], b1[];
	Pair prr[];
	char ch[][];
	HashSet<Integer> hs = new HashSet<>();

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
		public void run() {
			try {

		//new Main().soln();
		} catch (Exception e) {
				System.out.println(e);
			}
		}
	}, "1", 1 << 26).start();
		new Main().soln();
	}
	void solve() {
		long n = nl(), s = nl();
		long low = 1, high = n+1;
		long ans = high;
		while(low<=high){
			long mid = (high+low)/2;
			if((mid - getSum(mid))>=s){
				high = mid-1;
				ans = mid;
			}
			else{
				low = mid+1;
			}
		}
		System.out.println(Math.max(0, n-ans+1));
	}
	int getSum(long s){
		String str = Long.toString(s);
		int ans = 0;
		for(char ch : str.toCharArray()) ans += (ch-'0');
		return ans;
	}
	int recur(int x){
		//System.out.println(x);
		int ans = 0;
		b[x] = true;
		for(int i : amp[x]){
			if(!b[i]){
				b[i] = true;
				ans = Math.max(recur(i), ans);
				b[i] = false;
			}
		}
		return 1+ans;
	}
	int max = 0;
	int getParent(int x){
		//System.out.println(x+" "+parent[x]);
		if(parent[x]!=x){
			parent[x] = getParent(parent[x]);
		}
		return parent[x];
	}
	int bfs(int x){
		b[x] = true;
		Queue<Integer> q =  new LinkedList<>();
		q.add(x);
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i : amp[y]){
				if(!b[i]){
					b[i] = true;
					val[i] = val[y]+1;
					max = Math.max(val[i], max);
					q.add(i);
				}
			}
		}
		return max;
	}
	class Pair implements Comparable<Pair>{
		int u, v, r;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v));// || (v == other.u && u ==... 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        for (int i = s.length() - 1; i > 0; i--)
            for (int j = 0; j <= s.length() - i; j++)
                if (s.substring(0, j + i - 1).contains(s.substring(j, j + i))
                        || s.substring(j + 1).contains(s.substring(j, j + i))) {
                    System.out.println(i);
                    return;
                }
        System.out.println(0);
    }
}
 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.util.*;
import java.io.*;
import java.math.*;

/**
 *
 * @Har_Har_Mahadev
 */

public class D {

	private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353;
	private static int N = 0;
	private static long[][][] dp;
	private static long[][] ff;
	private static long[][] ss;

	public static void process() throws IOException {

		int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();
		
		ff = new long[n][m];
		ss = new long[n][m];
		for(int i = 0; i<n; i++) {
			for(int j = 0; j<m-1; j++) {
				ff[i][j] = sc.nextLong();
			}
		}
		for(int i = 0; i<n-1; i++) {
			for(int j = 0; j<m; j++) {
				ss[i][j] = sc.nextLong();
			}
		}
		
		if(k%2 == 1) {
			for(int i = 0; i<n; i++) {
				for(int j = 0; j<m; j++)System.out.print(-1+" ");
				System.out.println();
			}
			return;
		}
		
		dp = new long[n+1][m+1][11];
		for(int i = 0; i<=n; i++) {
			for(int j = 0; j<=m; j++)Arrays.fill(dp[i][j], -1);
		}
		for(int i = 0; i<=n; i++) {
			for(int j = 0; j<=m; j++) {
				dp[i][j][0] = 0;
			}
		}
		
		k/=2;
		long ans[][] = new long[n][m];
		for(int i = 0; i<n; i++) {
			for(int j = 0; j<m; j++) {
				ans[i][j] = solve(i,j,k,n,m)*2L;
			}
		}
		for(int i = 0; i<n; i++) {
			for(int j = 0; j<m; j++)print(ans[i][j]+" ");
			println();
		}
	}

	private static long solve(int i, int j, int k, int n, int m) {
		if(dp[i][j][k] != -1)return dp[i][j][k];
		long ans = Long.MAX_VALUE;
		if(i+1<n) {
			ans = min(ans,ss[i][j] + solve(i+1, j, k-1, n, m));
		}
		if(i-1>=0) {
			ans = min(ans,ss[i-1][j] + solve(i-1, j, k-1, n, m));
		}
		if(j+1<m) {
			ans = min(ans,ff[i][j] + solve(i, j+1, k-1, n, m));
		}
		if(j-1>=0) {
			ans = min(ans,ff[i][j-1] + solve(i, j-1, k-1, n, m));
		}
		
		return dp[i][j][k] = ans;
	}

	//=============================================================================
	//--------------------------The End---------------------------------
	//=============================================================================

	static FastScanner sc;
	static PrintWriter out;

	public... 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.PrintWriter;
import java.util.StringTokenizer;
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
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        G1PleilistDlyaPolikarpaUproshennayaVersiya solver = new G1PleilistDlyaPolikarpaUproshennayaVersiya();
        solver.solve(1, in, out);
        out.close();
    }

    static class G1PleilistDlyaPolikarpaUproshennayaVersiya {

        static final int MOD = (int) 1e9 + 7;
        int n;
        int t;
        int[][] a = new int[15][2];
        long[][] mem = new long[1 << 15][4];

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            for (int i = 0; i < (1 << 15); i++) {
                for (int h = 0; h < 4; h++) {
                    mem[i][h] = -1;
                }
            }
            n = in.nextInt();
            t = in.nextInt();
            for (int i = 0; i < n; i++) {
                a[i][0] = in.nextInt();
                a[i][1] = in.nextInt();
            }
            out.println(doit(0, 0, 0));
        }

        private long doit(int mask, int genre, int sum) {
            if (mem[mask][genre] != -1) {
                return mem[mask][genre];
            }
            if (sum > t) {
                mem[mask][genre] = 0;
                return mem[mask][genre];
            }
            if (sum == t) {
                mem[mask][genre] = 1;
                return mem[mask][genre];
            }
            long ct = 0;
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) > 0 || genre == a[i][1]) {
                   ... Complexity:
targets: np
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
/*

2
3 5

2
6 5
1 11
-10 12

3
3 6 2


1   8   5   3
-7  9   5   3
-7  4   14  3


1   8   5   3
1   3   13  3
-2  4   13  3
   

3
1 3 6

3 3 6

5 12
-7 19


3 5 7 11 13
-2 8


5 9


5 9


3 6 7
-3 9 7

6 3 7


*/

public class c {
	static int n;
	static int[] fs;
	static int[] cfs;
	static long[][] choose = chooseTable(1001);
	static long[] fact;
	static final long MOD = (long) (1e9 + 7);
	static long[][] memo;
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		n = in.nextInt();
		fact = new long[301];
		fact[0] = 1;
		for (int i = 1; i < fact.length; i++) {
			fact[i] = fact[i - 1] * i;
			fact[i] %= MOD;
		}
		HashMap<Long, Integer> map = new HashMap<Long, Integer>();
		fs = new int[n];
		for (int i = 0; i < n; i++) {
			long v = in.nextLong();
			long r = 1;
			for (int d = 2; d * d <= v; d++) {
				int cnt = 0;
				while (v % d == 0) {
					v /= d;
					cnt ^= 1;
				}
				if (cnt == 1) {
					r *= d;
				}
			}
			r *= v;
			if (!map.containsKey(r)) {
				map.put(r, map.size());
			}
			fs[map.get(r)]++;
		}
		cfs = new int[n];
		for (int i = 1; i < n; i++) {
			cfs[i] = cfs[i - 1] + fs[i - 1];
		}
		memo = new long[n+1][n+1];
		for(long[] arr : memo)
			Arrays.fill(arr, -1);
		System.out.println(go(0, 0));
	}

	static long go(int color, int priorities) {
		if (color == n)
			return priorities == 0 ? 1 : 0;
//		System.out.println(color + " "+  priorities);
		if(memo[color][priorities] != -1)
			return memo[color][priorities];
		int nonpriorities = cfs[color] - priorities + 1;
		long ans = 0;
		for (int cntPrio = 0; cntPrio <= priorities && cntPrio <= fs[color]; cntPrio++) {
			for (int cntNonPrio = 0; cntNonPrio <= nonpriorities && cntNonPrio + cntPrio <= fs[color]; cntNonPrio++) {
				if(cntPrio + cntNonPrio == 0 && fs[color] != 0)... 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: /*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         //bin search
         //ugh I'm shafting
         long x = (long)N;
         long low = 0L;
         long high = N;
         while(low != high)
         {
            x = (low+high+1)/2;
            long add = (x*(x+1))/2;
            long y = N-x;
            if(add-y > K)
               high = x;
            else if(add-y == K)
            {
               System.out.println(y);
               break;
            }
            else
               low = x;
         }
         //run time?
      }
      public static void sort(int[] arr)
      {
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   } What is the time complexity of the previous code?
targets: logn