<commit_before>import java.io.*;
import java.util.*;

public class Solution {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
				
		 RunningMedian rm = new RunningMedian();

		while(n-- > 0) {
			rm.insert(s.nextInt());
			System.out.println(rm.getMedian());
		}
	}
	 
}


class RunningMedian {
	PriorityQueue<Integer> lower = new PriorityQueue<Integer>(10,
		new Comparator<Integer>() {
				public int compare(Integer arg0, Integer arg1) {
						return (arg0 < arg1) ? 1 : arg0 == arg1 ? 0 : -1;
				}
		}), higher = new PriorityQueue<Integer>();

	public void insert(Integer n) {
		if (lower.isEmpty() && higher.isEmpty())
			lower.add(n);
		else {
			if (n <= lower.peek())
				lower.add(n);
			else
				higher.add(n);
			rebalance();
		}
	}

	void rebalance() {
		if (lower.size() < higher.size() - 1)
			lower.add(higher.remove());
		else if (higher.size() < lower.size() - 1)
			higher.add(lower.remove());
	}

	public Double getMedian() {
		if (lower.isEmpty() && higher.isEmpty())
			return null;
		else if (lower.size() == higher.size())
			return (lower.peek() + higher.peek()) / 2.0;
		else
			return (lower.size() < higher.size()) ? (double) higher.peek() : (double) lower.peek();
	}
}<commit_msg>formatting<commit_after>import java.io.*;
import java.util.*;

public class Solution {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
				
		 RunningMedian rm = new RunningMedian();

		while(n-- > 0) {
			rm.insert(s.nextInt());
			System.out.println(rm.getMedian());
		}
	}
	 
}


class RunningMedian {
	PriorityQueue<Integer> lower = new PriorityQueue<Integer>(10,
		new Comparator<Integer>() {
			public int compare(Integer arg0, Integer arg1) {
				return (arg0 < arg1) ? 1 : arg0 == arg1 ? 0 : -1;
			}
		}), 
		higher = new PriorityQueue<Integer>();

	public void insert(Integer n) {
		if (lower.isEmpty() && higher.isEmpty())
			lower.add(n);
		else {
			if (n <= lower.peek())
				lower.add(n);
			else
				higher.add(n);
			rebalance();
		}
	}

	void rebalance() {
		if (lower.size() < higher.size() - 1)
			lower.add(higher.remove());
		else if (higher.size() < lower.size() - 1)
			higher.add(lower.remove());
	}

	public Double getMedian() {
		if (lower.isEmpty() && higher.isEmpty())
			return null;
		else if (lower.size() == higher.size())
			return (lower.peek() + higher.peek()) / 2.0;
		else
			return (lower.size() < higher.size()) ? (double) higher.peek() : (double) lower.peek();
	}
}
{'fraction_non_alphanumeric': 0.18117088607594936, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 3.187086092715232, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 13, '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': '3172237', 'n_tokens_mistral': 1056, 'n_tokens_neox': 888, 'n_words': 210}