Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tigers also stood together. The trainer swaps the animals in pairs not to create a mess. He orders two animals to step out of the circle and swap places. As hamsters feel highly uncomfortable when tigers are nearby as well as tigers get nervous when there's so much potential prey around (consisting not only of hamsters but also of yummier spectators), the trainer wants to spend as little time as possible moving the animals, i.e. he wants to achieve it with the minimal number of swaps. Your task is to help him.

The first line contains number n (2≤n≤1000) which indicates the total number of animals in the arena. The second line contains the description of the animals' positions. The line consists of n symbols "H" and "T". The "H"s correspond to hamsters and the "T"s correspond to tigers. It is guaranteed that at least one hamster and one tiger are present on the arena. The animals are given in the order in which they are located circle-wise, in addition, the last animal stands near the first one.

Print the single number which is the minimal number of swaps that let the trainer to achieve his goal.

In the first example we shouldn't move anybody because the animals of each species already stand apart from the other species. In the second example you may swap, for example, the tiger in position 2 with the hamster in position 5 and then — the tiger in position 9 with the hamster in position 7.

#![allow(non_snake_case)]
#[allow(dead_code)] fn read_line() -> String { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("failed to read line"); buffer.trim().to_string() }
#[allow(dead_code)] fn read<T : std::str::FromStr>() -> T where T::Err: std::fmt::Debug { read_line().trim().parse::<T>().expect("failed to read value") }
#[allow(dead_code)]fn read_vec<T : std::str::FromStr>() -> Vec<T> where T::Err: std::fmt::Debug { read_line().split_whitespace().map(|x| x.parse::<T>().expect("failed to read values")).collect() }
fn lock_stdout() -> std::io::BufWriter<std::io::StdoutLock<'static>> { let stdout = std::io::stdout().lock(); std::io::BufWriter::new(stdout) }
struct StdoutLogger {buf: std::io::BufWriter<std::io::StdoutLock<'static>>}impl StdoutLogger {fn log(&mut self, s: &str) {std::io::Write::write(&mut self.buf, s.as_bytes()).expect("error writing stdout");std::io::Write::write(&mut self.buf, "\n".as_bytes()).expect("error writing stdout");}}
macro_rules! init {($name: ident) => {let mut $name = StdoutLogger{buf:lock_stdout()};}}

use std::collections::VecDeque;

fn main() {
    init!(outp);

    let _n = read::<usize>();
    let inp = read_line();

    // let inp = "HTHTHTHHT";

    let cycle = inp.chars().collect::<VecDeque<_>>();

    let h_cnt = cycle.iter().filter(|&&ch| ch=='H').count();

    let mut t_cnt = i32::MAX;
    for i in 0..cycle.len() {
        let mut remain = h_cnt;
        let mut c = 0;
        for j in i..i+cycle.len() {
            if remain==0 {break}
            if cycle[j%cycle.len()]=='T' {c+=1};
            remain-=1;
        }
        if c<t_cnt {t_cnt=c}
    }

    outp.log(&format!("{t_cnt}"));

}

[{'input': ['3\r\nHTH\r\n'], 'output': ['0\r\n']}, {'input': ['9\r\nHTHTHTHHT\r\n'], 'output': ['2\r\n']}, {'input': ['2\r\nTH\r\n'], 'output': ['0\r\n']}, {'input': ['4\r\nHTTH\r\n'], 'output': ['0\r\n']}, {'input': ['4\r\nHTHT\r\n'], 'output': ['1\r\n']}, {'input': ['7\r\nTTTHTTT\r\n'], 'output': ['0\r\n']}, {'input': ['8\r\nHHTHHTHH\r\n'], 'output': ['1\r\n']}, {'input': ['13\r\nHTTTHHHTTTTHH\r\n'], 'output': ['3\r\n']}, {'input': ['20\r\nTTHTHTHHTHTTHHTTTHHH\r\n'], 'output': ['4\r\n']}, {'input': ['35\r\nTTTTTTHTTHTTTTTHTTTTTTTTTTTHTHTTTTT\r\n'], 'output': ['3\r\n']}, {'input': ['120\r\nTTTTTTTHTHTHTTTTTHTHTTTTHTTTTTTTTTTTTTTTTTTTTHTTHTTTTHTTHTTTTTTTTTTTTTTTHTTTTTTHTHTTHTTTTTTHTTTTTTTTTHTTHTTTTHTTTHTTTTTH\r\n'], 'output': ['14\r\n']}, {'input': ['19\r\nHHHHHHHHHHHHHTTTHHH\r\n'], 'output': ['0\r\n']}, {'input': ['87\r\nHTHHTTHHHHTHHHHHTTTHHTHHHHTTTTHHHTTHHTHTHTHHTTHTHHTHTHTTHHHTTTTTHTTHHHHHHTHHTHHTHTTHTHH\r\n'], 'output': ['17\r\n']}, {'input': ['178\r\nTHHHTHTTTHTTHTTHHHHHTTTHTTHHTHTTTHTHTTTTTHHHTHTHHHTHHHTTTTTTTTHHHHTTHHTHHHHTHTTTHHHHHHTHHTHTTHTHTTTTTTTTTHHTTHHTHTTHHTHHHHHTTHHTTHHTTHHHTTHHTTTTHTHHHTHTTHTHTTTHHHHTHHTHHHTHTTTTTT\r\n'], 'output': ['40\r\n']}]


Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing n characters (which is the size of one text message). Thus, whole sentences and words get split!Fangy did not like it, so he faced the task of breaking the text into minimal messages on his own so that no sentence were broken into pieces when it is sent and the number of text messages to be sent would be minimal. If two consecutive sentences are in different messages, the space between them can be ignored (Fangy does not write this space).The little walrus's text looks in the following manner: TEXT ::= SENTENCE | SENTENCE SPACE TEXTSENTENCE ::= WORD SPACE SENTENCE | WORD ENDEND ::= {'.', '?', '!'}WORD ::= LETTER | LETTER WORDLETTER ::= {'a'..'z', 'A'..'Z'}SPACE ::= ' 'SPACE stands for the symbol of a space.So, how many messages did Fangy send?

The first line contains an integer n, which is the size of one message (2≤n≤255). The second line contains the text. The length of the text does not exceed 10^4 characters. It is guaranteed that the text satisfies the above described format. Specifically, this implies that the text is not empty.

On the first and only line print the number of text messages Fangy will need. If it is impossible to split the text, print "Impossible" without the quotes.

Let's take a look at the third sample. The text will be split into three messages: "Hello!", "Do you like fish?" and "Why?".

#![allow(non_snake_case)]
#[allow(dead_code)] fn read_line() -> String { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("failed to read line"); buffer.trim().to_string() }
#[allow(dead_code)] fn read<T : std::str::FromStr>() -> T where T::Err: std::fmt::Debug { read_line().trim().parse::<T>().expect("failed to read value") }
#[allow(dead_code)]fn read_vec<T : std::str::FromStr>() -> Vec<T> where T::Err: std::fmt::Debug { read_line().split_whitespace().map(|x| x.parse::<T>().expect("failed to read values")).collect() }
#[allow(dead_code)] fn lock_stdout() -> std::io::BufWriter<std::io::StdoutLock<'static>> { let stdout = std::io::stdout().lock(); std::io::BufWriter::new(stdout) }
#[allow(dead_code)] struct StdoutLogger {buf: std::io::BufWriter<std::io::StdoutLock<'static>>}impl StdoutLogger {fn log(&mut self, s: &str) {std::io::Write::write(&mut self.buf, s.as_bytes()).expect("error writing stdout");std::io::Write::write(&mut self.buf, "\n".as_bytes()).expect("error writing stdout");}}
#[allow(dead_code)] macro_rules! init {($name: ident) => {#[allow(unused_mut)]let mut $name = StdoutLogger{buf:lock_stdout()};}}

fn main() {
    init!(outp);

    let n = read::<usize>();
    let inp = read_line();

    // let n = 4;
    // let inp = "ab. b. de.";

    // let n = 146;
    // let inp = "iIQVkDsPqzAJyBrtHk EhBSN gzDoigItCMzETerb cIbXhTPbKYMdMoYqyFTEN. qcrrseVwmaZEiQUQoGT SUyErST lJDejKkjqTdoUrHR tsZYDyI? pmuNNHYqQUISxdZfWOB XdEECvNz hnNmVfODaIC qjhRIEPAlEsQBxo apZ! gCpqoiUFIwWLBOmYubywj qJojFVhLd dCpovICpXHfgihydEOoij?";

    // let n = 2;
    // let inp = "How are you?";

    // let n = 19;
    // let inp = "Hello! Do you like fish? Why?";

    let sntncs = inp.split(['.', '?', '!']);
    let mut cnt = 1;
    let mut sntnc_c = 0;
    let mut p = 0;
    let mut i = 0;
    for sntnc in sntncs {
        if sntnc.len()==0 {continue};
        let sntnc = sntnc.trim();

        let sntnc_len = sntnc.len()+1; //+1 for .,?,!
        let spaced_sntnc_len = sntnc_len + if i==0{0}else{1};
        if sntnc_len > n {
            println!("Impossible");
            return;
        }

        //println!("sntnc:{sntnc} len:{}", sntnc.len());
        if p+spaced_sntnc_len<=n {
            // println!("spaced_sntnc_len {}", spaced_sntnc_len);
            sntnc_c += 1;
            p += spaced_sntnc_len;
        } else {
            if sntnc_c==0 {
                println!("Impossible");
                return;
            }
            p = sntnc_len;
            cnt += 1;
        }

        i+=1;
    }
    println!("{cnt}");

}

[{'input': ['25\r\nHello. I am a little walrus.\r\n'], 'output': ['2\r\n']}, {'input': ['2\r\nHow are you?\r\n'], 'output': ['Impossible\r\n']}, {'input': ['19\r\nHello! Do you like fish? Why?\r\n'], 'output': ['3\r\n']}, {'input': ['4\r\na. A.\r\n'], 'output': ['2\r\n']}, {'input': ['191\r\nEvx vnxZtUSgtzH yDNXCsTaxCKQus gVZLHppOplkGGekIK xbme. krbusMqUs YEnBBTJpjNicZPlx TqEtBPcbejZMzvn fFTub CHYWLmiOFkDdzR! LoQmXPfHJ KVnfrbrFooVSkj xwAZwrRr DdILZ kpco cLoRmJbVKhnbOEhnHKpci. PgYhxFPXdlvlrp mDLZBnVRf AgRMUjxepFuLyKlIAhLS wtmEiLDNUAHpZEsKnkOu!\r\n'], 'output': ['2\r\n']}, {'input': ['146\r\niIQVkDsPqzAJyBrtHk EhBSN gzDoigItCMzETerb cIbXhTPbKYMdMoYqyFTEN. qcrrseVwmaZEiQUQoGT SUyErST lJDejKkjqTdoUrHR tsZYDyI? pmuNNHYqQUISxdZfWOB XdEECvNz hnNmVfODaIC qjhRIEPAlEsQBxo apZ! gCpqoiUFIwWLBOmYubywj qJojFVhLd dCpovICpXHfgihydEOoij?\r\n'], 'output': ['2\r\n']}, {'input': ['151\r\nayDIuxJXWNqu OImqJLodviANkQNxZ OpDpwyoPQdZyosXJpqRx! ZFQNQJPnoEVUEEbjqs iyfUYK HuGCOtlsEllsCiHIdEuW ZmlRSWVOmLAD MSYsC? CGKxobjmddejDDdF qbQsAWi qxViwV iLmPHfhLjP ZfNCItjZikwaQyhQGC? bvSaaZhwHdbNKSiiI bEJXRjANEasfrElNHPA UuQCajtuODHgxwgL qbssJss TqT.\r\n'], 'output': ['2\r\n']}, {'input': ['123\r\nOjg CVJm qfE RnHislFds nNKKt TCPLWukqNGAsVBplYbTfq? VeYKjfFGTzXWA ydpVZLIImNub yApKnAHv iXQmqv GjQvxrnAgtfTApiQyCKtg. GdmapGwvI udRqxTbnzgnOUNZx slAuEuLGCJycZJvtCczQ vommS xuuT eIK! DOJeFEaubbz HYLGlIIlNKfyaJQKVN eFNnUvKKCQLXvGhwX gjmRscMkedELUlHq? aTbyMGB EofzX wcAEjyRQpxghWvXhdJb cwIz FEUsEFicYZ.\r\n'], 'output': ['3\r\n']}, {'input': ['126\r\ntjQvloOnRednqfvIRudX wAPhGdwEZ BiuuuAW EfSzDuRTdC rptjpHnxyM? FkLaTBruN IwuIQMdpdUpn etTVVJUsKztaR YNY EAENiDgJwYXDDrayjyuKp! yKqRNHznLRpnTqjisR LuapWDnWmwYDE NcClOZBNzMYrpa? SEZdSZIgBekpCPvyEiO AMjztArkFRJuS ilycvolFExqxrXJK. sLvBUxjIOomxUqYd jZsOXWN iBtqSykbeUbAsQgRVs DinPLrpzt.\r\n'], 'output': ['3\r\n']}, {'input': ['118\r\ngweVo bjbEKaZQw PpSi AWOYt sQSvAHNRswh vUaGuLbtExNECz! USsQxMCjaGOmUESwHvyY SshkERibaWkmNLSZOtWZy FFTUWQgekPRjLRetAdSFt! sIhcimZTisFvndrYioLF HetLn wjoaDUKfbkagupl QdYb fFiV GNqBygStKQw. XLiYZEOGnTLSHmCwktEr pVBePMoRGopNt LdEujxuxzmlbycQdR?\r\n'], 'output': ['4\r\n']}, {'input': ['16\r\nAbacaba. Abacaba. abacaba. abacab.\r\n'], 'output': ['3\r\n']}, {'input': ['21\r\nHello. I am a little walrus.\r\n'], 'output': ['2\r\n']}, {'input': ['16\r\nAbacaba. Abacab. abacaba. abacaba.\r\n'], 'output': ['3\r\n']}, {'input': ['10\r\nhello! how are you?\r\n'], 'output': ['Impossible\r\n']}, {'input': ['5\r\nabc. abcd.\r\n'], 'output': ['2\r\n']}, {'input': ['16\r\nabacaba. abacab. Abacaba. Abacaba.\r\n'], 'output': ['3\r\n']}, {'input': ['5\r\na. b. c. d.\r\n'], 'output': ['2\r\n']}, {'input': ['8\r\nabc! ab.\r\n'], 'output': ['1\r\n']}, {'input': ['2\r\na. b.\r\n'], 'output': ['2\r\n']}]


Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...$$$n$$$ friends live in a city which can be represented as a number line. The $$$i$$$-th friend lives in a house with an integer coordinate $$$x_i$$$. The $$$i$$$-th friend can come celebrate the New Year to the house with coordinate $$$x_i-1$$$, $$$x_i+1$$$ or stay at $$$x_i$$$. Each friend is allowed to move no more than once.For all friends $$$1 \le x_i \le n$$$ holds, however, they can come to houses with coordinates $$$0$$$ and $$$n+1$$$ (if their houses are at $$$1$$$ or $$$n$$$, respectively).For example, let the initial positions be $$$x = [1, 2, 4, 4]$$$. The final ones then can be $$$[1, 3, 3, 4]$$$, $$$[0, 2, 3, 3]$$$, $$$[2, 2, 5, 5]$$$, $$$[2, 1, 3, 5]$$$ and so on. The number of occupied houses is the number of distinct positions among the final ones.So all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of friends.
The second line contains $$$n$$$ integers $$$x_1, x_2, \dots, x_n$$$ ($$$1 \le x_i \le n$$$) — the coordinates of the houses of the friends.

Print two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.

struct Scanner<R> {
    reader: R,
    line: Vec<u8>,
    ptr: usize

}

impl<R: std::io::BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        return Self {reader, line: vec![], ptr: 0};
    }

    fn scan<T: std::str::FromStr>(&mut self) -> T {
        loop {
            while self.ptr < self.line.len() && self.line[self.ptr].is_ascii_whitespace() {
                self.ptr += 1;
            }
            if self.ptr != self.line.len() {
                let start = self.ptr;
                while self.ptr < self.line.len() && !self.line[self.ptr].is_ascii_whitespace() {
                    self.ptr += 1;
                }
                return std::str::from_utf8(&self.line[start..self.ptr]).unwrap().parse().ok().
                    expect("parse error");
            }
            self.line.clear();
            self.reader.read_until(b'\n', &mut self.line).expect("read error");
            self.ptr = 0;
        }
    }

}

fn solve_min(counts: &Vec<usize>) -> usize {
    let mut result = 0;
    let mut ptr = 0;
    while ptr < counts.len() {
        if counts[ptr] == 0 {
            ptr += 1;
            continue;
        }
        ptr += 3;
        result += 1;
    }
    return result;
}

fn solve_max(mut counts: Vec<usize>) -> usize {
    let mut result = 0;
    for i in 0..counts.len() {
        if let Some(v) = counts.get_mut(i.wrapping_sub(1)) {
            if *v != 0 {
                *v -= 1;
                result += 1;
                continue;
            }
        }
        if counts[i] != 0 {
            counts[i] -= 1;
            result += 1;
            continue;
        }
        if let Some(v) = counts.get_mut(i + 1) {
            if *v != 0 {
                *v -= 1;
                result += 1;
                continue;
            }
        }
    }
    return result;
}

fn solve<R: std::io::BufRead, W: std::io::Write>(scanner: &mut Scanner<R>, writer: &mut W) {
    let n: usize = scanner.scan();
    let x: Vec<usize> = (0..n).map(|_| scanner.scan()).collect();
    let mut counts: Vec<usize> = vec![0; n + 2];
    for &x in &x {
        counts[x] += 1;
    }
    let min = solve_min(&counts);
    let max = solve_max(counts);
    writeln!(writer, "{} {}", min, max).unwrap();
}

fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut writer = std::io::BufWriter::new(stdout.lock());
    let mut scanner = Scanner::new(stdin.lock());
    let tests: usize = 1;
    for _ in 0..tests {
        solve(&mut scanner, &mut writer);
    }
}


This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to color all its characters the minimum number of colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in $$$s$$$).After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times.The goal is to make the string sorted, i.e. all characters should be in alphabetical order.Your task is to find the minimum number of colors which you have to color the given string in so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$.
The second line of the input contains the string $$$s$$$ consisting of exactly $$$n$$$ lowercase Latin letters.

In the first line print one integer $$$res$$$ ($$$1 \le res \le n$$$) — the minimum number of colors in which you have to color the given string so that after coloring it can become sorted by some sequence of swaps.
In the second line print any possible coloring that can be used to sort the string using some sequence of swaps described in the problem statement. The coloring is the array $$$c$$$ of length $$$n$$$, where $$$1 \le c_i \le res$$$ and $$$c_i$$$ means the color of the $$$i$$$-th character.

pub mod solution {
//{"name":"E2. String Coloring (hard version)","group":"Codeforces - Codeforces Round #617 (Div. 3)","url":"https://codeforces.com/contest/1296/problem/E2","interactive":false,"timeLimit":1000,"tests":[{"input":"9\nabacbecfd\n","output":"2\n1 1 2 1 2 1 2 1 2\n"},{"input":"8\naaabbcbb\n","output":"2\n1 2 1 2 1 2 1 1\n"},{"input":"7\nabcdedc\n","output":"3\n1 1 1 1 1 2 3\n"},{"input":"5\nabcde\n","output":"1\n1 1 1 1 1\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"E2StringColoringHardVersion"}}}

#![allow(
    unused_imports,
    non_snake_case,
    clippy::many_single_char_names,
    clippy::comparison_chain,
    clippy::if_same_then_else,
    clippy::if_not_else,
    clippy::ifs_same_cond,
    clippy::type_complexity,
    clippy::collapsible_if,
    clippy::collapsible_else_if,
    clippy::needless_range_loop
)]

use crate::{collections::iter_ext::IterExt,io::{input::Input,output::output,task_io_settings::{TaskIoSettings, TaskIoType},task_runner::run_task,},};
#[allow(unused)]
use crate::{dbg, out, out_line};

fn solve(input: &mut Input, _test_case: usize) {
    let n = input.read::<usize>();
    let s = input.read_string().bytes().map(|b| b - b'a').collect_vec();

    let mut sp = s.iter().copied().enumerate().collect_vec();

    let mut ans = vec![0; n];

    let mut count = 0;
    while !sp.is_empty() {
        count += 1;
        let mut removed = vec![false; sp.len()];
        let mut last = 0;
        for (idx, &(i, c)) in sp.iter().enumerate() {
            if c < last {
                continue;
            }
            last = c;
            ans[i] = count;
            removed[idx] = true;
        }
        sp = sp
            .into_iter()
            .enumerate()
            .filter_map(|(idx, e)| (!removed[idx]).then_some(e))
            .collect();
    }

    out_line!(count);
    out_line!(ans);
}

pub(crate) fn run(mut input: Input) -> bool {
    solve(&mut input, 1);
    output().flush();
    input.skip_whitespace();
    input.peek().is_none()
}

#[allow(unused)]
pub fn submit() -> bool {
    let io = TaskIoSettings {
        is_interactive: false,
        input: TaskIoType::Std,
        output: TaskIoType::Std,
    };

    run_task(io, run)
}

}
pub mod collections {
pub mod iter_ext {
use std::cmp::Ordering;

pub trait IterPartialEqExt<T: PartialEq>: Iterator<Item = T> + Sized {
    fn find(mut self, item: T) -> Option<usize> {
        self.position(|r| r == item)
    }
    fn count_eq(self, item: &T) -> usize {
        Iterator::count(self.filter(|r| r == item))
    }
}

impl<T: PartialEq, I: Iterator<Item = T>> IterPartialEqExt<T> for I {}

pub trait IterExt<T>: Iterator<Item = T> + Sized {
    fn enumerate_sort_by<F>(self, mut f: F) -> Vec<(usize, T)>
    where
        F: FnMut(&T, &T) -> Ordering,
    {
        let mut res: Vec<_> = self.enumerate().collect();
        res.sort_by(|(i, vi), (j, vj)| {
            let res = f(vi, vj);
            if res != Ordering::Equal {
                res
            } else {
                i.cmp(j)
            }
        });
        res
    }
    fn collect_vec(self) -> Vec<T> {
        self.collect()
    }
}

impl<T, I: Iterator<Item = T> + Sized> IterExt<T> for I {}

pub trait IterOrdExt<T: Ord>: IterExt<T> {
    fn enumerate_sort(self) -> Vec<(usize, T)> {
        self.enumerate_sort_by(|a, b| a.cmp(b))
    }

    fn max_position(self) -> Option<usize> {
        let mut res = None;
        let mut val: Option<T> = None;
        for (i, cur) in self.enumerate() {
            if val.is_none() || *val.as_ref().unwrap() < cur {
                val = Some(cur);
                res = Some(i);
            }
        }
        res
    }

    fn min_position(self) -> Option<usize> {
        let mut res = None;
        let mut val = None;
        for (i, cur) in self.enumerate() {
            if val.is_none() || *val.as_ref().unwrap() > cur {
                val = Some(cur);
                res = Some(i);
            }
        }
        res
    }
}

impl<T: Ord, I: Iterator<Item = T> + Sized> IterOrdExt<T> for I {}

#[macro_export]
macro_rules! zip {
    ( @closure $p:pat => $tup:expr ) => {
        |$p| $tup
    };

    ( @closure $p:pat => ( $($tup:tt)* ) , $_iter:expr $( , $tail:expr )* ) => {
        zip!(@closure ($p, b) => ( $($tup)*, b ) $( , $tail )*)
    };

    ($first:expr $(,)*) => {
        std::iter::IntoIterator::into_iter($first)
    };

    // binary
    ($first:expr, $second:expr $(,)*) => {
        zip!($first).zip($second)
    };

    // n-ary where n > 2
    ( $first:expr $( , $rest:expr )* $(,)* ) => {
        zip!($first)
            $(
                .zip($rest)
            )*
            .map(
                zip!(@closure a => (a) $( , $rest )*)
            )
    };
}

pub fn interleave<T>(
    mut iter1: impl Iterator<Item = T>,
    mut iter2: impl Iterator<Item = T>,
) -> impl Iterator<Item = T> {
    std::iter::from_fn(move || -> Option<T> {
        enum NextFrom {
            First,
            Second,
        }
        static mut NEXT_FROM: NextFrom = NextFrom::First;
        unsafe {
            match NEXT_FROM {
                NextFrom::First => {
                    NEXT_FROM = NextFrom::Second;
                    iter1.next()
                }
                NextFrom::Second => {
                    NEXT_FROM = NextFrom::First;
                    iter2.next()
                }
            }
        }
    })
}
}
}
pub mod io {
pub mod input {
use crate::numbers::num_traits::add_sub::AddSub;
use crate::numbers::num_traits::from_u8::FromU8;
use crate::numbers::num_traits::mul_div_rem::Multable;
use crate::numbers::num_traits::sign::IsSigned;
use crate::numbers::num_traits::zero_one::ZeroOne;
use std::fmt::Display;
use std::io::Read;
use std::marker::PhantomData;

macro_rules! read_impl {
    ($t: ty, $read_name: ident, $read_vec_name: ident) => {
        pub fn $read_name(&mut self) -> $t {
            self.read()
        }

        pub fn $read_vec_name(&mut self, len: usize) -> Vec<$t> {
            self.read_vec(len)
        }
    };

    ($t: ty, $read_name: ident, $read_vec_name: ident, $read_pair_vec_name: ident) => {
        read_impl!($t, $read_name, $read_vec_name);

        pub fn $read_pair_vec_name(&mut self, len: usize) -> Vec<($t, $t)> {
            self.read_vec(len)
        }
    };
}

pub struct Input<'s> {
    input: &'s mut dyn Read,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

impl<'s> Input<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(input: &'s mut dyn Read) -> Self {
        Self {
            input,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_with_size(input: &'s mut dyn Read, buf_size: usize) -> Self {
        Self {
            input,
            buf: vec![0; buf_size],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            Some(self.buf[self.at])
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !char::from(b).is_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if char::from(c).is_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.read());
        }
        res
    }

    pub fn read_line(&mut self) -> String {
        let mut res = String::new();
        while let Some(c) = self.get() {
            if c == b'\n' {
                break;
            }
            if c == b'\r' {
                if self.peek() == Some(b'\n') {
                    self.get();
                }
                break;
            }
            res.push(c.into());
        }
        res
    }

    pub fn iter<'t, T: Readable + 't + 's>(&'t mut self) -> InputIterator<'t, 's, T>
    where
        's: 't,
    {
        InputIterator {
            input: self,
            phantom: Default::default(),
        }
    }

    fn read_integer<T: IsSigned + ZeroOne + FromU8 + AddSub + Multable + Display>(&mut self) -> T {
        self.skip_whitespace();
        let mut c = self.get().unwrap();
        let sgn = if c == b'-' {
            if !T::SIGNED {
                panic!("negative integer")
            }
            c = self.get().unwrap();
            true
        } else if c == b'+' {
            c = self.get().unwrap();
            false
        } else {
            false
        };
        let mut res = T::zero();
        loop {
            if !c.is_ascii_digit() {
                panic!(
                    "expected integer, found {}{}{}",
                    if sgn { "-" } else { "" },
                    res,
                    c as char
                );
            }
            res *= T::from_u8(10);
            res += T::from_u8(c - b'0');
            match self.get() {
                None => {
                    break;
                }
                Some(ch) => {
                    if char::from(ch).is_whitespace() {
                        break;
                    } else {
                        c = ch;
                    }
                }
            }
        }
        if sgn {
            debug_assert!(T::SIGNED);
            res = T::zero() - res
        }
        res
    }

    pub fn read_string(&mut self) -> String {
        match self.next_token() {
            None => {
                panic!("Input exhausted");
            }
            Some(res) => unsafe { String::from_utf8_unchecked(res) },
        }
    }

    pub fn read_char(&mut self) -> char {
        self.skip_whitespace();
        self.get().unwrap().into()
    }

    read_impl!(u8, read_u8, read_u8_vec);
    read_impl!(u16, read_u16, read_u16_vec);
    read_impl!(u32, read_unsigned, read_unsigned_vec);
    read_impl!(u64, read_u64, read_u64_vec);
    read_impl!(u128, read_u128, read_u128_vec);
    read_impl!(usize, read_usize, read_usize_vec, read_usize_pair_vec);
    read_impl!(i8, read_i8, read_i8_vec);
    read_impl!(i16, read_i16, read_i16_vec);
    read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
    read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
    read_impl!(i128, read_i128, read_i128_vec);
    read_impl!(isize, read_isize, read_isize_vec);
    read_impl!(f64, read_float, read_float_vec);

    fn read_float_impl(&mut self) -> f64 {
        self.read::<String>().parse().unwrap()
    }

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }
}

pub struct InputIterator<'t, 's: 't, T: Readable + 't + 's> {
    input: &'t mut Input<'s>,
    phantom: PhantomData<T>,
}

impl<'t, 's: 't, T: Readable + 't + 's> Iterator for InputIterator<'t, 's, T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        self.input.skip_whitespace();
        self.input.peek().map(|_| self.input.read())
    }
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for String {
    fn read(input: &mut Input) -> Self {
        input.read_string()
    }
}

impl Readable for char {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl Readable for f64 {
    fn read(input: &mut Input) -> Self {
        input.read_float_impl()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.read_vec(size)
    }
}

macro_rules! read_integer {
    ($($t:ident)+) => {$(
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.read_integer()
            }
        }
    )+};
}

read_integer!(i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize);

macro_rules! tuple_readable {
    ($($name:ident)+) => {
        impl<$($name: Readable), +> Readable for ($($name,)+) {
            fn read(input: &mut Input) -> Self {
                ($($name::read(input),)+)
            }
        }
    }
}

tuple_readable! {T}
tuple_readable! {T U}
tuple_readable! {T U V}
tuple_readable! {T U V X}
tuple_readable! {T U V X Y}
tuple_readable! {T U V X Y Z}
tuple_readable! {T U V X Y Z A}
tuple_readable! {T U V X Y Z A B}
tuple_readable! {T U V X Y Z A B C}
tuple_readable! {T U V X Y Z A B C D}
tuple_readable! {T U V X Y Z A B C D E}
tuple_readable! {T U V X Y Z A B C D E F}
}
pub mod output {
use std::io::Write;

#[derive(Copy, Clone)]
pub enum BoolOutput {
    YesNo,
    YesNoCaps,
    PossibleImpossible,
    Custom(&'static str, &'static str),
}

impl BoolOutput {
    pub fn output(&self, output: &mut Output, val: bool) {
        (if val { self.yes() } else { self.no() }).write(output);
    }

    fn yes(&self) -> &str {
        match self {
            BoolOutput::YesNo => "Yes",
            BoolOutput::YesNoCaps => "YES",
            BoolOutput::PossibleImpossible => "Possible",
            BoolOutput::Custom(yes, _) => yes,
        }
    }

    fn no(&self) -> &str {
        match self {
            BoolOutput::YesNo => "No",
            BoolOutput::YesNoCaps => "NO",
            BoolOutput::PossibleImpossible => "Impossible",
            BoolOutput::Custom(_, no) => no,
        }
    }
}

pub struct Output {
    output: Box<dyn Write>,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
    bool_output: BoolOutput,
}

impl Output {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: false,
            bool_output: BoolOutput::YesNoCaps,
        }
    }

    pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: true,
            bool_output: BoolOutput::YesNoCaps,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.output.flush().unwrap();
            self.at = 0;
        }
    }

    pub fn print<T: Writable>(&mut self, s: &T) {
        s.write(self);
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        for i in arg {
            i.write(self);
            self.put(b'\n');
        }
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }
}

pub fn set_bool_output(bool_output: BoolOutput) {
    output().bool_output = bool_output
}

impl Write for Output {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        if self.auto_flush {
            self.flush();
        }
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl<T: Writable> Writable for &[T] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable> Writable for &T {
    fn write(&self, output: &mut Output) {
        T::write(self, output)
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        (&self[..]).write(output);
    }
}

macro_rules! write_to_string {
    ($($t:ident)+) => {$(
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    )+};
}

write_to_string!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize f32 f64);

impl<T: Writable, U: Writable> Writable for (T, U) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable, W: Writable> Writable for (T, U, V, W) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
        output.put(b' ');
        self.3.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable, W: Writable, X: Writable> Writable for (T, U, V, W, X) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
        output.put(b' ');
        self.3.write(output);
        output.put(b' ');
        self.4.write(output);
    }
}

impl<T: Writable> Writable for Option<T> {
    fn write(&self, output: &mut Output) {
        match self {
            None => (-1).write(output),
            Some(t) => t.write(output),
        }
    }
}

impl Writable for bool {
    fn write(&self, output: &mut Output) {
        let bool_output = output.bool_output;
        bool_output.output(output, *self)
    }
}

pub static mut OUTPUT: Option<Output> = None;

pub fn set_global_output_to_stdout() {
    unsafe {
        OUTPUT = Some(Output::new(Box::new(std::io::stdout())));
    }
}

pub fn set_global_output_to_file(path: &str) {
    unsafe {
        let out_file =
            std::fs::File::create(path).unwrap_or_else(|_| panic!("Can't create file {}", path));
        OUTPUT = Some(Output::new(Box::new(out_file)));
    }
}

pub fn set_global_output_to_none() {
    unsafe {
        match &mut OUTPUT {
            None => {}
            Some(output) => output.flush(),
        }
        OUTPUT = None;
    }
}

pub fn output() -> &'static mut Output {
    unsafe {
        match &mut OUTPUT {
            None => {
                panic!("No output set.");
            }
            Some(output) => output,
        }
    }
}

#[macro_export]
macro_rules! out {
    ($first: expr $(,$args:expr )*) => {
        $crate::io::output::output().print(&$first);
        $($crate::io::output::output().put(b' ');
        $crate::io::output::output().print(&$args);
        )*
        $crate::io::output::output().maybe_flush();
    }
}

#[macro_export]
macro_rules! out_line {
    ($first: expr $(, $args:expr )* ) => {
        $crate::out!($first $(,$args)*);
        $crate::io::output::output().put(b'\n');
        $crate::io::output::output().maybe_flush();
    };
    () => {
        output().put(b'\n');
        output().maybe_flush();
    };
}
}
pub mod task_io_settings {
pub enum TaskIoType {
    Std,
    File(String),
}

pub struct TaskIoSettings {
    pub is_interactive: bool,
    pub input: TaskIoType,
    pub output: TaskIoType,
}
}
pub mod task_runner {
use std::io::Write;

use super::{input::Input,output::{Output, OUTPUT},task_io_settings::{TaskIoSettings, TaskIoType},};

pub fn run_task<Res>(io: TaskIoSettings, run: impl FnOnce(Input) -> Res) -> Res {
    let output: Box<dyn Write> = match io.output {
        TaskIoType::Std => Box::new(std::io::stdout()),
        TaskIoType::File(file) => {
            let out_file = std::fs::File::create(file).unwrap();
            Box::new(out_file)
        }
    };

    unsafe {
        if io.is_interactive {
            OUTPUT = Some(Output::new_with_auto_flush(output));
        } else {
            OUTPUT = Some(Output::new(output));
        }
    }

    match io.input {
        TaskIoType::Std => {
            let mut sin = std::io::stdin();
            let input = if io.is_interactive {
                Input::new_with_size(&mut sin, 1)
            } else {
                Input::new(&mut sin)
            };
            run(input)
        }
        TaskIoType::File(file) => {
            let mut in_file = std::fs::File::open(file).unwrap();
            let input = if io.is_interactive {
                Input::new_with_size(&mut in_file, 1)
            } else {
                Input::new(&mut in_file)
            };
            run(input)
        }
    }
}
}
}
pub mod misc {
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
    ($first_val:expr, $($val:expr),+ $(,)?) => {
        eprint!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
        ($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
        eprintln!();
    };
    ($first_val:expr) => {
        eprintln!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val)
    };
}
}
}
pub mod numbers {
pub mod num_traits {
pub mod add_sub {
use std::ops::{Add, AddAssign, Sub, SubAssign};

pub trait Addable: Add<Output = Self> + AddAssign + Copy {}
impl<T: Add<Output = Self> + AddAssign + Copy> Addable for T {}

pub trait AddSub: Addable + Sub<Output = Self> + SubAssign {}
impl<T: Addable + Sub<Output = Self> + SubAssign> AddSub for T {}
}
pub mod from_u8 {
pub trait FromU8 {
    fn from_u8(val: u8) -> Self;
}

macro_rules! from_u8_impl {
    ($($t: ident)+) => {$(
        impl FromU8 for $t {
            fn from_u8(val: u8) -> Self {
                val as $t
            }
        }
    )+};
}

from_u8_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize f32 f64);
}
pub mod mul_div_rem {
use std::ops::{Div, DivAssign, Mul, MulAssign, Rem, RemAssign};

pub trait Multable: Mul<Output = Self> + MulAssign + Copy {}
impl<T: Mul<Output = Self> + MulAssign + Copy> Multable for T {}

pub trait MulDiv: Multable + Div<Output = Self> + DivAssign {}
impl<T: Multable + Div<Output = Self> + DivAssign> MulDiv for T {}

pub trait MulDivRem: MulDiv + Rem<Output = Self> + RemAssign {}
impl<T: MulDiv + Rem<Output = Self> + RemAssign> MulDivRem for T {}
}
pub mod sign {
pub trait IsSigned {
    const SIGNED: bool;
}

pub trait Signed: IsSigned {}

pub trait Unsigned: IsSigned {}

macro_rules! unsigned_impl {
    ($($t: ident)+) => {$(
        impl Unsigned for $t {}

        impl IsSigned for $t {
            const SIGNED: bool = false;
        }
    )+};
}

unsigned_impl!(u128 u64 u32 u16 u8 usize);

macro_rules! signed_impl {
    ($($t: ident)+) => {$(
        impl Signed for $t {}

        impl IsSigned for $t {
            const SIGNED: bool = true;
        }
    )+};
}

signed_impl!(i128 i64 i32 i16 i8 isize f64 f32);
}
pub mod zero_one {
pub trait ZeroOne {
    fn zero() -> Self;
    fn one() -> Self;
}

macro_rules! zero_one_integer_impl {
    ($($t: ident)+) => {$(
        impl ZeroOne for $t {
            fn zero() -> Self {
                0
            }

            fn one() -> Self {
                1
            }
        }
    )+};
}

zero_one_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);

macro_rules! zero_one_float_impl {
    ($($t: ident)+) => {$(
        impl ZeroOne for $t {
            fn zero() -> Self {
                0.
            }

            fn one() -> Self {
                1.
            }
        }
    )+};
}

zero_one_float_impl!(f32 f64);
}
}
}
fn main() {
    crate::solution::submit();
}

[{'input': ['9\r\nabacbecfd\r\n'], 'output': ['2\r\n1 1 2 1 2 1 2 1 2 \r\n']}, {'input': ['8\r\naaabbcbb\r\n'], 'output': ['2\r\n1 1 1 1 1 1 2 2 \r\n']}, {'input': ['7\r\nabcdedc\r\n'], 'output': ['3\r\n1 1 1 1 1 2 3 \r\n']}, {'input': ['5\r\nabcde\r\n'], 'output': ['1\r\n1 1 1 1 1 \r\n']}, {'input': ['200\r\nraaaaabbbccccccccccdddddeeeeeeeeeeeeeeffffffffffggggggggghhhhhiiiiiiiiijjjjkkkkkkkkkkllllllllmmmmmmmmnnnnnnnooooooooppppppqqqqqqqqqqrrrrrrrrssssttttttttttuuuuuuuuvvvvvvwwwwwwxxxxxxxyyyyyyyzzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\nazaaaaaabbbbbbbcccccccccdeeeeeeefffffffgggggggghhhhhhiijjjjjkkkkkkkkkllllllmmmmmmmmmmmmnnnnnnoooooopppppppppppqqqqqrrrrrrrrrrrrrssssssssssstttttttttttuuuuuuuuvvvvvvvwwwwwwwwwxxxxxxxyyyyyy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 1 1 2 \r\n']}, {'input': ['200\r\ncnaaaaaabbbbbccccdddddddddddddeeeeeeeeefffffffgggggggggghhhhhhhhhiiijjjjjkkkkkkklllllllmmmmmmmnnnnnnnnnooooooooooooppppppppqqqqqqqqqqqrrrssssssstuuuuuuuuvvvvvvvvvvvvwwwwwwxxxxxxxxyyyyyyyzzzzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaawaaaabbbbccccccccddddddddddeeeeeeeffffffffffgggggggggghhhhhhhhiiiiiiiiijjjjjjjkkkkkkkkklllllllmmmmmmmmnnnnnnooooooooppppppppqqqqrrrrrrrsssssssttttttuuuuuuuuuvvvvvvvvvwwwwwwwxxxxxxxyyyyyyyzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaabbbbbbbbbbbccccccdddddddddeeeeeefffffffffggggggggggggggghhhhhhhhhiiiiijjjjjjjjjjjkkkkkklllllllmmmmmmmmmnnnnnnnnnnoooooppppppqqqqqqqrrrrrssssssstttttuuuuuuuuvvvvwwwwwwwwwwwwxxxxxxyyyyyyzzzzzzzzzmu\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 \r\n']}, {'input': ['200\r\nfhrvyaaaaaaaaabbbbbbbccccccccccdddddeeeeeeeeeeeeefffffggggggghhiiiiiiiiiiiijjjjjkkkklllllllmmmmmmmmnnnnnoooooppppppppqqqrrrrrrrrrrsssssssstttttttttttttuuuuuuuvvvvvvwwwwwwwwwwwwwwxxxxxxyyyyyyyyzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2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2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaeillaoobbwbbxbzbbcccccccdddddddddeeeeeeeffffffffggggghhhhhiiiijjjjjjjkkkkklllllmmmmmmmmmnnnnnnnnnnnnnooooooooppppqqqqqqqqqqrrrrrrrrrrrsssssssssttttttttttuuuuuuuvvvvvvvwwwwwwwxxxxxxyyyyzzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 2 1 1 2 2 1 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaaaaabbbbbccccccccccccccdddddddddeeeeeeefffffffffgggggghhhhhhiiiiiiijjjjjjjjjjkkkkkkllllllllmmmmmmmmnnnnnnoooooooppppppqqqqqqqqqqqrrrrrrsssssssttttttttuuuuuuvvvvvwwwwwxxxyyyyzzzzzzzzzzzcddddjksvw\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 \r\n']}, {'input': ['200\r\naaaabbbbcceefffgghhhhijjllnnnnopqrrsstuuvvvwwxxyyyaaaabbbbbbbbcccdddddeeeeeefffffggggghhhhhhhhhiiiiiiiiijjjjkkkkkkllllllmmmmmmmnnnnnoooooooopppppppqqqrrrrrrsssssstttttuuuuuuuvvvvvwwwxxxxxyyyyzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaabbaaaaabcbebebbccecccffgjklccmcmnccoccooddoqqqdddqderreerrsfffsfsfghuuhhhvhhhhvviwixixixxixijjjxjyjzzjzkkklllllmmmmmmmnnnnnnnoooooppppppppppppqqqqqrrrrrrrsssssstttuuuvvvvvv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 2 2 2 1 1 1 \r\n']}, {'input': ['200\r\naaaabbbbbbccccddddefffffgghhhiiiiiiiiijjjjjkkklmmmmnnnnnnooopppppppprrrstuuuuuuvvvvvvvwwxxxxyyyyyyzzaabbbbbbcccdddddddddeffggggghhhhhhiiijjjjjjkkkkllllmmmnnnoopqqqrrssssttttuuuvvvvvwwwwwxxxxyyyyyzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaabcbbbbcccccdccdcdddddeeddeeeeeeeeeefffffffggghgghghhhhhhhihhhiiiiiiiijijijjjjkjkkkkkkkklkkllllllllmmmmmmmmmmmnnnnnnnnoooppnqnnqoqroooorsoppqqstttqruuurruvrrvvtvttvvtuwvwwwwxxxwxyzzxzzyyzzyyzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 2 1 1 2 2 2 2 1 1 2 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 2 1 1 2 2 1 1 1 1 \r\n']}, {'input': ['200\r\naaaabccccdddddddeefffffffgghhhiiiiiijjjjjjjkkkkkllllmmmmnnnnnoooooooppqqqqqrrrrsssttuuuuuvwwxxyyyzzzaaaaaabbbbbccccddddddeefffffffggghhiiiikkllmmnnnnnnoooooppppqqqqrrrrsttttuuuuuvvvvwwwwwwxxxxyyyzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaaaabbbbcccccccccccdddeeeeeeeefffgggghhhhhhhhiiiiiiijjjjjjjkkklllmmmmmnnnnnnnoooooppppppppqqqqrrrrrrrssssssttttuuuuuuvvvvvwwwwxxxxxxyyyyyzzzzzzzzaabbbcccdeeefggggghhhhiijjjjkllnpqqqrrsssstuuvwyzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \r\n']}, {'input': ['200\r\naaaaaadeafgibbbbbbjbjlncpccccsdsdddtdtdtdeetuevwwezzefffffgggghhhhhhhiijjjjjjjjkkklllllllmmmmmmmmmmmmmnnnnnnnooooooooopppppppppppppqqqqrrrrrrsssssssttttttttttuuuuuuuuuvvvvvvvwwwwwwxxxxxyyyyyyyyyzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 2 1 1 1 2 2 2 2 2 2 1 2 1 1 1 2 1 2 2 2 2 1 2 1 2 2 2 1 2 1 2 1 2 2 2 1 1 2 1 1 1 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naadfgghjjjkmnpqqtuuwwxyzaaaaaaaabbbbbbbbcccccddddeeeeeeeeeffgggghhhhhhiiiiiiiijjjjjjjjkkkkklllllmmmmmmmmmmmnnnnnoooooppppppppqqqqqqqqrrrrrrrrrrrssssstttttttttuuuuuuuuvvvvvvvwwwwwwxxxxxxxyyyyyzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaaaaabbbbbbccccccddddddddddddeeeeeeeeeeffffffffggggghhhhhhiiijjjjjjkkkkkklllllllllllllmmmmmmmnnnnnooooooooooppppppppppqqqqqqqqqrrrrrrrrsssssstttttttttuuuuvvvvvvwwwwwwwwwwwxxxxxyyyyyyyyyyzzzzzzzzw\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 \r\n']}, {'input': ['200\r\naaabbsbbbbbbbbbbbbbcccccccccdddddddddddddeeeeeeeeffffffffgggggggggghhhhhhhhhhhhijjjjjjjjjjkkkkkkllllmmmmmnnnnnnoooooooppppppqqqqqqqqqqqqrrrrrsssssssssttttttuuuuuuvvvvvvvvvwwwwwwxxxxxx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 1 1 1 1 \r\n']}, {'input': ['200\r\nzywmerhahxlqsjekpqsdqxnjiduyjrytswiweohctztgpiorwimhjmdfofqynyggcrtzslbyvkuvqrsgwyacyvcuathplliwwshusluiqwuhutnzwvuchfedhwwfdzizltdxibtsaocpnqezstblgkfdcvfsjjyzwalkksumsaljqljmmkcyejwwdkolmcgmodoiclte\r\n'], 'output': ['19\r\n1 2 3 4 5 4 5 6 5 3 5 5 4 6 7 6 6 5 4 8 5 3 7 8 9 10 4 2 8 5 2 5 6 4 9 4 10 7 10 11 5 1 5 11 7 9 8 7 4 9 9 10 10 9 12 12 8 12 8 2 9 2 11 11 13 7 5 1 6 10 14 2 5 11 6 5 8 7 7 12 4 2 15 13 2 5 13 6 15 7 12 9 10 10 12 4 4 8 13 6 8 10 6 12 9 4 6 13 6 7 10 1 4 5 6 14 13 14 15 16 13 4 4 14 16 1 12 1 11 7 16 3 12 17 7 8 18 10 17 10 11 9 15 1 8 7 18 12 14 13 15 16 17 5 15 8 14 14 2 1 4 19 12 13 13 8 6 12 8 19 13 14 9 13 14 12 12 14 17 2 16 15 4 4 17 14 11 13 12 18 16 12 11 17 11 16 18 13 7 17 \r\n']}, {'input': ['200\r\ntoimpgygoklxroowdhpacrtrrwmkhcgcpidapeyxrjmiqgilveimnazyydvnujtqpenfkeqdbylfdinompxupfwvirxohaampqihjueasygkucweptgcowjibgnwyqetynykgoujeargnhjbmntfovwusqavpdwtpnpqpkcgaxbhgdxloyealksmgkxprtpfugixdyfn\r\n'], 'output': ['19\r\n1 2 3 3 2 4 1 4 3 4 4 2 3 4 4 3 5 5 4 6 6 4 4 5 5 3 6 7 8 9 9 10 6 8 10 11 6 10 1 2 5 8 7 9 6 10 9 8 4 11 9 7 7 12 1 2 2 12 4 7 5 9 6 7 8 11 9 11 10 12 7 13 14 2 10 11 13 11 9 9 10 8 3 5 8 12 4 5 11 7 3 9 12 15 15 10 8 8 11 12 11 6 13 15 7 2 13 11 6 14 4 14 9 7 13 15 10 4 12 13 16 14 11 4 2 8 15 7 2 11 2 12 14 10 6 13 15 17 8 14 11 14 13 16 12 11 7 15 10 5 4 6 8 9 17 5 10 16 4 7 10 11 10 9 10 13 17 15 18 3 18 14 15 16 3 13 11 2 16 19 13 14 8 12 15 14 3 10 9 7 10 16 6 15 15 3 17 2 16 12 \r\n']}, {'input': ['200\r\nndwpatpnvwldptairxlxqmzzysfvglpjkwbebtosqvfnoebfvxfpupvohcaazsjbdshoducigmfoqzltdgvmdmputqmoaqscilmtafqrxdunwnijhrtbwonpvpeouednmjswhauahmgyozmbiilxxflkkmwywvuojbrwwbkyhxtdywiktkfcsmozklhrwlwyajekejrx\r\n'], 'output': ['19\r\n1 2 1 2 3 2 3 4 2 1 5 6 3 3 7 6 4 1 5 1 5 6 1 1 2 4 7 3 7 7 6 8 8 3 9 9 10 4 7 5 6 4 9 8 7 10 11 9 4 3 9 7 5 7 4 8 9 11 12 12 1 6 9 12 11 6 10 8 11 5 12 10 11 9 12 8 7 1 10 6 13 11 4 9 13 9 8 5 6 7 9 9 14 7 7 14 11 10 10 6 15 12 8 8 3 13 5 10 4 10 11 11 12 8 6 15 4 9 10 9 5 9 13 10 6 13 14 11 12 13 7 4 14 16 6 16 14 12 15 2 10 1 12 16 14 14 13 3 3 16 13 14 14 12 4 2 4 5 6 10 15 17 8 4 4 17 14 2 16 3 7 17 2 4 16 14 7 14 17 18 8 12 10 1 14 13 17 9 4 13 4 2 19 15 18 14 18 15 9 3 \r\n']}, {'input': ['200\r\nftiqlgirbkmlpzkthoivcifhflyietxsfiwiojenqgxrnetzutdsyfuhrbfpedyksfzuvnqonbyydogbrwsfuuivboanufitbjngppagzfgqwyroaofcdgrwoxwfpvcgzdnkhnwtlavnoppdbddpfpcaaipdcqskcqtccrrspvjyqpvjwziexnmmnlqvacdpgnzzhude\r\n'], 'output': ['18\r\n1 1 2 2 3 4 4 2 5 4 3 4 3 1 5 2 6 4 6 2 7 6 7 7 8 5 2 6 9 3 3 4 8 6 4 6 5 6 9 6 5 8 3 5 6 9 5 1 5 6 10 7 2 9 5 8 8 11 9 9 10 11 2 10 7 11 1 5 5 10 9 10 11 12 2 2 12 10 12 13 8 4 7 13 6 6 12 5 14 10 15 11 6 13 12 7 14 12 11 13 10 10 15 13 1 14 13 9 4 2 8 11 15 11 14 15 15 13 8 4 11 3 4 14 10 5 16 13 1 15 12 13 14 12 4 7 13 17 5 12 11 10 10 15 17 15 15 10 15 10 16 18 18 14 10 16 17 9 8 14 17 9 7 17 17 9 9 8 10 5 15 2 10 11 5 15 4 1 16 17 3 12 13 13 12 14 10 5 18 18 18 11 17 12 1 1 17 6 18 18 \r\n']}, {'input': ['2\r\ntj\r\n'], 'output': ['2\r\n1 2 \r\n']}, {'input': ['1\r\nr\r\n'], 'output': ['1\r\n1 \r\n']}, {'input': ['30\r\nrzlwlvhfatfwmlpvndtgrxyphfjnnm\r\n'], 'output': ['8\r\n1 1 2 2 3 3 4 5 6 4 5 2 5 6 5 3 6 7 4 7 5 2 2 6 7 8 7 7 7 8 \r\n']}, {'input': ['30\r\nlpxzyiymhgfemqbhburdctevpybxlv\r\n'], 'output': ['10\r\n1 1 1 1 2 3 2 3 4 5 6 7 3 3 8 4 8 3 4 8 9 4 7 3 5 2 10 3 6 4 \r\n']}, {'input': ['30\r\ndcjajwrqosgljwltqlozqmldwuukkg\r\n'], 'output': ['8\r\n1 2 1 3 1 1 2 3 4 2 5 5 6 1 5 2 3 5 4 1 3 5 6 7 2 3 3 7 7 8 \r\n']}, {'input': ['30\r\nxsvbtliwvggtjbvdebjwcirlfnnuio\r\n'], 'output': ['8\r\n1 2 2 3 3 4 5 2 3 6 6 4 5 7 3 7 7 8 5 2 8 6 5 6 7 6 6 4 7 6 \r\n']}, {'input': ['30\r\nrhkegyacbthzhghossgtqdxtmjfhhx\r\n'], 'output': ['7\r\n1 2 2 3 3 1 4 4 5 2 3 1 3 4 3 3 3 3 4 2 4 5 2 3 5 6 7 7 7 2 \r\n']}, {'input': ['100\r\nyojtyktazyfegvnnsexxiosqxdlpdwlyojsghpvjpavnvjvttbylqcdabyhleltltzalmgoelxdalcbjejsjxnfebzsxusnujdyk\r\n'], 'output': ['15\r\n1 2 3 2 1 3 2 4 1 2 4 5 4 3 4 4 4 5 3 3 5 5 4 5 3 6 6 6 7 4 7 2 7 8 5 9 9 6 5 8 6 10 5 8 5 9 5 6 6 10 2 9 7 10 10 11 11 2 10 9 11 9 6 9 6 1 12 9 9 11 8 12 10 3 13 14 10 14 15 11 12 11 7 11 3 9 12 13 15 1 7 3 6 7 9 6 11 14 2 11 \r\n']}, {'input': ['100\r\nqdvwjzmgfmgngaxzgvuuukxyfzecafuflxpkvemenkorwhmnsxuoxsatlymyjugwjmutfxcksnwhxrwruyqbouyflxhwqhflczzx\r\n'], 'output': ['14\r\n1 2 1 1 2 1 2 3 4 2 3 2 3 5 2 1 3 3 4 4 4 5 2 2 6 1 7 8 9 6 4 6 5 3 5 6 4 7 6 7 6 7 6 5 4 8 7 7 5 3 5 6 3 6 9 6 8 2 8 2 9 5 10 4 9 8 5 6 11 3 12 9 7 8 4 10 3 8 4 8 5 2 9 13 10 5 2 11 11 3 12 4 9 12 13 11 14 1 1 3 \r\n']}, {'input': ['100\r\nkshxumdmoygtdgjkwmpsiffhoswmapcogjkngvcznwhtufgjstqrbgwjtxrnoevhwaoaxporxbnrijtwkqnteergtvvwkxvbvwch\r\n'], 'output': ['12\r\n1 1 2 1 2 3 4 3 3 1 4 3 5 4 4 4 2 4 4 4 5 6 6 6 5 4 2 6 7 5 7 6 7 7 7 7 8 3 9 1 7 2 8 4 4 9 9 8 5 5 6 6 10 9 2 8 5 2 6 7 7 10 3 9 3 11 7 11 2 7 8 6 2 11 9 6 10 10 5 3 10 7 9 5 11 11 6 11 5 4 4 3 10 2 4 12 4 3 12 11 \r\n']}, {'input': ['100\r\neivzgzvqvlgzdltwjcmpublpvopzxylucxhrrltwmizxtdxdrnmuivvcewvaunkqmnjgqgcwdphbvapebhkltmkfcslvgmnqoseu\r\n'], 'output': ['14\r\n1 1 1 1 2 1 2 3 2 4 5 1 6 4 3 2 5 7 4 4 3 8 5 4 3 5 4 1 2 2 6 4 7 3 7 5 5 6 5 4 6 7 1 3 5 8 3 8 6 7 8 5 9 5 5 10 10 4 5 11 6 7 9 7 8 8 10 11 7 11 12 4 12 8 11 13 5 14 8 12 13 11 9 9 7 9 10 12 13 8 10 5 12 9 9 9 10 8 13 6 \r\n']}, {'input': ['100\r\nyvharmmxcxhibqfixtjmhurxchhkvhubxjcveajrkssbsbrxpijxolrtmvanzyybzbdpgzocicakipmkpxhcjtegksbvabfghpfg\r\n'], 'output': ['15\r\n1 2 3 4 3 4 4 2 5 2 5 5 6 4 6 5 2 3 5 5 6 3 4 2 7 6 6 6 3 7 4 8 2 7 8 3 8 9 7 5 6 5 5 9 5 9 6 2 7 8 8 2 8 9 6 5 9 3 10 9 1 2 2 10 1 10 10 7 10 1 8 11 10 11 12 10 11 7 10 11 7 3 12 13 12 5 13 13 11 6 14 4 15 14 14 13 13 7 14 14 \r\n']}, {'input': ['8\r\nenjmfmcb\r\n'], 'output': ['5\r\n1 1 2 2 3 2 4 5 \r\n']}, {'input': ['8\r\nhinzrvgh\r\n'], 'output': ['3\r\n1 1 1 1 2 2 3 3 \r\n']}]


It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be transferred from one accumulator to the other. Every time x units of energy are transferred (x is not necessarily an integer) k percent of it is lost. That is, if x units were transferred from one accumulator to the other, amount of energy in the first one decreased by x units and in other increased by  units.Your task is to help Petya find what maximum equal amount of energy can be stored in each accumulator after the transfers.

First line of the input contains two integers n and k (1≤n≤10000,0≤k≤99) — number of accumulators and the percent of energy that is lost during transfers.
Next line contains n integers a1,a2,... ,an — amounts of energy in the first, second, .., n-th accumulator respectively (0≤ai≤1000,1≤i≤n).

Output maximum possible amount of energy that can remain in each of accumulators after the transfers of energy.
The absolute or relative error in the answer should not exceed 10^-6.

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();

    let mut lines = input.lines();
    let params: Vec<usize> = lines.next().unwrap().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let n = params[0];
    let k = params[1];

    let energy: Vec<f64> = lines.next().unwrap().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut low = 0.0;
    let mut high = 1000.0;

    for _ in 0..100 {
        let mid = (low + high) / 2.0;
        let mut total_loss = 0.0;

        for i in 0..n {
            if energy[i] > mid {
                total_loss += (energy[i] - mid) * (1.0 - (k as f64) / 100.0);
            } else {
                total_loss -= (mid - energy[i]);
            }
        }

        if total_loss > 0.0 {
            low = mid;
        } else {
            high = mid;
        }
    }

    println!("{:.9}", low);
}


Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1,s2,...,sn. All those strings consist of uppercase and lowercase Latin letters. String w has the length of |w|, its characters are numbered from 1 to |w|.First Petya should find all the occurrences of forbidden substrings in the w string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings "aBC" and "ABc" are considered equal.After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position i should be replaced by any other one if for position i in string w there exist pair of indices l,r (1≤l≤i≤r≤|w|) such that substring w[l ... r] is contained in the collection s1,s2,...,sn, when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.Letter letter (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the letter occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.

The first line contains the only integer n (1≤n≤100) — the number of forbidden substrings in the collection. Next n lines contain these substrings. The next line contains string w. All those n+1 lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed 100. The last line contains a lowercase letter letter.

Output the only line — Petya's resulting string with the maximum number of letters letter. If there are several answers then output the one that comes first lexicographically.
The lexicographical comparison is performed by the standard < operator in modern programming languages. The line a is lexicographically smaller than the line b, if a is a prefix of b, or there exists such an i (1≤i≤|a|), that ai<bi, and for any j (1≤j<i) aj=bj. |a| stands for the length of string a.

4
hello
party
abefglghjdhfgj
IVan
petrsmatchwin
a

#![allow(non_snake_case)]
#[allow(dead_code)] fn read_line() -> String { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("failed to read line"); buffer.trim().to_string() }
#[allow(dead_code)] fn read<T : std::str::FromStr>() -> T where T::Err: std::fmt::Debug { read_line().trim().parse::<T>().expect("failed to read value") }
#[allow(dead_code)]fn read_vec<T : std::str::FromStr>() -> Vec<T> where T::Err: std::fmt::Debug { read_line().split_whitespace().map(|x| x.parse::<T>().expect("failed to read values")).collect() }
#[allow(dead_code)] fn lock_stdout() -> std::io::BufWriter<std::io::StdoutLock<'static>> { let stdout = std::io::stdout().lock(); std::io::BufWriter::new(stdout) }
#[allow(dead_code)] struct StdoutLogger {buf: std::io::BufWriter<std::io::StdoutLock<'static>>}impl StdoutLogger {fn log(&mut self, s: &str) {std::io::Write::write(&mut self.buf, s.as_bytes()).expect("error writing stdout");std::io::Write::write(&mut self.buf, "\n".as_bytes()).expect("error writing stdout");}}
#[allow(dead_code)] macro_rules! init {($name: ident) => {#[allow(unused_mut)]let mut $name = StdoutLogger{buf:lock_stdout()};}}

fn main() {
    init!(outp);

    let excl_c = read::<usize>();
    let excl_ws = (0..excl_c).map(|_| read_line()).collect::<Vec<_>>();
    let excl_ws = excl_ws.iter().map(|s| s.as_str()).collect::<Vec<_>>();
    let inp = read_line();
    let the_ch = read_line().chars().next().unwrap();

    // let excl_ws = vec![
    //     "aCa",
    //     "cba",
    // ];
    // let inp = "abAcaba";
    // let the_ch = 'c';

    let mut repl = vec![0; 100];
    let inp_lc = inp.to_lowercase();
    for &w in &excl_ws {
        let mut p = 0;
        while let Some(o) = inp_lc[p..].find(&w.to_lowercase()) {
            for i in p+o..p+o+w.len() {repl[i]=1}
            p += o + 1;
        }
    }

    fn match_case(ch: char, to_ch: char) -> char {
        if to_ch.is_uppercase(){ch.to_uppercase().next().unwrap()}else{ch.to_lowercase().next().unwrap()}
    }
    let mut inp = inp.chars().collect::<Vec<_>>();
    for i in 0..repl.len() {
        if repl[i]==1 {
            let the_ch_lc = the_ch.to_lowercase().next().unwrap();
            let inp_lc = inp[i].to_lowercase().next().unwrap();
            if inp_lc==the_ch_lc {
                inp[i] = match_case(if the_ch_lc=='a'{'b'}else{'a'}, inp[i]);
            } else {
                inp[i] = match_case(the_ch, inp[i]);
            }
        }
    }

    //println!("{inp:?}");
    println!("{}", inp.iter().collect::<String>());
}

[{'input': ['3\r\nbers\r\nucky\r\nelu\r\nPetrLoveLuckyNumbers\r\nt\r\n'], 'output': ['PetrLovtTttttNumtttt\r\n']}, {'input': ['4\r\nhello\r\nparty\r\nabefglghjdhfgj\r\nIVan\r\npetrsmatchwin\r\na\r\n'], 'output': ['petrsmatchwin\r\n']}, {'input': ['2\r\naCa\r\ncba\r\nabAcaba\r\nc\r\n'], 'output': ['abCacba\r\n']}, {'input': ['3\r\nlol\r\nhello\r\neho\r\nPetrUnited\r\nt\r\n'], 'output': ['PetrUnited\r\n']}, {'input': ['2\r\ntrsd\r\ndream\r\nPetrsDreamOh\r\ny\r\n'], 'output': ['PeyyyYyyyyOh\r\n']}, {'input': ['1\r\nPetrsDreamOh\r\nPetrsDreamOh\r\nh\r\n'], 'output': ['HhhhhHhhhhHa\r\n']}, {'input': ['3\r\netr\r\ned\r\nied\r\nPetrUnited\r\nd\r\n'], 'output': ['PdddUnitda\r\n']}, {'input': ['3\r\netr\r\ned\r\nied\r\nPetrUnited\r\nz\r\n'], 'output': ['PzzzUnitzz\r\n']}, {'input': ['3\r\nab\r\nBa\r\naB\r\nABBA\r\na\r\n'], 'output': ['BAAB\r\n']}, {'input': ['3\r\nab\r\nBa\r\naB\r\nABBAC\r\nb\r\n'], 'output': ['BAABC\r\n']}, {'input': ['7\r\na\r\nb\r\ng\r\nk\r\ne\r\nt\r\nt\r\nA\r\na\r\n'], 'output': ['B\r\n']}, {'input': ['4\r\nEfron\r\nKeyt\r\ncesho\r\ncool\r\nCodeForcesHockeyTeam\r\np\r\n'], 'output': ['CodeForpppPpcpppPeam\r\n']}, {'input': ['4\r\nEfron\r\nKeyt\r\ncesho\r\ncool\r\nCodeForcesOldHockeyNewTeam\r\np\r\n'], 'output': ['CodeForcesOldHockeyNewTeam\r\n']}, {'input': ['2\r\nA\r\nB\r\nabababBabaBBaBBBBAaaaAAAAA\r\na\r\n'], 'output': ['bababaAbabAAbAAAABbbbBBBBB\r\n']}, {'input': ['7\r\nS\r\nT\r\ng\r\ni\r\nO\r\nr\r\nq\r\nkljpfP\r\nv\r\n'], 'output': ['kljpfP\r\n']}, {'input': ['47\r\nV\r\nS\r\ng\r\nr\r\nC\r\nR\r\nB\r\nb\r\nl\r\nW\r\nJ\r\ni\r\nU\r\nn\r\nq\r\nq\r\nj\r\nL\r\nR\r\nu\r\nQ\r\nC\r\nf\r\nC\r\nU\r\nu\r\nx\r\nh\r\nq\r\nE\r\nY\r\nu\r\nK\r\nt\r\nM\r\nU\r\nA\r\nA\r\ns\r\ni\r\nV\r\nT\r\nj\r\nb\r\nk\r\nW\r\nN\r\nNlVwRlWzQQWoCI\r\nz\r\n'], 'output': ['ZzZzZzZzZZZoZZ\r\n']}, {'input': ['47\r\njw\r\nL\r\nxIp\r\nW\r\nI\r\naI\r\nEp\r\nylG\r\nNe\r\nEglZ\r\noYkyo\r\nwDuZK\r\nDVh\r\nuoAoF\r\nGWj\r\nt\r\nP\r\nuNQz\r\nbPSg\r\neqru\r\nxvll\r\nO\r\nmb\r\nCM\r\nwnmvv\r\nYpFsq\r\nFYID\r\nc\r\nr\r\nrhbl\r\nYseyB\r\nRGcRj\r\nhDtz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oEhhUorvsHHcQIlaXRQqrfTZZoNvjutjhGpGXmHHQQWCzeHhMHHxclmiNnErphA\r\n']}, {'input': ['100\r\nqn\r\nBE\r\nyN\r\nep\r\nPq\r\nXz\r\nLM\r\nEZ\r\ndb\r\nMn\r\nbn\r\nFe\r\nqA\r\nzc\r\nyq\r\npC\r\nyA\r\nWk\r\nYq\r\nrs\r\noD\r\nvD\r\nzW\r\nxZ\r\nbl\r\nur\r\nkf\r\ndf\r\nLS\r\nUW\r\nMy\r\nhR\r\nsh\r\nNh\r\nog\r\nCW\r\nor\r\nzo\r\nrO\r\nao\r\nXH\r\nDq\r\nKa\r\nlL\r\nYQ\r\nOh\r\nRZ\r\nAx\r\nta\r\nko\r\nDn\r\nNg\r\nNy\r\nDB\r\nYD\r\njO\r\nAp\r\nFT\r\noB\r\nNc\r\nwB\r\nHO\r\neW\r\nAc\r\nDr\r\nMt\r\nDf\r\nbF\r\nFP\r\nRa\r\nnF\r\nhF\r\nXC\r\nnG\r\nan\r\nZY\r\nuB\r\nHP\r\nOR\r\nKN\r\nUv\r\nLe\r\nIj\r\nlH\r\nVw\r\njb\r\nXn\r\nqu\r\nJo\r\nzL\r\nKW\r\nLS\r\naV\r\nLs\r\nBX\r\nMY\r\noK\r\nfh\r\ngP\r\nTB\r\npBWBEkqznLlZykhmPrfidzWbQMNDdBaDLykOfdvOZjKoUxCqKwJdGuhseuxaYcVyAGTSTwXYmKweRMUdbyfxssSNGLSAhckIknDj\r\nd\r\n'], 'output': ['pBDDDkqznDdDdkhmPrfiddDdQDDDaDaDLydDfdvOZjDdUdDqDdJdGuhseuxaYcVdDGTSTwXYmDdeRMUadyfxssSDDDDAhckIddDj\r\n']}, {'input': ['3\r\na\r\nA\r\na\r\nA\r\na\r\n'], 'output': ['B\r\n']}, {'input': ['3\r\na\r\nA\r\na\r\nA\r\nb\r\n'], 'output': ['B\r\n']}, {'input': ['4\r\na\r\nA\r\ni\r\nA\r\nPetyaIsVeryCoolGuy\r\np\r\n'], 'output': ['PetypPsVeryCoolGuy\r\n']}, {'input': ['3\r\njap\r\nthd\r\ndshipssinceW\r\nJapanisexperiencingitsgreatesthardshipssinceWorldWarIIthardshipssinceWorldWarIItesthardshixper\r\nc\r\n'], 'output': ['CccanisexperiencingitsgreatestharcccccccccacCorldWarIItharcccccccccacCorldWarIItesthardshixper\r\n']}, {'input': ['3\r\njap\r\nthd\r\ndshipssinceW\r\nJapanisexperiencingitsgreatesthardshipssinceWorldWarIIthardshipssinceWorldWarIItesthardshixper\r\na\r\n'], 'output': ['AbaanisexperiencingitsgreatestharaaaaaaaaaaaAorldWarIItharaaaaaaaaaaaAorldWarIItesthardshixper\r\n']}, {'input': ['7\r\na\r\nh\r\nu\r\np\r\nfgh\r\nwyz\r\ndefghijkl\r\nabcdefghijklmnopqrstuvwxyz\r\na\r\n'], 'output': ['bbcaaaaaaaaamnoaqrstavwxyz\r\n']}, {'input': ['9\r\na\r\nh\r\nu\r\np\r\nz\r\nfgh\r\nwyz\r\ndefghijkl\r\nghijklmnopqrstu\r\nabcdefghijklmnopqrstuvwxyz\r\na\r\n'], 'output': ['bbcaaaaaaaaaaaaaaaaaavwxya\r\n']}, {'input': ['3\r\nab\r\nBa\r\naB\r\nABBA\r\nl\r\n'], 'output': ['LLLL\r\n']}]


You are given a string $$$s$$$ consisting only of first $$$20$$$ lowercase Latin letters ('a', 'b', ..., 't').Recall that the substring $$$s[l; r]$$$ of the string $$$s$$$ is the string $$$s_l s_{l + 1} \dots s_r$$$. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".You can perform the following operation no more than once: choose some substring $$$s[l; r]$$$ and reverse it (i.e. the string $$$s_l s_{l + 1} \dots s_r$$$ becomes $$$s_r s_{r - 1} \dots s_l$$$).Your goal is to maximize the length of the maximum substring of $$$s$$$ consisting of distinct (i.e. unique) characters.The string consists of distinct characters if no character in this string appears more than once. For example, strings "abcde", "arctg" and "minecraft" consist of distinct characters but strings "codeforces", "abacaba" do not consist of distinct characters.

The only line of the input contains one string $$$s$$$ consisting of no more than $$$10^6$$$ characters 'a', 'b', ..., 't' (first $$$20$$$ lowercase Latin letters).

Print one integer — the maximum possible length of the maximum substring of $$$s$$$ consisting of distinct characters after reversing no more than one its substring.

struct Scanner<R> {
    reader: R,
    line: Vec<u8>,
    ptr: usize

}

impl<R: std::io::BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self{reader, line: vec![], ptr: 0}
    }

    fn scan<T: std::str::FromStr>(&mut self) -> T {
        loop {
            while self.ptr < self.line.len() && self.line[self.ptr].is_ascii_whitespace() {
                self.ptr += 1;
            }
            if self.ptr != self.line.len() {
                let start = self.ptr;
                while self.ptr < self.line.len() && !self.line[self.ptr].is_ascii_whitespace() {
                    self.ptr += 1;
                }
                return std::str::from_utf8(&self.line[start..self.ptr]).unwrap().parse().ok().
                    expect("parse error");
            }
            self.line.clear();
            self.reader.read_until(b'\n', &mut self.line).expect("read error");
            self.ptr = 0;
        }
    }

}

fn fill(mask: usize, set: &Vec<bool>, maxs: &mut Vec<u32>) -> u32 {
    if maxs[mask] != u32::MAX {
        return maxs[mask];
    }
    maxs[mask] = if set[mask] {mask.count_ones()} else {0};
    let mut tmp = mask;
    while tmp != 0 {
        let bit = (tmp & (tmp - 1)) ^ tmp;
        tmp ^= bit;
        let next = mask ^ bit;
        fill(next, set, maxs);
        maxs[mask] = maxs[mask].max(maxs[next]);
    }
    return maxs[mask];
}

fn solve<R: std::io::BufRead, W: std::io::Write>(scanner: &mut Scanner<R>, writer: &mut W) {
    let s: Vec<usize> = scanner.scan::<String>().bytes().map(|c| 1usize << (c - b'a')).collect();
    let masks = 1 << 20;
    let mut set = vec![false; masks];
    let n = s.len();
    for i in 0..n {
        let mut mask = 0;
        for j in i..n {
            if mask & s[j] != 0 {
                break;
            }
            mask |= s[j];
            set[mask] = true;
        }
    }
    let mut maxs = vec![u32::MAX; masks];
    fill(masks - 1, &set, &mut maxs);
    let mut result = 0;
    for mask in 0..masks {
        if !set[mask] {
            continue;
        }
        result = result.max(mask.count_ones() + maxs[!mask & (masks - 1)]);
    }
    writeln!(writer, "{}", result).unwrap();
}

fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut writer = std::io::BufWriter::new(stdout.lock());
    let mut scanner = Scanner::new(stdin.lock());
    let tests: usize = 1;
    for _ in 0..tests {
        solve(&mut scanner, &mut writer);
    }
}

[{'input': ['abacaba\r\n'], 'output': ['3\r\n']}, {'input': ['abcdecdf\r\n'], 'output': ['6\r\n']}, {'input': ['aabbcc\r\n'], 'output': ['3\r\n']}, {'input': ['abcdeefc\r\n'], 'output': ['6\r\n']}, {'input': ['b\r\n'], 'output': ['1\r\n']}, {'input': ['bh\r\n'], 'output': ['2\r\n']}, {'input': ['rmohl\r\n'], 'output': ['5\r\n']}, {'input': ['sbkedsbhen\r\n'], 'output': ['7\r\n']}, {'input': ['boodbpmpdfrmackcrtbasatcjbbbgkkrcdmiejqpqiqqpfepinqscfcrhglqnqnehsrmljoqdtsboammreagilegamlforqsknbn\r\n'], 'output': ['16\r\n']}, {'input': ['kbceqetaboafejrbkibcbnqaildribhoggaogmfoqfcejmgcrroliqkohsmpsppsmagdthblnbjsmdcscnsfjsradgdsclaahlisehqeafjplqblaqtdermttgitbhkmeakmnjrtkosbtihlbhofallpecrremgsbrtapfdblklnapearnkrpbhqbcmrffgoneiddsacoijjtqfrqojmllopttjhrqqmcbarmnttladfrjjrhoajrrksjickadpimoajrkbgtstmnmqoocsjcscghnbgnldphfqlsrqmflchgcktlbjpmlcackgmcmmterpqkgnonklrishirhoiemscnqtisrsjptoepifcaiqhggdmfrehgroobgsfmibclorktmdknlonsalffoqkkglsfaptopoeacqdhkdqnrqcorrsfssbdcdmrhpectqictsgicnkhspoqfpptbnbhkegksgfnlppoftpitcgiatsklemgaso\r\n'], 'output': ['18\r\n']}, {'input': ['rbakamtrsr\r\n'], 'output': ['7\r\n']}, {'input': ['qnhssobqcc\r\n'], 'output': ['7\r\n']}]


You are given a tree consisting of $$$n$$$ vertices. A tree is an undirected connected acyclic graph.  Example of a tree.You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color.You have to paint the vertices so that any path consisting of exactly three distinct vertices does not contain any vertices with equal colors. In other words, let's consider all triples $$$(x, y, z)$$$ such that $$$x \neq y, y \neq z, x \neq z$$$, $$$x$$$ is connected by an edge with $$$y$$$, and $$$y$$$ is connected by an edge with $$$z$$$. The colours of $$$x$$$, $$$y$$$ and $$$z$$$ should be pairwise distinct. Let's call a painting which meets this condition good.You have to calculate the minimum cost of a good painting and find one of the optimal paintings. If there is no good painting, report about it.

The first line contains one integer $$$n$$$ $$$(3 \le n \le 100\,000)$$$ — the number of vertices.
The second line contains a sequence of integers $$$c_{1, 1}, c_{1, 2}, \dots, c_{1, n}$$$ $$$(1 \le c_{1, i} \le 10^{9})$$$, where $$$c_{1, i}$$$ is the cost of painting the $$$i$$$-th vertex into the first color.
The third line contains a sequence of integers $$$c_{2, 1}, c_{2, 2}, \dots, c_{2, n}$$$ $$$(1 \le c_{2, i} \le 10^{9})$$$, where $$$c_{2, i}$$$ is the cost of painting the $$$i$$$-th vertex into the second color.
The fourth line contains a sequence of integers $$$c_{3, 1}, c_{3, 2}, \dots, c_{3, n}$$$ $$$(1 \le c_{3, i} \le 10^{9})$$$, where $$$c_{3, i}$$$ is the cost of painting the $$$i$$$-th vertex into the third color.
Then $$$(n - 1)$$$ lines follow, each containing two integers $$$u_j$$$ and $$$v_j$$$ $$$(1 \le u_j, v_j \le n, u_j \neq v_j)$$$ — the numbers of vertices connected by the $$$j$$$-th undirected edge. It is guaranteed that these edges denote a tree.

If there is no good painting, print $$$-1$$$.
Otherwise, print the minimum cost of a good painting in the first line. In the second line print $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ $$$(1 \le b_i \le 3)$$$, where the $$$i$$$-th integer should denote the color of the $$$i$$$-th vertex. If there are multiple good paintings with minimum cost, print any of them.

fn main() {
    input!{
        n: usize,
        costs: [[usize; n]; 3],
    };

    let mut children = vec![vec![]; n];
    for _ in 1..n {
        input!{ u: usize1, v: usize1 };
        if children[u].len() >= 2 || children[v].len() >= 2 {
            println!("-1");
            return;
        }
        children[u].push(v);
        children[v].push(u);
    }

    for i in 0..n {
        if children[i].len() == 1 {
            let line = makeline(&children, i);
            let mut min = usize::MAX;
            let mut scheme = [0; 3];
            for pat in [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]] {
                let mut cost = 0;
                for (i, &idx) in line.iter().enumerate() {
                    cost += costs[pat[i % 3]][idx];
                }
                if cost < min {
                    min = cost;
                    scheme = pat;
                }
            }
            let mut painted = vec![0; n];
            for (i, &idx) in line.iter().enumerate() {
                painted[idx] = scheme[i % 3];
            }
            println!("{min}");
            for c in painted {
                print!("{} ", c + 1);
            }
            return;
        }
    }
}

fn makeline(tree: &[Vec<usize>], root: usize) -> Vec<usize> {
    let n = tree.len();
    let mut line = Vec::with_capacity(n);
    let (mut cur, mut fa) = (tree[root][0], root);
    line.push(fa);
    line.push(cur);

    while line.len() < n {
        let next = if tree[cur][0] == fa { tree[cur][1] } else { tree[cur][0] };
        line.push(next);
        fa = cur;
        cur = next;
    }

    line
}

mod io {
    use std::cell::RefCell;
    use std::io::*;

    std::thread_local! {
        pub static STDIN: RefCell<Stdin> = RefCell::new(stdin());
        pub static STDOUT: RefCell<BufWriter<Stdout>> = RefCell::new(BufWriter::new(stdout()));
    }

    #[macro_export]
    macro_rules! input {
        () => {};
        (mut $var:ident: $t:tt, $($rest:tt)*) => {
            let mut $var = __input_inner!($t);
            input!($($rest)*)
        };
        ($var:ident: $t:tt, $($rest:tt)*) => {
            let $var = __input_inner!($t);
            input!($($rest)*)
        };
        (mut $var:ident: $t:tt) => {
            let mut $var = __input_inner!($t);
        };
        ($var:ident: $t:tt) => {
            let $var = __input_inner!($t);
        };
    }

    #[macro_export]
    macro_rules! __input_inner {
        (($($t:tt),*)) => {
            ($(__input_inner!($t)),*)
        };
        ([$t:tt; $n:expr]) => {
            (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        };
        ([$t:tt]) => {{
            let n = __input_inner!(usize);
            (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        }};
        (chars) => {
            __input_inner!(String).chars().collect::<Vec<_>>()
        };
        (bytes) => {
            __input_inner!(String).into_bytes()
        };
        (usize1) => {
            __input_inner!(usize) - 1
        };
        ($t:ty) => {
            $crate::io::STDIN.with(|r| {
                use std::io::BufRead;
                let r = r.borrow_mut();
                let mut r = r.lock();
                let mut s = vec![];
                loop {
                    let buf = r.fill_buf().unwrap();
                    if buf.is_empty() {
                        break;
                    }
                    if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {
                        s.extend_from_slice(&buf[..i]);
                        r.consume(i + 1);
                        if !s.is_empty() {
                            break;
                        }
                    } else {
                        s.extend_from_slice(buf);
                        let n = buf.len();
                        r.consume(n);
                    }
                }
                std::str::from_utf8(&s).unwrap().parse::<$t>().unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! println {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut()).unwrap()
            })
        };
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! print {
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::write!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! flush {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                w.borrow_mut().flush().unwrap()
            })
        };
    }
}


You are given a sequence $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ integers.You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can perform the aforementioned operation no more than $$$k$$$ times.

The first line contains two integers $$$n$$$ and $$$k$$$ $$$(2 \le n \le 10^{5}, 1 \le k \le 10^{14})$$$ — the number of elements in the sequence and the maximum number of times you can perform the operation, respectively.
The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le 10^{9})$$$.

Print the minimum possible difference between the maximum element and the minimum element in the sequence, if you can perform the aforementioned operation no more than $$$k$$$ times.

fn main() {
    input!{
        n: usize,
        k: usize,
        mut a: [usize; n],
    };
    a.sort_unstable();
    let sum = a.iter().sum::<usize>();

    let check = |max: usize| {
        let mut l = 0;
        let (mut lsum, mut rsum) = (0, sum);
        for (r, &x) in a.iter().enumerate() {
            rsum -= x;
            while x - a[l] > max {
                lsum += a[l];
                l += 1;
            }
            let op = if l == 0 { 0 } else { l * (x - max) - lsum } + rsum - (n - 1 - r) * x;
            if op <= k {
                return true;
            }
        }

        let mut r = n - 1;
        lsum = sum;
        rsum = 0;
        for (l, &x) in a.iter().enumerate().rev() {
            lsum -= x;
            while a[r] - x > max {
                rsum += a[r];
                r -= 1;
            }
            let op = x * l - lsum + rsum - (n - 1 - r) * (x + max);
            if op <= k {
                return true;
            }
        }
        false
    };

    let (mut low, mut high) = (0, a[n - 1] - a[0]);
    while low < high {
        let mid = (high - low)/2 + low;
        if check(mid) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }

    println!("{}", high);
}

mod io {
    use std::cell::RefCell;
    use std::io::*;

    std::thread_local! {
        pub static STDIN: RefCell<Stdin> = RefCell::new(stdin());
        pub static STDOUT: RefCell<BufWriter<Stdout>> = RefCell::new(BufWriter::new(stdout()));
    }

    #[macro_export]
    macro_rules! input {
        () => {};
        (mut $var:ident: $t:tt, $($rest:tt)*) => {
            let mut $var = __input_inner!($t);
            input!($($rest)*)
        };
        ($var:ident: $t:tt, $($rest:tt)*) => {
            let $var = __input_inner!($t);
            input!($($rest)*)
        };
        (mut $var:ident: $t:tt) => {
            let mut $var = __input_inner!($t);
        };
        ($var:ident: $t:tt) => {
            let $var = __input_inner!($t);
        };
    }

    #[macro_export]
    macro_rules! __input_inner {
        (($($t:tt),*)) => {
            ($(__input_inner!($t)),*)
        };
        ([$t:tt; $n:expr]) => {
            (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        };
        ([$t:tt]) => {{
            let n = __input_inner!(usize);
            (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        }};
        (chars) => {
            __input_inner!(String).chars().collect::<Vec<_>>()
        };
        (bytes) => {
            __input_inner!(String).into_bytes()
        };
        (usize1) => {
            __input_inner!(usize) - 1
        };
        ($t:ty) => {
            $crate::io::STDIN.with(|r| {
                use std::io::BufRead;
                let r = r.borrow_mut();
                let mut r = r.lock();
                let mut s = vec![];
                loop {
                    let buf = r.fill_buf().unwrap();
                    if buf.is_empty() {
                        break;
                    }
                    if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {
                        s.extend_from_slice(&buf[..i]);
                        r.consume(i + 1);
                        if !s.is_empty() {
                            break;
                        }
                    } else {
                        s.extend_from_slice(buf);
                        let n = buf.len();
                        r.consume(n);
                    }
                }
                std::str::from_utf8(&s).unwrap().parse::<$t>().unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! println {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut()).unwrap()
            })
        };
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! print {
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::write!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! flush {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                w.borrow_mut().flush().unwrap()
            })
        };
    }
}