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.*;
public class D5 {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), v = input.nextInt();
    int l = input.nextInt(), d = input.nextInt(), w = input.nextInt();
    double lo = 0, hi = v;
    for(int iter = 0; iter < 1000; iter++)
    {
        double mid = (lo+hi)/2;
        if(can(mid, a, d, w)) lo = mid;
        else hi = mid;
    }
    //System.out.println(lo);
    double t1 = lo / a;
    double gone = .5 * t1 * t1 * a;
    if(lo > w)
    {
        gone += -a * .5 * (lo - w) / a * (lo - w) / a + lo * (lo - w) / a;
        t1 += (lo - w) / a;
    }
    t1 += (d - gone) / lo;
    //System.out.println(t1);
    double v0 = Math.min(lo, w);
    double togo = l - d;
    double toAdd = (-v0 + Math.sqrt(v0 * v0 + 4 * togo * .5 * a)) / a;
    if(toAdd * a + v0 > v)
    {
        double tt = (v - v0) / a;
        t1 += tt;
        togo -= .5 * a * tt * tt + v0 * tt;
        t1 += togo / v;
    }
    else t1 += toAdd;
    System.out.println(t1);
}
static boolean can(double v, double a, double d, double max)
{
    double t1 = v / a;
    double distGone = .5 * a * t1 * t1;
    if(v > max)
    {
        t1 = (v - max) / a;
        distGone += -.5 * a * t1 * t1 + v * t1;
    }
    return distGone <= d;
}
}
 Complexity:
targets: constant
inputs: import java.io.*;
import java.util.*;

public class CF {
    private FastScanner in;
    private PrintWriter out;

    final int mod = (int) 1e9 + 7;

    private long f(String s, int digit) {
        final int n = s.length();
        int[][] dp = new int[2][n + 1]; // [less][cntBigger] -> sum
        dp[0][0] = 1;
        int[][] ndp = new int[2][n + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                Arrays.fill(ndp[j], 0);
            }
            for (int less = 0; less < 2; less++) {
                for (int cntBigger = 0; cntBigger <= n; cntBigger++) {
                    int cur = dp[less][cntBigger];
                    if (cur == 0) {
                        continue;
                    }
                    int max = less == 1 ? 9 : (s.charAt(i) - '0');
                    for (int next = 0; next <= max; next++) {
                        int nextLess = (less == 1) || (next < max) ? 1 : 0;
                        int nextCntBigger = cntBigger + ((next >= digit) ? 1 : 0);
                        ndp[nextLess][nextCntBigger] += cur;
                        while (ndp[nextLess][nextCntBigger] >= mod) {
                            ndp[nextLess][nextCntBigger] -= mod;
                        }
                    }
                }
            }
            int[][] tmp = dp;
            dp = ndp;
            ndp = tmp;
        }
        long result = 0;
        for (int less = 0; less < 2; less++) {
            long sum = 0;
            for (int cntBigger = 1; cntBigger <= n; cntBigger++) {
                sum = (sum * 10 + 1) % mod;
                result = (result + sum * dp[less][cntBigger]) % mod;
            }
        }
        return result % mod;
    }

    private void solve() {
        final String number = in.next();
        long result = 0;
        for (int digit = 1; digit < 10; digit++) {
            long cur = f(number, digit);
            result += cur;
        }
        out.println(result % mod);
    }

    private void run() {
        try... 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.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

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

class TaskB {

    static int myLevel;
    static int[] level;
    static int[] loyalty;

    static double get(int n) {
        double ret = 0;
        for (int mask = 0; mask < 1 << n; mask++) {
            int k = Integer.bitCount(mask);
            double prob = 1.;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if (((mask >> i) & 1) == 1) {
                    prob *= loyalty[i] * .1;
                } else {
                    prob *= (10 - loyalty[i]) * .1;
                    sum += level[i];
                }
            }
            if (k * 2 > n) {
                ret += prob;
            } else {
                ret += prob * myLevel / (myLevel + sum);
            }
        }
        return ret;
    }

    static double go(int x, int k, int n) {
        if (x == n) {
            return get(n);
        }
        double ret = 0;
        for (int i = 0; i <= k && loyalty[x] + i <= 10; i++) {
            loyalty[x] += i;
            ret = Math.max(go(x + 1, k - i, n), ret);
            loyalty[x] -= i;
        }
        return ret;
    }

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        myLevel = in.nextInt();
        level = new int[n];
        loyalty = new int[n];
        for (int i = 0; i < n;... What is the time complexity of the previous code?
targets: np
inputs: import java.util.*;
public class substring
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String s = input.nextLine();
Boolean found = false;
int i = s.length();
while(found==false)
{
i--;
ArrayList<String> sub = new ArrayList<String>();
for(int j = 0; j <= s.length() - i; j++)
{
if(sub.contains(s.substring(j, j+i)))
found = true;
else
sub.add(s.substring(j, j+i));
}

}
System.out.println(i);
}
} What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author vadimmm
 */
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();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long l = in.nextLong();
        long r = in.nextLong();
        /*
        long max = 1;
        boolean good = false;
        for (int i = 0; i < 62; ++i) {
            max <<= 1;
            if (max > r) {
                max >>= 1;
                if (max >= l) {
                    good = true;
                }
                break;
            }
        }
        if (good) {
            if (max - 1 >= l)
                out.println(max ^ (max - 1));
            else
                out.println(max ^ r);
            return;
        }
        */
        boolean[][] answer = new boolean[2][100];
        int cur = 0;
        while (r > 0) {
            answer[0][cur] = (r % 2 != 0);
            ++cur;
            r >>= 1;
        }
        cur = 0;
        while (l > 0) {
            answer[1][cur] = (l % 2 != 0);
            ++cur;
            l >>= 1;
        }
        int old = -1;
        for (int i = 63; i >= 0; --i) {
            if (answer[0][i] && !answer[1][i]) {
                old = i;
                break;
            }
        }
        if (old == -1) {
            out.println(0);
            return;
        }
        long a = 1;
        for (int i = 0; i < old; ++i) {
            a <<= 1;
            a += 1;
        }
        out.println(a);
    }
}

class InputReader {

    private... 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 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);
	}
}	
 Complexity:
targets: constant
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. //contest 23. You're Given A String
import java.util.*;
public class ProblemA
{
	public static void main(String[] args)
	{
		Scanner keyboard = new Scanner(System.in);
		String input = keyboard.nextLine();
		boolean con = false;
		for( int i = input.length()-1; i > 0 ; i--)
		{	
			for ( int j = 0; j+i< input.length(); j++ )
				for( int k = j+1; k+i <= input.length(); k++ )
					if( input.substring(j,j+i).equals( input.substring(k,k+i) ) ) 
					{
						System.out.print(i+"\n");
						k = input.length()+1;
						j = input.length();
						i = -1;
						con = true;
					}
		}
		if( con == false )
			System.out.print(0+"\n");
	}	
} Complexity:
targets: cubic
inputs: import java.util.Scanner;

public class TaxiDriversAndLyft2 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		long m = scanner.nextLong();
		long[] people = new long[(int) (n+m)];
		int[] taxiDrivers = new int[(int) (n+m)];
		
		for(int i = 0;i< (n+m); i++) {
			people[i] = scanner.nextLong();
		}
		
		for(int i = 0;i< (n+m); i++) {
			taxiDrivers[i] = scanner.nextInt();
		}
		
		int lastTaxiDriverIndex = -1;
		long[] riderCountArray = new long[(int) (m)];
		long[] a1 = new long[(int)n];
		long[] b1 = new long[(int)m];
		
		int j=0, k=0;
		for(int i = 0;i< (n+m); i++) {	
			if(taxiDrivers[i] == 0) {
				a1[j] = people[i];
				j++;
			}
			else  {
				b1[k] = people[i];
				k++;
			}
		}
		
		int l = 0, q=0;
		for(int i=0;i<j;i++) {
			while ((l<m-1 && m>1) && Math.abs(a1[i] - b1[l]) > Math.abs(a1[i] - b1[l+1])) {
				l++; 
			}
			
			riderCountArray[l]++;	
		}
		
		for(int i = 0;i< (m); i++) {
			System.out.print(riderCountArray[i]+" ");
		}
	} 
}
 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class CF125A {

	private void work() throws IOException {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
				System.in)));
		int n = sc.nextInt();
		System.out.printf("%d %d %d\n", 0, 0, n);
		System.out.close();
	}

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

}
 Complexity:
targets: constant
inputs: import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;
/**
 * 9:50 ~ 
 *
 */
public class Main {
	public static int n, x, y;
	public static int[] a,b;
	public static int dp[], before[];
	public static int dx[];
	public static int d[][];
	public static final int INF = 24 * 201 * 201; 
	public static void main(String[] argv) {
		FastScanner scan = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		x = scan.nextInt();
		y = scan.nextInt();
		
		n = scan.nextInt();
		
		a = new int[n+1];
		b = new int[n+1];
		dx = new int[n+1];
		d = new int[n+1][n+1];
		for(int i = 0; i < n; ++i){
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		
		for(int i = 0; i < n; ++i){
			dx[i] = dist(i);
		}
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				d[i][j] = dist(i,j);
			}
		}
		
		dp = new int[1 << n];
		before = new int[1 << n];
		Arrays.fill(dp, INF);
		dp[0] = 0;
		for(int state = 0; state < (1<<n); state++){
			//if(dp[state] == INF) continue;
			for(int i = 0; i < n; ++i){
				int ii = (1 << i);
				if((state & ii) > 0){
					if(dp[state - ii] == INF) continue;
					int newdist = dp[state - ii] + dx[i] + dx[i];
					if(dp[state] > newdist){
						dp[state] = newdist;
						before[state] = state - ii;
					}
					
				} else continue;
				
				for(int j = i + 1; j < n; ++j){
					if(i == j) continue;
					int jj = (1 << j);
					if((state & jj) > 0){
						if(dp[state - ii - jj] == INF) continue;
						int newdist = dp[state - ii - jj] + dx[i] + d[i][j] + dx[j];
						if(dp[state] > newdist){
							dp[state] = newdist;
							before[state] = state - ii - jj;
						}
						
					}
				}
				break;
			}
		}

		System.out.println(dp[(1<<n)-1]);
		int state = (1<<n) - 1;
		StringBuffer ret = new StringBuffer();
		while(state > 0){
			int... What is the time complexity of the previous code?
targets: np
inputs: import java.io.*; 
import java.util.*; 


public class p7{
	
	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; 
		} 
	}

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        //PrintWriter out = new PrintWriter(System.out); 
        int n = sc.nextInt();
		int k = sc.nextInt();
		long one = (long)Math.pow(2, k) - 1;
		
		long[] arr = new long[n+1];
		
		arr[0] = 0;
		for(int i=1;i<=n;i++){
			arr[i] = sc.nextLong();
			arr[i] ^= arr[i-1];
		}

		Map<Long, Long> count = new HashMap<>();

		for(int i=0;i<=n;i++){
			Long key = Math.min(arr[i], (arr[i]^one));
			Long val = count.get(key);
			if(val==null) val = 0L;
			count.put(key, val+1);
		}

		long num = n;
		long ans = num*(num+1)/2;
		
		for(Map.Entry<Long, Long> ent: count.entrySet()){
			
			Long cnt = ent.getValue();
			
			long num1 = cnt/2;
			long num2 = (cnt+1)/2;
			
			ans -= ( (num1*(num1-1))/2 );
			ans -= ( (num2*(num2-1))/2 );
		}

		System.out.println(ans);
	}
}
 What is the time complexity of the previous code?
targets: nlogn
inputs: import java.util.*;

public class Beta17PA {

	boolean[] isPrime = new boolean[1001];
	int[] prime = new int[200];

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Beta17PA().solve();
	}

	public void solve() {
		Scanner scan = new Scanner(System.in);
		int n, k;
		n = scan.nextInt();
		k = scan.nextInt();
		init();
		int m = 0;
		for(int i=2; i<=n; i++) {
			if(check(i)) m ++;
		}
		if(m>=k) System.out.println("YES");
		else System.out.println("NO");
	}

	private boolean check(int n) {
		if(n<6||!isPrime[n]) return false;
		int d = n-1;
		for(int i=0; i<199&&prime[i]+prime[i+1]<=d; i++) {
			if(prime[i]+prime[i+1]==d) return true;
		}
		return false;
	}

	private void init() {
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for(int i=2; i<1001; i++) {
			if(!isPrime[i]) continue;
			for(int j=i+i; j<1001; j+=i) {
				isPrime[j] = false;
			}
		}
		int count = 0;
		for(int i=2; i<1001; i++) {
			if(isPrime[i]) prime[count++] = i;
		}
	}
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
import java.util.*;
import java.io.*;
import java.math.*;
public class A{

    void solve(){
        int n=ni();
        s=new char[n+1];
        s[0]='.';
        for(int i=1;i<=n;i++) s[i]=ns().charAt(0);
        dp=new long[5001][5001];

        dp[1][0]=1;
        long sum[]=new long[n+2];
        sum[0]=1;
        for(int i=2;i<=n;i++){
            for(int j=0;j<=n;j++) {
                if (s[i - 1] == 'f') {
                        if(j-1>=0) dp[i][j]=dp[i-1][j-1];
                        else dp[i][j]=0;
                }else {
                   dp[i][j]=sum[j];
                }
            }
            for(int j=n;j>=0;j--){
                sum[j]=(sum[j+1]+dp[i][j])%M;
            }
        }
        long ans=0;
        for(int i=0;i<=n;i++){
            ans+=dp[n][i];
            if(ans>=M) ans%=M;
        }
        pw.println(ans);

    }
    char s[];
    long dp[][];
    long go(int x,int cnt,int n){
   //    pw.println(x+" "+cnt);
        if(x>n) return 1;
        long cc=0;
        if(dp[x][cnt]!=-1) return dp[x][cnt];
        if(s[x]=='f'){
            cc=(cc+go(x+1,cnt+1,n))%M;
        }else {

            for(int j=cnt;j>=0;j--) cc=(cc+go(x+1,j,n))%M;
            if(x==n) cc=(cc-cnt+M)%M;
        }
        cc%=M;

        dp[x][cnt]=cc;
        return cc;
    }



    long M=(long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
    }

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

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

    private int readByte() {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf... 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 three {
    static boolean check;

    public static void main(String[] args) {
        check = true;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = n + "";
        recurse(n, s.length(), "4");
        if (!check)
            System.out.println("YES");
        else {
            recurse(n, s.length(), "7");
            if (!check)
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }

    private static void recurse(int n, int length, String string) {
        int k = Integer.parseInt(string);
        if (n % k == 0) {
            check = false;
        } else if (string.length() <= length && check) {
            recurse(n, length, string + "4");
            recurse(n, length, string + "7");
        }

    }
} Complexity:
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.util.*;
import java.io.*;

public class _1036_B_DiagonalWalkingV2 {

	public static void main(String[] args) throws IOException {
		int Q = readInt();
		while(Q-- > 0) {
			long n = readLong(), m = readLong(), k = readLong();
			if(Math.max(n, m) > k) println(-1);
			else {
				long ans = k;
				if(n%2 != k%2) ans--;
				if(m%2 != k%2) ans--;
				println(ans);
			}
		}
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c =... Complexity:
targets: linear
inputs: import java.io.*;
import java.util.*;
 
import java.math.*;
import java.awt.Point;
 
public class Main {
    //static final long MOD = 1000000007L;
    //static final long MOD2 = 1000000009L;
    static final long MOD = 998244353L;
    //static final long INF = 500000000000L;
    static final int INF =   1000000005;
    static final int NINF = -1000000005;
    //static final long NINF = -1000000000000000000L;
    static FastScanner sc;
    static PrintWriter pw;
    static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}};


    public static void main(String[] args) {
        sc = new FastScanner();
        pw = new PrintWriter(System.out);
        


        int Q = sc.ni();
        for (int q = 0; q < Q; q++) {
            int N = sc.ni();
            String ans = "NO";
            if (N%2==0 && isSquare(N/2))
                ans = "YES";
            if (N%4==0 && isSquare(N/4))
                ans = "YES";
            pw.println(ans);
        }
        pw.close();
    }

    public static boolean isSquare(int x) {
        int s = (int)Math.round(Math.sqrt(x));
        return s*s==x;
    }

 
    public static void sort(int[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }
 
    public static void sort(long[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            long temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }
 
    //Sort an array (immune to quicksort TLE)
    public static void sort(int[][] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int[] temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
       ... 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class B {
	public static BufferedReader in;
	public static PrintWriter out;

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

		boolean showLineError = true;
		if (showLineError) {
			solve();
			out.close();
		} else {
			try {
				solve();
			} catch (Exception e) {
			} finally {
				out.close();
			}
		}

	}

	static void debug(Object... os) {
		out.println(Arrays.deepToString(os));
	}

	private static void solve() throws IOException {
		String[] line = in.readLine().split(" ");
		long n = Long.parseLong(line[0]) - 1;
		long k = Long.parseLong(line[1]) - 1;
		if (f(1, k) < n) {
			out.println(-1);
			return;
		}
		if (n == 0) {
			out.println(0);
			return;
		}
		long lo = 0l;
		long hi = k;
		while (lo + 1l < hi) {
			long m = (lo + hi) / 2l;
			long f = f(k - m + 1, k);
			if (f < n) {
				lo = m;
			} else {
				hi = m;
			}
		}
		out.println(hi);

	}

	private static long f(long lo, long hi) {
		return (lo + hi) * (hi - lo + 1l) / 2l;
	}
} Complexity:
targets: logn
inputs: import java.io.*;
import java.util.StringTokenizer;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class Main {
    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

    void solve() {
        int t = in.nextInt();

        for (int sdfsdf = 0; sdfsdf < t; sdfsdf++) {
            long n = in.nextLong();
            long k = in.nextLong();

            if (n == 1) {
                if (k == 1)  {
                    out.println("YES 0");
                } else {
                    out.println("NO");
                }
                continue;
            }

            if (k == 3) {
                if (n == 2) {
                    out.println("NO");
                } else {
                    out.println("YES " + (n - 1));
                }
                continue;
            }

           ... 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            boolean[] isF = new boolean[n];
            for (int i = 0; i < n; i++) {
                isF[i] = in.readCharacter() == 'f';
            }
            FenwickTree[] fenwickTrees = new FenwickTree[n + 1];
            for (int i = 0; i < fenwickTrees.length; i++) {
                fenwickTrees[i] = new FenwickTree(n + 1);
            }
            fenwickTrees[n].add(0, 1);
            for (int idx = n - 1; idx >= 0; idx--) {
                for (int indentLevel = 0; indentLevel < n; indentLevel++) {
                    long fenwickRes;
                    if (isF[idx]) {
                        fenwickRes = fenwickTrees[idx + 1].get(indentLevel + 1, indentLevel + 1);
                    } else {
                        fenwickRes = fenwickTrees[idx + 1].get(0, indentLevel);
                    }
                    fenwickTrees[idx].add(indentLevel, fenwickRes % MiscUtils.MOD7);
                }
            }
            out.printLine(fenwickTrees[0].get(0, 0));
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int... Complexity:
targets: quadratic
inputs: import java.util.*;

public class Beta22PA {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int minimum = 200, second = 200;
		for(int i=0; i<n; i++) {
			int temp = scan.nextInt();
			if(temp<minimum) {
				second = minimum;
				minimum = temp;
			} else if(temp>minimum&&temp<second) {
				second = temp;
			}
		}
		if(second>100) {
			System.out.println("NO");
		} else {
			System.out.println(second);
		}
	}
}
 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.*;

public class practice {
	public static void main(String[] args) throws Exception {
		//Scanner in = new Scanner(new File("practice.in"));
		Scanner in = new Scanner(System.in);

		String str = in.nextLine();
		long n = Long.parseLong(str.substring(0, str.indexOf(" ")));
		long m = Long.parseLong(str.substring(str.indexOf(" ") + 1));
		if(m - n < 2) {
			System.out.println("-1");
		} else {
			if(m - n == 2 && m % 2 == 1) {
				System.out.println("-1");
			} else {
				System.out.println((n + n % 2) + " " + (n + 1 + n % 2) + " " + (n + 2 + n % 2));
			}
		}
	}
} 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.math.*;
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	

	public void solve() throws Exception {
		int n = nextInt();
		int a [] = new int [n];
		for (int i = 0 ;i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);
		if (n == 1) {
			if (a[0] == 1) {
				out.print(2);
			} else {
				out.print(1);
			}
		} else {
			out.print(1);
			for (int i = 1; i < n; i++) {
				if (i == n-1 && a[i] == 1) {
					out.print(" "+2);
				} else {
					out.print(" "+a[i-1]);
				}
			}
		}
	}
	
		
	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;
	
	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}
	
	public void run() {
		try {
			//Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

	
}
 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.util.*;
 
public class Main{
    private static final int MAX_SIZE = 100005;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(((m + 1) / 60 < a) || ((m + 1) / 60 == a && (m + 1) % 60 <= b)) {
            out(0, 0);
            System.exit(0);
        }
        for(int i = 2; i <= n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            int bb = b + 2 * m + 2;
            int aa = a + bb / 60;
            bb %= 60;

            if((aa < x) || (aa == x && bb <= y)) {
                b = b + m + 1;
                a = a + b / 60;
                b %= 60;
                out(a, b);
                System.exit(0);
            }
            a = x;
            b = y;
        }
        b = b + m + 1;
        a = a + b / 60;
        b = b % 60;        
        out(a, b);
    }

    private static void out(int a, int b) {
        cout(a);
        cout(" ");
        cout(b);
    }

    private static void cout(Object a) {
        System.out.print(a);
    }
} Complexity:
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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class A {	
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;
    
	public void solve() throws IOException {				
		long A = nextLong();
		long B = nextLong();		
		long ans = 0;
		while(A > 0){
			if(A >= B){
				ans += A/B;
				A %= B;
				if(A == 0) break;
			}
			else{
				long tmp = A; A = B; B = tmp;
			}			
		}		
		out.println(ans);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new A().run();
	}
	
	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

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

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

import static java.lang.Math.*;

public class Solution implements Runnable {
	

	public void solve() throws Exception {
		int n = nextInt();
		int a [] = new int [n];
		for (int i = 0 ;i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);
		if (n == 1) {
			if (a[0] == 1) {
				out.print(2);
			} else {
				out.print(1);
			}
		} else {
			out.print(1);
			for (int i = 1; i < n; i++) {
				if (i == n-1 && a[i] == 1) {
					out.print(" "+2);
				} else {
					out.print(" "+a[i-1]);
				}
			}
		}
	}
	
		
	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;
	
	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}
	
	public void run() {
		try {
			//Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

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

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] in = br.readLine().split(" ");
		long n = Long.parseLong(in[0]), s = Long.parseLong(in[1]);
		Solver solver = new Solver(n, s);
		System.out.println(solver.solve());

	}

}

class Solver {

	private long n, s;

	Solver(long n, long s) {
		this.n = n;
		this.s = s;
	}

	public long solve() {
		long low = 1, high = n;
		for (int i = 0; i < 72; ++i) {
			long x = low + (high - low) / 2;
			if (check(x))
				high = x - 1;
			else
				low = x + 1;
		}
		return n - high;
	}

	private boolean check(long x) {

		long tmp = x;
		int sum = 0;
		while (tmp > 0) {
			sum += tmp % 10;
			tmp /= 10;
		}
		return x - sum >= s;
	}
}
 What is the time complexity of the previous code?
targets: logn
inputs: import java.util.Scanner;


public class R025A {
	int n;
	int[] nums;
	public R025A() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		nums = new int[n];
		for(int i=0; i<n; i++) {
			nums[i] = scanner.nextInt();
		}
	}

	private void process() {
		int[] c = new int[2];
		int[] r = new int[2];
		for(int i=0; i<n; i++) {
			c[nums[i] % 2]++;
			if(r[nums[i] %2] == 0) {
				r[nums[i] % 2] = i+1;
			}
		}
		System.out.println(r[c[0]==1 ? 0 : 1]);
	}

	public static void main(String[] args) {
		new R025A().process();
	}
}
 What is the time complexity of the previous code?
targets: linear
inputs: import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.cos;
import static java.lang.Math.min;

public class E_fast {
    static int g[][];
    static int n, m;
    static char[] s;
    static int dp[], inf = (int) 2e9;
    static int cost[][];

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextInt();
        m = in.nextInt();
        s = in.next().toCharArray();
        g = new int[m][m];
        for (int i = 1; i < n; i++) {
            int x = s[i - 1] - 'a', y = s[i] - 'a';
            if (x != y) {
                g[x][y]++;
                g[y][x]++;
            }
        }
        cost = new int[m][1 << m];
        for (int i = 0; i < m; i++) {
            int w = 0;
            for (int j = 0; j < m; j++) w += g[i][j];
            pre(i, 0, 0, -w);
        }
        dp = new int[1 << m];
        Arrays.fill(dp, -1);
        pw.println(solve(0, 0));

        pw.close();
    }

    static void pre(int x, int pos, int mask, int w) {
        if (pos >= m) {
            cost[x][mask] = w;
            return;
        }
        pre(x, pos + 1, mask, w);
        pre(x, pos + 1, set(mask, pos), w + 2 * g[x][pos]);
    }

    static int solve(int pos, int mask) {
        if (pos >= m) return 0;
        if (dp[mask] != -1) return dp[mask];
        int min = inf;
        for (int i = 0; i < m; i++) {
            if (!check(mask, i)) {
                int res = cost[i][mask] * pos + solve(pos + 1, set(mask, i));
                min = min(min, res);
            }
        }
        return dp[mask] = min;
    }

    static boolean check(int N, int pos) {
        return (N & (1 << pos)) != 0;
    }

    static int set(int N, int pos) {
        return N = N | (1 << pos);
    }

    static int reset(int N, int pos) {
        return N = N & ~(1 << pos);
    }

    static void debug(Object... obj) {
       ... What is the time complexity of the previous code?
targets: np
inputs: import java.io.*;         
import java.util.*;         
import java.math.*;         

 
public class Main  implements Runnable {
//public static final String FileName = "test";
StreamTokenizer ST;      
PrintWriter out;      
BufferedReader br;   
Scanner in;
static final int inf = 1000000000;
 
int nextInt() throws IOException{      
    ST.nextToken();      
    return (int)ST.nval;      
}
long nextLong() throws IOException{      
    ST.nextToken();      
    return (long)ST.nval;      
}      
String next() throws IOException{      
    ST.nextToken();      
    return ST.sval;      
}      
double nextD() throws IOException{      
    ST.nextToken();      
    return ST.nval;      
}      
public static void main(String[] args) throws IOException {       
   new Thread(new Main()).start();
//  new Main().run();
}
 
public void run()  {      
    try {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));      
        //br = new BufferedReader(new FileReader(new File(FileName+".in")));
        //out = new PrintWriter(new BufferedWriter(new FileWriter(FileName+".out")));
        in = new Scanner(br);
        ST = new StreamTokenizer(br);      
        solve();      
        out.close();
        //in.close();
        br.close();   
    }         
    catch (IOException e) {       
        e.printStackTrace();
        throw new IllegalStateException(e);  
    }      
}


public void solve() throws IOException {
    int n = nextInt();
    int K = nextInt();
    boolean[] f = new boolean[n+1];
    Arrays.fill(f, true);
    Vector<Integer> P = new Vector<Integer>();
    for (int i=2; i<=n; i++)
        if (f[i]) {
            for (int j=2*i; j<=n; j+=i) 
                f[j] = false;
            P.add(i);
        }
    for (int i=0; i<P.size()-1; i++) {
        int x = P.elementAt(i)+P.elementAt(i+1)+1;
        if (x<=n && f[x]) K--;
    }
    if (K<=0) out.println("YES"); else out.println("NO");
    //for (int... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
import java.util.*;
import java.io.*;


public class DigitSequenceA {
    public static void main(String[] args) throws IOException{
        FastReader in = new FastReader();
        double digit = in.nextDouble();
        double temp = digit;
        long[] seq = new long[13];
        for(int i = 1; i<13; i++){
            seq[i] = (9* (long)Math.pow(10,i-1)) * (i) +seq[i-1];
        }
        int power = 0;
        for(int i = 0; i< 13; i++){
            if(temp-seq[i] >0){
                continue;
            }
            else{
                power = i;
                break;
            }
        }
        long place = (long) Math.ceil(digit - seq[power-1]);
        place = (long)Math.ceil(place/power);
        if((digit - seq[power-1])%power>0){
            place++;
        }

        long num = (long) (place + Math.pow(10,power-1)-1);
        String num2 = Long.toString(num);
        long end =  seq[power-1] + place*power;
        long answer = (long)(power-(end - digit));
        //System.out.println("Digit is at the " + power + " power");
        //System.out.println("Digit is at the " + place + " number of the sequence");
        //System.out.println("Number is " + num);
        //System.out.println("Digit is at the " + answer+  " in that number");
        //System.out.println("Answer is " + num2.charAt((int)answer-1));
        System.out.println(num2.charAt((int)answer-1));

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

 ... Complexity:
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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Main {

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


    private void run() throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());
        int[] arr = new int[n];
        String[] line = reader.readLine().split("\\s");

        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }

        Arrays.sort(arr);

        Set<Integer> numbers = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            Iterator<Integer> iter = numbers.iterator();
            boolean contains = false;
            while (iter.hasNext()){
                int elem = iter.next();
                if(gcd(elem, arr[i]) == elem){
                    contains = true;
                }

            }
            if(!contains)
                numbers.add(arr[i]);
        }


        System.out.println(numbers.size());

    }

    private int gcd(int a, int b){
        while (a != b){
            if(a > b)
                a -= b;
            else
                b -= a;
        }

        return a;
    }



} Complexity:
targets: quadratic