codeparrot/codecomplex huggingface dataset:
// 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.util.StringTokenizer;
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int inv = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    if (a[j] > a[i]) {
                        inv++;
                    }
                }
            }
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                int s = (r - l + 1) * (r - l) / 2;
                inv = (inv + s) % 2;
                out.println(inv % 2 == 0 ? "even" : "odd");
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}
// Problem: 1033_C. Permutation Game
// Time complexity: nlogn
import com.sun.org.apache.xpath.internal.operations.Bool;

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = scan.nextInt();
        int[] vals = new int[n];
        for (int i = 0; i < n; i++) {
            vals[i] = scan.nextInt();
        }

        for (int i = 0; i < n; i++) {
            if (solve(i, vals)) {
                out.print('A');
            } else {
                out.print('B');
            }
        }

        out.close();
    }

    static HashMap<Integer, Boolean> dpResult = new HashMap<>();

    private static boolean solve(int pos, int[] vals) {
        if (dpResult.containsKey(pos)) return dpResult.get(pos);
        int val = vals[pos];
        boolean hasLose = false;
        for (int i = pos; i < vals.length; i += val) {
            if (i == pos) continue;
            if (vals[i] <= vals[pos]) continue;
            if (hasLose) break;
            if (!solve(i, vals)) {
                hasLose = true;
            }
        }
        for (int i = pos; i >= 0; i -= val) {
            if (i == pos) continue;
            if (vals[i] <= vals[pos]) continue;
            if (hasLose) break;
            if (!solve(i, vals)) {
                hasLose = true;
            }
        }
        dpResult.put(pos, hasLose);
        return hasLose;
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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: 975_D. Ghosts
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Main {
    public void solve() {
        int n = ni();
        int a = ni();
        int b = ni();

        long ans = 0;
        HashMap<Long, Long> m = new HashMap<>();
        HashMap<String, Long> s = new HashMap<>();

        for (int i = 0; i < n; i++) {
            ni();
            long vx = ni();
            long vy = ni();
            long v = (long) a * vx - vy;
            String k = vx + "|" + vy;
            long cs = s.getOrDefault(k, 0L);
            long c = m.getOrDefault(v, 0L);
            ans += c - cs;
            m.put(v, c + 1);
            s.put(k, cs + 1);
        }
        write (ans * 2 + "\n");
    }



    public static void main(String[] args) {
        Main m = new Main();
        m.solve();
        try {
            m.out.close();
        } catch (IOException e) {}
    }

    BufferedReader in;
    BufferedWriter out;
    StringTokenizer tokenizer;
    public Main() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new BufferedWriter(new OutputStreamWriter(System.out));
    }
    public String n() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(in.readLine());
            } catch (IOException e) {}
        }
        return tokenizer.nextToken();
    }
    public int ni() {
        return Integer.parseInt(n());
    }
    public long nl() {
        return Long.parseLong(n());
    }
    public void write(String s) {
        try {
            out.write(s);
        } catch (IOException e) {}
    }
}
// Problem: 1073_B. Vasya and Books
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


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

        int n = Integer.parseInt(br.readLine());

        int[] a = new int[n];
        int[] b = new int[n];

        StringTokenizer st = new StringTokenizer(br.readLine());

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

        solve(n, a, b, out);
        out.flush();
        out.close();
    }

    private static void solve(int n, int[] a, int[] b, PrintWriter out) {
        boolean[] book = new boolean[n+1];
        boolean f;
        int j1 = 0, j2 = 0;
        for (int i = 0; i < n; i++) {
            f = false;
            int num = b[i];
            if(!book[num]) {
                f = true;
                j1 = j2;
                for (;j2 < n; j2++) {
                    book[a[j2]] = true;
                    if (a[j2] == num) {
                        j2++;
                        break;
                    }
                }
            }
            out.print(f ? j2-j1 + " ": 0 + " ");
        }
    }
}
// Problem: 961_B. Lecture Sleep
// Time complexity: linear
import java.io.*;
import java.util.*;

public class LectureSleep {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);


    public static void main(String[] args) {
        int n = r.nextInt(); // duration of lecture
        int k = r.nextInt(); // number of minutes keep mishka awake
        int[] theorems = new int[n+1];
        for(int i = 1; i <= n; i++){
            theorems[i] = r.nextInt();
        }
        int[] mishka = new int[n+1];
        for(int i = 1; i <= n; i++){
            mishka[i] = r.nextInt();
        }
        int[] sums = new int[n+1];
        for(int i = 1; i <= n; i++){
            if(mishka[i] == 0){
                sums[i] = sums[i-1] + theorems[i];
            } else{
                sums[i] = sums[i-1];
            }
        }
        int max = 0;
        for(int i = 1; i <= n-k+1; i++){
            int sum = sums[i+k-1] - sums[i-1];
            max = Math.max(max, sum);
        }
        int totalSum = 0;
        for(int i = 1; i <= n; i++){
            if(mishka[i] == 1){
                totalSum += theorems[i];
            }
        }

        pw.println(totalSum + max);

        pw.close();
    }
}
// Problem: 914_C. Travelling Salesman and Special Numbers
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {

	public static int mod = 1000000000 + 7;

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

		String n = br.readLine();
		int k = Integer.parseInt(br.readLine());
		int l = n.length();
		
		if(k == 0) {
			System.out.println(1);
		}else {
			int max = 1000;
			if (l <= 10) {
				max = Integer.min(1000, Integer.parseInt(n, 2));
			}

			int[] steps = new int[max + 1];
					
			for (int i = 2; i <= max; i++) {
				int ones = numberOfOnes(i);
				steps[i] = 1 + steps[ones];
			}

			if (l <= 10) {
				int ans = 0;
				for (int i = 1; i <= max; i++) {
					if (steps[i] == k) {
						ans++;
					}
				}
				System.out.println(ans);
			} else {
				int[][] C = binomial(max);

				int ans = 0;
				int count = 0;

				for (int i = 0; i < l; i++) {
					if (n.charAt(i) == '1') {
						for (int j = count; j < max; j++) {
							if (steps[j] == k - 1) {
								ans = (ans + C[l - i - 1][j - count]) % mod;
								if (i == 0 && k == 1) {
									ans = (ans + mod - 1) % mod;
								}
							}
						}
						count++;
					}
				}

				int ones = 0;
				for (int i = 0; i < l; i++) {
					if (n.charAt(i) == '1') {
						ones++;
					}
				}
				if (steps[ones] == k-1) {
					ans = (ans + 1) % mod;
				}
				
				System.out.println(ans);
			}
		}
	}

	public static int numberOfOnes(int x) {
		char[] s = Integer.toBinaryString(x).toCharArray();
		int count = 0;
		for (char c : s) {
			if (c == '1') {
				count++;
			}
		}
		return count;
	}

	public static int[][] binomial(int n) {
		int[][] C = new int[n + 1][n + 1];

		for (int i = 0; i <= n; i++) {
			C[i][0] = 1;
			for (int j = 1; j <= i; j++) {
				C[i][j] = ((C[i - 1][j - 1] % mod) + (C[i - 1][j] % mod)) % mod;
			}
		}

		return C;
	}

}
// Problem: 1036_A. Function Height
// Time complexity: constant
import java.io.BufferedReader;
import java.io.PrintWriter;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.StringTokenizer;

import java.util.Arrays;

public class Main {
    
    static Scanner in = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);
    
    public static void main(String[] args) throws IOException {
        long n = in.nextLong(), m = in.nextLong();
        out.print(m / n + (m % n == 0 ? 0 : 1));
        out.close();
    }
    
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;
        
        public Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }
        
        public String next() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}
// Problem: 964_A. Splits
// Time complexity: constant
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class CodeForces
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		System.out.println(input.nextInt() / 2 + 1);
	}
}
// Problem: 990_B. Micro-World
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class MicroWorld {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		
		int[] temp = new int[1000001];
		
		StringTokenizer st1 = new StringTokenizer(br.readLine());
		
		for (int i = 0; i < n; i++){
			
			temp[Integer.parseInt(st1.nextToken())]++;
		}
		
		int b = k + 1;
		
		for (int i = 1000000; i > 0; i--){
			
			if (temp[i] > 0){
				if (b <= k){
					n -= temp[i];
				}
				b = 1;
			}else{
				b++;
			}
		}
		
		System.out.println(n);
		
	}

}
// Problem: 1004_B. Sonya and Exhibition
// Time complexity: linear
import java.util.*;
import java.io.*;

public class SonyaExhibition {
	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 = {0,1};
		for(int i = 0; i < n; i++) {
			System.out.print(arr[i % 2]);
		}
		System.out.println();
	}

	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());
	}
}
// Problem: 1197_A. DIY Wooden Ladder
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class ayyyyyy
{
	public static void main(String[] args) { new ayyyyyy(); }
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	int t, n;
	int[] a;
	
	ayyyyyy()
	{
		t = in.nextInt();
		while (t --> 0)
		{
			a = new int[n = in.nextInt()];
			for (int i = 0; i < n; i++)
				a[i] = in.nextInt();
			shuffle(a);
			Arrays.sort(a);
			out.println(Math.min(n-2, a[n-2]-1));
		}
		
		out.close();
	}
	
	void shuffle(int[] x)
	{
		for (int i = 0; i < n; i++)
		{
			int swp = (int)(n*Math.random());
			int tmp = x[swp];
			x[swp] = x[i];
			x[i] = tmp;
		}
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        double a = (double)read.nextInt();
        double v = (double)read.nextInt();
        double l = (double)read.nextInt();
        double d = (double)read.nextInt();
        double w = (double)read.nextInt();
        double t=0;
        if(w>=v){
            double d1=v*v/(2*a);
            if(d1>l){
                t+= Math.sqrt(2*l/a);
            }
            else{
                t+= v/a + (l-d1)/v;
            }
        }
        else{
            double temp = (v-w)/a;
            double d1 = v*v/(2*a);
            double d2 = d - v*temp + a*temp*temp/2;
            if(d1>d2){
                double temp2 = Math.sqrt(2*a*d);
                if(temp2<w){
                    w=temp2;
                    temp=(v-w)/a;
                    t+= temp2/a;
                }
                else{
                    double vx=Math.sqrt(v*v/2+a*d2);
                    t+= (vx/a) + ((vx-w)/a);
                }
            }
            else{
                t+= (v/a) + ((d2-d1)/v) + (temp);
            }
            double d3 = d + w*temp + a*temp*temp/2;
            if(d3>l){
                t+= (-w+Math.sqrt(w*w+2*a*(l-d)))/a;
            }
            else{
                t+= (temp) + ((l-d3)/v);
            }
        }
        System.out.printf("%.6f", t);
        read.close();
    }
}
// Problem: 1061_B. Views Matter
// Time complexity: nlogn
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 m=Integer.parseInt(s1[1]);
            int a[]=new int[n];
            String s2[]=br.readLine().split(" ");
            long S=0;
            for(int i=0;i<n;i++)
            { a[i]=Integer.parseInt(s2[i]);  S+=(long)a[i]; }
            
            Arrays.sort(a);
            m=a[n-1];
            int last=1;
            int t=1;
            for(int i=1;i<n-1;i++)
            {
                  if(a[i]==last)
                   t++;
                  else
                  {
                        t++;
                        last=last+1;
                  }
            }
            if(last<m)
            { t+=m-last; }
            else
             t++;
            System.out.println(S-t);
      }
}
// Problem: 527_B. Error Correct System
// Time complexity: linear
import java.util.*;

public class ErrorCorrectSystem
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String a = scan.next();
		String b = scan.next();
		
		int[][] mismatch = new int[26][26];
		for(int i = 0; i < 26; i++) Arrays.fill(mismatch[i], -1);
		int[][] pair = new int[2][26];
		for(int i = 0; i < 2; i++) Arrays.fill(pair[i], -1);
		int hd = 0;
		for(int i = 0; i < n; i++) {
			if(a.charAt(i) != b.charAt(i)) {
				hd++;
				mismatch[a.charAt(i)-'a'][b.charAt(i)-'a'] = i;
				pair[0][a.charAt(i)-'a'] = i;
				pair[1][b.charAt(i)-'a'] = i;
			}
		}
		for(int i = 0; i < 26; i++) {
			for(int j = i+1; j < 26; j++) {
				if(mismatch[i][j] > -1 && mismatch[j][i] > -1) {
					System.out.println(hd-2);
					System.out.println((mismatch[i][j]+1)+" "+(mismatch[j][i]+1));
					return;
				}
			}
		}
		for(int i = 0; i < n; i++) {
			if(a.charAt(i) != b.charAt(i)) {
				//try a gets b's letter
				if(pair[0][b.charAt(i)-'a'] > -1) {
					System.out.println(hd-1);
					System.out.println((i+1)+" "+(pair[0][b.charAt(i)-'a']+1));
					return;
				}
			}
		}
		
		System.out.println(hd);
		System.out.println("-1 -1");
	}

}
// Problem: 1054_A. Elevator or Stairs?
// Time complexity: constant
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class ElevatorOrStairs {

	private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private static final OutputStreamWriter writer = new OutputStreamWriter(System.out);
	
	public static void main(String...strings) throws Exception {
		String[] specs = reader.readLine().split(" ");
		
		int x = Integer.parseInt(specs[0]);
		int y = Integer.parseInt(specs[1]);
		int z = Integer.parseInt(specs[2]);
		int t1 = Integer.parseInt(specs[3]);
		int t2 = Integer.parseInt(specs[4]);
		int t3 = Integer.parseInt(specs[5]);
		
		reader.close();
		String ans = solve(x, y, z, t1, t2, t3);
		writer.append(ans);
		writer.flush();
		writer.close();
	}
	
	private static String solve(int x, int y, int z, int t1, int t2, int t3) {
		int time_using_stairs = Math.abs(x - y) * t1;
		int elevator_time_between_floor = Math.abs(x - z) * t2;
		int elevator_from_z_to_x = elevator_time_between_floor + 2*t3;
		
 		int time_using_elevator = elevator_from_z_to_x + (Math.abs(x - y) * t2) + t3;
 		
 		if(time_using_elevator <= time_using_stairs) {
 			return "YES";
 		}
 		return "NO";
	}
}
// Problem: 1005_E1. Median on Segments (Permutations Edition)
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok;
    static boolean hasNext()
    {
        while(tok==null||!tok.hasMoreTokens())
            try{
                tok=new StringTokenizer(in.readLine());
            }
            catch(Exception e){
                return false;
            }
        return true;
    }
    static String next()
    {
        hasNext();
        return tok.nextToken();
    }
    static long nextLong()
    {
        return Long.parseLong(next());
    }
    static int nextInt()
    {
        return Integer.parseInt(next());
    }
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) {
        Map<Integer,Integer> map = new HashMap();
        map.put(0,1);
        int n = nextInt();
        int m = nextInt();
        int index = -1;
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i]=nextInt();
            if(a[i]==m)
                index=i;
        }
        int sum = 0;
        for(int i=0;i<index;i++){
            if (a[i]<m)
                sum--;
            else
                sum++;
            if (map.containsKey(sum)){
                map.put(sum,map.get(sum)+1);
            }else {
                map.put(sum,1);
            }
        }
        long ans = 0;
        for(int i=index;i<n;i++){
            if (a[i]<m)
                sum--;
            else if(a[i]>m)
                sum++;
            if (map.containsKey(sum))
                ans+=map.get(sum);
            if (map.containsKey(sum-1))
                ans+=map.get(sum-1);
        }
        out.print(ans);
        out.flush();
    }
}
// Problem: 992_A. Nastya and an Array
// Time complexity: linear
import java.util.HashSet;
import java.util.Scanner;


public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i<n; i++){
            int a = sc.nextInt();
            if(a!=0){
                set.add(a);
            }
        }
        System.out.println(set.size());
    }
}