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

public class Task122A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		if ( (n % 4 == 0)   ||
			 (n % 7 == 0)   ||
			 (n % 44 == 0)  ||
			 (n % 47 == 0)  ||
			 (n % 74 == 0)  ||
			 (n % 77 == 0)  ||
		   	 (n % 444 == 0) ||
			 (n % 447 == 0) ||
			 (n % 474 == 0) ||
			 (n % 477 == 0) ||
			 (n % 744 == 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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskF {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = in.nextInt(); }

            Map<Integer, List<Range>> rgs = new HashMap<Integer, List<Range>>();

            for (int i = 0; i < n; i++) {
                int s = 0;
                for (int j = i; j < n; j++) {
                    s += a[j];

                    if (rgs.get(s) == null) {  rgs.put(s, new ArrayList<Range>()); }

                    rgs.get(s).add(new Range(i, j));
                }
            }

            Iterator it = rgs.entrySet().iterator();
            List<Range> ans = new ArrayList<Range>();

            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                int sum = (int) pair.getKey();
                List<Range> ranges = rgs.get(sum);

                List<Range> cand = new ArrayList<Range>();

                for (Range r : ranges) {
                    if (cand.size() == 0) {
                        cand.add(r);
                        continue;
        ... 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.util.ArrayList;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.*;
 public class Main {


    public static void main(String[] args) throws NumberFormatException, IOException 
    {
        Scanner sc = new Scanner(new File("input.txt"));
        
        int n = sc.nextInt();
        int m =sc.nextInt();
        sc.nextLine();
        int k =sc.nextInt();
        int les[][] = new int[n][m];
        PrintWriter out = new PrintWriter(new FileWriter("output.txt")); 
        //sc.nextLine();
        ArrayList<Integer[]> list = new ArrayList();
        sc.nextLine();
        for(int i = 0;i<k;i++)
        {
            
            Integer[] ii = new Integer[2];
            ii[0] = sc.nextInt()-1;
            ii[1] = sc.nextInt()-1;
            list.add(ii);
            
        }
        sc.close(); 
        int maxr = 0;
        int maxi = 0;
        int maxj = 0;
        for(int i = 0;i<n;i++)
        {
            for(int j = 0;j<m;j++)
            {
                int minr = 100000;
                int mini = 0;
                int minj = 0;
                for(int f = 0;f<k;f++)
                {
                    Integer[] ii = list.get(f);
                    int ww = Math.abs(ii[0] - i);
                    int hh = Math.abs(ii[1] - j);
                    int r = ww+hh;
                    if(r<minr)
                    {
                        minr = r;
                        mini=i;
                        minj=j;
                    }
                    
                }
                if(maxr<minr&&minr<100000)
                {
                    maxi = mini;
                    maxj = minj;
                    maxr = minr;
                }
            }
        }
        
        out.print((maxi+1)+" "+(maxj+1));
        out.close();
        
    }
    
    


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

public class C1523 {
	public static void print(Stack<Integer> st, PrintWriter pw) {
		for (int i = 0; i < st.size(); i++) {
			pw.print(st.get(i));
			if (i != st.size() - 1) {
				pw.print(".");
			}
		}
		pw.println();
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			int[] arr = sc.nextIntArr(n);
			Stack<Integer> st = new Stack<Integer>();
			st.add(arr[0]);
			print(st, pw);
			for (int i = 1; i < n; i++) {
				if (arr[i] == 1) {
					st.add(arr[i]);
				} else {
					while (st.peek() != arr[i] - 1) {
						st.pop();
					}
					st.pop();
					st.add(arr[i]);
				}
				print(st, pw);
			}
		}
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		public Scanner(FileReader f) {
			br = new BufferedReader(f);
		}

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

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

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

public class A {
  FastScanner in;
  PrintWriter out;

  public void run() {
    try {
      in = new FastScanner(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
      solve();
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  public void solve() throws IOException {
    long l = new Long(in.next());
    long r = new Long(in.next());
    if (r - l < 2 || (r - l == 2 && l % 2 != 0)) {
      out.println("-1");
    } else {
      if (l % 2 != 0) {
        l++;
      }
      out.println(l);
      out.println(l+1);
      out.println(l+2);
    }
  }

  class FastScanner {
    BufferedReader br;
    StringTokenizer st;

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

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

      return str;
    }

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

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

  public static void main(String[] arg) {
    A o = new A();
    o.run();
  }

}
 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.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long num = input.nextLong();
        if(num==0){
            System.out.println(num);
        }else if(num==1||num==2){
            System.out.println(num);}
        else if(num%2==0&&num>2&&num%3!=0){
            System.out.println(num*(num-1)*(num-3));
        }
        else if(num%2==0&&num%3==0){
            System.out.println((num-1)*(num-2)*(num-3));
        }
        else{
        System.out.println(num*(num-1)*(num-2));}
    }
   
}
 Complexity:
targets: constant
inputs: import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
    InputStream is;
    PrintWriter out;
    String INPUT = "" ;
    boolean local = false;
    int inf=0x7FFFFFFF;
    int MOD=(int)(1e9+7);
    double eps=1e-5;
    double PI=Math.acos(-1);
    void solve() {
        long maxn=nl();
        long L=1,R=maxn,ans=-1;
        while (L<=R){
            long mid=(L+R)/2;
            if(ask(1,1,mid,maxn)<1)L=mid+1;
            else{
                R=mid-1;
                ans=mid;
            }
        }
        if(ask(1,1,ans,maxn)==1 && ask(ans+1,1,maxn,maxn)==1){
            Yts1999 a1=gao(1,1,ans,maxn);
            Yts1999 a2=gao(ans+1,1,maxn,maxn);
            answer(a1,a2);
        }else{
            L=1;R=maxn;ans=-1;
            while (L<=R){
                long mid=(L+R)/2;
                if(ask(1,1,maxn,mid)<1)L=mid+1;
                else{
                    R=mid-1;
                    ans=mid;
                }
            }
            Yts1999 a1=gao(1,1,maxn,ans);
            Yts1999 a2=gao(1,ans+1,maxn,maxn);
            answer(a1,a2);
        }
    }
    void answer(Yts1999 a1,Yts1999 a2){
        out.print("!");
        a1.print();
        a2.print();
        out.flush();
    }
    int ask(long a,long b,long c,long d){
        out.printf("? %d %d %d %d",a,b,c,d);
        out.println();
        out.flush();
        return ni();
    }
    Yts1999 gao(long x1,long x2,long y1,long y2){
        long a1=0,a2=0,a3=0,a4=0;
        long L,R;
        L=x1;R=y1;
        while(L<=R){
            long mid=(L+R)/2;
            if(ask(mid,x2,y1,y2)==1){
                a1=mid;
                L=mid+1;
            }else R=mid-1;
        }
        L=x1;R=y1;
        while(L<=R){
            long mid=(L+R)/2;
            if(ask(x1,x2,mid,y2)==1){
                a3=mid;
                R=mid-1;
            }else L=mid+1;
        }
        L=x2;R=y2;
        while(L<=R){
            long mid=(L+R)/2;
            if(ask(x1,mid,y1,y2)==1){
                a2=mid;
               ... What is the time complexity of the previous code?
targets: logn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 

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

public class Test5 {
    public static void main(String[] z){
        StreamTokenizer st = new StreamTokenizer(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(), o=0;
        String i = "";
        ArrayList<String> l1 = new ArrayList<>(), l2 = new ArrayList<>();
        for(int q=0; q<a; q++){
            l1.add(s.next());
        }
        for(int q=0; q<a; q++){
            i = s.next();
            if(l1.contains(i)) l1.remove(i);
            else l2.add(i);
        }
        Collections.sort(l1);
        Collections.sort(l2);

        for(int q=0; q<l1.size(); q++){
            if(l1.get(q).charAt(l1.get(q).length()-1)!=l2.get(q).charAt(l2.get(q).length()-1)) o++;
        }
        System.out.println(o);
        pw.flush();
    }

    static class PyraSort {

        private static int heapSize;

        public static void sort(int[] a) {
            buildHeap(a);
            while (heapSize > 1) {
                swap(a, 0, heapSize - 1);
                heapSize--;
                heapify(a, 0);
            }
        }

        private static void buildHeap(int[] a) {
            heapSize = a.length;
            for (int i = a.length / 2; i >= 0; i--) {
                heapify(a, i);
            }
        }

        private static void heapify(int[] a, int i) {
            int l = 2 * i + 2;
            int r = 2 * i + 1;
            int largest = i;
            if (l < heapSize && a[i] < a[l]) {
                largest = l;
            }
            if (r < heapSize && a[largest] < a[r]) {
                largest = r;
            }
            if (i != largest) {
                swap(a, i, largest);
                heapify(a, largest);
            }
        }

        private static void swap(int[] a, int i, int j) {
            a[i] ^= a[j] ^= a[i];
            a[j] ^= a[i];
        }
    }
}
 Complexity:
targets: linear
inputs: import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;


public class Main {

    private void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        final int[] p = new int[n];
        final int[] t = new int[n];
        for(int i =0 ; i < n; ++i) {
            p[i] = in.nextInt();
            t[i] = in.nextInt();
        }
        Integer[] ord = new Integer[n];
        for(int i = 0; i < n; ++i)
            ord[i] = i;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n - 1; ++j) {
                if (Less(ord[j], ord[j + 1], p, t)) {
                    Integer tx = ord[j];
                    ord[j] = ord[j + 1];
                    ord[j + 1] = tx;
                }
            }
        }
        
        
        
        for(int i = 0, j = 0; i < n; i = j) {
            for(j = i; j < n && p[ord[i]] == p[ord[j]] && t[ord[i]] == t[ord[j]]; ++j) ;
            int first = i+1;
            int second = j;
            if (first <= k && k <= second) {
                out.print(j - i);
                return ;
            }
        }
        out.print(0);
    }
    private boolean Less(Integer i, Integer j, int[] p, int[] t) {
        return p[i] < p[j] || p[i] == p[j] && t[i] > t[j];
    }
    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new OutputStreamWriter(System.out));
            solve();
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
    FastScanner in;
    PrintWriter out;
    class FastScanner {
        public BufferedReader reader;
        private StringTokenizer tokenizer;
        public FastScanner(String file) {
            try {
                reader = new BufferedReader(new FileReader(new File(file)));
                tokenizer = null;
            } catch (FileNotFoundException e) {
... 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.io.BufferedReader;
import java.io.IOException;
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.Scanner;
import java.util.StringTokenizer;

public class c {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n = in.nextInt(), m = in.nextInt();
		long bounty = in.nextInt(), increase = in.nextInt();
		int damage = in.nextInt();
		int[] mh = new int[n];
		int[] sh = new int[n];
		int[] reg = new int[n];
		long countKilled = 0;
		ArrayList<Event> es = new ArrayList<>();
		Event[] regen = new Event[n];
		for(int i=0;i<n;i++) {
			mh[i] = in.nextInt();
			sh[i] = in.nextInt();
			reg[i] = in.nextInt();
			if(sh[i] <= damage)
				countKilled++;
			if(reg[i] > 0) {
				int time = (damage+1 - sh[i]+reg[i]-1)/reg[i];
				if(time > 0 && mh[i] >= damage+1) {
					Event e2 = new Event(time, i, damage+1);
					regen[i] = e2;
					es.add(e2);
				}
			}
		}
		for(int i=0;i<m;i++) {
			Event e = new Event(in.nextInt(), in.nextInt()-1, in.nextInt());
			es.add(e);
			if(reg[e.e] > 0) {
				int time = (damage+1 - e.h+reg[e.e]-1)/reg[e.e];
				if(time > 0 && mh[e.e] >= damage+1) {
					Event e2 = new Event(e.t + time, e.e, damage+1);
					e.regen = e2;
					es.add(e2);
				}
			}
		}
		Collections.sort(es, (a,b) -> a.t-b.t);
		long ans = countKilled*bounty;
		int lastTime = 0;
		for(Event e : es) {
			if(e.t == -1) continue;
			if(regen[e.e] != e && regen[e.e] != null) {
				regen[e.e].t = -1;
				regen[e.e] = null;
			}
			if(lastTime != e.t) {
				ans = Math.max(ans, countKilled*(bounty+(e.t-1)*increase));
			}
			if(sh[e.e] <= damage)
				countKilled--;
			sh[e.e] = e.h;
			if(sh[e.e] <= damage)
				countKilled++;
			if(e.regen != null) {
				regen[e.e] = e.regen;
			}
			lastTime = e.t;
		}
		if(countKilled != 0) {
			if(increase > 0)
				ans = -1;
			else
				ans = Math.max(ans,... Complexity:
targets: nlogn
inputs: //package global14;
import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class B {
	InputStream is;
	FastWriter out;
	String INPUT = "";
	
	void solve()
	{
		for(int T = ni();T > 0;T--)go();
	}

	void go()
	{
		int n = ni();
		if(n % 2 == 0){
			int u = (int)Math.sqrt(n/2);
			if(u*u == n/2){
				out.println("YES");
				return;
			}
		}
		if(n % 4 == 0){
			int u = (int)Math.sqrt(n/4);
			if(u*u == n/4){
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new FastWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new B().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 = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i =... What is the time complexity of the previous code?
targets: linear
inputs: import java.util.Arrays;
import java.util.Scanner;


public class Success {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b=scan.nextInt();
		int[] t=new int[n];
		for(int i=0;i<n;i++)
		{
			t[i]=scan.nextInt();
		}
		Arrays.sort(t);
		System.out.println(t[b]-t[b-1]);
		}
		

	}

 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.math.BigInteger;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andy Phan
 */
public class p1096f {
    static long MOD = 998244353;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        BIT invert = new BIT(n+5);
        BIT neg = new BIT(n+5);
        long res = 0;
        int[] arr = new int[n];
        boolean[] has = new boolean[n+1];
        long num1 = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            if(arr[i] != -1) {
                res += invert.read(n+5)-invert.read(arr[i]);
                res %= MOD;
                invert.update(arr[i], 1);
                has[arr[i]] = true;
            } else num1++;
        }
        if(num1 == 0) {
            System.out.println(res);
            return;
        }
        for(int i = 1; i <= n; i++) if(!has[i]) neg.update(i, 1);
        long invertNum1 = modInv(num1, MOD);
        res += ((num1*(num1-1))%MOD)*modInv(4, MOD);
        res %= MOD;
        long cnt = 0;
        for(int i = 0; i < n; i++) {
            if(arr[i] == -1) {
                cnt++;
                continue;
            }
            res += (((neg.read(n+5)-neg.read(arr[i]))*cnt)%MOD)*invertNum1;
            res %= MOD;
        }
        cnt = 0;
        for(int i = n-1; i >= 0; i--) {
            if(arr[i] == -1) {
                cnt++;
                continue;
            }
            res += (((neg.read(arr[i]))*cnt)%MOD)*invertNum1;
            res %= MOD;
        }
        System.out.println(res);
    }
    
    //@
    static class BIT {
            int n;
            int[] tree;
            public BIT(int n) {
                    this.n = n;
                    tree = new int[n + 1];
            }

            int read(int i) {
                    int sum = 0;
             ... What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.PrintWriter;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = in.nextLine();

        int ans = 0;

        outer: for (int i = s.length() - 1; i >= 1; i--)
            for (int j = 0; j < s.length() - i; j++) {
                String sub = s.substring(j, j + i);
                String str = s.substring(j + 1);

                if (str.contains(sub)) {
                    ans = i;
                    break outer;
                }
            }

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

public class Codeforces913F {
	public static void main(String[] args) throws IOException {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int a = input.nextInt();
		int b = input.nextInt();
		input.close();
		final int mod = 998244353;
		
		int frac = multiply(a, inverse(b, mod), mod);
		int reverse = (mod+1-frac)%mod;
		
		int[] fracpower = new int[n+1];
		int[] reversepower = new int[n+1];
		fracpower[0] = 1;
		reversepower[0] = 1;
		for (int i = 1; i <= n; i++) {
			fracpower[i] = multiply(fracpower[i-1], frac, mod);
			reversepower[i] = multiply(reversepower[i-1], reverse, mod);
		}
		
		int[][] dp1 = new int[n+1][n+1];
		dp1[2][1] = 1;
		for (int i = 3; i <= n; i++) {
			for (int j = 1; j < i; j++) {
				if (j == 1) {
					dp1[i][j] = fracpower[i-1];
				}
				else {
					dp1[i][j] = multiply(dp1[i-1][j-1], fracpower[i-j], mod);
				}
				if (j == i-1) {
					dp1[i][j] += reversepower[i-1];
					dp1[i][j] %= mod;
				}
				else {
					dp1[i][j] += multiply(dp1[i-1][j], reversepower[j], mod);
					dp1[i][j] %= mod;
				}
			}
		}
		
		int[][] dp2 = new int[n+1][n+1];
		dp2[1][1] = 1;
		dp2[2][1] = 1;
		dp2[2][2] = 0;
		for (int i = 3; i <= n; i++) {
			int val = 0;
			for (int j = 1; j < i; j++) {
				dp2[i][j] = multiply(dp2[j][j], dp1[i][j], mod);
				val += dp2[i][j];
				val %= mod;
			}
			dp2[i][i] = (mod+1-val)%mod;
		}
		
		/*for (int i = 2; i <= n; i++) {
			for (int j = 1; j <= i; j++) {
				System.out.print(dp2[i][j] + " ");
			}
			System.out.println();
		}*/
		
		int[] EV = new int[n+1];
		EV[1] = 0;
		EV[2] = 1;
		for (int i = 3; i <= n; i++) {
			int val = 0;
			for (int j = 1; j < i; j++) {
				int r = j*(i-j) + (j*(j-1))/2 + EV[i-j] + EV[j];
				r %= mod;
				val += multiply(dp2[i][j], r, mod);
				val %= mod;
			}
			val += multiply((i*(i-1))/2, dp2[i][i], mod);
			val %= mod;
			
			int s = (mod+1-dp2[i][i])%mod;
			EV[i] = multiply(val, inverse(s, mod), mod);
		}
		
		System.out.println(EV[n]);
	}
	
	public static int... Complexity:
targets: quadratic
inputs: import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.*;

/**
 *
 * @author jon
 */
public class Fish {
    double memo[] = new double[(1<<18)];
    int N, FULL;
    double prob[][] = new double[18][18];
    Fish() {
        Scanner in = new Scanner(System.in);
        Arrays.fill(memo, -1);

        N = in.nextInt();
        FULL = (1<<N) - 1;

        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                prob[i][j] = in.nextDouble();
            }
        }

        for(int i = 0; i < N; i++) {
            System.out.printf("%.6f ", go((1<<i)));
        }
        System.out.println();



    }
    public double go(int mask) {
        if(mask == FULL) return 1.0;
        if(memo[mask] >= 0) return memo[mask];
        double ret = 0;
        double mult = Integer.bitCount(mask) + 1;
        mult *= (mult-1)/2.0;


        for(int i = 0; i < N; i++) {
            if(((1<<i) & mask) != 0) {
                for(int j = 0; j < N; j++) {
                    if(((1<<j) & mask) == 0) {
                        ret += go(mask | (1<<j)) * prob[i][j];
                    }
                }
            }
        }
        ret /= mult;

        memo[mask] = ret;
        return ret;
    }
    public static void main(String args[]) {
        new Fish();
    }
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np
inputs: import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

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

		long s=0;
		long e=n;

		long ans = -1;
		while (s<=e) {
			long m = (s+e)/2;
			long temp = ((n-m)*(n-m+1))/2 - m;

			if (temp < k) 
				e = m-1;
			else if (temp > k)
				s = m+1;
			else {
				ans = m;
				break;
			} 
		}

		writer.println(ans);
		writer.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();
		}

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

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

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

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: 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.*;
public class hackerearth {

    public  static  void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();

        HashMap<String,Integer> map=new HashMap<>();
        HashMap<String,Integer> map2=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            String s=sc.next();
            if(map.containsKey(s))
                map.put(s,map.get(s)+1);
            else
                map.put(s,1);
        }
        for(int i=0;i<n;i++)
        {
            String s=sc.next();
            if(map2.containsKey(s))
                map2.put(s,map2.get(s)+1);
            else
                map2.put(s,1);

            if(map.containsKey(s)) {
                int feq = map.get(s);
                feq--;
                if (feq <= 0)
                    map.remove(s);
                else
                    map.put(s, feq);
            }

        }


        int ans=0;
        for(Map.Entry<String,Integer> entry:map.entrySet())
        {
            ans+=entry.getValue();
        }
        System.out.println(ans);


    }



}
 Complexity:
targets: linear
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int max=0;
        for(int i=0;i<s.length();i++){
            int len=0;
            int k=i;
            boolean flag=false;
            for(int j=i+1;j<s.length();j++){
                if(s.charAt(k)==s.charAt(j)){
                len++;
                k++;
                flag=true;
                }
                else if(flag==true){
                    j=j-len;
                    k=i;
                    if(max<len)
                    max=len;
                    len=0;
                    flag=false;
                    
                }
                   
            }
            if(max<len)
            max=len;
        }
        System.out.print(max);
    }} What is the time complexity of the previous code?
targets: cubic
inputs: /**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

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

        int N = sc.nextInt();
        int[] pre = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            pre[i] = pre[i - 1] + sc.nextInt();
        }
        var sumMap = new HashMap<Integer, ArrayList<Pair>>();
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <= N; j++) {
                int sum = pre[j] - pre[i - 1];
                sumMap.computeIfAbsent(sum, val -> new ArrayList<>()).add(new Pair(i, j));
            }
        }
        var ans = new ArrayList<Pair>();
        for (var list : sumMap.values()) {
            Collections.sort(list, Comparator.comparingInt(p -> p.r));
            // greedily schedule the intervals
            int last = 0;
            var group = new ArrayList<Pair>();
            for (Pair p : list) {
                if (p.l > last) {
                    group.add(p);
                    last = p.r;
                }
            }
            if (group.size() > ans.size()) {
                ans = group;
            }
        }
        out.println(ans.size());
        for (Pair p : ans) {
            out.println(p);
        }
        out.close();
    }

    static class Pair {
        int l, r;
        public Pair(int ll, int rr) {
            l = ll; r = rr;
        }
        public String toString() {
            return l + " " + r;
        }
    }

    static class FastScanner {
        private int BS = 1<<16;
        private char NC = (char)0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
         ... What is the time complexity of the previous code?
targets: quadratic
inputs: import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

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

class TaskA {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] input = IOUtils.readIntArray(in, n);
        Arrays.sort(input);
        int x = input[b-1];
        int y = input[b];
        out.println(y - x);
    }
}

class IOUtils {

    public static int[] readIntArray(Scanner in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.nextInt();
        return array;
    }

    }

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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;
	
	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.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());
	}

	final int oo = Integer.MAX_VALUE;
	
	int [][]s;
	int n, ALL;
	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		n = nextInt();
		char []a = next().toCharArray();
		s = new int[n][52];
		boolean []set = new boolean[52];

		for(int i = 0; i < n; ++i) {
			int pos = get(a[i]);
			if (!set[pos]) {
				++ALL;
				set[pos] = true;
			}
			for(int j = 0; j < 52; ++j) {
				if (i > 0) {
					s[i][j] += s[i-1][j];	
				}
				if (j == pos) {
					s[i][j]++;
				}
			}
		}

		int ret = oo;
		for(int i = 0; i < n; ++i) {
			ret = Math.min(ret, get(i));
		}

		out.println(ret);
		out.close();
	}

	private int get(int i) {
		int lo = i - 1, hi = n;
		while(hi - lo > 1) {
			int m = lo + (hi - lo) / 2;
			int c = 0;
			for(int j = 0; j < 52; ++j) {
				if (sum(j, i, m) > 0) {
					++c;
				}
			}
			if (c < ALL) {
				lo = m;
			} else {
				hi = m;
			}
		}

		if (hi != n) {
			return hi - i + 1;
		}
		return oo;
	}

	private int sum(int pos, int l, int r) {
		int ret = s[r][pos];
		if (l > 0) ret -= s[l - 1][pos];
		return ret;
	}

	private int get(char x) {
		if ('a' <= x && x <= 'z') return (int)(x - 'a');
		return (int)(x - 'A' + 26);
	}

	public static void main(String[] args) throws Exception{
		new Main().run();
	}
}
 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

/* Template for TopCoder and ACMonline. */
public class A {
    private static StreamTokenizer in = null;
    private static PrintWriter out = null;
    
    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }
    
    static long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return (double) in.nval;
    }
    
    static String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }
    
    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        // Here is the solution:
        new A().solve();
        out.flush();
    }
    
    public void solve() throws IOException {
        int n = nextInt();
        int min = Integer.MAX_VALUE;
        int res = Integer.MAX_VALUE;
        for (int i=0; i<n; ++i) {
            int d = nextInt();
            if (d<min) {
                res = min;
                min = d;
            } else if (d>min && d<res)
                res = d;
        }
        if (res == Integer.MAX_VALUE)
            out.println("NO");
        else
            out.println(res);
    }
} What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.*;
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int x,y;
        boolean graph[][]=new boolean[n][n];
        for(int i=0;i<m;i++){
            x=sc.nextInt()-1;
            y=sc.nextInt()-1;
            graph[x][y]=graph[y][x]=true;
        }
        long dp[][]=new long[1<<n][n];
        long res=0;
        for(int i=0;i<n;i++){
            dp[1<<i][i]=1;
        }
        for(int mask=1;mask<(1<<n);mask++){
            int first=-1;
            for(int f=0;f<n;f++){
                if((mask&(1<<f))!=0){
                    first=f;
                    break;
                }
            }
            for(int i=0;i<n;i++){
                if((mask&(1<<i))!=0&&i!=first){
                    for(int j=0;j<n;j++){
                        if(graph[j][i]&&((mask&1<<j)!=0)){
                            dp[mask][i]+=dp[mask^1<<i][j];
                        }
                    }
                }
                if(Integer.bitCount(mask)>2&&graph[first][i]){
                    res+=dp[mask][i];
                }
            }
        }
        
        System.out.println(res/2);
    }
    
} 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.util.*;
import java.io.*;

public class PythonIndentation {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(in.readLine());
		int[][] dp = new int[N][N];
		dp[0][0] = 1;
		for(int i = 1; i < N; ++i) {
			char lastCmd = in.readLine().charAt(0);
			int[] sum = new int[N];
			sum[N - 1] = dp[i - 1][N - 1];
			for(int j = N - 2; j >= 0; --j)
				sum[j] = (sum[j + 1] + dp[i - 1][j]) % 1000000007;
			for(int j = 0; j < N; ++j) {
				if(lastCmd == 'f' && j > 0)
					dp[i][j] = dp[i - 1][j - 1];
				else if(lastCmd == 's')
					dp[i][j] = sum[j];
			}
		}
		int ans = 0;
		for(int i = 0; i < N; ++i)
			ans = (ans + dp[N - 1][i]) % 1000000007;
		System.out.println(ans);
	}
}
 Complexity:
targets: quadratic
inputs: import java.util.LinkedList;
import java.util.Locale;
import java.util.Scanner;

public class A{

    void exe(){
        LinkedList<Integer> list=new LinkedList<Integer>();
        for(int i=2;i<=1000;i++)
            if(isPrime(i))
                list.add(i);
        Object[] primes=list.toArray();
        
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int cnt=0;
        for(int c=2;c<=n;c++){
            if(!isPrime(c))
                continue;
            for(int i=0;i<primes.length-1;i++){
                int p1=(Integer)primes[i];
                int p2=(Integer)primes[i+1];
                if(c==1+p1+p2){
//                  System.out.println("c="+c+", i="+p1+", j="+p2);
                    cnt++;
                }
            }
        }
        if(cnt>=k){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

    boolean isPrime(int n){
        if(n<=1)return false;
        if(n==2)return true;
        if(n%2==0)return false;
        int m=(int)Math.sqrt(n)+1;
        for(int i=3;i<=m;i+=2)
            if(n%i==0)
                return false;
        return true;
    }
    
    public static void main(String[] args){
        Locale.setDefault(Locale.US);
        new A().exe();
    }
}
 What is the time complexity of the previous code?
targets: linear
inputs: import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Main implements Runnable {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            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 long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
... What is the time complexity of the previous code?
targets: linear
inputs: import java.util.*;

public class helloWorld 
{
	public static void main(String[] args) 
	{		
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int n = in.nextInt();

		int ans = n - (a + b - c);
		if(ans < 1 || a >= n || b >= n || c > a || c > b)
			ans = -1;
		
		System.out.println(ans);
		
		in.close();
	}
} 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.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long n = in.nextLong();
    long k = in.nextLong();

    long res = solve(n, k);
    System.out.println(res);
  }

  private static long solve(long n, long k) {
    return solveEq(1, -3 - 2 * n, n * n + n - 2 * k);
  }

  private static long solveEq(long a, long b, long c) {
    long delta = b * b - 4 * a * c;
    return (-b - (long)Math.sqrt(delta)) / (2 * a);
  }
}
 What is the time complexity of the previous code?
targets: logn
inputs: import java.util.*;
import java.io.*;

import static java.lang.Math.*;

public class Main {
    static int n;
     static long TotalTime;
    static Problem[] problems;
    static StringBuilder sb;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        sb = new StringBuilder();
        n = sc.nextInt();
        TotalTime = sc.nextLong();
        problems = new Problem[n];
        for (int i = 0; i < n; i++) {
            problems[i] = new Problem (sc.nextInt(), sc.nextLong(), i);
        }
        Arrays.sort(problems);
        long num = -1;
        long high = n;
        long low = 0;
        int iter = 0;
        while (high - low > 1) {
            num = (high + low) / 2;
            if (test(num, false)) {
                low = num;
            }
            else {
                high = num;
            }
        }
        if (test(high, false))
            num = high;
        else
            num = low;
        test(num, true);
        System.out.print(sb);
    }

    public static boolean test (long num, boolean print) {
        int count = 0;
        long sum = 0L;
        if (print) sb.append(num + "\n" + num + "\n");
        for (int i = 0; i < n && count < num; i++) {
            if (problems[i].a >= num) {
                count++;
                sum += problems[i].t;
                if (print) sb.append((problems[i].index + 1) + " ");
            }
        }
        return (count == num) && (sum <= TotalTime);
    }

    public static class Problem implements Comparable<Problem>  {
        int a;
        long t;
        int index;
        
        public int compareTo(Problem o) {
          return Long.compare(t, o.t);
        }
        public Problem (int a, long t, int index) {
            this.a = a;
            this.t = t;
            this.index = index;
        }
    }


    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
      ... 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.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		
		int t = scn.nextInt();
		while(t-- >0){
			String str = scn.next();
			Pattern p = Pattern.compile("R[0-9]+C[0-9]+");
			Matcher m = p.matcher(str);
			if (m.matches()){
				String nums[] = str.split("[RC]");
				String first = nums[1];
				String second = nums[2];
				
				String ans = "";
				long num = Integer.parseInt(second);
				while(num >0){
					if (num % 26 > 0){
						ans += (char)(num%26+'A'-1);
						num/=26;
					} else {
						ans += 'Z';
						num/=26;
						num--;
					}
				}
				for (int i = ans.length()-1; i>=0;--i){
					System.out.print(ans.charAt(i));
				}
				
				System.out.println(first);
			} else {
				String first = str.split("[0-9]+")[0];
				String second = str.split("[A-Z]+")[1];
				System.out.print("R"+second);
				
				long num = 0, pow = 1;
				for (int i = first.length()-1; i>=0; --i){
					num += (long)(first.charAt(i)-'A'+1) * pow;
					pow*=26;
				}
				System.out.println("C"+num);
			}
			
		}
	}
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear