Muennighoff/xP3x-sample huggingface dataset:
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. //Author: Patel Rag
//Java version "1.8.0_211"
import java.util.*;
import java.io.*;

public class Main
{
  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()); }

    float nextFloat() { return Float.parseFloat(next()); }

    boolean nextBoolean() { return Boolean.parseBoolean(next()); }

    String nextLine()
    {
      String str = "";
      try
      {
        str = br.readLine();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      return str;
    }
  }
  static long modExp(long x, long n, long mod)    //binary Modular exponentiation
  {
    long result = 1;
    while(n > 0)
    {
        if(n % 2 == 1)
            result = (result%mod * x%mod)%mod;
        x = (x%mod * x%mod)%mod;
        n=n/2;
    }
    return result;
  }
  static long gcd(long a, long b)
  {
    if(a==0) return b;
    return gcd(b%a,a);
  }
  public static void main(String[] args)
  throws IOException
  {
    FastReader fr = new FastReader();
    int n = fr.nextInt();
    int q = fr.nextInt();
    long[] a = new long[n];
    long[] k = new long[q];
    for(int i = 0; i < n; i++) a[i] = fr.nextLong();
    for(int i = 0; i < q; i++) k[i] = fr.nextLong();
    long[] pre = new long[n];
    pre[0] = a[0];
    for(int i = 1; i < n; i++) pre[i] = pre[i-1] + a[i];
    long pd = 0;
    for(int i = 0; i < q; i++)
    {
      int l = 0;
      int r = n - 1;
      while(r > l)
      {
        int mid = (l + r) >> 1;

        if(pre[mid] - pd <... Complexity:
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.*;
import java.io.*;

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

	int n = in.nextInt();
	int s = in.nextInt();
	int deg[] = new int [n];
	
	for (int i = 1; i < n; ++i) {
	    deg[in.nextInt() - 1] ++;
	    deg[in.nextInt() - 1] ++;
	}

	int l = 0;
	for (int i = 0; i < n; ++i)
	    if (deg[i] == 1) l ++;

	out.println((double) 2 * s / l);
	out.close();
    }

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

	public InputReader(InputStream stream) {
	    reader = new BufferedReader(new InputStreamReader(stream), 32768);
	    tokenizer = null;
	}

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

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

	public long nextLong() {
            return Long.parseLong(next());
        }
    }
}
 Complexity:
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;
import java.math.*;
// import java.awt.Point;
 
public class Main {
    InputStream is;
    PrintWriter out;
    String INPUT = "";
 
    long MOD = 1_000_000_007;
    int inf = Integer.MAX_VALUE;

    void solve()
    {
        int n = ni();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = ni();
        }
        long ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                if(a[j]<a[i]) ans++;
            }
        }
        if(ans%2==0) ans = 0;
        else ans = 1;
        int m = ni();
        for(int i = 0; i < m; i++){
            long s = nl();
            long g = nl();
            long sub = g-s;
            long res = sub*(sub+1)/2;
            if(res%2==1) ans = 1 - ans;
            if(ans==0) out.println("even");
            else out.println("odd");
        }

    }

     
        
    void run() throws Exception
    {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);
        
        long s = System.currentTimeMillis();
        solve();
        out.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
    }
    
    public static void main(String[] args) throws Exception { new Main().run(); }
    
    private byte[] inbuf = new byte[1024];
    private 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() {... Complexity:
targets: quadratic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.*;
public class test{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int m=s.nextInt();
int arr[]=new int[n];
int max = Integer.MIN_VALUE;
        long sum = 0;
        for(int i=0;i<n;i++)
        {
            arr[i] = s.nextInt();
            sum = sum + arr[i];
            max = Math.max(max,arr[i]);
        }
        Arrays.sort(arr);
        int i = 0;
        int count = 0;
        int d = 0;
        for(i=0; i<n; i++)
        {
            if(arr[i] > d)
            {
                count++;
                d++;
            }
            else if(arr[i] == d && arr[i] > 0)
            {
                count++;
            }
        }
        //System.out.println(count + " " + max);
        if(max - d > 0)
        {
            count = count + max - d;
        }
        System.out.println(sum - count);}} Complexity:
targets: nlogn
inputs: import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        Set<Integer> div = new HashSet<>();
        boolean[] d = new boolean[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0 ; j < n; j++) {
                if (d[j]) {
                    continue;
                }
                if (a[j]%a[i] == 0) {
                    d[j] = true;
                    div.add(a[i]);
                }
            }
        }

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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            Arrays.sort(ar);
            boolean[] u = new boolean[n];
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (!u[i]) {
                    u[i] = true;
                    ans++;
                    for (int j = 0; j < n; j++) {
                        if (!u[j] && ar[j] % ar[i] == 0) {
                            u[j] = true;
                        }
                    }
                }
            }
            out.println(ans);
        }

    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new... What is the time complexity of the previous code?
targets: quadratic
inputs: import java.util.Scanner;

public class cf_contest_1177_problem_B {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        long k = s.nextLong();
        if (k<=9)
            System.out.println(k);
        else
        {

            int c = 1;
            while(k>c*((Math.pow(10,c)) - Math.pow(10,c-1)))
            {
                k-=c*((Math.pow(10,c)) - Math.pow(10,c-1));
//                System.out.println(k + " hello " + c);
                c++;
            }
//            System.out.println("k is " + k);
            long mo = k%c;

//            System.out.println("mo is " + mo);
            k = k/c;

            if (mo == 0) {
                mo = c;
                k--;
            }
            mo--;
//            k = Math.max(k-1,0);
//            System.out.println("k/c is " + k);
            long j = (long) (Math.pow(10,c-1) + k);

            String j1 = "" + j;
//            System.out.println("j1 is " + j1);
//            System.out.println("final ans= " + j1.charAt((int)mo));
//            System.out.println();
            System.out.println(j1.charAt((int)mo));
        }

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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author madis
 */
public class Pjar {

    static int a[][];

    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("input.txt"));
        PrintWriter out = new PrintWriter("output.txt");

        int N = in.nextInt();
        int M = in.nextInt();

        a = new int[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                a[i][j] = Integer.MAX_VALUE;
            }
        }
        int k = in.nextInt();
        in.nextLine();
        for (int i = 0; i < k; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            a[x - 1][y - 1] = 1;
            burn(x - 1, y - 1);
        }
        int max = Integer.MIN_VALUE;
        int x = 0;
        int y = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if(a[i][j]>max){
                    max = a[i][j];
                    x = i+1;
                    y = j+1;
                }
            }
        }
        out.printf("%d %d",x,y);
        out.close();
        in.close();
    }

    static void burn(int i, int j) {
        for(int k = 0;k<a.length;k++){
            for(int l=0;l<a[k].length;l++){
                if(a[k][l]>Math.abs(k-i) + Math.abs(l-j)){
                    a[k][l]=Math.abs(k-i) + Math.abs(l-j);
                }
            }
        }
    }
}
 What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: Alexey
 * Date: 16.09.12
 * Time: 19:29
 * To change this template use File | Settings | File Templates.
 */
public class stub implements Runnable {
    public static void main(String[] args) {
        new stub().run();
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer st;

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

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

    private void solve() throws IOException {
        int[] cnt = new int[(int) 1e6];
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];

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

        int cur = 0;
        int left = 0;
        int i = left;
        while (i < n && cur != k) {
            if (cnt[a[i]] == 0) {
                cur++;
            }
            cnt[a[i]]++;
            i++;
        }
        i--;
        if (cur != k) {
            out.println("-1 -1");
            return;
        }
        int right = i;
        while (cnt[a[left]] > 1) {
            cnt[a[left]]--;
            left++;
        }
        out.println((left + 1) + " " + (right + 1));
    }

    public void run() {
        try {
            solve();
            out.close();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 What is the time complexity of the previous code?
targets: linear
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

  static class TaskA {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int d = in.nextInt();
      Set<Integer> pts = new HashSet<>();
      int[] x = in.nextIntArray(n);
      for (int i = 0; i < n; i++) {
        pts.add(x[i] - d);
        pts.add(x[i] + d);
      }
      Set<Integer> ans = new HashSet<>();
      for (int pt : pts) {
        int min = (int) (1e9 + 10);
        for (int i = 0; i < n; i++) {
          min = Math.min(Math.abs(x[i] - pt), min);
        }
        if (min >= d) {
          ans.add(pt);
        }
      }
      out.println(ans.size());
    }

  }

  static class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

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

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
    ... What is the time complexity of the previous code?
targets: linear
inputs: /* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n%2==0){
            System.out.println(4 + " " + (n-4));
        }
        else{
            int a = Math.min(9,n-9);
            int b = Math.max(9,n-9);
            System.out.println(a + " " + b);
        }
    }
} What is the time complexity of the previous code?
targets: constant
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;
public class A{
	public static BufferedReader k;
	public static BufferedWriter z;
	

	
	public static void main(String [] args)throws IOException{
		k = new BufferedReader(new InputStreamReader(System.in));
		z = new BufferedWriter(new OutputStreamWriter(System.out));
		
		
	        String[] dat = k.readLine().split(" ");

	        long l = Long.parseLong(dat[0]);
	        long r = Long.parseLong(dat[1]);
			
			if(r-l<=1){
				z.write(-1+"\n");
			}
			else if(r-l == 2){
				
				
				if((l&1)!=0){
					z.write(-1+"\n");
				}
				else{
					z.write(l+" "+(l+1)+" "+r+"\n");
				}
				
			}
			else{
				if(l%2==0){
					z.write(l+" "+(l+1)+" "+(l+2)+"\n");
				}
				else{
					z.write((l+1)+" "+(l+2)+" "+(l+3)+"\n");
				}
			}
			
			
			
			
		
		z.flush();

	}

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

public class PhoenixAndComputers {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int mod = Integer.parseInt(st.nextToken());
        long[][] dp = new long[n+2][n+1];
        long[] pow = new long[n+1];
        pow[0] = 1;
        for (int i=1; i <= n; i++){
            pow[i] = pow[i-1]*2;
            pow[i] %= mod;
        }
        long[][] choose = new long[n*2+1][n+1];
        for (int i=0; i <= n; i++){
            choose[i][i] = 1;
        }
        for (int i=1; i <= n*2; i++){
            for (int j=0; j <= n; j++){
                choose[i][j] = choose[i-1][j];
                if (j > 0){
                    choose[i][j] += choose[i-1][j-1];
                }
                choose[i][j] %= mod;
            }
        }
        dp[0][0] = 1;
        for (int i=0; i < n; i++){ // number of computers on
            for (int j=0; j <= i; j++){ // number manually turned on
                for (int k=1; k+i <= n; k++){ // number of computers manually turned on in next "block"
                    dp[i+k+1][j+k] += (pow[k-1] * choose[j+k][k])%mod * dp[i][j];
                    dp[i+k+1][j+k] %= mod;
                }
            }
        }
        long ans = 0;
        for (int j=0; j <= n; j++){
            ans += dp[n+1][j];
            ans %= mod;
        }
        System.out.println(ans);
    }
}
 What is the time complexity of the previous code?
targets: cubic
inputs: import java.util.*;
import java.io.*;
import java.math.*;
public class Main1
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long 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 int i(){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 double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //   ... What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.*;
import java.util.*;

public class Main {
    private static HashMap<String, Integer> nodes;
    private static void dfs(String cur, PrintWriter out) {
        if(cur.length() > 0) {
            out.println(cur.substring(1));
        }
        int children = nodes.get(cur);
        for(int i = 1; i <= children; i++) {
            dfs(cur+"."+i, out);
        }
    }
    public static void main(String[] args) throws IOException {
        //Scanner f = new Scanner(new File("uva.in"));
        //Scanner f = new Scanner(System.in);
        //BufferedReader f = new BufferedReader(new FileReader("uva.in"));
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int t = Integer.parseInt(f.readLine());
        while(t-- > 0) {
            int n = Integer.parseInt(f.readLine());
            nodes = new HashMap<>();
            nodes.put("", 0);
            String cur = "";
            for(int i = 0; i < n; i++) {
                int a = Integer.parseInt(f.readLine());
                while(nodes.get(cur) != a-1) {
                    cur = cur.substring(0, cur.lastIndexOf("."));
                }
                nodes.put(cur, a);
                cur = cur+"."+a;
                nodes.put(cur, 0);
            }
            dfs("", out);
        }
        f.close();
        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.util.*;
import java.io.*;

public class virtual1{

    static InputReader in = new InputReader();
    static PrintWriter out = new PrintWriter(System.out);
    
    public static void main(String[] args) {
            long x = in.nextLong();
            long k = in.nextLong();
            long mod = (long)1e9+7l;
            //out.println(mod);
            long mul1 = 1;
            long mul2 = 2*x-1;
            mul2 = mul2%mod;
            long pow = k;
            long to = 2;
            while(pow>0l){
                if(pow%2l==1l){
                    mul1 = mul1*to;
                    mul1%=mod;
                }
                to=to*to;
                to%=mod;
                pow = pow/2l;
            }
            mul1 = mul1*mul2;
            mul1%=mod;
            mul1+=1;
            if(x!=0)
            out.println(mul1%mod);
            else
            out.println(0);
        
        out.close();    
    }

    static class InputReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public InputReader()
        {
            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)
      ... Complexity:
targets: logn
inputs: import java.util.InputMismatchException;
import java.io.*;
import java.util.HashMap;

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new StreamInputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        run(in, out);
    }

    public static void run(InputReader in, PrintWriter out) {
        Solver solver = new SimpleCycles();
        solver.solve(1, in, out);
        Exit.exit(in, out);
    }
}

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

    public StreamInputReader(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++];
    }

    @Override
    public void close() {
        try {
            stream.close();
        } catch (IOException ignored) {
        }
    }
}

abstract class InputReader {
    private boolean finished = false;

    public abstract int read();

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


    public String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public void setFinished(boolean finished) {
       ... 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 SonyaExhibition {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = {0,1};
		for(int i = 0; i < n; i++) {
			System.out.print(arr[i % 2]);
		}
		System.out.println();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}
 Complexity:
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.HashSet;
import java.util.Scanner;


public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i<n; i++){
            int a = sc.nextInt();
            if(a!=0){
                set.add(a);
            }
        }
        System.out.println(set.size());
    }
} Complexity:
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.*;
import java.io.*;

public class A {

    ArrayList<Integer> list = new ArrayList<Integer>();
    
    
    boolean valid(int n) {
        Queue<Integer> q = new LinkedList<Integer>();
        q.add(4);
        q.add(7);
        int crnt;
        while(!q.isEmpty()) {
            crnt = q.poll();
            if(n%crnt == 0) return true;
            if ( crnt*10 + 4 <= 1000 ) q.add(crnt*10 + 4);
            if ( crnt*10 + 7 <= 1000 ) q.add(crnt*10 + 7);
        }
        return false;
    }
    
    void dfs(int n){
        if(n>1000)return;
        if(n!=0)list.add(n);
        n = n*10;
        dfs(n+4);
        dfs(n+7);
    }

    void run() {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        if (valid(n)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        new A().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.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args){
        try {
            new Main().solve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    ArrayList<Edge>[]edge;
    int n,m,cnt=0;
    int ord;
    int[]order;int[]vis;
    Edge[] e;
    private void solve() throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n=in.nextInt();m=in.nextInt();
        edge=new ArrayList[n+1];
        e=new Edge[m];
        vis=new int[n+1];
        order=new int[n+1];
        for(int i=1;i<=n;i++){
            edge[i]=new ArrayList<>();
        }
        for(int i=1;i<=m;i++){
            int s=in.nextInt(),t=in.nextInt(),c=in.nextInt();
            edge[s].add(new Edge(s,t,c,i));
        }
        int l=0,r=1000000000;
        while (l<r){
            int mid=(l+r)>>>1;
            if(judge(mid,false))r=mid;
            else l=mid+1;
        }
        out.print(l+" ");
        judge(l,true);
        Arrays.sort(e,0,cnt,Comparator.comparingInt(x->x.id));
        int ans=0;
        int[]a=new int[m];
        for(int i=0;i<cnt;i++){
            if(order[e[i].s]<order[e[i].t])a[ans++]=e[i].id;
        }
        out.println(ans);
        for(int i=0;i<ans;i++){
            out.print(a[i]+" ");
        }
        out.println();
        out.flush();
    }
    boolean judge(int min,boolean mod){
        Arrays.fill(vis,0);
        cycle=false;
        for(int i=1;i<=n;i++){
            if(vis[i]==0){
                dfs(i,min,mod);
                if(cycle)return false;
            }
        }
        return true;
    }
    boolean cycle=false;
    void dfs(int cur,int min,boolean mod){
        if(cycle)return;
        vis[cur]=1;
        for(Edge e:edge[cur]){
            if(e.c<=min){
                if(mod)this.e[cnt++]=e;
                continue;
            }
            if(vis[e.t]==1){
               ... Complexity:
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class GeorgeAndInterestingGraph {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] edgeFrom = new int[M];
        int[] edgeTo = new int[M];
        for (int i = 0; i < M; i++) {
        	edgeFrom[i] = sc.nextInt();
        	edgeTo[i] = sc.nextInt();
        }
        
        int best = Integer.MAX_VALUE;
    	boolean[][] adjMat = makeAdjMat(N, edgeFrom, edgeTo);
        for (int i = 0; i < N; i++) {
        	boolean[][] mat = copyOfArray2d(adjMat);
        	best = Math.min(best, count(mat, M, i));
        }
        
        System.out.println(best);
    }
    
    public static boolean[][] copyOfArray2d(boolean[][] arr) {
    	int N = arr.length;
    	int M = arr[0].length;
    	boolean[][] copy = new boolean[N][M];
    	for (int i = 0; i < N; i++) {
    		System.arraycopy(arr[i], 0, copy[i], 0, M);
    	}
    	return copy;
    }
    
    public static int count(boolean[][] mat, int M, int center) {
//    	int N = mat.length;
//    	int M = mat[0].length;
//
//    	int centerConnect = (mat[center][center]) ? 0 : 1;
//    	for (int i = 0; i < N; i++) {
//			if (i != center) {
//				if (!mat[i][center]) {
//					centerConnect++;
//				}
//				if (!mat[center][i]) {
//					centerConnect++;
//				}
//			}
//	    	mat[i][center] = false;
//	    	mat[center][i] = false;
//		}
//    	
//    	int[][] adjMat = new int[2 * N + 2][2 * N + 2];
//    	for (int i = 0; i < N; i++) {
//    		for (int j = 0; j < N; j++) {
//    			int idx = N + j;
//    			adjMat[i][idx] = (mat[i][j]) ? 1 : 0;
//    		}
//    	}
//    	int s = 2 * N;
//    	int t = 2 * N + 1;
//    	for (int i = 0; i < N; i++) {
//    		adjMat[s][i] = 1;
//    	}
//    	for (int i = N; i < 2 * N; i++) {
//    		adjMat[i][t] = 1;
//    	}
//    	
//    	int matches =... Complexity:
targets: cubic
inputs: import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class ElongatedMatrix {
    private static int n;
    /**
     * if the rows are arranged in some permutation [p_1, p_2,...i,j,...p_n],
     * 1!=i!=j!=n, minCost[i][j] is the min k for any permutation with i&j adjacent
     **/
    private static int[][] minCost;
    /**
     * minCostEndpoints[i][j] is the min k for any permutation such that
     * the rows are arranged in some permutation [i, p_2, ... p_{n-1}, j],
     **/
    private static int[][] minCostEndpoints;

    /**
     * Max k of a path over a subset of all rows ending at a certain vertex
     * The first 16 bits of the key represent the subset. Node n is in the subset iff (x & (2 << n))!=0
     * key/(1<<16) is the end vertex number
     */
    private static HashMap<Integer, Integer> costs = new HashMap<>();

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] params = Arrays.stream(br.readLine().split(" "))
                .mapToInt(x -> Integer.parseInt(x)).toArray();
        n = params[0];
        int m = params[1];
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++) {
            matrix[i] = Arrays.stream(br.readLine().split(" "))
                    .mapToInt(x -> Integer.parseInt(x)).toArray();
        }
        minCost = new int[n][n];
        minCostEndpoints = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i > j) {
                    minCost[i][j] = Integer.MAX_VALUE;
                    for (int k = 0; k < m; k++) {
                        int diff = Math.abs(matrix[i][k] - matrix[j][k]);
                        if (diff < minCost[i][j]) {
                            minCost[i][j] = diff;
                        }
                    }
                   ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Map.Entry;

public class Solution implements Runnable {

	public static void main(String[] args) {
		(new Thread(new Solution())).start();
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	
	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String r = in.readLine();
			if (r == null) return null;
			st = new StringTokenizer(r);
		}
		return st.nextToken();
	}

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

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

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	int n;
	int[] b, l;
	double ans;
	int[] sw;
	int a;
	
	void sol() {
		for (int i = 0; i < n; i++) l[i] += sw[i] * 10;
		double yes = 0;
		for (int q = 0; q < (1 << n); q++) {
			double p = 1;
			int bb = 0;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				if ((q & (1 << i)) == 0) {
					p *= (1.0 - (double)l[i] / 100);
					bb += b[i];
				} else {
					p *= 1.0 * (double)l[i] / 100;
					cnt++;
				}
			}
			if (cnt > n / 2) {
				yes += p;
			} else {
				yes += p * (double)a / (double)(a + bb); 
			}
		}
		if (ans < yes) ans = yes;
		for (int i = 0; i < n; i++) l[i] -= sw[i] * 10;
	}
	
	void rek(int i, int k) {
		if (i == n) sol(); else {
			for (int q = 0; q <= k && l[i] + q * 10 <= 100; q++) {
				sw[i] = q;
				rek(i + 1, k - q);
			}
		}
	}
	
	void solve() throws Exception {
		n = nextInt();
		int k = nextInt();
		a = nextInt();
		b = new int[n];
		l = new int[n];
		sw = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = nextInt();
			l[i] = nextInt();
		}
		rek(0, k);
		out.printf("%.10f", ans);
	}

	public void run() {
		Locale.setDefault(Locale.UK);
		try {
			in = new... Complexity:
targets: np
inputs: import java.io.*;
import java.util.*;

public class A implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        int all = 0;
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
            all += a[i];
        }
        Arrays.sort(a);
        int sum = 0, ans = 0;
        for (int i = n - 1; i >= 0; --i) {
            sum += a[i];
            ++ans;
            if (sum > all - sum) {
                break;
            }
        }
        out.println(ans);
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

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

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

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

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

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

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

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

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

        public... 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.util.Scanner;

public class Main3 implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main3(), "", 128 * 1024 * 1024).start();
    }

    private static Scanner in = new Scanner(System.in);

    public void run() {
        int n = in.nextInt();
        int m = 1_000_000_007;
        boolean[] state = new boolean[n];
        for (int i = 0; i < n; i++) {
            state[i] = in.next().equals("f");
        }
        // 使うのは[n][n]だけど、j+1==nのときif分岐せずに済むようにn+1にしてる
        long[][] dp = new long[n][n + 1];
        dp[0][0] = 1;
        // iは既に埋まっていてi+1に書き込んでいくから、i<n-1まででいい
        for (int i = 0; i < n - 1; i++) {
            if (state[i]) {
                // 右下にコピーしていくから溢れないようにj<n-1
                for (int j = 0; j < n - 1; j++) {
                    dp[i + 1][j + 1] = dp[i][j];
                }
            } else {
                // 何通りかというのを右から埋めていくからj--で進める
                for (int j = n - 1; j >= 0; j--) {
                    // 足していくと大きくなるからこの時点でもう%mしておく
                    dp[i + 1][j] = (dp[i][j] + dp[i + 1][j + 1]) % m;
                }
            }
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += dp[n - 1][i] % m;
        }
        System.out.println(sum % m);
    }
} Complexity:
targets: quadratic
inputs: import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

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

class TaskB {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n=in.nextInt(),k=in.nextInt();
        int a[]=new int[n];
        int i;
        for(i=0;i<n;i++)
            a[i]=in.nextInt();
        HashSet<Integer> hs=new HashSet<Integer>();
        boolean status=false;
        int index=-1;
        for(i=0;i<n;i++)
        {
            
            hs.add(a[i]);
            if(hs.size()==k)
            {
                index=i;
                status=true;
                break;
            }
        }
        if(!status)
        {
            out.println(-1+" "+ -1);
            return;
        }
        HashSet<Integer> hash=new HashSet<Integer>();
        for(i=index;i>=0;i--)
        {

            hash.add(a[i]);
            if(hash.size()==k)
            {
                break;
            }
        }
        out.println((i+1)+" "+(index+1));
    }
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return... What is the time complexity of the previous code?
targets: linear
inputs: import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class A implements Runnable
{
    String file = "input";
    
    boolean TEST = System.getProperty("ONLINE_JUDGE") == null;
    
    void solve() throws IOException
    {
        int n = nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = nextInt();
        int[] b = a.clone();
        qsort(b);
        //sortInt(b);
        int count = 0;
        for(int i = 0; i < a.length; i++)
            if(a[i] != b[i]) count++;
        if(count == 0 || count == 2) out.println("YES");
        else out.println("NO");
    }
    
    void qsort(int[] a)
    {
        List<Integer> as = new ArrayList<Integer>();
        for(int x : a) as.add(x);
        Collections.shuffle(as);
        for(int i = 0; i < a.length; i++) a[i] = as.get(i);
        sort(a);
    }
    
    Random rnd = new Random();
    
    void sortInt(int[] a)
    {
        sortInt(a, 0, a.length - 1);
    }
    
    void sortInt(int[] a, int from, int to)
    {
        if(from >= to) return;
        int i = from - 1;
        int p = rnd.nextInt(to - from + 1) + from;
        int t = a[p]; a[p] = a[to]; a[to] = t;
        for(int j = from; j < to; j++)
            if(a[j] <= a[to])
            {
                i++;
                t = a[i]; a[i] = a[j]; a[j] = t;
            }
        t = a[i + 1]; a[i + 1] = a[to]; a[to] = t;
        sortInt(a, i + 2, to);
        while(i >= 0 && a[i] == a[i + 1]) i--;
        sortInt(a, from, i);
        
    }
    
    String next() throws IOException
    {
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(input.readLine());
        return st.nextToken();
    }
    
    int nextInt() throws IOException
    {
        return Integer.parseInt(next());
    }
    
    long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }
    
    double nextDouble() throws IOException
   ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: nlogn