codeparrot/codecomplex huggingface dataset:
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;

public class B {
	static Vector<Integer> primes;

	public static void main(String[] args) throws IOException {
		InputReader myScanner = new InputReader();
		int n = myScanner.nextInt(), k = myScanner.nextInt();
		myScanner.hasNext();
		int all[] = new int[n];
		boolean numbers[] = new boolean[100100];
		int diff[] = new int[n];
		all[0] = myScanner.nextInt();
		diff[0] = 1;
		numbers[all[0]] = true;
		int r = -1;
		if (k == 1)
			r = 1;
		for (int i = 1; i < all.length; i++) {
			all[i] = myScanner.nextInt();
			diff[i] = diff[i - 1];
			if (!numbers[all[i]]) {
				if (r == -1 && diff[i] + 1 == k)
					r = i + 1;
				numbers[all[i]] = true;
				diff[i]++;
			}
		}
		if (r == -1)
			System.out.println(-1 + " " + -1);
		else {
			numbers = new boolean[100010];
			int l = 0, cnt = 1;
			numbers[all[r - 1]] = true;
			if (k == 1)
				System.out.println(1 + " " + 1);
			else {
				for (int i = r - 2; i >= 0; i--) {
					if (!numbers[all[i]]) {
						numbers[all[i]] = true;
						cnt++;
					}
					if (cnt == k) {
						l = i + 1;
						break;
					}
				}

				System.out.println(l + " " + r);
			}
		}
	}

	static class InputReader {
		BufferedReader buff;
		StringTokenizer tok;
		String cur;

		public InputReader() throws IOException {
			buff = new BufferedReader(new InputStreamReader(System.in));
			tok = new StringTokenizer(cur = buff.readLine());
		}

		public boolean hasNext() throws IOException {
			if (!tok.hasMoreElements()) {
				cur = buff.readLine();
				if (cur == null)
					return false;
				tok = new StringTokenizer(cur);
			}
			return true;
		}

		public String next() throws IOException {
			while (!tok.hasMoreElements())
				tok = new StringTokenizer(cur = buff.readLine());

			return tok.nextToken();
		}

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

		public long nextLong() throws NumberFormatException, IOException {
			while (!tok.hasMoreElements())
				tok = new StringTokenizer(cur = buff.readLine());

			return Long.parseLong(next());
		}
	}

}
// Problem: 224_B. Array
// Time complexity: linear


import java.io.DataInputStream;
import java.io.InputStream;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class B {

    
    public static void main(String[] args) throws Exception {
        Parserdoubt2333 s = new Parserdoubt2333(System.in);
        
        int n = s.nextInt();
        int k = s.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = s.nextInt();
            
        }
        
        TreeMap<Integer, Integer> tree = new TreeMap<Integer,Integer>();
        
        int left = 0;
        int right = 0;
        
        for (right = 0; right < a.length; right++) {
            if(tree.containsKey(a[right]))
                tree.put(a[right], tree.get(a[right]) + 1);
            else 
                tree.put(a[right],1);
            if(tree.size() == k)
                break;
        }
        
        if(tree.size() < k){
            System.out.println("-1 -1");
            return ;
        }
//      System.out.println(right);
        for (left = 0; left < a.length; left++) {
            int val = tree.get(a[left]);
            val--;
            if(val > 0)
                tree.put(a[left],val);
            if(val == 0)
                break;
            
        }
        left++;
        right++;
        System.out.println(left + " "+right);
    }

}



class Parserdoubt2333
{
   final private int BUFFER_SIZE = 1 << 18;
 
   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;
 
   public Parserdoubt2333(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }
 
   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;

public class TaskB {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        int n = s.nextInt();
        int k = s.nextInt();
        int[] nums = new int[100000 + 10];
        
        int first = -1, last = -1;
        Set<Integer> dif = new TreeSet<Integer>();
        
        s.nextLine();
        for (int i = 0; i < n; i++) {
            nums[i] = s.nextInt();
            dif.add(nums[i]);
            if (dif.size() == k) {
                last = i;
                break;
            }
        }

        dif.clear();

        for (int i = last; i >= 0; i--) {
            dif.add(nums[i]);
            if (dif.size() == k) {
                first = i;
                break;
            }
        }
        
        if (last == -1)
            System.out.print("-1 -1");
        else
            System.out.print(Integer.toString(first + 1) + " "  + Integer.toString(last + 1));
    }
}
// Problem: 224_B. Array
// Time complexity: linear

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		Scanner scan = new Scanner(System.in);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n  = Integer.parseInt(st.nextToken());
		int k  = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int[] a = new int[n];
		for(int i = 0 ; i  <n;i++)
			a[i] = Integer.parseInt(st.nextToken());
		
		int l = 0, r = 0;
		int[] t = new int[100001];
		int kk = 0;
		int min = 1 << 25 , ll =-1 , rr = -1;
		while(r < n)
		{
			int x = a[r++];
			t[x]++;
			if(t[x] == 1)
				kk++;
			while(r < n && kk < k)
			{
				x = a[r++];
				t[x]++;
				if(t[x] == 1)
					kk++;
			}
			while(kk == k && l < r)
			{
				x = a[l];
				if(t[x] == 1)
					break;
				t[x]--;
				l++;
			}
			if(kk == k)
			{
				int m = r-l+1;
				if(m < min)
				{
					ll = l+1;
					rr = r;
					min = m;
				}
			}
		}
		System.out.println(ll +" "+rr);
	}

}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;
public class b {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt(), k = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++)
        data[i] = input.nextInt();
    int[] freq = new int[100001];
    int count = 0;
    for(int i = 0; i<n; i++)
    {
        if(freq[data[i]] == 0)
            count++;
        freq[data[i]]++;
    }
    if(count<k)
        System.out.println("-1 -1");
    
    else
    {
        int start = 0;
        for(int i = 0; i<n; i++)
        {
            //System.out.println(i + " " + count + " " + freq[data[i]]);
            if(count > k)
            {
                freq[data[i]]--;
                if(freq[data[i]] == 0)
                    count--;
            }
            else
            {
                if(freq[data[i]] > 1)
                {
                    freq[data[i]]--;
                }
                else
                {
                    start = i;
                    break;
                }
            }
        }
        int end = n-1;
        for(int i = n-1; i>=0; i--)
        {
            if(freq[data[i]] == 1)
            {
                end = i;
                break;
            }
            else
                freq[data[i]]--;

        }
        start++;
        end++;
        if(start<= end)
        System.out.println(start + " " + end);
        else
            System.out.println(-1 + " " + -1);
    }
}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	//
    //	static long sum=0;
	// int a,b,c;
	// 1000000007 (10^9+7)
	//static int mod = 1000000007;
    //static int dx[]={1,-1,0,0};
	//static int dy[]={0,0,1,-1};
    //static long H,L;
	
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	Reader sc = new Reader(System.in);
  // while( ){
	   int  n=sc.nextInt(),m=sc.nextInt(),a[]=new int[n];
	   int b[]=new int[100000+1], r=n+1;
	for(int i=0;i<n;i++)a[i]=sc.nextInt(); 
		// db(a);
		int s=0,t=-1, sum=0;
		int as=0,at=0;
	for(;;){
		while(t<n-1 && sum<m){
			t++;
			if( b[ a[t] ]<1 ){sum++; }
			 b[a[t]]++;
	}
		db(s,t,sum);
		if( sum<m )break;
		as=s;at=t;
		r=min(r,t-s+1);
		if( b[ a[s] ]==1 ){sum--; }
	//	if(t==n-1)break;
		 b[a[s]]--;
		 s++;
	}
	
	if( n<r )System.out.println("-1 -1");
	else System.out.println(as+1+" "+(at+1));
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}


/*
class P implements Comparable<P>{
//	implements Comparable<P>
    
	int x;
	boolean b;
	P(int x,boolean b){
		this.x=x;
		this.b=b;
	} 

	   public int compareTo(P y){
         
		  return  x-y.x;
		   
		   }	
	
}
//*/
class Reader
{
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Array224B {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int[] array = new int[n];
		int[] visited = new int[100002];
		st = new StringTokenizer(f.readLine());
		for(int i=0;i<n;i++){
			array[i] = Integer.parseInt(st.nextToken());
		}
		int count = 0;
		int begin = array[0];
		while(count<n && array[count] == begin){
			count++;
		}
		count--;
		int kcount = 1;
		visited[array[count]]++;
		int bindex = count;
		boolean good=true;
		count++;
		while(kcount<k){
			if(count==n){
				System.out.println("-1 -1");
				good=false;
				break;
			}
			if(visited[array[count]]==0){
				kcount++;
			}
			visited[array[count]]++;
			count++;
		}
		if(good&&k!=1){
		for(int i=bindex;i<count;i++){
			if(visited[array[i]]==1){
				break;
			}
			bindex++;
			visited[array[i]]--;
		}
		for(int i=count-1;i>bindex;i--){
			if(visited[array[i]]==1){
				break;
			}
			count--;
			visited[array[i]]--;
		}
		}
		if(k==1){
			System.out.println("1 1");
		}
		else if(good){
			System.out.println(bindex+1+" "+count);
		}
	}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

public class Array implements Runnable {

    void solve() throws IOException {
        int n = readInt();
        int k = readInt();
        int a[] = new int[n];
        int startIdx = 0;
        int endIdx = -1;
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i ++) {
            a[i] = readInt();
            if(map.containsKey(a[i]))
                map.put(a[i], map.get(a[i]) + 1);
            else
                map.put(a[i], 1);
            if(map.size() == k && endIdx == -1) {
                endIdx = i;
                break;
            }
        }

        if(endIdx != -1) {
            while(startIdx < n && map.get(a[startIdx])>1) {
                map.put(a[startIdx], map.get(a[startIdx]) - 1);
                startIdx ++;
            }
            startIdx ++;
            endIdx   ++;
        } else
            startIdx = -1;

        out.println((startIdx)+" "+(endIdx));


    }



    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

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

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            if (System.getProperty("ONLINE_JUDGE") != null) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader("/Users/shenchen/input.txt"));
                out = new PrintWriter("/Users/shenchen/output.txt");
            }
            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }


}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt(), k = sc.nextInt();
        long rhs = 2l * (n + k);
        for (int x = 1; ; x++) {
            long lhs = 1l * x * x + 3l * x;
            if (rhs == lhs) {
                out.println(n - x);
                break;
            }
        }
        out.flush();
        out.close();
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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


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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }


        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            double n=sc.nextInt();
            double k=sc.nextInt();
            
            double ans=n-(-1.5+Math.sqrt(9.0/4+2*(n+k)));
            out.printf("%.0f\n",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 RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class B {
    static long n, k;

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextLong();
        k = in.nextLong();
        long ans = n - TernarySearch(0, n);
        pw.println(ans);
        pw.close();
    }

    static long cal(long m) {
        long x = (m * (m + 1)) / 2;
        long y = x - (n - m);
        return abs(k - y);
    }

    static long TernarySearch(long l, long r) {
        long m1, m2;
        while (r - l > 5) {
            m1 = (2 * l + r) / 3;
            m2 = (l + 2 * r) / 3;
            if (cal(m1) > cal(m2)) l = m1;
            else r = m2;
        }
        long min = cal(l), i = l;
        for (; l <= r; l++) {
            long t = cal(l);
            if (t < min) {
                min = t;
                i = l;
            }
        }
        return i;
    }


    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
//never leave a uncompleted question in this file, always remove the code after submitting it.

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

public class run{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long k = in.nextInt();
        long ans = (-3 + (long)Math.sqrt(9+8*(n+k)))/2;
        System.out.println(n-ans);
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

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

    }

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

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

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

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            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;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}