codeparrot/codecomplex huggingface dataset:
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.util.*;
import java.io.*;

public class SameSumBlock {
	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 = new int[n];
		int[] pSum = new int[n];
		for(int i = 0; i< n; i++) {
			arr[i] = nextInt();
			if(i != 0)
				pSum[i] += pSum[i - 1];
			pSum[i] += arr[i];
		}
		ArrayList<Interval> sorted = new ArrayList<Interval>();
		for(int i = 0; i < n; i++)
			sorted.add(new Interval(pSum[i],0, i));
		for(int i = 1; i < n; i++) {
			for(int j = i; j < n; j++) {
				sorted.add(new Interval(pSum[j] - pSum[i - 1], i, j));
			}
		}
		sorted.sort(null);
		int i = 0;
		int max = 0, idx = 0, end = 0;
		while(i < sorted.size()) {
			int last = i;
			int curr = 1;
			int start = i;
			sorted.get(i).marked = true;
			while(i < sorted.size() - 1 && sorted.get(i).val == sorted.get(i + 1).val) {
				i++;
				if(sorted.get(i).l > sorted.get(last).r) {
					sorted.get(i).marked = true;
					curr++;
					last = i;
				}
			}
			if(curr > max) {
				max = curr;
				idx = start;
				end = i;
			}
			i++;
		}
		System.out.println(max);
		for(int j = idx; j <= end; j++) {
			if(sorted.get(j).marked)
				System.out.println(sorted.get(j).l + 1 + " " + (sorted.get(j).r + 1));
		}
	}

	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());
	}
}
class Interval implements Comparable<Interval> {
	int val, l, r;
	boolean marked;
	public Interval(int val, int l, int r) {
		super();
		this.val = val;
		this.l = l;
		this.r = r;
	}

	@Override
	public int compareTo(Interval o) {
		if(val != o.val)
			return val - o.val;
		return r - o.r;
	}
	
}
// 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());
         //thonky wonky
         HashMap<Long, ArrayList<Range>> map = new HashMap<Long, ArrayList<Range>>();
         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<Range>());
               map.get(sum).add(new Range(i, r));
            }
         }
         ArrayList<Range> res = new ArrayList<Range>();
         for(long key: map.keySet())
         {
            ArrayList<Range> ls = map.get(key);
            ArrayList<Range> temp = new ArrayList<Range>();
            temp.add(ls.get(0));
            int r = ls.get(0).r;
            for(int i=1; i < ls.size(); i++)
               if(r < ls.get(i).l)
               {
                  r = ls.get(i).r;
                  temp.add(ls.get(i));
               }
            if(res.size() < temp.size())
               res = temp;
         }
         System.out.println(res.size());
         StringBuilder sb = new StringBuilder();
         for(Range x: res)
         {
            sb.append(x.l+" "+x.r);
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }
   class Range
   {
      public int l;
      public int r;
      
      public Range(int a, int b)
      {
         l = a+1;
         r = b+1;
      }
   }
// Problem: 1141_F2. Same Sum Blocks (Hard)
// Time complexity: quadratic
import java.io.*;
import java.util.*;

public class CF1141F {
	static class V {
		int l, r, a;
		V(int l, int r, int a) {
			this.l = l; this.r = r; this.a = a;
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[] aa = new int[n + 1];
		for (int i = 1; i <= n; i++)
			aa[i] = Integer.parseInt(st.nextToken());
		for (int i = 1; i <= n; i++)
			aa[i] += aa[i - 1];
		int m = n * (n + 1) / 2;
		V[] vv = new V[m];
		m = 0;
		for (int i = 1; i <= n; i++)
			for (int j = i; j <= n; j++)
				vv[m++] = new V(i, j, aa[j] - aa[i - 1]);
		Arrays.sort(vv, (u, v) -> u.a != v.a ? u.a - v.a : u.r - v.r);
		int[] ii_ = new int[m];
		int[] ii = new int[m];
		int k_ = 0;
		for (int i = 0, j; i < m; i = j) {
			j = i + 1;
			while (j < m && vv[j].a == vv[i].a)
				j++;
			int k = 0, r = 0;
			for (int h = i; h < j; h++)
				if (vv[h].l > r) {
					ii[k++] = h;
					r = vv[h].r;
				}
			if (k_ < k) {
				k_ = k;
				int[] tmp = ii_; ii_ = ii; ii = tmp;
			}
		}
		pw.println(k_);
		for (int h = 0; h < k_; h++) {
			int i = ii_[h];
			pw.println(vv[i].l + " " + vv[i].r);
		}
		pw.close();
	}
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.util.Arrays.sort;

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

public class A {

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		sort(a);
		int ans = 0;
		ans: while (true) {
			for (int i = 0;; i++) {
				if (i == n) {
					break ans;
				}
				if (a[i] != 0) {
					++ans;
					int t = a[i];
					a[i] = 0;
					for (i++; i < n; i++) {
						if (a[i] % t == 0) {
							a[i] = 0;
						}
					}
					break;
				}
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

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

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception
	{
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    int n=Integer.parseInt(br.readLine());
	    String s=br.readLine();
	    String ss[]=s.split(" ");
	    int arr[]=new int[n];
	    for(int i=0;i<n;i++)
	    arr[i]=Integer.parseInt(ss[i]);
	    Arrays.sort(arr);
	    int coun=0,coun2=0;
	    for(int i=arr[0],k=0;k<n;)
	    {
	        for(int j=k;j<n;j++)
	        {
	            if(arr[j]%i==0)
	            {
	                arr[j]=-1;
	                coun2++;
	            }
	        }
	        Arrays.sort(arr);
	        k=coun2;
	        coun++;
	        if(coun2<n)
	        i=arr[coun2];
	        else
	        break;
	        
	    }
		System.out.println(coun);
	}
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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
 *
 * @author null
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Input in = new Input(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, Input in, PrintWriter out) {
            try {
                int n = in.readInt();
                int[] a = new int[n];
                for (int i = 0; i < n; i++) {
                    a[i] = in.readInt();
                }
                Arrays.sort(a);
                boolean[] b = new boolean[n];
                int ans = 0;
                while (true) {
                    int x = 0;
                    for (int i = 0; i < n; i++) {
                        if (!b[i] && x == 0) {
                            x = a[i];
                        }
                        if (x != 0 && a[i] % x == 0) {
                            b[i] = true;
                        }
                    }
                    if (x == 0) {
                        break;
                    }
                    ans++;
                }
                out.println(ans);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }

    static class Input {
        public final BufferedReader reader;
        private String line = "";
        private int pos = 0;

        public Input(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private boolean isSpace(char ch) {
            return ch <= 32;
        }

        public String readWord() throws IOException {
            skip();
            int start = pos;
            while (pos < line.length() && !isSpace(line.charAt(pos))) {
                pos++;
            }
            return line.substring(start, pos);
        }

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

        private void skip() throws IOException {
            while (true) {
                if (pos >= line.length()) {
                    line = reader.readLine();
                    pos = 0;
                }
                while (pos < line.length() && isSpace(line.charAt(pos))) {
                    pos++;
                }
                if (pos < line.length()) {
                    return;
                }
            }
        }

    }
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.util.*;
import java.io.*;

public class Main {

	static Scanner console;
	public static void main(String[] args) {
		console = new Scanner(System.in);
		int n = console.nextInt();
		List<Integer> arr= new ArrayList<>();		
		for(int i = 0; i < n; i++) arr.add( console.nextInt());
		Collections.sort(arr);
		List<Integer> groups = new ArrayList<>();
//		System.out.println(arr);
		for(int i = 0; i < arr.size() - 1; i++) {
			int j = i+1;
			groups.add(arr.get(i));
//			System.out.println(groups);
			while(j < arr.size()) {
//				System.out.println(j);
				if(arr.get(j) % arr.get(i) == 0) {
					arr.remove(j);
					
				}
				else {
//					groups.add(arr.get(j));
					j++;
				}
			}
		}
//		System.out.println(arr);
		System.out.println(arr.size());
	}
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic

import java.io.BufferedReader;
import java.io.InputStreamReader;
 
import java.util.*;
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Ideone {
    public static void main(String args[] ) throws Exception{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int n,i,j,k,temp ;
       n = ni(br.readLine());
       int[] a = nia(br);
       Arrays.sort(a);
       int c = 0;
       for( i = 0; i< n ; i++) {
    	   if(a[i] > 0) {
    		   c++;
    		   temp = a[i];
    		   for(j = i+1; j< n; j++) {
    			   if(a[j] % temp == 0)
    				    a[j] = 0;
    		   }
    	   }
       }
       
       
       System.out.println(c);
	
    }
    static Integer[] nIa(BufferedReader br) throws Exception{
        String sa[]=br.readLine().split(" ");
        Integer [] a = new Integer [sa.length];
        for(int i = 0; i< sa.length; i++){
            a[i]= ni(sa[i]);
        }
        return a;
   }
    static int[] nia(BufferedReader br) throws Exception{
        String sa[]=br.readLine().split(" ");
        int [] a = new int [sa.length];
        for(int i = 0; i< sa.length; i++){
            a[i]= ni(sa[i]);
        }
        return a;
   }
    
    static int ni(String s){
        return Integer.parseInt(s);
    }
    static float nf(String s){
        return Float.parseFloat(s);
    }
    static double nd(String s){
        return Double.parseDouble(s);
    }

  
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.util.Arrays;
import java.util.Scanner;

public class problemA {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] numbs = new int[n];
        int[] smallest_color = new int[n];
        for(int i =  0; i < n;i++){
            numbs[i] = scan.nextInt();
        }
        Arrays.sort(numbs);
        int count = 0;
        for(int i =0; i < n; i++){
            for(int j=0; j <n;j++ ){
                if(smallest_color[j] == 0){
                    count++;
                    smallest_color[j] = numbs[i];
                    break;
                }
                if(numbs[i] % smallest_color[j] == 0){
                    break;
                }
            }
        }
        System.out.println(count);
    }
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class AG1 {
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int n=scan.nextInt();
        int[] arr=new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i]=scan.nextInt();
        }
        Arrays.sort(arr);
        boolean[] done=new boolean[n];
        int ans=0;
        for(int i=0;i<n;i++){
            if(!done[i]){
                done[i]=true;
                ans++;
                for(int j=i+1;j<n;j++){
                    if(arr[j]%arr[i]==0){
                        done[j]=true;
                    }
                }
            }
        }
        System.out.println(ans);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.util.*;

public class codea{
	public static void main(String args[])
	{
	  Scanner in = new Scanner(System.in);
	  int n = in.nextInt();
	  int arr[] = new int[n];
	  for(int i =0;i<n;i++)
	   arr[i]= in.nextInt();
	  Arrays.sort(arr);
	  int max =0;
	  boolean check[]= new boolean [n];
	  int count=0;
	  for(int i =0;i<n;i++)
	  {
	   
	   if(!check[i])
	   {
	   	count++;
	   
	   for(int j=i;j<n;j++)
	   {
	   
	    if(arr[j]%arr[i]==0)
	     check[j]=true;
	   }
	   
	   }	
	  }
	  System.out.println(count);	
	}
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
//package Round584;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class typeA {
	public static void main(String[] args) {
		FastReader s = new FastReader();
		int n = s.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=s.nextInt();
		}
		boolean[] arr2  = new boolean[n];
		Arrays.sort(arr);
		for(int i=0;i<arr2.length;i++) {
			arr2[i]=true;
		}
		//arr2[0]=true;
		for(int i=0;i<n-1;i++) {
			for(int j=i+1;j<n;j++) {
					if(arr[j]%arr[i]==0) {
						arr2[j]=false;
					}
				}
			}
		int count=0;
		for(int i=0;i<n;i++) {
			if(arr2[i]==true) {
				count++;
			}
		}
		System.out.println(count);
	}
	static class FastReader 
	
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    void solve() {
       int n=ni();
       int a[]=new int[n+1];
       for(int i=1;i<=n;i++) a[i]=ni();
       int vis[]=new int[101];
       int ans=0;
       Arrays.sort(a,1,n+1);
       for(int i=1;i<=n;i++){
           if(vis[a[i]]==1) continue;
           ans++;
           for(int j=a[i];j<=100;j+=a[i]) vis[j]=1;
       }
       pw.println(ans);
    }

    long M = (long)1e9+7;
    // END
    PrintWriter pw;
    StringTokenizer st;
    BufferedReader br;

    void run() throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
    }
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static PrintWriter writer;

    static String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

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

    static void banana() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        int[] color = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        int c = 0;
        while(true) {
            int mn = 1000;
            for (int i = 0; i < n; i++) {
                if(color[i] == 0) {
                    mn = Math.min(mn, a[i]);
                }
            }
            if (mn == 1000) {
                break;
            }
            c++;
            for (int i = 0; i < n; i++) {
                if (color[i] == 0) {
                    if (a[i] % mn == 0) {
                        color[i] = c;
                    }
                }
            }
        }
        writer.println(c);
    }

    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = null;
        writer = new PrintWriter(System.out);
        banana();
        reader.close();
        writer.close();
    }
}
// Problem: 1209_A. Paint the Numbers
// Time complexity: quadratic
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        int[] flag = new int[N];
        int ans = 0;
        for (int i=0;i<N;i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(a);
        for (int i=0;i<N;i++) {
            int used = 0;
            for (int j=0;j<N;j++) {
                if (flag[j]==1) {
                    continue;
                } else {
                    if (a[j]%a[i]==0) {
                        used=1;
                        flag[j]=1;
                    }
                }
            }
            if (used==1) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}