<commit_before>import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Verify a solution to The Monk problem using an EL-system. The solution should contain a
 * directed graph G consisting of one component, and a set of solution vectors describing the
 * movement of the pursuers.
 * 
 * The solution to be checked is read from stdin and the program answers YES or NO to stdout.
 * 
 * Input format: 
 * Row					Data
 * 0					Should contain the number of rows "r" in the neighbour matrix for G.
 * 1 to r				Should contain the data (separated by space) for the neighbour matrix.
 * r+1					Should contain two integers separated by space; the number of pursuers "p" 
 * 						and the length of a solution vector.
 * r+2 to r+2+p 		Should contain the movement of the pursuers (solution vectors for G).
 * 						The vertices of G are assumed to be labeled from 1 and up (see the
 * 						example below).
 * 
 * Example:
 * 5
 * 0 1 0 0 0
 * 1 0 1 0 0
 * 0 1 0 1 0
 * 0 0 1 0 1
 * 0 0 0 1 0
 * 1 6
 * 2 3 4 4 3 2
 * 
 * The example describes a solution to the original version of The Monk Problem
 * stated by <NAME>, in which a monk is to be found by one pursuer, in a 
 * "chained graph" with 5 vertices as shown below.
 * (1) <--> (2) <--> (3) <--> (4) <--> (5)
 * 
 * Run the verifier with javac Verify.java && cat solution.txt | java Verify
 * 
 * @author Realiserad
 */
public class Verify {
	private final int ROWS;
	private int[][] graph;
	private int[] w;
	
	public static void main(String[] args) {
		new Verify();
	}

	/**
	 * Constructor suitable for reading graph from System.in.
	 */
	public Verify() {
		Kattio io = new Kattio(System.in);
		
		/* Read neighbour matrix */
		ROWS = io.getInt();
		graph = new int[ROWS][ROWS];
		w = new int[ROWS];
		for (int row = 0; row < ROWS; row++) {
			for (int col = 0; col < ROWS; col++) {
				graph[row][col] = io.getInt() == 0 ? 0 : 1; // 1 means "has edge (col -> row)"
				if (graph[row][col] == 1) w[row]++; // w[i] should contain Hamming weight for row i
			}
		}
		
		/* Read solution vectors */
		final int P = io.getInt();
		final int LEN = io.getInt();
		int[][] seed = new int[LEN][P];
		for (int col = 0; col < P; col++) {
			for (int row = 0; row < LEN; row++) {
				seed[row][col] = io.getInt()-1; // use 0-indexing internally
			}
		}
		
		/* Verify solution by iterating the formula s_{n+1}=graph*s_{n}+seed with s_{0} = 0 */
		int[] s = expand(seed[0], ROWS); // s_{1}
		for (int i = 1; i < LEN; i++) {
			s = radd(rmul(graph, s, w), expand(seed[i], ROWS));
		}
		
		if (onesOnly(s)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
		io.close();<commit_msg>Saving states and printing in sequence after outputting "YES" or "NO".<commit_after>import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Verify a solution to The Monk problem using an EL-system. The solution should contain a
 * directed graph G consisting of one component, and a set of solution vectors describing the
 * movement of the pursuers.
 * 
 * The solution to be checked is read from stdin and the program answers YES or NO to stdout
 * followed by the states produced in sequence by the solution vectors.
 * 
 * 
 * Input format: 
 * Row					Data
 * 0					Should contain the number of rows "r" in the neighbour matrix for G.
 * 1 to r				Should contain the data (separated by space) for the neighbour matrix.
 * r+1					Should contain two integers separated by space; the number of pursuers "p" 
 * 						and the length of a solution vector.
 * r+2 to r+2+p 		Should contain the movement of the pursuers (solution vectors for G).
 * 						The vertices of G are assumed to be labeled from 1 and up (see the
 * 						example below).
 * 
 * Example:
 * 5
 * 0 1 0 0 0
 * 1 0 1 0 0
 * 0 1 0 1 0
 * 0 0 1 0 1
 * 0 0 0 1 0
 * 1 6
 * 2 3 4 4 3 2
 * 
 * The example describes a solution to the original version of The Monk Problem
 * stated by <NAME>, in which a monk is to be found by one pursuer, in a 
 * "chained graph" with 5 vertices as shown below.
 * (1) <--> (2) <--> (3) <--> (4) <--> (5)
 * 
 * Run the verifier with javac Verify.java && cat solution.txt | java Verify
 * 
 * @author Realiserad
 */
public class Verify {
	private final int ROWS;
	private int[][] graph;
	private int[] w;
	
	public static void main(String[] args) {
		new Verify();
	}

	/**
	 * Constructor suitable for reading graph from System.in.
	 */
	public Verify() {
		Kattio io = new Kattio(System.in);
		
		/* Read neighbour matrix */
		ROWS = io.getInt();
		graph = new int[ROWS][ROWS];
		w = new int[ROWS];
		for (int row = 0; row < ROWS; row++) {
			for (int col = 0; col < ROWS; col++) {
				graph[row][col] = io.getInt() == 0 ? 0 : 1; // 1 means "has edge (col -> row)"
				if (graph[row][col] == 1) w[row]++; // w[i] should contain Hamming weight for row i
			}
		}
		
		/* Read solution vectors */
		final int P = io.getInt();
		final int LEN = io.getInt();
		int[][] seed = new int[LEN][P];
		for (int col = 0; col < P; col++) {
			for (int row = 0; row < LEN; row++) {
				seed[row][col] = io.getInt()-1; // use 0-indexing internally
			}
		}
		
		/* Save the states for debugging, i.e. can check by hand */
		List<int[]> states = new LinkedList<int[]>();
		/* Verify solution by iterating the formula s_{n+1}=graph*s_{n}+seed with s_{0} = 0 */
		int[] s = expand(seed[0], ROWS); // s_{1}
		states.add(s);
		for (int i = 1; i < LEN; i++) {
			s = radd(rmul(graph, s, w), expand(seed[i], ROWS));
			states.add(s);
		}
		
		if (onesOnly(s)) {
			io.println("YES");
		} else {
			io.println("NO");
		}
		/* Print states */
		for (int i = 0; i < states.size(); i++) {
			io.println("State "+(i+1)+":    ");
			int[] state = states.get(i);
			for (int j = 0; j < state.length; j++) {
				io.print(state[j] + " ");
			}
		}
		
		io.close();
{'fraction_non_alphanumeric': 0.13703943115707823, 'fraction_numerical': 0.020846800258564963, 'mean_word_length': 2.8274582560296846, 'pattern_counts': {'":': 1, '<': 27, '<?xml version=': 0, '>': 17, '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': '5582800', 'n_tokens_mistral': 2394, 'n_tokens_neox': 2075, 'n_words': 836}