<commit_before>package it.unimi.dsi.sux4j.mph;


import it.unimi.dsi.Util;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntIterator;
import it.unimi.dsi.fastutil.ints.IntListIterator;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Modulo2SparseSystem {

	/** A modulo-2 equation. */
	public static class Modulo2Equation {
		/** The variables. */
		public final IntArrayList variables;
		/** The constant term. */
		public int c;

		/** Creates a new equation.
		 * 
		 * @param c the constant term.
		 */
		public Modulo2Equation( final int c ) {
			variables = new IntArrayList();
			this.c = c;
		}
			
		public Modulo2Equation add( int variable ){
			if ( ! variables.isEmpty() && variable < variables.getInt( variables.size() - 1 ) ) throw new IllegalArgumentException();
			variables.add( variable );
			return this;
		}
		
		protected Modulo2Equation( Modulo2Equation equation ) {
			this.variables = equation.variables.clone();
			this.c = equation.c;
		}

		public void eliminate( final Modulo2Equation equation ) {
			assert this.variables.getInt( 0 ) == equation.variables.getInt( 0 ) : this.variables.getInt( 0 ) + " != " + equation.variables.getInt( 0 ); 
			add( equation );
		}

		public int firstVar() {
			return variables.size() != 0 ? variables.getInt( 0 ) : Integer.MAX_VALUE;
		}
		
		/** Adds the provided equation to this equation.
		 * 
		 * @param equation an equation.
		 */
		
		public void add( final Modulo2Equation equation ) {
			IntListIterator iteratorThis = this.variables.iterator();
			IntListIterator iteratorOther = equation.variables.iterator();
			
			int a = iteratorThis.nextInt(), b = iteratorOther.nextInt();
			for ( ;; ) {
				if ( a < b ) {
					if ( !iteratorThis.hasNext() ) {
						iteratorThis.add( b );
						break;
					}
					a = iteratorThis.nextInt();
				}
				else if ( a > b ) {
					iteratorThis.previousInt();
					iteratorThis.add( b );
					iteratorThis.nextInt();
					if ( !iteratorOther.hasNext() ) break;
					b = iteratorOther.nextInt();
				}
				else {
					iteratorThis.remove();
					if ( !iteratorThis.hasNext() ) break;
					if ( !iteratorOther.hasNext() ) break;
					a = iteratorThis.nextInt();
					b = iteratorOther.nextInt();
				}
			}

			while ( iteratorOther.hasNext() )
				variables.add( iteratorOther.nextInt() );
			
			c ^= equation.c;
		}

		public boolean isUnsolvable() {
			return variables.isEmpty() && c != 0;
		}

		public boolean isIdentity() {
			return variables.isEmpty() && c == 0;
		}

		public Modulo2Equation copy() {
			return new Modulo2Equation( this );
		}
		<commit_msg>Tweaking<commit_after>package it.unimi.dsi.sux4j.mph;


import it.unimi.dsi.Util;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntIterator;
import it.unimi.dsi.fastutil.ints.IntListIterator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Modulo2SparseSystem {

	/** A modulo-2 equation. */
	public static class Modulo2Equation {
		/** The variables. */
		public final IntArrayList variables;
		/** The constant term. */
		public int c;

		/** Creates a new equation.
		 * 
		 * @param c the constant term.
		 */
		public Modulo2Equation( final int c ) {
			variables = new IntArrayList();
			this.c = c;
		}
			
		public Modulo2Equation add( int variable ){
			if ( ! variables.isEmpty() && variable < variables.getInt( variables.size() - 1 ) ) throw new IllegalArgumentException();
			variables.add( variable );
			return this;
		}
		
		protected Modulo2Equation( Modulo2Equation equation ) {
			this.variables = equation.variables.clone();
			this.c = equation.c;
		}

		public void eliminate( final Modulo2Equation equation ) {
			assert this.variables.getInt( 0 ) == equation.variables.getInt( 0 ) : this.variables.getInt( 0 ) + " != " + equation.variables.getInt( 0 ); 
			add( equation );
		}

		public int firstVar() {
			return variables.size() != 0 ? variables.getInt( 0 ) : Integer.MAX_VALUE;
		}
		
		/** Adds the provided equation to this equation.
		 * 
		 * @param equation an equation.
		 */
		
		public void add( final Modulo2Equation equation ) {
			IntListIterator iteratorThis = this.variables.iterator();
			IntListIterator iteratorOther = equation.variables.iterator();

			if ( iteratorOther.hasNext() )  {
				if ( iteratorThis.hasNext() ) {
					int a = iteratorThis.nextInt(), b = iteratorOther.nextInt();
					for ( ;; ) {
						if ( a < b ) {
							if ( !iteratorThis.hasNext() ) {
								iteratorThis.add( b );
								break;
							}
							a = iteratorThis.nextInt();
						}
						else if ( a > b ) {
							iteratorThis.previousInt();
							iteratorThis.add( b );
							iteratorThis.nextInt();
							if ( !iteratorOther.hasNext() ) break;
							b = iteratorOther.nextInt();
						}
						else {
							iteratorThis.remove();
							if ( !iteratorThis.hasNext() ) break;
							if ( !iteratorOther.hasNext() ) break;
							a = iteratorThis.nextInt();
							b = iteratorOther.nextInt();
						}
					}
				}
				while ( iteratorOther.hasNext() )
					variables.add( iteratorOther.nextInt() );
			}

			c ^= equation.c;
		}

		public boolean isUnsolvable() {
			return variables.isEmpty() && c != 0;
		}

		public boolean isIdentity() {
			return variables.isEmpty() && c == 0;
		}

		public Modulo2Equation copy() {
			return new Modulo2Equation( this );
		}
		
{'fraction_non_alphanumeric': 0.12940748818611414, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 2.842877094972067, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211244', 'n_tokens_mistral': 2145, 'n_tokens_neox': 1688, 'n_words': 406}