Language: Java

import javafx.util.Pair;

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        Pair<Integer, Integer> a1 = new Pair<>(0, 0);
        Pair<Integer, Integer> b1 = new Pair<>(0, 0);
        Pair<Integer, Integer> a2 = new Pair<>(0, 0);
        Pair<Integer, Integer> b2 = new Pair<>(0, 0);
        for( int i=1; i<= num; i++ ) {
            int val = sc.nextInt();
            if( i%4 == 0 ) {
                if( b1.getKey() == val ) {
                    b1 = new Pair<>(val, b1.getValue()+1);
                } else {
                    b2 = new Pair<>(val, 1);
                }
                continue;
            }
            if( i%3 == 0 && i%6 != 0 ) {
                if( a1.getKey() == val ) {
                    a1 = new Pair<>(val, a1.getValue()+1);
                } else {
                    a2 = new Pair<>(val, 1);
                }
                continue;
            }
            if( i%2 == 0 ) {
                if( b2.getKey() == val ) {
                    b2 = new Pair<>(val, b2.getValue()+1);
                } else {
                    b1 = new Pair<>(val, 1);
                }
                continue;
            }
            if( i%1 == 0 ) {
                if( a2.getKey() == val ) {
                    a2 = new Pair<>(val, a2.getValue()+1);
                } else {
                    a1 = new Pair<>(val, 1);
                }
                continue;
            }
        }
        int a = 0, b = 0;
        if( a2.getValue() != 0 ) {
            a = (a1.getValue() > a2.getValue()) ? a1.getValue() : a2.getValue();
            if( a< 0 ) a *= -1;
            a = (num / 2) - a;
        }
        if( b2.getValue() != 0 ) {
            b = (b1.getValue() > b2.getValue()) ? b1.getValue() : b2.getValue();
            if( b< 0 ) b *= -1;
            b = (num / 2) - b;
        }
        int result = a + b;
        if( result == 0 && a1.getKey() == b1.getKey() ) result = num / 2;

        System.out.println( result );
    }
}

Compiler output:
Main.java:1: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:10: error: cannot find symbol
        Pair<Integer, Integer> a1 = new Pair<>(0, 0);
        ^
  symbol:   class Pair
  location: class Main
Main.java:10: error: cannot find symbol
        Pair<Integer, Integer> a1 = new Pair<>(0, 0);
                                        ^
  symbol:   class Pair
  location: class Main
Main.java:11: error: cannot find symbol
        Pair<Integer, Integer> b1 = new Pair<>(0, 0);
        ^
  symbol:   class Pair
  location: class Main
Main.java:11: error: cannot find symbol
        Pair<Integer, Integer> b1 = new Pair<>(0, 0);
                                        ^
  symbol:   class Pair
  location: class Main
Main.java:12: error: cannot find symbol
        Pair<Integer, Integer> a2 = new Pair<>(0, 0);
        ^
  symbol:   class Pair
  location: class Main
Main.java:12: error: cannot find symbol
        Pair<Integer, Integer> a2 = new Pair<>(0, 0);
                                        ^
  symbol:   class Pair
  location: class Main
Main.java:13: error: cannot find symbol
        Pair<Integer, Integer> b2 = new Pair<>(0, 0);
        ^
  symbol:   class Pair
  location: class Main
Main.java:13: error: cannot find symbol
        Pair<Integer, Integer> b2 = new Pair<>(0, 0);
                                        ^
  symbol:   class Pair
  location: class Main
Main.java:18: error: cannot find symbol
                    b1 = new Pair<>(val, b1.getValue()+1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:20: error: cannot find symbol
                    b2 = new Pair<>(val, 1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:26: error: cannot find symbol
                    a1 = new Pair<>(val, a1.getValue()+1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:28: error: cannot find symbol
                    a2 = new Pair<>(val, 1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:34: error: cannot find symbol
                    b2 = new Pair<>(val, b2.getValue()+1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:36: error: cannot find symbol
                    b1 = new Pair<>(val, 1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:42: error: cannot find symbol
                    a2 = new Pair<>(val, a2.getValue()+1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:44: error: cannot find symbol
                    a1 = new Pair<>(val, 1);
                             ^
  symbol:   class Pair
  location: class Main
17 errors