codeparrot/codecomplex huggingface dataset:
// Problem: 1179_B. Tolik and His Uncle
// Time complexity: quadratic
import java.io.*;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class D {
    static class FastWriter {
        private final BufferedWriter bw;

        public FastWriter() {
            this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        public void print(Object object) throws IOException {
            bw.append("" + object);
        }

        public void println(Object object) throws IOException {
            print(object);
            bw.append("\n");
        }

        public void close() throws IOException {
            bw.close();
        }
    }

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

        BigInteger nextBigInteger() {
            try {
                return new BigInteger(nextLine());
            } catch (NumberFormatException e) {
                throw new InputMismatchException();
            }
        }
    }

    public static void main(String[] args) throws IOException {
        FastReader fr = new FastReader();
        FastWriter fw = new FastWriter();
        int n = fr.nextInt();
        int m = fr.nextInt();
        for (int r = 0; r < n / 2; r++) {
            for (int c = 0; c < m; c++) {
                fw.println((r + 1) + " " + (c + 1));
                fw.println((n - r) + " " + (m - c));
            }
        }
        if (n % 2 != 0) {
            int r = n / 2;
            for (int c = 0; c < m / 2; c++) {
                fw.println((r + 1) + " " + (c + 1));
                fw.println((r + 1) + " " + (m - c));
            }
            if (m % 2 != 0) fw.println((r + 1) + " " + (m / 2 + 1));
        }
        fw.close();
    }
}
// Problem: 1197_B. Pillars
// Time complexity: linear
import java.util.Scanner;
 
public class pillar {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[200005];
		for (int i=1;i<=n;i++) 
		a[i]=sc.nextInt();
		for (int i=2;i<n;i++) 
		if (a[i-1]>a[i]&&a[i]<a[i+1]) {
			System.out.println("NO");
			return;
		}
		System.out.println("YES");
	}
}
// Problem: 1059_C. Sequence Transformation
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class SequenceTransformation {
    void solve() {
        int p = 1, n = in.nextInt();
        while (n > 0) {
            if (n == 1) {
                out.print(p + " ");
                break;
            }
            if (n == 2) {
                out.print(p + " ");
                out.print(2 * p + " ");
                break;
            }
            if (n == 3) {
                out.print(p + " ");
                out.print(p + " ");
                out.print(3 * p + " ");
                break;
            }
            for (int i = 0; i < (n + 1) / 2; i++) {
                out.print(p + " ");
            }
            p *= 2;
            n /= 2;
        }
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new SequenceTransformation().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
// Problem: 527_B. Error Correct System
// Time complexity: quadratic
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.util.*;

import static java.lang.System.gc;
import static java.lang.System.out;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().solve();
    }


    void solve() {

        int n = scanner.nextInt();
        scanner.nextLine();
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();


        int ans = 0;
        boolean a[] = new boolean[30];
        boolean b[] = new boolean[30];

        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                ans ++;
                a[s1.charAt(i)  - 'a'] = true;
                b[s2.charAt(i)  - 'a'] = true;
            }
        }
        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i) && a[s2.charAt(i) - 'a'] && b[s1.charAt(i) - 'a']) {
                for (int j = i + 1; j < n; j ++) {
                    if (s1.charAt(i) == s2.charAt(j) && s1.charAt(j) == s2.charAt(i)) {
                        out.println(ans - 2);
                        out.println((i + 1) + " " + (j + 1));
                        return;
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i) && (a[s2.charAt(i) - 'a'] || b[s1.charAt(i) - 'a'])) {
                for (int j = i + 1; j < n; j ++) {
                    if (s1.charAt(j) != s2.charAt(j) && (s1.charAt(i) == s2.charAt(j) || s1.charAt(j) == s2.charAt(i))) {
                        out.println(ans - 1);
                        out.println((i + 1) + " " + (j + 1));
                        return;
                    }
                }
            }
        }

        out.println(ans);
        out.println(-1 + " " + -1);
    }
}
// Problem: 1197_C. Array Splitting
// Time complexity: nlogn
import java.io.*;
import java.util.*;

import javax.lang.model.util.ElementScanner6;
public class codef
{
    public static void main(String ar[]) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer nk=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(nk.nextToken());
        int k=Integer.parseInt(nk.nextToken());
        String st[]=br.readLine().split(" ");
        
        int ans[]=new int[n];
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            ans[i]=Integer.parseInt(st[i]);  

        for(int i=1;i<n;i++)
            a[i]=ans[i]-ans[i-1];
        a[0]=-1;

        Arrays.sort(a);
        int count=0,sum=0;
        for(int i=0;i<n;i++)
            if(a[i]<0)
                count++;
            else
                sum=sum+a[i];
        
        k=k-count;
        int i=n-1;
        while(k>0 && i>=0)
        {
            if(a[i]>-1)
            {
                sum=sum-a[i];
                k--;
            }
            i--;
        }
        System.out.println(sum);
    }
}
// Problem: 1028_B. Unnatural Conditions
// Time complexity: constant
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class B {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        StringBuilder ans1 = new StringBuilder();
        StringBuilder ans2 = new StringBuilder();
        for(int i=0; i<2229; i++) ans1.append('5');
        ans1.append('6');
        for(int i=0; i<2230; i++) ans2.append('4');
        out.println(ans1.toString());
        out.println(ans2.toString());
        out.close(); System.exit(0);
    }
}
// Problem: 1011_B. Planning The Expedition
// Time complexity: quadratic
import java.io.*;
import java.util.*;

public class Solution{
    
    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;
        }
    }
    
    public static void main(String args[] ) {
        
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[105];
        
        for(int i=0;i<m;i++){
            int a = sc.nextInt();
            arr[a]++;
        }
        
        for(int i=1;i<=1000;i++){
            int sum=0;
            
            for(int a:arr){
                if(a!=0){
                    sum+=(a/i);
                }
            }
            
            
            if(sum<n){
                System.out.println(i-1);
                return;
            }
            
        }
    }

}
// Problem: 1061_A. Coins
// Time complexity: constant
import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s1[]=br.readLine().split(" ");
            int n=Integer.parseInt(s1[0]);
            int S=Integer.parseInt(s1[1]);
            if(S%n==0)
             System.out.println(S/n);
            else
             System.out.println(S/n+1);
      }
}
// Problem: 1159_C. The Party and Sweets
// Time complexity: nlogn

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
	static StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	public static void main(String[] args) {
		int n=nextInt();
		int m=nextInt();
		long b[]=new long[n];
		long g[]=new long[m];
		for(int i=0;i<n;i++)
			b[i]=nextInt();
		for(int i=0;i<m;i++)
			g[i]=nextInt();
		Arrays.sort(b);
		Arrays.sort(g);
		if(b[n-1]>g[0])
			System.out.println("-1");
		else if(b[n-1]==g[0]){
			long sum=0;
			for(int i=0;i<m;i++)
				sum+=g[i];
			for(int i=0;i<n-1;i++){
				sum+=(m*b[i]);
			}
			System.out.println(sum);
		}else{
			long sum=0;
			for(int i=0;i<m;i++)
				sum+=g[i];
			sum+=b[n-1];
			sum+=(b[n-2]*(m-1));
			for(int i=0;i<n-2;i++){
				sum+=(m*b[i]);
			}
			System.out.println(sum);
		}
	}
	static int nextInt(){
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int)st.nval;
	}
}
// Problem: 912_A. Tricky Alchemy
// Time complexity: constant
import java.util.*;

public class A912 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		long x = scan.nextInt();
		long y = scan.nextInt();
		long z = scan.nextInt();
		
		long requiredA = x * 2 + y;
		long requiredB = y + z * 3;
		
		long neededA = Math.max(0, requiredA - A);
		long neededB = Math.max(0, requiredB - B);
		System.out.print(neededA + neededB);
	}

}
// Problem: 1180_C. Valeriy and Deque
// Time complexity: linear


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class C {

    void solve(){
       int n = readInt();
       int q = readInt();
       int max = 0;
       int[] a = new int[n];
       Deque<Integer> deque = new ArrayDeque<>();
       for(int i = 0;i<n;i++){
           a[i] = readInt();
           deque.addLast(a[i]);
           max = Math.max(max, a[i]);
       }
        List<String> ans = new ArrayList<>();
        while(deque.peekFirst() != max){
           int one = deque.pollFirst();
           int two = deque.pollFirst();
           ans.add(one + " " + two);
           deque.addFirst(one > two ? one : two);
           deque.addLast(one > two ? two : one);
           if(one == max) break;
       }

       for(int i = 0;i<n;i++){
           a[i] = deque.pollFirst();
       }

       for(int i = 0;i<q;i++){
          long x = readLong();
           if(x <= ans.size()){
               out.println(ans.get((int)x - 1));
               continue;
           }
           x -= ans.size();
           int y =(int) (x%(n - 1) - 1%(n - 1) + (n - 1)) % (n - 1) + 1;
           out.println(max + " " + a[y]);
       }
    }

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

    void run(){
        init();
        solve();
        out.close();
    }

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok = new StringTokenizer("");

    void init(){
        in = new BufferedReader(new InputStreamReader(System.in));
        out  = new PrintWriter(System.out);
    }

    String readLine(){
        try{
            return in.readLine();
        }catch(Exception ex){
            throw new RuntimeException(ex);
        }
    }
    String readString(){
        while(!tok.hasMoreTokens()){
            String nextLine = readLine();
            if(nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

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

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

    double readDouble(){
        return Double.parseDouble(readString());
    }
}
// Problem: 1013_B. And
// Time complexity: linear
//package contese_476;
import java.util.*;
public class q1 
{
	int m=(int)1e9+7;
public class Node
{
	int a;
	int b;
	public void Node(int a,int b)
	{
		this.a=a;
		this.b=b;
	}
}
public int mul(int a ,int b)
{
a=a%m;
b=b%m;
return((a*b)%m);
}
public int pow(int a,int b)
{
	int x=1;
	while(b>0)
	{
		if(b%2!=0)
			x=mul(x,a);
		a=mul(a,a);
		b=b/2;
	}
	return x;
}
public static long gcd(long a,long b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	HashMap<Integer,Integer> h=new HashMap();
	//HashMap<Integer,Integer> h1=new HashMap();
	int[] a=new int[n];
	int x=sc.nextInt();
	for(int i=0;i<n;i++)
	{
		a[i]=sc.nextInt();
		if(h.get(a[i])==null)
		{
			h.put(a[i], 1);
			//h1.put(a[i],i);
		}
		else
		{
			System.out.print(0);
			System.exit(0);
		}
	}
	for(int i=0;i<n;i++)
	{
		int num=a[i]&x;
		if(num==a[i])
			continue;
		if(h.get(num)==null)
			continue;
		
		else
		{
			
			System.out.print(1);
			System.exit(0);
		}
	}
	for(int i=0;i<n;i++)
	{
		int num=a[i]&x;
		if(num==a[i])
			continue;
		if(h.get(num)==null)
			h.put(num, 1);
		else
		{
			System.out.print(2);
			System.exit(0);
		}
	}
	System.out.print(-1);
	
     
}

}
// Problem: 1011_B. Planning The Expedition
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class Solution {

    private static int[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), m = sc.nextInt();

        a = new int[101];
        for (int i = 0; i < m; i++) {
            int type = sc.nextInt();
            a[type] = a[type] + 1;
        }

        int lo=1, hi=100, max=0;

        while (lo <= hi) {
            int mid = lo + (hi - lo)/2;
            if (check(n, mid)) {
                max = mid;
                lo = mid+1;
            } else {
                hi = mid -1;
            }
        }
        System.out.println(max);
    }

    public static boolean check(int n, int target) {
        int result = 0;
        for (int i=0; i <a.length; i++) {
            result = result + (a[i] / target);
        }
        if (result >= n) {return true;}
        return false;
    }
}
// Problem: 1027_D. Mouse Hunt
// Time complexity: linear
import java.io.*;
import java.util.*;

public class CF1027D {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[] cc = new int[n];
		for (int i = 0; i < n; i++)
			cc[i] = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = Integer.parseInt(st.nextToken()) - 1;
		int[] used = new int[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (used[i] == 2)
				continue;
			int j = i;
			while (used[j] == 0) {
				used[j] = 1;
				j = aa[j];
			}
			if (used[j] == 1) {
				int c = cc[j];
				while (used[j] == 1) {
					used[j] = 2;
					c = Math.min(c, cc[j]);
					j = aa[j];
				}
				ans += c;
			}
			j = i;
			while (used[j] == 1) {
				used[j] = 2;
				j = aa[j];
			}
		}
		System.out.println(ans);
	}
}
// Problem: 1179_B. Tolik and His Uncle
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D {

    private void solve() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = nextInt(), m = nextInt(), u = 1, d = n;

        while (u < d) {
            for (int i = 1; i <= m; i++) {
                out.println(u + " " + i);
                out.println(d + " " + (m - i + 1));
            }
            u++;
            d--;
        }
        if (u == d) {
            int l = 1, r = m;
            while (l < r) {
                out.println(u + " " + l++);
                out.println(d + " " + r--);
            }
            if (l == r) out.println(u + " " + l);
        }

        out.close();
    }

    public static void main(String[] args) {
        new D().solve();
    }

    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter out;

    private String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

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

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

    private double nextDouble() {
        return Double.parseDouble(next());
    }
}
// Problem: 1159_B. Expansion coefficient of the array
// Time complexity: linear
//package com.krakn.CF.B1159;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n;
        n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int min = 1000000000, temp;

        for (int i = 0; i < n; i++) {
            temp = arr[i] / Math.max(i, n - 1 - i);
            if (temp < min)
                min = temp;
//            System.out.println(i + " " + temp);
        }

        System.out.println(min);
    }
}
// Problem: 903_D. Almost Difference
// Time complexity: nlogn
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/* 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]);
		}
		Map memo=new HashMap();
		int[] f=new int[n];
		for(int i=0;i<n;i++){
			if(!memo.containsKey(A[i])){
				memo.put(A[i],1);
			}
			else{
				int ct=(int)memo.get(A[i]);
				memo.put(A[i],ct+1);
			}
			int tot=0;
			if(memo.containsKey(A[i]-1)){
				tot+=(int)memo.get(A[i]-1);
			}
			if(memo.containsKey(A[i]+1)){
				tot+=(int)memo.get(A[i]+1);
			}
			tot+=(int)memo.get(A[i]);
			f[i]=tot;
		}
		BigInteger res=new BigInteger("0");
		for(int i=0;i<n;i++){
			int tot1=i+1-f[i];
			int tot2=0;
			if(memo.containsKey(A[i]-1)){
				tot2+=(int)memo.get(A[i]-1);
			}
			if(memo.containsKey(A[i]+1)){
				tot2+=(int)memo.get(A[i]+1);
			}
			tot2+=(int)memo.get(A[i]);
			tot2=n-i-1-(tot2-f[i]);
			//res+=(long)(tot1-tot2)*(long)A[i];
			res=res.add(BigInteger.valueOf((long)(tot1-tot2)*(long)A[i]));
		}
		System.out.println(res);
	}
}
// Problem: 1180_B. Nick and Array
// Time complexity: linear
import java.util.*;


public class Main {
    static int n=5;
    static int[] arr=new int[5];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for (int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
        for (int i=0;i<n;i++)
        {
            if (arr[i]>=0)
            {
                arr[i]=-arr[i]-1;
            }
        }
        if (n%2!=0)
        {
            int min=0;
            for (int i=1;i<n;i++)
            {
                if (arr[i]<arr[min])
                    min=i;
            }
            arr[min]=-arr[min]-1;
        }
        for (int x:arr)
        {
            System.out.print(x + " ");
        }

    }
}