codeparrot/codecomplex huggingface dataset:
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
//make sure to make new file!
import java.io.*;
import java.util.*;

public class CDS2021{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int t = Integer.parseInt(f.readLine());
      
      for(int q = 1; q <= t; q++){

         int n = Integer.parseInt(f.readLine());
      
         int[] array = new int[n];
         for(int k = 0; k < n; k++){
            array[k] = Integer.parseInt(f.readLine());
         }
         
         StringJoiner sj = new StringJoiner("\n");
         Stack<Entry> stack = new Stack<Entry>();
         
         //first element should be 1
         sj.add("1");
         stack.push(new Entry("1",1));
         
         for(int k = 1; k < n; k++){
            if(array[k] == 1){
               //add new depth
               String s = stack.peek().s + ".1";
               sj.add(s);
               stack.push(new Entry(s,1));
            } else {
               while(!stack.isEmpty() && stack.peek().last != array[k]-1){
                  stack.pop();
               }
               
               if(stack.isEmpty()) break;             //shouldn't happen
               
               String s = "";
               int index = stack.peek().s.lastIndexOf(".");
               if(index == -1) s = "" + array[k];
               else s = stack.peek().s.substring(0,index+1) + array[k];
               sj.add(s);
               stack.pop();
               stack.push(new Entry(s,array[k]));
            }
         }
         
         out.println(sj.toString());
      }
      
      
      
      
      out.close();
   }
   
   public static class Entry{
      String s;
      int last;
      public Entry(String a, int b){
         s = a;
         last = b;
      }
   }
      
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0, t = sc.nextInt(); i < t; i++) {
            int n = sc.nextInt();
            LinkedList<Set<Integer>> stack = new LinkedList<>();
            for (int j = 0; j < n; j++) {
                printStack(stack);
                int val = sc.nextInt();
                if (val == 1) {
                    Set<Integer> branch = new HashSet<>();
                    branch.add(val);
                    stack.push(branch);
                    continue;
                }
                Set<Integer> branch = stack.peek();
                assert branch != null;
                while (branch.contains(val) || branch.stream().max(Integer::compareTo).get() + 1 != val) {
                    stack.pop();
                    branch = stack.peek();
                }
                branch.add(val);
            }
            printStack(stack);
        }
    }

    public static void printStack(LinkedList<Set<Integer>> stack) {
        if (stack.size() == 0) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = stack.size() - 1; i >= 0; i--) {
            sb.append(stack.get(i).stream().max(Integer::compareTo).get()).append(".");
        }
        System.out.println(sb.substring(0, sb.length() - 1));
    }
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
/*
1
4
1
1
2
3
 */
public class C {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int T=fs.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		for (int tt=0; tt<T; tt++) {
			int n=fs.nextInt();
			int[] a=fs.readArray(n);
			int[] stack=new int[n];
			int size=0;
			for (int i:a) {
				if (i==1) {
					stack[size++]=i;
				}
				else {
					while (stack[size-1]!=i-1) {
						size--;
					}
					size--;
					stack[size++]=i;
				}
				for (int j=0; j<size; j++) {
					out.print(stack[j]);
					if (j!=size-1) out.print('.');
				}
				out.println();
			}
			
//			int[] mapTo=new int[n];
//			Arrays.fill(mapTo, -1);
//			ArrayDeque<Integer>[] occsOf=new ArrayDeque[1001];
//			for (int i=0; i<occsOf.length; i++) occsOf[i]=new ArrayDeque<>();
//			int lastOne=-1;
//			
//			for (int i=0; i<n; i++) {
//				if (a[i]==1) {
//					mapTo[i]=lastOne;
//					lastOne=i;
//				}
//			}
//			for (int value=2; value<occsOf.length; value++) {
//				for (int i:occsOf[value]) {
//					int mapsTo=occsOf[value-1].removeFirst();
//					mapTo[i]=mapsTo;
//				}
//			}
//			System.out.println(Arrays.toString(mapTo));
//			for (int i=0; i<n; i++) {
//				ArrayList<Integer> listBackwards=new ArrayList<>();
//				listBackwards.add(a[i]);
//				int at=i;
//				while (true) {
////					System.out.println("x");
//					if (mapTo[at]==-1) {
//						break;
//					}
//					if (a[mapTo[at]]!=a[at]-1) {
//						listBackwards.add(a[mapTo[at]]);
//					}
//					at=mapTo[at];
//				}
//				for (int j=listBackwards.size()-1; j>=0; j--) {
//					out.print(listBackwards.get(j));
//					if (j!=0) out.print('.');
//				}
//				out.println();
//			}
		}
		out.close();
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

public class C{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long mod=1000000007l;
        int cases=sc.nextInt();


        while(cases>0)
        {
            cases--;
            Stack<Integer> stack=new Stack<>();

            int n=sc.nextInt();

            for(int j=0;j<n;j++)
            {
                int x=sc.nextInt();
                if(x==1)
                {
                    stack.add(1);
                }
                else
                {
                    int p=stack.pop();
                    if(p==x-1)
                    {
                        stack.add(x);
                    }
                    else {
                        while (p != x-1) {
                            p = stack.pop();
                        }

                        stack.add(x);

                    }

                }
                StringBuilder f=new StringBuilder();
                Stack<Integer> temp=new Stack<>();

                while(stack.isEmpty()==false)
                {
                    temp.add(stack.pop());
                }

                while(temp.isEmpty()==false)
                {
                    int z=temp.pop();
                    f.append(z+".");
                    stack.add(z);
                }


                System.out.println(f.substring(0,f.length()-1));

            }

        }

    }
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.*;
public class CompressionAndExpansion {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int N = in.nextInt();
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                int n = in.nextInt();
                if (n == 1) {
                    list.add(n);
                } else {
                    for (int j = list.size() - 1; j >= 0; j--) {
                        if (list.get(j) == n - 1) {
                            list.set(j, n);
                            break;
                        }
                        list.remove(j);
                    }
                }
                for (int j = 0; j < list.size(); j++) {
                    System.out.print(list.get(j) + (j == list.size() - 1 ? "\n" : "."));
                }
            }
        }
    }
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
// package contest;

import java.io.*;
import java.util.Stack;
import java.util.StringTokenizer;

public class teama {

    static int mod = 2_000_000_007;

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

        int T = Integer.parseInt(br.readLine());
        for (int t = 0; t < T; t++) {
            int N = Integer.parseInt(br.readLine());
            Stack<Integer> stack = new Stack();
            for (int i = 0; i < N; i++) {
                int a = Integer.parseInt(br.readLine());
                if (a != 1) {
                    while (stack.peek() + 1 != a) {
                        stack.pop();
                    }
                    stack.pop();
                }
                stack.push(a);

                boolean dummy = false;
                for (int j : stack) {
                    if (dummy) {
                        pw.print(".");
                    }
                    pw.print(j);
                    dummy = true;
                }
                pw.println();
            }
        }

        pw.close();
        br.close();
    }
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.*;
import java.io.*;
 
public class uo{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int testcases = Integer.parseInt(st.nextToken());
		for(int lmn=0;lmn<testcases;lmn++){
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			// int k = Integer.parseInt(st.nextToken());
			// st = new StringTokenizer(br.readLine());
			ArrayList<Integer> a = new ArrayList<>();
			for(int lmn1 = 0;lmn1<n;lmn1++){
				st = new StringTokenizer(br.readLine());
				int a1 = Integer.parseInt(st.nextToken());
				if(a.size()>0 && (a1==1)){
					// a.add(a1);
				}
				else if(a.size()>0){
					if(a.size()==1){
						a.remove(0);
					}
					else{
						int i = a.size()-1;
						while(a.size()>0 && i>=0 && a.get(i)+1 != a1){
							a.remove(i);
							i--;
						}
						a.remove(a.size()-1);
						// System.out.println(a+" "+i);

					}
				}
				// while(a.size()>0 && a.get(a.size()-1)+1<a1){
				// 	a.remove(a.size()-1);
				// }
				if(a.size()==0){
					a.add(a1);
				}
				else{
					a.add(a1);
				}
				if(a.size()==1){
					System.out.println(a.get(0));
				}
				else{
					for(int i=0;i<a.size()-1;i++){
						
						System.out.print(a.get(i)+".");
					}
					System.out.println(a.get(a.size()-1));
				}
				

			}
		}
		
	}
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic

import java.util.*;
import java.util.Scanner;

public class Def {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while (t-->0) {
			
			int n = s.nextInt();
			int[] arr = new int[n];
			for (int i=0; i<n; i++) {
				arr[i] = s.nextInt();
			}

//			int deep = 0;
//			System.out.println(n+"     n");
			List<Integer> al = new ArrayList<>();
			al.add(1);
			System.out.println(1);
			for(int i=1; i<n;i++) {
				int len = al.size();
//				for (int d =0; d<len; d++) {
//					System.out.print(al.get(d)+" ");
//				}
//				System.out.println();
				if (arr[i] == 1) {
					for(int j=0; j<len; j++) {
						System.out.print(al.get(j)+".");
					}
					System.out.println(1);
					al.add(1);
				}else if (arr[i] == arr[i-1] && arr[i]==1) {
					
					for(int j=0; j<len; j++) {
						System.out.print(al.get(j)+".");
					}
					System.out.println(1);
					al.add(1);
				}else {
					for (int j=len-1; j>-1; j--) {
						if (al.get(j)+1 == arr[i]) {
							for(int k=0; k<j; k++) {
								System.out.print(al.get(k)+".");
							}
							System.out.println(arr[i]);
							al.set(j, al.get(j)+1);
							al.subList(j+1, len).clear();
							break;
						}
					}
				}
			}
			
		}
		s.close();
		

	}

}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.*;
import java.io.*;


public class Main{
    public static void pri(ArrayList<Integer> list)
    {
        int len=list.size();
        for(int i=0;i<len-1;++i)
            System.out.print(list.get(i)+".");
        System.out.println(list.get(len-1));
    }
    public static void main(String[] args) throws java.io.IOException {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            int[] arr=new int[n];
            for(int i=0;i<n;++i)
            {
                arr[i]=sc.nextInt();
            }
            ArrayList<Integer> cur=new ArrayList<>();
            cur.add(1);
            System.out.println(1);
            for(int i=1;i<n;++i)
            {
                if(arr[i]==1)
                {
                    cur.add(1);
                    pri(cur);
                    continue;
                }
                int len=cur.size();
                while(cur.get(len-1)!=arr[i]-1)
                {
                    cur.remove(len-1);
                    len--;
                }
                cur.set(len-1,arr[i]);
                pri(cur);
                continue;
            }
        }
    }
}
// 1 0 1 1 0 0 1
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
/* package codechef; // 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 Codechef
{
    /*static long power(long a,long b,long m)
    {
        if(b==0)
        return 1;
        if((b&1)==0)
        return power((a*a)%m,b/2,m);
        else
        return (a*power((a*a)%m,b/2,m))%m;
    }*/
    /*
    static int gcd(int a,int b)
    {
        if(b==0)
        return a;
        else
        return gcd(b,a%b);
    }
    */
    public static void main (String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        PrintWriter p=new PrintWriter(System.out);
        while(t-->0)
        {
            //StringTokenizer st=new StringTokenizer(br.readLine());
            int n=Integer.parseInt(br.readLine());
            String a[]=new String[n];
            for(int i=0;i<n;i++)
            {
                a[i]=br.readLine();
            }
            String pre="1";
            for(int i=1;i<n;i++)
            {
                if(a[i].equals("1"))
                {
                    a[i]=pre+".1";
                    pre=a[i];
                    continue;
                }
                int li=pre.lastIndexOf('.');
                while(li!=-1 && Integer.parseInt(pre.substring(li+1))+1!=Integer.parseInt(a[i]))
                {
                    pre=pre.substring(0,li);
                    li=pre.lastIndexOf('.');
                }
                //li=pre.lastIndexOf('.');
                if(li!=-1)
                a[i]=pre.substring(0,li+1)+a[i];
                pre=a[i];
            }
            for(int i=0;i<n;i++)
            {
                p.println(a[i]);
            }
            p.flush();
        }
	}
}
// Problem: 1523_C. Compression and Expansion
// Time complexity: cubic
import java.util.*;
import java.io.*;

public class _1523_C {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int t = Integer.parseInt(in.readLine());
        while(t-- > 0) {
            int n = Integer.parseInt(in.readLine());
            int[] a = new int[n];
            for(int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.readLine());
            }
            boolean[][] used = new boolean[n][n + 1];
            boolean[] used2 = new boolean[n];
            String[][] res = new String[n][2];
            res[0][0] = "1";
            res[0][1] = "";
            for(int i = 1; i < n; i++) {
                if(a[i] == 1) {
                    for(int j = i - 1; j >= 0; j--) {
                        if(!used[j][a[i]] && !used2[j]) {
                            res[i][0] = res[j][0] + ".1";
                            res[i][1] = res[j][0];
                            used[j][a[i]] = true;
                            break;
                        }
                    }
                }else {
                    for(int j = i - 1; j >= 0; j--) {
                        if(!used[j][a[i]] && !used2[j] && a[j] == a[i] - 1) {
                            if(res[j][1].equals("")) {
                                res[i][0] = "" + a[i];
                            }else {
                                res[i][0] = res[j][1] + "." + a[i];
                            }
                            res[i][1] = res[j][1];
                            used[j][a[i]] = true;
                            break;
                        }
                        used2[j] = true;
                    }
                }
            }
            for(int i = 0; i < n; i++) {
                out.println(res[i][0]);
            }
        }
        in.close();
        out.close();
    }
}
// Problem: 839_E. Mother of Dragons
// Time complexity: np

import java.util.*;
import java.io.*;
public class code839E
{
    public static void main(String[] args) throws Exception{
        BufferedReader bff=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter wff=new PrintWriter(System.out);
        String[] st=bff.readLine().split(" ");
        int V=Integer.parseInt(st[0]);
        int K=Integer.parseInt(st[1]);
        BronKerbosch bk=new BronKerbosch(V);
        for(int i=0;i<V;i++){
            st=bff.readLine().split(" ");
            for(int j=0;j<V;j++){
                if(st[j].equals("1")){
                    bk.anadir(i,j);
                }
            }
        }
        long num=bk.numeroCamarilla();
        wff.printf("%.12f\n", num * (num - 1.0) / 2 * K / num * K / num);
        wff.flush();
    }
    
    
    
static class BronKerbosch {
    int V;
    long[] neig;
    Random random = new Random();
    long maxClique;

    public BronKerbosch(int v){
        V=v;
        neig=new long[V];
    }

    public void anadir(int a,int b){
        long aux=1;
        neig[a] |= aux << (long)b;
    }
    
    public long numeroCamarilla(){
        long numero = Long.bitCount(bronKerbosch());
        return numero;
    }
    
    public long bronKerbosch() {
        maxClique = 0;
        bronKerbosch2(0, (1L << V) - 1, 0);
        return maxClique;
    }

    public void bronKerbosch2(long r, long p, long x) {
        if (Long.bitCount(maxClique) >= Long.bitCount(r | p | x)) return;
        long px = p | x;
        if (px == 0) {
            if (Long.bitCount(maxClique) < Long.bitCount(r)) {
                maxClique = r;
            }
            return;
        }
        int cnt = Long.bitCount(px);
        int choice = random.nextInt(cnt);
        int u;
        for (int i = 0; ; i++) {
            if ((px >>> i & 1) != 0 && choice-- == 0) {
                u = i;
                break;
            }
        }

        long ne = p & ~neig[u];
        for (int v = 0; v < V; v++){
            if ((ne >>> v & 1) != 0) {
                bronKerbosch2(r | 1L << v, p & neig[v], x & neig[v]);
                p &= ~(1L << v);
                x |= 1L << v;
            }
        }
    }

}


    
}
// Problem: 839_E. Mother of Dragons
// Time complexity: np
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.IOException;
import java.util.StringTokenizer;
/*
 * @author Tnascimento 
 */

public class MaeDosDragoes {
	public static PrintWriter saida = new PrintWriter(System.out, false);
	public static class Escanear {
        BufferedReader reader;
        StringTokenizer tokenizer;
		public Escanear() {
            this(new InputStreamReader(System.in));
        }
		public Escanear(Reader in) {
            reader = new BufferedReader(in);
        }
        String proximo() {
            if (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(proximo());
        }
    }



    public static void main(String[] args) {
		Escanear fastScanner = new Escanear();
        int proximoInt = fastScanner.nextInt();
        double proximoDouble = fastScanner.nextInt();
        long[] graph = new long[proximoInt];
        for(Integer i = 0; i < proximoInt; i++) {
            for(Integer j =0; j < proximoInt; j++) {
                Integer val = fastScanner.nextInt();
                if (val.equals(1) || i.equals(j)) {
				 graph[i] |= 1L << j;
				}
            }
        }

        int szLeft = proximoInt/2;
        int szRight = proximoInt - szLeft;

        int[] dp = new int[1 << szLeft];
        int maxMask = 1 << szLeft;

        for(int mask = 1; mask <maxMask; mask++) {
            int curMask = mask;

            for(int j = 0; j < szLeft; j++) {
                if (((1 << j) & mask) > 0) {
                    curMask &= graph[j + szRight] >> szRight;
                    dp[mask] = Math.max(dp[mask], dp[mask ^ (1 << j)]);
                }
            }
            if (mask == curMask) {
                dp[mask] = Math.max(dp[mask],Integer.bitCount(mask));
            }
        }
        int ans = 0;
        int rmaxMask = 1 << szRight;
        for(int mask = 0; mask < rmaxMask; mask++) {
            int curMask = mask;
            int oMask = maxMask -1;
            for(int j = 0; j < szRight; j++) {
                if (((1 << j) & mask) > 0) {
                    curMask &= (graph[j] & (rmaxMask-1));
                    oMask &= graph[j] >> szRight;
                }
            }
            if (curMask != mask) continue;
            ans = Math.max(ans, Integer.bitCount(mask) + dp[oMask]);
        }
        proximoDouble/=ans;
        saida.println(proximoDouble * proximoDouble * (ans * (ans-1))/2);
        saida.flush();
    }
}