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.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();
        }
    }
}
// Problem: 224_B. Array
// Time complexity: linear



import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;



public class Main{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Parser p = new Parser(System.in);
		PrintWriter pw= new PrintWriter(System.out);

		int n = p.nextInt();
		int k = p.nextInt();

		int[] a = p.nextIntArray(n);
		int [] pos = new int[100001];
		Arrays.fill(pos,-1);
		int cnt = 0;
		for(int i=0; i<n; ++i){
			int e = a[i];
			if( pos[e] == -1 ){
				++cnt;
			}
			pos[e] = i;
			if( cnt == k){
				break;
			}
		}
		if( cnt < k){
			pw.println("-1 -1");
			pw.close();
			return;
		}
		int min = 1000000;
		int max = -1;
		for(int i=0; i<100001; ++i){
			if(pos[i] != -1 && pos[i] < min ){
				min = pos[i];
			}
			if( pos[i] > max){
				max = pos[i];
			}
		}
		++min;
		++max;

		pw.println(min+" "+max);
		pw.close();
	}
	
	





	static class Parser{
		
		StringTokenizer st;
		BufferedReader br;

		public Parser(InputStream is){
			this.br = new BufferedReader( new InputStreamReader(is));
			
		}
		
		public int nextInt(){
			return Integer.parseInt(nextToken());
		}
		
		public double nextDouble(){
			return Double.parseDouble(nextToken());
		}
		
		public String nextString(){
			return nextToken();
		}
		
		public int[] nextIntArray(int s){
			int[] a = new int[s];
			for(int i=0; i<s; ++i){
				a[i] = nextInt();
			}
			return a;
		}
		
		public int[][] nextIntTable(int r, int c){
			int[][] a = new int[r][c];
			for(int i=0; i<r; ++i){
				a[i] = nextIntArray(c);
			}
			return a;
		}
	
		private String nextToken() {
			if( st == null || ! st.hasMoreTokens() ){
				try{
					st = new StringTokenizer( br.readLine());
				}catch( Exception e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		
	}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.Arrays;
import java.util.Scanner;

public class B {

    void run(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[n+1];
        for(int i=1;i<=n;i++)a[i]=sc.nextInt();
        int[] c = new int[100001];
        int num = 0;
        int ri = -1, rj = -1;
        int s = 1, t = 0;
        while(t<n){
            t++;
            if(c[a[t]]==0){
                num++;
            }
            c[a[t]]++;
            for(;k<=num;s++){
                if(ri==-1 || rj-ri+1>t-s+1){
                    ri = s; rj = t;
                }
                c[a[s]]--;
                if(c[a[s]]==0){
                    num--;
                }
            }
        }
        System.out.println(ri+" "+rj);
    }
    
    void debug(Object...o){
        System.out.println(Arrays.deepToString(o));
    }
    
    public static void main(String[] args) {
        new B().run();
    }
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Sunits789
 */
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();
        int k=in.nextInt();
        int arr[]=new int[n];
        in.getArray(arr);
        int ansl=-1;
        int ansr=n;
        int occ[]=new int[100100];
        boolean f[]=new boolean[n];
        Arrays.fill(occ,0);
        Arrays.fill(f,true);
        int pk=0;
        for (int l=0,r=0;r<n&&l<n;){
            int num=arr[r];
            if(f[r]){
                f[r]=false;
                occ[num]++;
                if(occ[num]==1){
                    pk++;
                }
            }
            //System.out.println(l+" "+r+" "+pk+" "+k);
            if(pk<k){
                r++;
            }
            else if (pk==k){
                if((r-l)<=(ansr-ansl)){
                    ansl=l+1;
                    ansr=r+1;
                }
                num=arr[l];
                occ[num]--;
                if(occ[num]==0){
                    pk--;
                }
                l++;
            }
            else {
                num=arr[l];
                occ[num]--;
                if(occ[num]==0){
                    pk--;
                }
                l++;
            }
        }
        if(ansl==-1){
            ansr=-1;
        }
        out.println(ansl+" "+ansr);
    }
}

class InputReader{
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        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 void getArray(int arr[]){
        for(int i=0;i<arr.length;i++){
            arr[i]=nextInt();
        }
    }

    }
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[100004];
        int b[] = new int[100004];
        int n, m, ans = 0, dau, cuoi=-1;
        n = sc.nextInt();
        m = sc.nextInt();
        for(int i=0;i<100004;i++) a[i] = 0;
        for(int i=0;i<n;i++){
            b[i] = sc.nextInt();
            if(a[b[i]]==0){
                a[b[i]] = 1;
                ans++;
                if(ans==m){
                    cuoi = i+1;
                    break;
                }
            }
        }
        for(int i=cuoi-1;i>=00;i--){
            if(a[b[i]]==1){
                a[b[i]] = 0;
                ans--;
                if(ans==0){
                    System.out.println((i+1)+" "+cuoi);
                    System.exit(0);
                }
            }
        }
        System.out.println("-1 -1");
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

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

class TaskB {
	public void solve(int testNumber, StreamInputReader in, PrintWriter out) {
        int N = in.readInt();
        int K = in.readInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = in.readInt();

        int num = 0;
        int left = 0;
        int right = 0;
        int[] seen = new int[100005];
        while(right < N && num < K) {
            if(seen[A[right]] == 0)
                num++;
            seen[A[right]]++;
            right++;
        }
        right--;

        if(num == K) {
            while(seen[A[left]] > 1) {
                seen[A[left]]--;
                left++;
            }

            out.print((left + 1) + " " + (right + 1));
            return;
        }
        out.print("-1 -1");
	}
}

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

    }

abstract class InputReader {

    public abstract int read();

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

    public String readString() {
        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;
    }

    }
// Problem: 224_B. Array
// Time complexity: linear
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public class CF224B {
    
    public static void main(String[] args) throws Exception {
        new CF224B().solve();
    }

    private void solve() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        final int MAX_A = 100000;
        int[] freq = new int[MAX_A+1];
        int numDistinct = 0;
        int r = -1;
        for (int i = 0; i < n; i++) {
            int t = a[i];
            freq[t]++;
            if (freq[t] == 1) {
                numDistinct++;
            }
            if (numDistinct == k) {
                r = i;
                break;
            }
        }
        if (r == -1) {
            System.out.println("-1 -1");
            return;
        }
        int l;
        for (l = 0; l < r; l++) {
            int t = a[l];
            freq[t]--;
            if (freq[t] == 0) {
                break;
            }
        }
        System.out.println((l+1) + " " + (r+1));
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.Scanner;
import java.util.TreeMap;

public class B {

    static Scanner in;

    static void put(TreeMap<Integer, Integer> m, int key) {
        if (m.containsKey(key)) {
            m.put(key, m.get(key) + 1);
        } else {
            m.put(key, 1);
        }
    }

    static void remove(TreeMap<Integer, Integer> m, int key) {
        if (!m.containsKey(key))
            return;
        m.put(key, m.get(key) - 1);
        if (m.get(key) == 0) {
            m.remove(key);
        }
    }

    public static void main(String[] args) {
        in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int i = 0;
        while (i + 1 < n && a[i + 1] == a[0]) {
            i++;
        }
        int left = i;
        TreeMap<Integer, Integer> used = new TreeMap<Integer, Integer>();
        for (; i < n; i++) {
            put(used, a[i]);
            if (used.size() == k) {
                while (used.get(a[left]) > 1) {
                    remove(used, a[left]);
                    left++;
                }
                System.out.println(left + 1 + " " + (i + 1));
                return;
            }
        }
        System.out.println("-1 -1");
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;


public class B
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public B() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
	}
	void run() throws NumberFormatException, IOException
	{
		int n = nextInt();
		int k = nextInt();
		int[] num = new int[n];
		for(int i = 0; i < n; i++)
			num[i] = nextInt();
		int[] cant = new int[100001];
		int cnt = 0;
		int r = 0;
		for(; r < n; r++)
		{
			if(cant[num[r]]==0)cnt++;
			cant[num[r]]++;
			if(cnt==k) break;
		}
		if(cnt<k)
		{
			out.println("-1 -1");
			return;
		}
		int l = 0;
		for(; l < r; l++)
		{
			cant[num[l]]--;
			if(cant[num[l]]==0)cnt--;
			if(cnt<k) break;
		}
		out.println((l+1)+" "+(r+1));
	}
	public static void main(String[] args) throws NumberFormatException, IOException 
	{
		new B();
	}
	String nextToken() throws IOException
	{
		if(tok ==null || !tok.hasMoreTokens()) tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.*;

public class C138B
{

    private static StringTokenizer st;
    
    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }
    
    public static int nextInt()
    {
        return Integer.parseInt(st.nextToken());
    }
    
    public static String next()
    {
        return st.nextToken();
    }
    
    public static long nextLong()
    {
        return Long.parseLong(st.nextToken());
    }
    /**
     * @param args
     */
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];
        nextLine(br);
        for (int i = 0; i < n; i++) a[i] = nextInt();
        
        int bp = 0, fp = 0, count = 0;
        boolean good = false;
        int[] mark = new int[100001];
        for (fp = 0; fp < n; fp++)
        {
            if (mark[a[fp]] == 0)
            {
                count++;
            }
            mark[a[fp]]++;
            if (count == k)
            {
                good = true;
                break;
            }
        }
        if (!good)
        {
            System.out.println("-1 -1");
            return;
        }
        for (bp = 0; bp < fp; bp++)
        {
            if (mark[a[bp]] > 1)
            {
                mark[a[bp]]--;
            }
            else break;
        }
        System.out.println((bp+1) + " " + (fp+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 {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        if (k > n) {
            System.out.println(-1 + " " + -1);
            return;
        }
        int[] v = new int[100010];
        int cnt = 0;
        for (int i = 0; i < k; i++) {
            if (v[a[i]] == 0) {
                cnt++;
            }
            v[a[i]]++;

        }
        int i = k;
        while (cnt < k && i < n) {
            if (v[a[i]] == 0) {
                cnt++;
            }
            v[a[i]]++;
            i++;
        }
        if (cnt != k) {
            System.out.println(-1 + " " + -1);
        } else {
            int st = 0;
            while (st < n && st < i && v[a[st]] > 1) {
                v[a[st]]--;
                st++;
            }
            System.out.println((st+1) + " " + (i));
        }
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

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

        public String next() throws IOException {
            while (!st.hasMoreElements())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

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

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

}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.Scanner;


public class BB {
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int a[]=new int[n+1];
    boolean used[]=new boolean[100009];
    for (int i = 1; i <=n; i++) {
        a[i]=sc.nextInt();
    }
    int cnt=0;
    int id=0;
    for (int i = 1; i <=n; i++) {
        if(!used[a[i]]){
            cnt++;
        used[a[i]]=true;
        }
        if(cnt==k){
            id=i;
            break;
        }
    }
    boolean x[]=new boolean[100005];
    int y=0;
    int id1=0;
    if(id==0){
        System.out.println(-1+" "+-1);
            return;
    }
    for (int i =id; i >=1; i--) {
        if(!x[a[i]]){
            y++;
            x[a[i]]=true;
        }
        if(y==k){
            id1=i;
            break;
        }
    }
    System.out.println(id1+" "+id);
}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;


public class B {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
//		System.setIn(new FileInputStream("b.in"));
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		String[] parts = bf.readLine().trim().split("[ ]+");
		int N = Integer.parseInt(parts[0]);
		int K = Integer.parseInt(parts[1]);
		
		int[] nums = new int[N];
		int idx = 0;
		
		String line = bf.readLine();
		for(int i = 0; i < line.length(); i++) {
			char c = line.charAt(i);
			if(c == ' ') idx++;
			else {
				int d = c - '0';
				nums[idx] = 10 * nums[idx] + d;
			}
		}
		
		int from = -1, to = -1;
		HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			Integer q = count.get(nums[i]);
			
			if(q == null) count.put(nums[i], 1);
			else count.put(nums[i], q + 1);
			
			if(count.size() == K) {
				to = i;
				break;
			}
		}
		
		if(count.size() < K) {
			System.out.println("-1 -1");
			return;
		}
		
		for(from = 0; from <= to; from++) {
			Integer q = count.get(nums[from]);
			
			if(q == 1) count.remove(nums[from]);
			else count.put(nums[from], q - 1);
			
			if(count.size() < K) break;
		}
		
		System.out.println((from + 1) + " " + (to + 1));

	}

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

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

public class BT {

    static BufferedReader in = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer str;
    static String SK;

    static String next() throws IOException {
        while ((str == null) || (!str.hasMoreTokens())) {
            SK = in.readLine();
            if (SK == null)
                return null;
            str = new StringTokenizer(SK);
        }
        return str.nextToken();
    }

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

    public static void main(String[] args) throws IOException {
        int n, k;
        n = nextInt();
        k = nextInt();
        HashSet<Integer> hs = new HashSet<Integer>();
        HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();

        int[] ar = new int[n];
        int ii = 0, jj = -1;
        for (int i = 0; i < n; i++) {
            ar[i] = nextInt();

            Integer iii = hm.get(ar[i]);
            if(iii!=null)
            hm.put(ar[i], ++iii); else hm.put(ar[i], 1);
            hs.add(ar[i]);
            if (hs.size() == k) {
                jj = i;
                break;
            }
        }
        if (jj == -1) {
            System.out.println(-1 + " " + (-1));
            System.exit(0);
        }
        for (int i = 0; i < ar.length; i++) {
            Integer iii = hm.get(ar[i]);
            if (iii != null && iii - 1 > 0) {
                hm.put(ar[i], --iii);
                ii++;
            } else {
                break;
            }
        }
        System.out.println((ii+1) + " " + (jj+1));

    }

}