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

import static java.lang.System.out;

public class Main {

    private FastScanner scanner = new FastScanner();

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

    private List<Integer>[] gr = new ArrayList[1000_000+5];
    private int dp[][] = new int[21][1000_000+5];
    private boolean used[] = new boolean[1000_000+5];

    void init(int v, int p) {
        Stack<Integer> st = new Stack<>();
        st.push(v);
        st.push(p);
        while (!st.isEmpty()) {
            p = st.pop();
            v = st.pop();
            used[v] = true;

            dp[0][v] =  p;
            for (int i = 1; i <= 20; i++) {
                if (dp[i - 1][v] != -1) {
                    dp[i][v] = dp[i - 1][dp[i - 1][v]];
                }
            }

            for (int next : gr[v]) {
                if (!used[next]) {
                    st.push(next);
                    st.push(v);
                }
            }

        }
    }


    private void solve() {
        int n = scanner.nextInt(), k = scanner.nextInt();
        boolean[] ans = new boolean[1000_000 + 5];

        for (int i = 0; i < n; i++) {
            gr[i] = new ArrayList<>();
        }

        for (int i = 0; i < n - 1; i ++) {
            int u = scanner.nextInt() - 1, v = scanner.nextInt() - 1;
            gr[u].add(v);
            gr[v].add(u);
        }

        k = n - k - 1;
        ans[n - 1] = true;

        init(n - 1 , n - 1);

        int t, d, next;
        for (int i = n - 2; i >= 0; i--) {
            t = i;
            d = 1;
            if (ans[i]) {
                continue;
            }
            for (int j = 20; j >= 0; j--){
                next = dp[j][t];
                if (next != -1 && !ans[next]) {
                    t = next;
                    d +=  1 << j;
                }
            }

            if (d <= k) {
                k -=d;
                t = i;

                while (!ans[t]) {
                    ans[t] = true;
              ... 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: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException, URISyntaxException {
        Reader.init(new FileInputStream("input.txt"));
        StringBuilder s=new StringBuilder();
        boolean[][]vis=new boolean[Reader.nextInt()][Reader.nextInt()];
        int k=Reader.nextInt(),r,c;
        Queue<Point>q=new LinkedList<Point>();
        while(k-->0) {
            r=Reader.nextInt()-1;
            c=Reader.nextInt()-1;
            vis[r][c]=true;
            q.add(new Point(r,c));
        }
        Point end=null;
        int[]x={0,0,1,-1},y={1,-1,0,0};
        int a,b,i;
        while(!q.isEmpty()) {
            end=q.poll();
            for(i=0;i<4;i++) {
                a=end.x+x[i];
                b=end.y+y[i];
                if(a>=0&&b>=0&&a<vis.length&&b<vis[a].length&&!vis[a][b]) {
                    vis[a][b]=true;
                    q.add(new Point(a,b));
                }
            }
        }
        s.append(end.x+1).append(' ').append(end.y+1);
        PrintWriter p=new PrintWriter("output.txt");
        p.println(s);
        p.close();
    }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                     new InputStreamReader(input, "UTF-8") );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
           ... Complexity:
targets: cubic
inputs: import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class CodeForces
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		System.out.println(input.nextInt() / 2 + 1);
	}
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: constant
inputs: import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;
/*
	  br = new BufferedReader(new FileReader("input.txt"));
	  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
	  br = new BufferedReader(new InputStreamReader(System.in));
	  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */


public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new FileReader("input.txt"));
		pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			int r = readInt();
			int c = readInt();
			int n = readInt();
			int[][] dist = new int[r][c];
			for(int i = 0; i < r; i++) {
				Arrays.fill(dist[i], 1 << 25);
			}
			LinkedList<State> q = new LinkedList<State>();
			while(n-- > 0) {
				q.add(new State(readInt()-1, readInt()-1));
				dist[q.peekLast().x][q.peekLast().y] = 0;
			}
			int[] dx = new int[]{-1,1,0,0};
			int[] dy = new int[]{0,0,-1,1};
			State ret = q.peekLast();
			while(!q.isEmpty()) {
				State curr = q.removeFirst();
				ret = curr;
				for(int k = 0; k < dx.length; k++) {
					int nx = curr.x + dx[k];
					int ny = curr.y + dy[k];
					if(nx >= 0 && nx < r && ny >= 0 && ny < c && dist[nx][ny] > 1 + dist[curr.x][curr.y]) {
						dist[nx][ny] = 1 + dist[curr.x][curr.y];
						q.add(new State(nx, ny));
					}
				}
			}
			pw.println(ret.x+1 + " " + (ret.y+1));
		}
		exitImmediately();
	}

	static class State {
		public int x,y;

		public State(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}
		
	}
	
	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException... What is the time complexity of the previous code?
targets: cubic
inputs: import java.util.*;

public class LCM235A
{
    public static void main(String[] args) 
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in); 
        // System.out.println("Enter n");
        long n = sc.nextLong();
        
        if (n==1)
        {
            System.out.println(1);
            return;
        }
        if (n==2)
        {
            System.out.println(2);
            return;
        }
        if (n==3)
        {
            System.out.println(6);
            return;
        }
        if (n==4)
        {
            System.out.println(12);
            return;
        }
        
        if (n%2 ==1)   // Odd number easy
        {
            System.out.println(n*(n-1)*(n-2));
            return;
        }
        
        // Even number is a bit harder
        if (n%3 == 0)
        {
            System.out.println((n-1)*(n-2)*(n-3));
        }
        else
        {
            System.out.println(n*(n-1)*(n-3));
        }
    }
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: constant
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		FastReader fr =new FastReader();

		PrintWriter op =new PrintWriter(System.out);

		long n =fr.nextLong() ,k =fr.nextLong() ,d =(long)Math.sqrt(9l+8l*(n+k)) ;

		d -= 3l ;	d /=2l ;op.println(n-d) ;

		op.flush();	op.close();
	}

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

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
} 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.util.*;
public class codeee {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n==1){System.out.println(1); return;}
        int []mas=new int[n];
        int sum=0;
        for (int i = 0; i < n; i++) {
            mas[i]=sc.nextInt();
            sum+=mas[i];
        }
        Arrays.sort(mas);
        int sum1=0;
        int ans=0;
        for(int i=0;i<n;i++){
            sum1+=mas[n-i-1];
            if(sum1>(sum-sum1)){
                ans=i;
                break;
            }
        }
        System.out.println(ans+1);
    }
}
 What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.*;
import java.util.*;

public class E
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        int zzz = Integer.parseInt(tok.nextToken());
        for (int zz = 0; zz < zzz; zz++)
        {
            ntok();
            int n = ipar();
            int m = ipar();
            int[][] mat = new int[n][m];
            for (int i = 0; i < n; i++)
            {
                ntok();
                mat[i] = iapar(m);
            }
            long[][] dp = new long[1 << n][m+1];
            for (int i = 0; i < 1 << n; i++)
            {
                dp[i][m] = -1000000000;
            }
            dp[(1 << n) - 1][m] = 0;
            for (int i = m-1; i >= 0; i--)
            {
                for (int e = 0; e < 1 << n; e++)
                {
                    dp[e][i] = dp[e][i+1];
                    for (int w = 0; w < 1 << n; w++)
                    {
                        if ((e & w) == 0)
                        {
                            dp[e][i] = Math.max(dp[e][i], best(w, mat, i) + dp[e|w][i+1]);
                        }
                    }
                }
            }
            // for (long[] arr : dp)
            // {
            //     out.println(Arrays.toString(arr));
            // }
            out.println(dp[0][0]);
        }

        out.flush();
        in.close();
    }

    public long best(int mask, int[][] mat, int col)
    {
        long max = 0;
        for (int t = 0; t < mat.length; t++)
        {
            long sum = 0;
            int mk = mask;
            for (int i = 0; i < mat.length; i++)
            {
                if (mk % 2 == 1)
                {
                    sum += mat[i][col];
                }
                mk /= 2;
            }
            max =... What is the time complexity of the previous code?
targets: np
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Bag implements Runnable {
    private void solve() throws IOException {
        int xs = nextInt();
        int ys = nextInt();
        int n = nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; ++i) {
            x[i] = nextInt();
            y[i] = nextInt();
        }
        final int[][] pair = new int[n][n];
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j)
                pair[i][j] = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys) + (x[j] - xs) * (x[j] - xs) + (y[j] - ys) * (y[j] - ys) + (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
        final int[] single = new int[n];
        for (int i = 0; i < n; ++i) {
            single[i] = 2 * ((x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys));
        }
        final int[] best = new int[1 << n];
        final int[] prev = new int[1 << n];
        for (int set = 1; set < (1 << n); ++set) {
            int i;
            for (i = 0; i < n; ++i)
                if ((set & (1 << i)) != 0)
                    break;
            int bestC = best[set ^ (1 << i)] + single[i];
            int prevC = 1 << i;
            int nextSet = set ^ (1 << i);
            int unoI = 1 << i;
            for (int j = i + 1, unoJ = 1 << (i + 1); j < n; ++j, unoJ <<= 1)
                if ((set & unoJ) != 0) {
                    int cur = best[nextSet ^ unoJ] + pair[i][j];
                    if (cur < bestC) {
                        bestC = cur;
                        prevC = unoI | unoJ;
                    }
                }
            best[set] = bestC;
            prev[set] = prevC;
        }
        writer.println(best[(1 << n) - 1]);
        int now = (1 << n) - 1;
        writer.print("0");
        while (now > 0) {
        	int differents = prev[now];
        	for(int i = 0; i < n;... 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.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;


public class Main{

    static long MOD = 1_000_000_007L;
    //static long MOD = 998_244_353L;
    //static long MOD = 1_000_000_033L;
    static long inv2 = (MOD + 1) / 2;

    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    static HashMap <Long, Long> memo = new HashMap();
    static MyScanner sc = new MyScanner();
    //static ArrayList <Integer> primes;

    static int nn = 300000;
    static long[] pow2;
    static long [] fac;
    static long [] pow;
    static long [] inv;
    static long [] facInv;
    static int[] base;
    static int[] numOfDiffDiv;
    static int[] numOfDiv;
    static ArrayList <Integer> primes;
    //static int[] primes;
    static int ptr = 0;
    static boolean[] isPrime;

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------



        /*fac = new long[nn + 1];
        fac[1] = 1;
        for(int i = 2; i <= nn; i++)
            fac[i] = fac[i - 1] * i % MOD;*/


        /*pow2 = new long[nn + 1];
        pow2[0] = 1L;
        for(int i = 1; i <= nn; i++)
            pow2[i] = pow2[i - 1] * 2L;*/


        /*inv = new long[nn + 1];
        inv[1] = 1;
        for (int i = 2; i <= nn; ++i)
            inv[i] = (MOD - MOD / i) * inv[(int)(MOD % i)] % MOD;*/

        /*facInv = new long[nn + 1];
        facInv[0] = facInv[1] = 1;
        for (int i = 2; i <= nn; ++i)
            facInv[i] = facInv[i - 1] * inv[i]... Complexity:
targets: cubic
inputs: import java.util.*;
public class q1
{
	public static void main(String[] args) 
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] arr1=new int[9];
		int[] arr2=new int[9];
		String ss;
		s.nextLine();
		for(int i=0;i<n;i++)
		{
			ss=s.nextLine();
			if(ss.equals("M"))
				arr1[0]++;
			else if(ss.equals("S"))
				arr1[1]++;
			else if(ss.equals("L"))
				arr1[2]++;
			else if(ss.equals("XS"))
				arr1[3]++;
			else if(ss.equals("XL"))
				arr1[4]++;
			else if(ss.equals("XXS"))
				arr1[5]++;
			else if(ss.equals("XXL"))
				arr1[6]++;
			else if(ss.equals("XXXS"))
				arr1[7]++;
			else if(ss.equals("XXXL"))
				arr1[8]++;
		}	
		for(int i=0;i<n;i++)
		{
			ss=s.nextLine();
			if(ss.equals("M"))
				arr2[0]++;
			else if(ss.equals("S"))
				arr2[1]++;
			else if(ss.equals("L"))
				arr2[2]++;
			else if(ss.equals("XS"))
				arr2[3]++;
			else if(ss.equals("XL"))
				arr2[4]++;
			else if(ss.equals("XXS"))
				arr2[5]++;
			else if(ss.equals("XXL"))
				arr2[6]++;
			else if(ss.equals("XXXS"))
				arr2[7]++;
			else if(ss.equals("XXXL"))
				arr2[8]++;
		}	
		int min;
		for(int i=0;i<9;i++)
		{
			if(arr1[i]<arr2[i])
				min=arr1[i];
			else
				min=arr2[i];
			arr1[i]-=min;
			arr2[i]-=min;
		}
		int sum=0;
		for(int i=0;i<9;i++)
		{
			sum+=arr1[i];
		}
		System.out.println(sum);
		//System.out.println(Arrays.toString(arr2));
	}
} What is the time complexity of the previous code?
targets: linear
inputs: import java.io.*;
import java.util.*;
public class EMatrix{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
            final int max = (int)(1E9);
            int n , m;
            int a[][];
            int gm[];
            boolean visit[][]; int dp[][];
            boolean check(int d){
                if(n == 1){
                    for(int i = 0; i < m - 1; i++){
                        if(Math.abs(a[0][i] - a[0][i + 1]) < d)return false;
                    }
                    return true;
                }
                int nm[] = new int[n], pm[] = new int[n];
                for(int i = 0; i < n; i++){
                    boolean r;
                    for(int j = 0; j < n; j++){
                        if(j == i)continue;
                        r = true;
                        for(int k = 0; k < m; k++){
                            if(Math.abs(a[i][k] - a[j][k]) < d){
                                r = false; break;
                            }
                        }
                        if(r){
                            nm[i] |= (1 << j);
                        }
                        r = true;
                        for(int k = 0; k < m - 1; k++){
                            if(Math.abs(a[i][k + 1] - a[j][k]) < d){
                                r = false; break;
                            }
                        }
                        if(r){
                            pm[i] |= (1 << j);
                        }
                    }
                }
                // for(int i = 0; i < n; i++){
                //     System.out.println(nm[i] + " " + pm[i]);
                // }
                for(int i = 0; i < n; i++){
          ... 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 sun.rmi.transport.DGCImpl_Stub;

import java.io.*;
import java.nio.file.ClosedWatchServiceException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));

//        String fileName = "C-large";
//        ConsoleIO io = new ConsoleIO(new FileReader("D:\\Dropbox\\code\\practice\\jb\\src\\" + fileName + ".in"), new PrintWriter(new File("D:\\Dropbox\\code\\practice\\jb\\src\\" + fileName + ".out")));

        new Main(io).solve();
//        new Main(io).solveLocal();

        io.close();
    }

    ConsoleIO io;

    Main(ConsoleIO io) {
        this.io = io;
    }

    ConsoleIO opt;

    Main(ConsoleIO io, ConsoleIO opt) {
        this.io = io;
        this.opt = opt;
    }

    List<List<Integer>> gr = new ArrayList<>();
    long MOD = 1_000_000_007;

    public void solve() {
        long x = io.readLong(), k = io.readLong();
        if(x==0){
            io.writeLine("0");
            return;
        }

        long res = ((pow(2, k+1, MOD) * (x % MOD)) % MOD - pow(2, k, MOD) % MOD + 1 + MOD) % MOD;
        io.writeLine(res+"");
    }

    long pow(long a, long p, long mod) {
        long res = 1;
        while (p > 0) {
            if (p % 2 == 1) res = (res * a) % mod;
            a = (a * a) % mod;
            p /= 2;
        }
        return res;
    }
}


class ConsoleIO {

    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(Reader reader, PrintWriter writer){br = new BufferedReader(reader);out = writer;}
    public void flush(){this.out.flush();}
    public void close(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public void writeIntArray(int[] a, int k, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0;... Complexity:
targets: logn
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();
            int[] xs = new int[n];
            for (int i = 0; i < n; i++) xs[i] = in.nextInt();
            double[] ys = new double[n];
            for (int i = 0; i < n; i++) {
                int x = xs[i];
                double y = r;
                for (int j = 0; j < i; j++) {
                    y = Math.max(y, calc(xs[j], ys[j], x, r));
                }
                ys[i] = y;
            }
            for (int i = 0; i < n; i++) {
                out.printf("%.10f ", ys[i]);
            }
            out.println();
        }

        private double calc(int x, double y, int x1, int r) {
            int dx = Math.abs(x - x1);
            if (dx > 2 * r) return 0;
            double dy = Math.sqrt(4 * r * r - dx * dx);
            return y + dy;
        }

    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in), 32768);
        }

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

... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: quadratic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;

public class Solution {
    public static void main (String[] args) throws IOException {
        boolean online = "true".equals(System.getProperty("ONLINE_JUDGE"));
        if (online) {
            in = new InputReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        else {
            in = new InputReader(new FileReader("input.txt"));
            out = new PrintWriter(new File("output.txt"));
        }
        
        new Solution().run();
        
        out.close();
    }
    
    long sum (int x) {
        return x * 1l * (x+1) / 2;
    }
    
    int bins (long n, int k) {
        int l = 1,
            r = k;
        while (l < r) {
            int w = (l+r)/2;
            long s = sum(k) - sum(w-1);
            if (s == n)
                return w;
            if (s < n)
                r = w;
            else
                l = w+1;
        }
        return l;
    }
    
    private void run () {
        long n = in.nextLong();
        int k = in.nextInt();
        if (n == 1) {
            out.println(0);
            return;
        }
        if (1 + sum(k-1) < n) {
            out.println(-1);
            return;
        }
        int c = bins(n-1,k-1);
        if (1 + sum(k-1) - sum(c-1) == n)
            out.println(k-c);
        else
            out.println(k-c+1);
    }
    
    private static InputReader in;
    private static PrintWriter out;
}

class InputReader {
    public InputReader (Reader r) {
        buff = new BufferedReader(r);
        try {
            str = new StringTokenizer(buff.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public String next () {
        while (!str.hasMoreTokens())
            try {
                str = new StringTokenizer(buff.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        return str.nextToken();
    }
    
    public int nextInt () {
       ... Complexity:
targets: logn
inputs: import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class A {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt()-1;
		PrimeGen p = new PrimeGen(n);
		List<Integer> prims = new ArrayList<Integer>();
		for(int i = 2; i <= n; i++){
			if(p.isPrime(i)>0){
				prims.add(i);
			}
		}
		int sum = 0;
		for(int i = 0; i < prims.size() - 1; i++){
			int c = prims.get(i) + prims.get(i+1) + 1;
			if(c <= n && p.isPrime(c)>0){
				sum ++;
			}
		}
		System.out.println(sum>=k?"YES":"NO");
	}

	static int sum(List<Integer> is) {
		int c = 0;
		for (int i : is)
			c += i;
		return c;
	}
	
	static class PrimeGen {
		public PrimeGen(int m) {
			m = (int) Math.sqrt(m);
			double max = 0;
			int r = 1;
			for (int i = 0; i < 4;) {
				max += r * m / Math.pow(Math.log1p(m), ++i);
				r *= i;
			}
			p = new int[(int) max];
			for (int i = 0, e = 2; i < p.length; i++) {
				for (; isPrime(e) < 1; e++)
					;
				p[i] = e++;
			}
			this.m = p[p.length - 1];
			this.m = this.m * this.m;
		}

		int isPrime(int n) {
			for (int e : p)
				if (e < 1)
					break;
				else if (n != e && n % e < 1)
					return 0;
			return 1;
		}

		int max() {
			return m;
		}

		int[] p;
		int m;
	}
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: import java.io.PrintWriter;

import java.util.*;
import java.util.Arrays ; 
import java .lang.String.* ;
import java .lang.StringBuilder ;


public class Test{
    static int pos = 0 ; 
    static int  arr[] ; 
  static LinkedList l1 = new  LinkedList() ; 
static void find(int p ,char[]x,int put[],String s){
    int c= 0 ; 
    for (int i = 0; i < s.length(); i++) {
        if(x[p]==s.charAt(i)){
        c++ ; }
    }
    put[p] = c ;  
}
static int mode(int m ,int[]x ){
    int temp = 0 ; 
    for (int i = x.length-1; i >=0; i--) {
        if(x[i]<=m){
            temp= x[i] ; 
           /// break ; 
             return m-temp ; 
             
        }
    }
     return m-temp ; 
}
static int mode2(int m ,int[]x ){
    int temp = 0 ; 
    
    for (int i = x.length-1; i >=0; i--) {
        if(x[i]<=m){
            temp= x[i] ; 
           /// break ; 
             return x[i] ; 
             
        }
    }
     return 0 ; 
}
static int find(int x[],int temp){
    int j = 0 ; 
    for (int i = x.length-1; i >=0; i--) {
        if(x[i]==temp) return j+1 ; 
        j++ ; 
    }
    return -1 ; 
}
static String ch(long[]x,long b){
    for (int i = 0; i < x.length; i++) {
        if(x[i]==b)return "YES" ;
    }
    return "NO" ; 
}

    public static void main(String[] args)  {

        Scanner in = new Scanner(System.in) ;
        PrintWriter pw = new PrintWriter(System.out);   
     int k=in.nextInt(), n=in.nextInt(), s=in.nextInt(), p=in.nextInt() ;
     int paper =n/s; 
     if(n%s!=0) paper++ ; 
     paper*=k ; 
     int fin = paper/p ; 
     if(paper%p!=0) fin++ ; 
        System.out.println( fin );
       
       
 }               
}

 What is the time complexity of the previous code?
targets: constant
inputs: //never leave a uncompleted question in this file, always remove the code after submitting it.

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

public class run{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long k = in.nextInt();
        long ans = (-3 + (long)Math.sqrt(9+8*(n+k)))/2;
        System.out.println(n-ans);
    }
} 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.util.*;
import java.io.*;

public class programA {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		if(n%2 == 0)System.out.println(n/2 +1);
		else System.out.println((int)Math.ceil((double)n/2));
	}
}




 Complexity:
targets: constant
inputs: import java.util.Scanner;


public class Subtractions {
	
	
	
	
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int test=sc.nextInt();
		while(test-->0){
			long a=sc.nextLong();
			long b=sc.nextLong();
			long count=0;
			long cnt=0;
			while(a>0&&b>0){
				count=0;
				//System.out.println(a+" "+b);
			if(a>b){
			count+=(a-b)/b;
			if(count!=0){
			cnt+=count;
			a-=b*count;}
			else {
				cnt++;
				a-=b;
			}
			}
			else{ 
				count+=(b-a)/a;
				if(count!=0){
				cnt+=count;
			b-=a*count;}
				else {
					cnt++;
					b-=a;
				}
			}
			}
		System.out.println(cnt);
		}
		
		
		
	}

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

public class StrangeAddition {

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

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

	static StringTokenizer sc;

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

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

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: constant
inputs: /*
 * PDPM IIITDM Jabalpur
 * Asutosh Rana
 */

import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
	long MOD = 1000000007;
	InputReader in;
	BufferedReader br;
	PrintWriter out;

	public static void main(String[] args) throws java.lang.Exception {
		Main solver = new Main();
		solver.in = new InputReader(System.in);
		solver.br = new BufferedReader(new InputStreamReader(System.in));
		solver.out = new PrintWriter(System.out);
		solver.solve();
		solver.out.flush();
		solver.out.close();
	}

	public void solve() {

		int tc = 1;//in.readInt();

		for (int cas = 1; cas <= tc; cas++) {
			int N = in.readInt();
			int[] A = new int[N];
			in.readInt(A);

			int res = 0;
			for(int i=0;i<N;i++){
				for(int j=i+1;j<N;j++){
					if(A[i]>A[j])
						res++;
				}
			}
			res = res % 2;
			
			int Q = in.readInt();
			while(Q-->0){
				int l = in.readInt();
				int r = in.readInt();
				int add = (r-l+1)/2;
				res = res + add;
				res%=2;
				out.println(res%2==0?"even":"odd");
			}
		}

	}

}

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

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

	public int read() {
		if (numChars == -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')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public void readInt(int[] A) {
		for (int i = 0; i < A.length; i++)
			A[i] = readInt();
	}

	public long readLong() {
		int c... What is the time complexity of the previous code?
targets: quadratic
inputs: import java.io.*;
import java.util.*;

public class B {

	static int n, t[], g[], MOD = (int) 1e9 + 7;
	static int[][][] memo1, memo2[], memo3[];

	static int dp1(int idx, int remCnt, int remSum) {
		if (idx == n)
			return remSum == 0 && remCnt == 0 ? 1 : 0;
		if (remCnt < 0 || remSum < 0)
			return 0;
		if (memo1[idx][remCnt][remSum] != -1)
			return memo1[idx][remCnt][remSum];
		int ans = dp1(idx + 1, remCnt, remSum);
		if (g[idx] == 0) {
			ans += dp1(idx + 1, remCnt - 1, remSum - t[idx]);
			if (ans >= MOD)
				ans -= MOD;
		}
		return memo1[idx][remCnt][remSum] = ans;
	}

	static int dp2(int idx, int remCnt1, int remCnt2, int remSum) {

		if (idx == n)
			return remSum == 0 && remCnt1 == 0 && remCnt2 == 0 ? 1 : 0;
		if (remSum < 0 || remCnt1 < 0 || remCnt2 < 0)
			return 0;
		if (memo2[idx][remCnt1][remCnt2][remSum] != -1)
			return memo2[idx][remCnt1][remCnt2][remSum];
		int ans = dp2(idx + 1, remCnt1, remCnt2, remSum);

		if (g[idx] == 1)
			ans += dp2(idx + 1, remCnt1 - 1, remCnt2, remSum - t[idx]);
		else if (g[idx] == 2)
			ans += dp2(idx + 1, remCnt1, remCnt2 - 1, remSum - t[idx]);
		if (ans >= MOD)
			ans -= MOD;
		return memo2[idx][remCnt1][remCnt2][remSum] = ans;
	}

	private static int dp3(int cnt0, int cnt1, int cnt2, int last) {
		if (cnt0 + cnt1 + cnt2 == 0)
			return 1;
		if (memo3[last][cnt0][cnt1][cnt2] != -1)
			return memo3[last][cnt0][cnt1][cnt2];
		long ans = 0;
		if (cnt0 > 0 && last != 0)
			ans += dp3(cnt0 - 1, cnt1, cnt2, 0);
		if (cnt1 > 0 && last != 1)
			ans += dp3(cnt0, cnt1 - 1, cnt2, 1);
		if (cnt2 > 0 && last != 2)
			ans += dp3(cnt0, cnt1, cnt2 - 1, 2);
		return memo3[last][cnt0][cnt1][cnt2] = (int) (ans % MOD);

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		n = sc.nextInt();
		int[] fac = new int[n + 1];
		t = new int[n];
		g = new int[n];
		int[] cnt = new int[3];
		fac[0] = 1;
		for (int i = 1; i <= n; i++)
			fac[i] = (int) (i * 1L * fac[i - 1] % MOD);
		int T =... What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class TaskC {
        private static final int MOD = (int) 1e9 + 7;
        private static final int N = 5000;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] dp = new int[N];
            Arrays.fill(dp, 0);
            dp[0] = 1;
            String pre = null, ch;
            for (int i = 0; i < n; ++i) {
                ch = in.next();
                if (i > 0) {
                    if (pre.equals("s")) {
                        int j = N - 1;
                        while (dp[j] == 0) {
                            --j;
                        }
                        long sum = 0;
                        for (; j >= 0; --j) {
                            sum += dp[j];
                            sum %= MOD;
                            dp[j] = (int) sum;
                        }
                    } else {
                        for (int k = N - 1; k > 0; --k) {
                            dp[k] = dp[k - 1];
                        }
                        dp[0] = 0;
                    }
                }
                pre = ch;
            }

            long sum = 0;
            for (int i = 0; i < N; ++i) {
                sum += dp[i];
                sum %= MOD;
            }
            out.println(sum);
        }

    }
}

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

/**
 * @author def
 * @version 1.0
 */
public class B {

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

    void solve() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = Integer.parseInt(in.readLine());
        while (n-- > 0) {
            String s = in.readLine();
            int pr = s.indexOf('R');
            int pc = s.indexOf('C');
            if (pr == 0 && pc > 1 && Character.isDigit(s.charAt(1))) {
                int r = Integer.parseInt(s.substring(1, pc));
                int c = Integer.parseInt(s.substring(pc + 1, s.length()));
                out.println(i2s(c) + r);
            } else {
                int i = 0;
                while (!Character.isDigit(s.charAt(i))) ++i;
                out.println("R" + Integer.parseInt(s.substring(i, s.length())) + "C" + s2i(s.substring(0, i)));
            }
        }

        out.close();
    }

    int s2i(String s) {
        int r = 0;
        for (int i = 0; i < s.length(); ++i) {
            r = r * 26 + (s.charAt(i) - 'A' + 1);
        }
        return r;
    }

    String i2s(int i) {
        StringBuffer s = new StringBuffer();
        while (i > 0) {
            i -= 1;
            s.append((char)('A' + (i % 26)));
            i /= 26;
        }
        return s.reverse().toString();
    }

    BufferedReader in;
    PrintWriter out;
}
 What is the time complexity of the previous code?
targets: linear
inputs: import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main implements Runnable
{
    boolean multiiple = false;

    void solve() throws Exception
    {
        int n = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++)
            list.add(sc.nextInt());
        Collections.sort(list);
        int ans = 0;
        while (!list.isEmpty())
        {
            ans++;
            int next = list.get(0);
            for (int i = list.size() - 1; i >= 1; i--)
            {
                if (list.get(i) % next == 0)
                    list.remove(i);
            }
            list.remove(0);
        }

        System.out.println(ans);
    }

    @Override
    public void run()
    {
        try
        {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            sc = new FastScanner(in);
            if (multiiple)
            {
                int q = sc.nextInt();
                for (int i = 0; i < q; i++)
                    solve();
            }
            else
                solve();
        }
        catch (Throwable uncaught)
        {
            Main.uncaught = uncaught;
        }
        finally
        {
            out.close();
        }
    }

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

    static Throwable uncaught;
    BufferedReader in;
    FastScanner sc;
    PrintWriter out;
}

class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in)
    {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
       ... 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. import java.util.Scanner;

public class Main {
    
    final static long Mod = 1000000009;
    static long n, m, k, t, l, u, ans;
    static Scanner cin = new Scanner(System.in); 
    
    static long multi_mod(long base, long cur) {
        long res = 1;
        while(cur > 0) {
            if(cur % 2 == 1) res = (res * base) % Mod;
            cur >>= 1;
            base = (base * base) % Mod;
        }
        return res;
    }
    
    public static void main(String[] args) {
        n = cin.nextLong(); m = cin.nextLong(); k = cin.nextLong();
        l = (k - 1)*(n / k) + n % k;
        if(m <= l) {
            System.out.println(m);
        }
        else {
            t = n / k;
            u = m - l;
            ans = (0 + (t - u) * (k - 1) + n % k) % Mod;
            ans = (ans + ((k)*((multi_mod(2, u + 1) - 2 + Mod) % Mod)) % Mod) % Mod;
            System.out.println(ans);
        }
    }
}
 Complexity:
targets: logn
inputs: import java.io.*;
import java.util.*;

public class n2{
    public static void main(String[] args) throws Exception{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        int[] S=new int[4];
        int[] L=new int[4];
        int m=0;
        for(int i=0;i<n;i++){
            String s=in.readLine();
            if(s.charAt(s.length()-1)=='L'){
                L[s.length()-1]++;
            }
            if(s.charAt(s.length()-1)=='S'){
                S[s.length()-1]++;
            }
            if(s.charAt(s.length()-1)=='M'){
                m++;
            }
        }
        for(int i=0;i<n;i++){
            String s=in.readLine();
            if(s.charAt(s.length()-1)=='L'){
                L[s.length()-1]--;
            }
            if(s.charAt(s.length()-1)=='S'){
                S[s.length()-1]--;
            }
            if(s.charAt(s.length()-1)=='M'){
                m--;
            }
        }
        int count=0;
        for(int i=0;i<=3;i++){
            if(S[i]>0){
                count+=S[i];
            }
            if(L[i]>0){
                count+=L[i];
            }
        }
        if(m>0){
            count+=m;
        }
        System.out.println(count);
    }
} What is the time complexity of the previous code?
targets: linear
inputs: import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    if (n % 4 == 0 || n % 7 == 0 || n % 47 == 0 || n % 77 == 0 || n % 74 == 0 || n % 447 == 0 || n % 474 == 0 || n % 477 == 0 || n % 747 == 0 || n % 774 == 0 || n % 777 == 0)
      System.out.println("YES");
    else
      System.out.println("NO");
  }
} What is the time complexity of the previous code?
targets: constant
inputs: import java.util.Scanner;
public class LCM {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		if(n < 3) {
			System.out.println(n);
		}
		else if(n % 2 != 0) {
			System.out.println(n * (n-1) * (n-2));
		}
		else if(n % 3 == 0) {
			System.out.println((n-1) * (n-2) * (n-3));
		}
		else {
			System.out.println(n * (n-1) * (n-3));
		}
	}
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: constant
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
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);
        BSportMafia solver = new BSportMafia();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSportMafia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long k = in.nextInt();
            long d = 9 + 4 * (2 * n + 2 * k);
            double smh = Math.sqrt(d);
            double ans = (-3 + smh) / 2;
            out.println(n - (int) ans);
        }

    }

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

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

        public 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 nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
... What is the time complexity of the previous code?
targets: logn