codeparrot/codecomplex huggingface dataset:
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class D {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int[]a = new int[n+1];
		for (int i = 1; i <= n; i++) {
			a[i] = nextInt();
		}
		int inv = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < i; j++) {
				if (a[j] > a[i])
					inv++;
			}
		}
		int m = nextInt();
		boolean odd = inv % 2==1;
		for (int i = 0; i < m; i++) {
			int left = nextInt();
			int right = nextInt();
			long k = right-left+1;
			if (k*(k-1)/2 % 2==1)
				odd = !odd;
			if (odd)
				pw.println("odd");
			else
				pw.println("even");
		}
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
import java.io.*;
import java.util.StringTokenizer;

public class D911 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        StringTokenizer st;

        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = Integer.parseInt(st.nextToken());
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (num[i] < num[j]) {
                    count++;
                }
            }
        }

        boolean ans = count % 2 == 0;
        for (int m = Integer.parseInt(br.readLine()); m-- > 0; ) {
            st = new StringTokenizer(br.readLine());
            int l = Integer.parseInt(st.nextToken());
            int r = Integer.parseInt(st.nextToken());
            if (((r - l + 1) / 2) % 2 != 0) {
                ans = !ans;
            }
            out.println(ans ? "even" : "odd");
        }
        out.close();
    }
}
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
import java.util.*;
import java.io.*;
public class D {
  
  static InputReader in = new InputReader(System.in);
  static PrintWriter out = new PrintWriter(System.out);
  
  public static void main(String[] args) {
    boolean even = true;
    int n = in.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = in.nextInt();
      for (int j = 0; j < i; j++) {
        if (a[j] > a[i]) {
          even = !even;
        }
      }
    }
    int m = in.nextInt();
    for (int i = 0; i < m; i++) {
      if ((1 - in.nextInt() + in.nextInt()) / 2 % 2 == 1) {
        even = !even;
      }
      if (even)
        out.println("even");
      else
        out.println("odd");
    }
    finish();
  }
  
  public static void finish() {
    out.close();
    in.close();
    System.exit(0);
  }

  static class InputReader implements Iterator<String>, Closeable {
    // Fast input reader. Based on Kattio.java from open.kattis.com
    // but has method names to match Scanner

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    public InputReader(InputStream i) {
      r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasNext() {
      return peekToken() != null;
    }

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

    public double nextDouble() {
      return Double.parseDouble(nextToken());
    }

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

    public String next() {
      return nextToken();
    }
    
    public String nextLine() {
      try {
        line = r.readLine();
      } catch (IOException e) {
        line = null;
      }
      token = null;
      st = null;
      return line;
    }
    
    public void close() {
      try {
        r.close();
      } catch (IOException e) {
      }
    }

    private String peekToken() {
      if (token == null)
        try {
          while (st == null || !st.hasMoreTokens()) {
            line = r.readLine();
            if (line == null)
              return null;
            st = new StringTokenizer(line);
          }
          token = st.nextToken();
        } catch (IOException e) {
        }
      return token;
    }

    private String nextToken() {
      String ans = peekToken();
      token = null;
      return ans;
    }
    
  }

}
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
import java.util.*;
import java.io.*;
public class CF911D {
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int[] array = new int[n];
      for(int i = 0; i < n; i++){
         array[i] = sc.nextInt();
      }
      int count = 0;
      for(int i = 0; i < array.length; i++){
         for(int j = i+1; j < array.length; j++){
            if(array[i] > array[j]){
               count++;
            }
         }
      }
      count%=2;
      int q = sc.nextInt();
      for(int i = 0; i < q; i++){
         int l = sc.nextInt();
         int r = sc.nextInt();
         int sz = r - l + 1;
         count += (sz*(sz-1))/2;
         count %= 2;
         if(count == 1) 
            System.out.println("odd");
         else 
            System.out.println("even");
      }
   }
}
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
/* 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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int[] A=new int[n];
		String[] s=br.readLine().split(" ");
		for(int i=0;i<n;i++){
			A[i]=Integer.parseInt(s[i]);
		}
		/*int[][] nck=new int[2000][2000];
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				nck[i][j]=0;
			}
		}
		for(int i=0;i<=n;i++){
			nck[i][0]=1;
			for(int j=1;j<=i;j++){
				nck[i][j]=nck[i-1][j]+nck[i-1][j-1];
				nck[i][j]%=2;
			}
		}*/
		int inv=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(A[i]>A[j]){
					inv++;
				}
			}
		}
		StringBuilder sb=new StringBuilder("");
		int m=Integer.parseInt(br.readLine());
		for(int i=0;i<m;i++){
			s=br.readLine().split(" ");
			int li=Integer.parseInt(s[0]);
			int ri=Integer.parseInt(s[1]);
			int tot=ri-li+1;
			inv=inv+tot*(tot-1)/2;
			if(inv%2==0){
				sb.append("even\n");
			}
			else{
				sb.append("odd\n");
			}
		}
		System.out.print(sb);
	}
}
// Problem: 911_D. Inversion Counting
// Time complexity: quadratic
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.io.InputStream;

public class BuildIn {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    public static void solve(InputReader in, PrintWriter out) throws IOException
    {
    	int n = in.nextInt();
    	int[] list = new int[n];
    	for(int i = 0; i < n; i++)
    	{
    		list[i]=in.nextInt();
    	}
    	
    	int count = 0;
    	for(int i = 0; i < n-1; i++)
    	{
    		for(int j = i+1; j < n; j++)
    		{
    			if(list[j]<list[i])
    			{
    				count++;
    			}
    		}
    	}
    	
    	boolean sta = true;
    	if(count%2==1) sta = false;
    	
    	int m =  in.nextInt();
    	for(int i = 0; i <m; i++)
    	{
    		int a = in.nextInt();
    		int b = in.nextInt();
    		if((b-a)%4==2) sta = !sta;
    		if((b-a)%4==1) sta = !sta;    		
    		if(sta) out.println("even");
    		else out.println("odd");
    	}
	}

	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: 911_D. Inversion Counting
// Time complexity: quadratic
import java.util.Scanner;

public class TaskD {

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

		int inv = 0;
		// count inversions
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] > a[j]) {
					inv++;
				}
			}
		}

		boolean odd = (inv % 2 == 1);

		for (int i = 0; i < m; i++) {
			int l = s.nextInt();
			int r = s.nextInt() + 1; // r excluding, l including
			int num = (r - l)*(r - l - 1)/2;
			if (num % 2 == 1) {
				odd = !odd;
			}
			System.out.println((odd) ? "odd" : "even");
		}
	}

}
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
// package codeforce.Training1900;

import java.io.PrintWriter;
import java.util.*;
//https://codeforces.com/problemset/problem/1141/F2

public class SameSumBlocks {
    //    MUST SEE BEFORE SUBMISSION
//    check whether int part would overflow or not, especially when it is a * b!!!!

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        int t = sc.nextInt();
        int t = 1;
        for (int i = 0; i < t; i++) {
            solve(sc, pw);
        }
        pw.close();
    }

    static void solve(Scanner in, PrintWriter out){
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Map<Long, List<int[]>> mp = new HashMap<>();
        long[] pre = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            pre[i] = pre[i - 1] + arr[i - 1];
        }
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                long sz = pre[j + 1] - pre[i];
                if (!mp.containsKey(sz)) mp.put(sz, new ArrayList<>());
                mp.get(sz).add(new int[]{i, j});
            }
        }
        int max = 0;
        List<int[]> ans = new ArrayList<>();
        for(List<int[]> ls : mp.values()){
            Collections.sort(ls, (a, b) -> {
                if (a[1] == b[1]) return b[0] - a[0];
                return a[1] - b[1];
            });
            List<int[]> tt = new ArrayList<>();
            int cnt = 0;
            int pr = -1;
            for (int i = 0; i < ls.size(); i++) {
                int[] get = ls.get(i);
                if (get[0] <= pr) continue;
                cnt++;
                tt.add(get);
                pr = get[1];
            }
            if (max < cnt){
                ans = tt;
                max = cnt;
            }
        }
        out.println(max);
        for(int[] v : ans){
            out.println((v[0] + 1) + " " + (v[1] + 1));
        }
    }
}
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.util.Scanner;
import java.util.Vector;
import java.util.HashMap;
import java.util.Comparator;


public class F2{
	static class Pair{
		int l;
		int r;
		Pair(int l, int r){
			this.l = l;
			this.r = r;
		}
		public String toString(){
			return "(" + l + ", " + r + ")";
		}
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n+1];
		for(int i = 1;i<=n;++i){
			a[i] = in.nextInt();
		}
		HashMap<Integer, Vector<Pair>> map = new HashMap<>();
		for(int i = 1;i<=n;++i){
			int sum = 0;
			for(int j = i;j<=n;++j){
				sum+=a[j];
				if(!map.containsKey(sum))
					map.put(sum,new Vector<>());
				map.get(sum).add(new Pair(i,j));
			}
		}
		Vector<Pair> an = null;
		for(Integer key : map.keySet()){
			Vector<Pair> vec = map.get(key);
			Vector<Pair> ans = new Vector<>();
			ans.add(vec.get(0));
			int size = 1;
			for(int i = 1;i<vec.size();++i){
				if(ans.get(size-1).r > vec.get(i).r)
					ans.set(size-1,vec.get(i));
				else if(ans.get(size-1).r < vec.get(i).l){
					ans.add(vec.get(i));
					size++;
				}
			}
			if(an == null || an.size() < size) an = ans;
		}
		StringBuilder res = new StringBuilder().append(an.size() + "\n");
		for(int i = 0;i<an.size();++i)
			res.append(an.get(i).l + " " + an.get(i).r + "\n");
		System.out.println(res);
	}
}
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int[] a = in.na(n);
		HashMap<Long, ArrayList<Pair>> v = new HashMap<>();
		for(int i = 0; i<n; i++) {
			long s  = 0;
			for(int j = i; j<n; j++) {
				s+=a[j];
				Pair p = new Pair(i+1, j+1);
				if(v.containsKey(s)) {
					v.get(s).add(p);
				}else {
					ArrayList<Pair> xd = new ArrayList<>();
					xd.add(p);
					v.put(s,xd);
				}
			}
		}
		ArrayList<Pair> ans = new ArrayList<>();
		for(Entry<Long,ArrayList<Pair>> e : v.entrySet()) {
			ArrayList<Pair> pairs = e.getValue();
			Collections.sort(pairs);
			Stack<Pair> st = new Stack<>();
			for(int i = 0; i<pairs.size(); i++) {
				Pair cur = pairs.get(i);
				if(st.isEmpty()||st.peek().r<cur.l) {
					st.push(cur);
				}else if(st.peek().r>cur.r) {
						st.pop();
						st.push(cur);
				}
				if(st.size()>ans.size()) ans = new ArrayList<>(st);
			}
		}
		System.out.println(ans.size());
		for(Pair p : ans)
			System.out.println(p.l +" "+p.r);
	}
	static class Pair implements Comparable<Pair>{
		int l,r;
		public Pair(int l, int r) {
			this.l = l;
			this.r = r;
		}
		@Override
		public int compareTo(Pair o) {
			return this.l - o.l;
		}
	}
	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;

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

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

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

		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}

		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}

		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}

		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}

		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}

		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class F11141 {
	static class Solver {

		ArrayList<int[]> ranges[];
		HashMap<Long, Integer> hm = new HashMap<>();

		int id(long s) {
			if (!hm.containsKey(s))
				hm.put(s, hm.size());
			return hm.get(s);
		}
		
		// max disjoint range set in ranges[r]
		int[] memo;
		int go(int r) {
			memo[N] = 0;
			int last = N;
			for(int[] a : ranges[r]) {
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			return memo[last];
		}

		ArrayDeque<int[]> ans = new ArrayDeque<>();
		
		void go2(int r) {
			memo[N] = 0;
			int last = N;
			int minAt[] = new int[N], oo = 987654321;
			Arrays.fill(minAt, oo);
			for(int[] a : ranges[r]) {
				minAt[a[0]] = Math.min(minAt[a[0]], a[1] - a[0]);
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			while(0 < last) {
				memo[last - 1] = memo[last];
				last--;
			}
			int k = 0;
			for(; k < N;) {
				if(minAt[k] == oo || memo[k] != 1 + memo[k + minAt[k] + 1]) k++;
				else {
					ans.push(new int[] {k, k + minAt[k]});
					k += minAt[k] + 1;
				}
			}
		}
		
		@SuppressWarnings("unchecked")
		Solver() {
			ranges = new ArrayList[2250001];
			for (int i = 0; i < ranges.length; i++)
				ranges[i] = new ArrayList<>();
		}

		int N, LID;
		long[] a;

		void solve(Scanner s, PrintWriter out) {
			N = s.nextInt();
			a = new long[N + 1];
			for (int i = 1; i <= N; i++)
				a[i] = s.nextLong() + a[i - 1];
			for (int i = N; i >= 1; i--)
				for (int j = i; j <= N; j++) {
					int x = id(a[j] - a[i - 1]);
					ranges[x].add(new int[] { i - 1, j - 1 });
				}
			
			int best = 0, bid = -1;
			memo = new int[N + 1];
			Arrays.sort(ranges, (a, b) -> b.size() - a.size());
			for(int i = 0; i < ranges.length; i++, LID++) {
				if(ranges[i].size() <= best) break;
				int ans = go(i);
				if(ans > best) {
					best = ans;
					bid = i;
				}
			}
			
			// backtrack on bid
			out.println(best);
			go2(bid);
						
			while(!ans.isEmpty()) {
				int[] c = ans.pop();
				out.println(++c[0] + " " + ++c[1]);
			}
			
		}

	}

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();

	}
}
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1141F
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         HashMap<Long, ArrayList<Integer>> map = new HashMap<Long, ArrayList<Integer>>();
         for(int r=0; r < N; r++)
         {
            long sum = 0L;
            for(int i=r; i >= 0; i--)
            {
               sum += arr[i];
               if(!map.containsKey(sum))
                  map.put(sum, new ArrayList<Integer>());
               map.get(sum).add(i);
               map.get(sum).add(r);
            }
         }
         ArrayList<Integer> res = new ArrayList<Integer>();
         for(long key: map.keySet())
         {
            ArrayList<Integer> ls = map.get(key);
            ArrayList<Integer> temp = new ArrayList<Integer>();
            temp.add(ls.get(0));
            temp.add(ls.get(1));
            int r = ls.get(1);
            for(int i=2; i < ls.size(); i+=2)
               if(r < ls.get(i))
               {
                  r = ls.get(i+1);
                  temp.add(ls.get(i));
                  temp.add(ls.get(i+1));
               }
            if(res.size() < temp.size())
               res = temp;
         }
         System.out.println(res.size()/2);
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < res.size(); i+=2)
         {
            sb.append((1+res.get(i))+" "+(1+res.get(i+1)));
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
public class Main {
	public static class node implements Comparable<node> {
		int l,r;
		node(){}
		node(int l,int r) {
			this.l=l;
			this.r=r;
		}
		@Override
		public int compareTo(node rhs) {
			return r-rhs.r;
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		StringTokenizer sa=new StringTokenizer(in.readLine());
		int n=Integer.parseInt(sa.nextToken());
		sa=new StringTokenizer(in.readLine());
		int[] a=new int[n];
		TreeMap<Integer,ArrayList<node>> mp=new TreeMap();
		for (int i=0;i<n;++i) a[i]=Integer.parseInt(sa.nextToken());
		ArrayList<node> ans=new ArrayList<node>();
		for (int i=0;i<n;++i) {
			int tmp=0;
			for (int j=i;j<n;++j) {
				tmp+=a[j];
				if (!mp.containsKey(tmp)) {
					ArrayList<node> t=new ArrayList();
					t.add(new node(i,j));
					mp.put(tmp,t);
				} else {
					ArrayList<node> t=mp.get(tmp);
					int left=0,right=t.size()-1,res=t.size();
					while (left<=right) {
						int mid=(left+right)>>1;
						if (t.get(mid).r>=i) {
							res=mid;
							right=mid-1;
						} else left=mid+1;
					}
					if (res==t.size()) t.add(new node(i,j));
					else if (t.get(res).r>j) t.set(res,new node(i,j));
				}
				if (mp.get(tmp).size()>ans.size()) ans=mp.get(tmp);
			}
		}
		out.println(ans.size());
		for (int i=0;i<ans.size();++i)
			out.printf("%d %d\n",ans.get(i).l+1,ans.get(i).r+1);
		out.flush();
	}
}