QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755591#9551. The Emperorucup-team296#AC ✓14ms18768kbRust35.8kb2024-11-16 17:43:082024-11-16 17:43:10

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 17:43:10]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:18768kb
  • [2024-11-16 17:43:08]
  • 提交

answer

// 
pub mod solution {
//{"name":"d","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""},{"input":"","output":""},{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"d"}}}

use crate::algo_lib::collections::array_2d::Array2D;
#[allow(unused)]
use crate::dbg;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::math::modulo::Mod_998_244_353;
use crate::algo_lib::misc::rec_function::Callable2;
use crate::algo_lib::misc::rec_function::RecursiveFunction2;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
struct Value {
    val: usize,
    loc: usize,
}

impl Value {
    fn new(val: usize, loc: usize) -> Self {
        Self { val, loc }
    }
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
enum Op {
    PopPush(Value, Value),
    Halt(Value),
}

type Mod = Mod_998_244_353;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
enum Res {
    NotSeen,
    Seen,
    Value(Mod, usize),
}

fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
    let n = input.usize();
    let mut ops = vec![];
    for _ in 0..n {
        let s = input.string_as_string();
        if s == "HALT;" {
            input.string(); // PUSH
            let b = input.usize();
            input.string(); // GOTO
            let loc = input.usize() - 1;
            ops.push(Op::Halt(Value::new(b, loc)));
        } else {
            assert_eq!(s, "POP");
            let a = input.usize();
            // TODO: ;
            input.string(); // GOTO
            let mut loc1_bytes = input.string();
            loc1_bytes.pop();
            let mut loc1: usize = String::from_utf8(loc1_bytes).unwrap().parse().unwrap();
            loc1 -= 1;
            input.string(); // PUSH
            let b = input.usize();
            input.string(); // GOTO
            let loc2 = input.usize() - 1;
            ops.push(Op::PopPush(Value::new(a, loc1), Value::new(b, loc2)));
        }
    }
    let mut max_value = 0;
    for op in ops.iter() {
        match op {
            Op::PopPush(a, b) => {
                max_value = max_value.max(a.val).max(b.val);
            }
            Op::Halt(b) => {
                max_value = max_value.max(b.val);
            }
        }
    }
    max_value += 1;

    let mut dp = Array2D::new(Res::NotSeen, ops.len() + 1, max_value + 1);
    for value in 0..=max_value {
        dp[ops.len()][value] = Res::Value(Mod::ZERO, ops.len());
    }

    let res = RecursiveFunction2::new(|f, pos, top_val: usize| -> Res {
        let cur = dp[pos][top_val];
        if cur == Res::Seen {
            return Res::Seen;
        }
        if cur != Res::NotSeen {
            return cur;
        }
        dp[pos][top_val] = Res::Seen;

        match ops[pos] {
            Op::PopPush(v1, v2) => {
                if top_val == v1.val {
                    dp[pos][top_val] = Res::Value(Mod::ONE, v1.loc);
                } else {
                    let go = f.call(v2.loc, v2.val);
                    if go == Res::Seen {
                        dp[pos][top_val] = Res::Seen;
                    } else {
                        match go {
                            Res::NotSeen => todo!(),
                            Res::Seen => todo!(),
                            Res::Value(len1, loc2) => {
                                let go2 = f.call(loc2, top_val);
                                match go2 {
                                    Res::NotSeen => todo!(),
                                    Res::Seen => dp[pos][top_val] = Res::Seen,
                                    Res::Value(len2, loc3) => {
                                        dp[pos][top_val] = Res::Value(len1 + len2 + Mod::ONE, loc3);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Op::Halt(v2) => {
                if top_val == max_value {
                    dp[pos][top_val] = Res::Value(Mod::ONE, ops.len());
                } else {
                    let go = f.call(v2.loc, v2.val);
                    if go == Res::Seen {
                        dp[pos][top_val] = Res::Seen;
                    } else {
                        match go {
                            Res::NotSeen => todo!(),
                            Res::Seen => todo!(),
                            Res::Value(len1, loc2) => {
                                let go2 = f.call(loc2, top_val);
                                match go2 {
                                    Res::NotSeen => todo!(),
                                    Res::Seen => dp[pos][top_val] = Res::Seen,
                                    Res::Value(len2, loc3) => {
                                        dp[pos][top_val] = Res::Value(len1 + len2 + Mod::ONE, loc3);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };
        dp[pos][top_val]
    })
    .call(0, max_value);

    match res {
        Res::NotSeen => unreachable!(),
        Res::Seen => out.println(-1),
        Res::Value(res, _) => out.println(res),
    };
}

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

}
pub mod algo_lib {
pub mod collections {
pub mod array_2d {
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::misc::num_traits::Number;
use std::io::Write;
use std::ops::Index;
use std::ops::IndexMut;
use std::ops::Mul;

// TODO: implement good Debug
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Array2D<T> {
    rows: usize,
    cols: usize,
    v: Vec<T>,
}

pub struct Iter<'a, T> {
    array: &'a Array2D<T>,
    row: usize,
    col: usize,
}

impl<T> Array2D<T>
where
    T: Clone,
{
    #[allow(unused)]
    pub fn new(empty: T, rows: usize, cols: usize) -> Self {
        Self {
            rows,
            cols,
            v: vec![empty; rows * cols],
        }
    }

    pub fn new_f(rows: usize, cols: usize, mut f: impl FnMut(usize, usize) -> T) -> Self {
        let mut v = Vec::with_capacity(rows * cols);
        for r in 0..rows {
            for c in 0..cols {
                v.push(f(r, c));
            }
        }
        Self { rows, cols, v }
    }

    pub fn rows(&self) -> usize {
        self.rows
    }

    #[allow(clippy::len_without_is_empty)]
    pub fn len(&self) -> usize {
        self.rows()
    }

    pub fn cols(&self) -> usize {
        self.cols
    }

    pub fn swap(&mut self, row1: usize, row2: usize) {
        assert!(row1 < self.rows);
        assert!(row2 < self.rows);
        if row1 != row2 {
            for col in 0..self.cols {
                self.v.swap(row1 * self.cols + col, row2 * self.cols + col);
            }
        }
    }

    pub fn transpose(&self) -> Self {
        Self::new_f(self.cols, self.rows, |r, c| self[c][r].clone())
    }

    pub fn iter(&self) -> Iter<T> {
        Iter {
            array: self,
            row: 0,
            col: 0,
        }
    }

    pub fn pref_sum(&self) -> Self
    where
        T: Number,
    {
        let mut res = Self::new(T::ZERO, self.rows + 1, self.cols + 1);
        for i in 0..self.rows {
            for j in 0..self.cols {
                let value = self[i][j] + res[i][j + 1] + res[i + 1][j] - res[i][j];
                res[i + 1][j + 1] = value;
            }
        }
        res
    }
}

impl<T> Writable for Array2D<T>
where
    T: Writable,
{
    fn write(&self, output: &mut Output) {
        for r in 0..self.rows {
            self[r].write(output);
            output.write_all(&[b'\n']).unwrap();
        }
    }
}

impl<T> Index<usize> for Array2D<T> {
    type Output = [T];

    fn index(&self, index: usize) -> &Self::Output {
        &self.v[(index) * self.cols..(index + 1) * self.cols]
    }
}

impl<T> IndexMut<usize> for Array2D<T> {
    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
        &mut self.v[(index) * self.cols..(index + 1) * self.cols]
    }
}

impl<T> Mul for &Array2D<T>
where
    T: Number,
{
    type Output = Array2D<T>;

    fn mul(self, rhs: Self) -> Self::Output {
        let n = self.rows;
        let m = self.cols;
        assert_eq!(m, rhs.rows);
        let k2 = rhs.cols;
        let mut res = Array2D::new(T::ZERO, n, k2);
        for i in 0..n {
            for j in 0..m {
                for k in 0..k2 {
                    res[i][k] += self[i][j] * rhs[j][k];
                }
            }
        }
        res
    }
}

impl<T> Array2D<T>
where
    T: Number,
{
    pub fn pown(&self, pw: usize) -> Self {
        assert_eq!(self.rows, self.cols);
        let n = self.rows;
        if pw == 0 {
            Self::new_f(n, n, |r, c| if r == c { T::ONE } else { T::ZERO })
        } else if pw == 1 {
            self.clone()
        } else {
            let half = self.pown(pw / 2);
            let half2 = &half * &half;
            if pw & 1 == 0 {
                half2
            } else {
                &half2 * self
            }
        }
    }
}

impl<'a, T> Iterator for Iter<'a, T> {
    type Item = &'a T;

    fn next(&mut self) -> Option<Self::Item> {
        if self.col == self.array.cols {
            self.col = 0;
            self.row += 1;
        }
        if self.row >= self.array.rows {
            return None;
        }
        let elem = &self.array[self.row][self.col];
        self.col += 1;
        Some(elem)
    }
}
}
pub mod last_exn {
use std::collections::BTreeSet;

pub trait LastExn<T> {
    fn last_exn(&self) -> &T;
}

impl<T> LastExn<T> for &[T] {
    fn last_exn(&self) -> &T {
        self.last().unwrap()
    }
}

impl<T> LastExn<T> for Vec<T> {
    fn last_exn(&self) -> &T {
        self.last().unwrap()
    }
}

impl<T> LastExn<T> for BTreeSet<T> {
    fn last_exn(&self) -> &T {
        self.iter().next_back().unwrap()
    }
}
}
}
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;

pub struct Input {
    input: Box<dyn Read>,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_integer_fun {
    ($t:ident) => {
        #[allow(unused)]
        pub fn $t(&mut self) -> $t {
            self.read_integer()
        }
    };
}

impl Input {
    const DEFAULT_BUF_SIZE: usize = 4096;

    ///
    /// Using with stdin:
    /// ```no_run
    /// use algo_lib::io::input::Input;
    /// let stdin = std::io::stdin();
    /// let input = Input::new(Box::new(stdin));
    /// ```
    ///
    /// For read files use ``new_file`` instead.
    ///
    ///
    pub fn new(input: Box<dyn Read>) -> Self {
        Self {
            input,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_stdin() -> Self {
        let stdin = std::io::stdin();
        Self::new(Box::new(stdin))
    }

    pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new(Box::new(file))
    }

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

    pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new_with_size(Box::new(file), buf_size)
    }

    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 has_more_elements(&mut self) -> bool {
        !self.is_exhausted()
    }

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

    pub fn 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 string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.string());
        }
        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
    }

    #[allow(clippy::should_implement_trait)]
    pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
        InputIterator {
            input: self,
            phantom: Default::default(),
        }
    }

    fn read_integer<T: FromStr + Debug>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let res = self.read_string();
        res.parse::<T>().unwrap()
    }

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

    pub fn string_as_string(&mut self) -> String {
        self.read_string()
    }

    pub fn string(&mut self) -> Vec<u8> {
        self.read_string().into_bytes()
    }

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

    fn read_float(&mut self) -> f64 {
        self.read_string().parse().unwrap()
    }

    pub fn f64(&mut self) -> f64 {
        self.read_float()
    }

    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
        }
    }

    read_integer_fun!(i32);
    read_integer_fun!(i64);
    read_integer_fun!(i128);
    read_integer_fun!(u32);
    read_integer_fun!(u64);
    read_integer_fun!(usize);
}

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_string().parse().unwrap()
    }
}

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

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

pub struct InputIterator<T: Readable> {
    input: Input,
    phantom: PhantomData<T>,
}

impl<T: Readable> Iterator for InputIterator<T> {
    type Item = T;

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

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

read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;

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

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,
        }
    }

    pub fn new_stdout() -> Self {
        let stdout = std::io::stdout();
        Self::new(Box::new(stdout))
    }

    pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
        let file = std::fs::File::create(path).unwrap();
        Self::new(Box::new(file))
    }

    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,
        }
    }

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

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

    pub fn println<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.put(b'\n');
    }

    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);
        }
    }
}

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 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);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(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);
    }
}
}
}
pub mod math {
pub mod modulo {
use crate::algo_lib::collections::last_exn::LastExn;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::input::Readable;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::io::output::Writable;
use crate::algo_lib::misc::num_traits::ConvSimple;
use crate::algo_lib::misc::num_traits::HasConstants;
use crate::algo_lib::misc::num_traits::Number;
use std::io::Write;
use std::marker::PhantomData;

pub trait Value: Clone + Copy + Eq + Default + Ord {
    fn val() -> i32;
}

#[derive(Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Hash)]
pub struct ModWithValue<M>(i32, PhantomData<M>)
where
    M: Value;

impl<M> ModWithValue<M>
where
    M: Value,
{
    #[allow(unused)]
    pub const ZERO: Self = Self(0, PhantomData);

    #[allow(unused)]
    pub const ONE: Self = Self(1, PhantomData);

    #[allow(unused)]
    pub const TWO: Self = Self(2, PhantomData);

    fn rev_rec(a: i32, m: i32) -> i32 {
        if a == 1 {
            return a;
        }
        ((1 - Self::rev_rec(m % a, a) as i64 * m as i64) / a as i64 + m as i64) as i32
    }

    #[allow(dead_code)]
    pub fn inv(self) -> Self {
        ModWithValue(Self::rev_rec(self.0, M::val()), PhantomData)
    }

    pub fn value(&self) -> i32 {
        self.0
    }

    pub fn i64(&self) -> i64 {
        self.0 as i64
    }

    #[allow(dead_code)]
    pub fn new<T: Number>(x: T) -> Self {
        let mut x = x.to_i32();
        if x < 0 {
            x += M::val();
            if x < 0 {
                x %= M::val();
                x += M::val();
            }
        } else if x >= M::val() {
            x -= M::val();
            if x >= M::val() {
                x %= M::val();
            }
        }
        assert!(0 <= x && x < M::val());
        Self(x, PhantomData)
    }

    pub fn pown(self, pw: usize) -> Self {
        if pw == 0 {
            Self::ONE
        } else if pw == 1 {
            self
        } else {
            let half = self.pown(pw / 2);
            let res = half * half;
            if pw % 2 == 0 {
                res
            } else {
                res * self
            }
        }
    }

    pub fn gen_powers(base: Self, n: usize) -> Vec<Self> {
        let mut res = Vec::with_capacity(n);
        res.push(Self::ONE);
        for _ in 1..n {
            res.push(*res.last_exn() * base);
        }
        res
    }
}

impl<M> std::fmt::Display for ModWithValue<M>
where
    M: Value,
{
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl<M> std::fmt::Debug for ModWithValue<M>
where
    M: Value + Copy + Eq,
{
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        const MAX: i32 = 100;

        if self.0 <= MAX {
            write!(f, "{}", self.0)
        } else if self.0 >= M::val() - MAX {
            write!(f, "-{}", M::val() - self.0)
        } else {
            for denom in 1..MAX {
                let num = *self * Self(denom, PhantomData);
                if num.0 <= MAX {
                    return write!(f, "{}/{}", num.0, denom);
                } else if num.0 >= M::val() - MAX {
                    return write!(f, "-{}/{}", M::val() - num.0, denom);
                }
            }
            write!(f, "(?? {} ??)", self.0)
        }
    }
}

impl<M> std::ops::Add for ModWithValue<M>
where
    M: Value,
{
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        let res = self.0 + rhs.0;
        if res >= M::val() {
            ModWithValue(res - M::val(), PhantomData)
        } else {
            ModWithValue(res, PhantomData)
        }
    }
}

impl<M> std::ops::AddAssign for ModWithValue<M>
where
    M: Value,
{
    fn add_assign(&mut self, rhs: Self) {
        self.0 += rhs.0;
        if self.0 >= M::val() {
            self.0 -= M::val();
        }
    }
}

impl<M> std::ops::Sub for ModWithValue<M>
where
    M: Value,
{
    type Output = Self;

    fn sub(self, rhs: Self) -> Self::Output {
        let res = self.0 - rhs.0;
        if res < 0 {
            ModWithValue(res + M::val(), PhantomData)
        } else {
            ModWithValue(res, PhantomData)
        }
    }
}

impl<M> std::ops::SubAssign for ModWithValue<M>
where
    M: Value,
{
    fn sub_assign(&mut self, rhs: Self) {
        self.0 -= rhs.0;
        if self.0 < 0 {
            self.0 += M::val();
        }
    }
}

impl<M> std::ops::Mul for ModWithValue<M>
where
    M: Value,
{
    type Output = Self;

    fn mul(self, rhs: Self) -> Self::Output {
        let res = (self.0 as i64) * (rhs.0 as i64) % (M::val() as i64);
        ModWithValue(res as i32, PhantomData)
    }
}

impl<M> std::ops::MulAssign for ModWithValue<M>
where
    M: Value,
{
    fn mul_assign(&mut self, rhs: Self) {
        self.0 = ((self.0 as i64) * (rhs.0 as i64) % (M::val() as i64)) as i32;
    }
}

impl<M> std::ops::Div for ModWithValue<M>
where
    M: Value,
{
    type Output = Self;

    #[allow(clippy::suspicious_arithmetic_impl)]
    fn div(self, rhs: Self) -> Self::Output {
        let rhs_inv = rhs.inv();
        self * rhs_inv
    }
}

impl<M> std::ops::DivAssign for ModWithValue<M>
where
    M: Value,
{
    #[allow(clippy::suspicious_op_assign_impl)]
    fn div_assign(&mut self, rhs: Self) {
        *self *= rhs.inv();
    }
}

impl<M> Writable for ModWithValue<M>
where
    M: Value,
{
    fn write(&self, output: &mut Output) {
        output.write_fmt(format_args!("{}", self.0)).unwrap();
    }
}

impl<M> Readable for ModWithValue<M>
where
    M: Value,
{
    fn read(input: &mut Input) -> Self {
        let i32 = input.i32();
        Self::new(i32)
    }
}

impl<M> HasConstants<ModWithValue<M>> for ModWithValue<M>
where
    M: Value,
{
    // This doesn't make much sense, but hope we never use
    const MAX: ModWithValue<M> = ModWithValue::ZERO;
    const MIN: ModWithValue<M> = ModWithValue::ZERO;
    const ZERO: ModWithValue<M> = ModWithValue::ZERO;
    const ONE: ModWithValue<M> = ModWithValue::ONE;
    const TWO: ModWithValue<M> = ModWithValue::TWO;
}

impl<M> ConvSimple<ModWithValue<M>> for ModWithValue<M>
where
    M: Value,
{
    fn from_i32(val: i32) -> ModWithValue<M> {
        ModWithValue::new(val)
    }

    fn to_i32(self) -> i32 {
        self.0
    }

    fn to_f64(self) -> f64 {
        self.0 as f64
    }
}

pub trait ConstValue: Value + Copy {
    const VAL: i32;
}

impl<V: ConstValue> Value for V {
    fn val() -> i32 {
        Self::VAL
    }
}

#[derive(Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Hash)]
pub struct Value7();
impl ConstValue for Value7 {
    const VAL: i32 = 1_000_000_007;
}
pub type Mod7 = ModWithValue<Value7>;

#[derive(Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Hash)]
pub struct Value9();
impl ConstValue for Value9 {
    const VAL: i32 = 1_000_000_009;
}
pub type Mod9 = ModWithValue<Value9>;

#[derive(Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Hash)]
#[allow(non_camel_case_types)]
pub struct Value_998_244_353();
impl ConstValue for Value_998_244_353 {
    const VAL: i32 = 998_244_353;
}
#[allow(non_camel_case_types)]
pub type Mod_998_244_353 = ModWithValue<Value_998_244_353>;

pub trait ModuloTrait: Number {
    fn mod_value() -> i32;
    fn pown(self, n: usize) -> Self;
}

impl<V: Value> ModuloTrait for ModWithValue<V> {
    fn mod_value() -> i32 {
        V::val()
    }

    fn pown(self, n: usize) -> Self {
        self.pown(n)
    }
}
}
}
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 num_traits {
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;

pub trait HasConstants<T> {
    const MAX: T;
    const MIN: T;
    const ZERO: T;
    const ONE: T;
    const TWO: T;
}

pub trait ConvSimple<T> {
    fn from_i32(val: i32) -> T;
    fn to_i32(self) -> i32;
    fn to_f64(self) -> f64;
}

pub trait Signum {
    fn signum(&self) -> i32;
}

pub trait Number:
    Copy
    + Add<Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Mul<Output = Self>
    + MulAssign
    + Div<Output = Self>
    + DivAssign
    + PartialOrd
    + PartialEq
    + HasConstants<Self>
    + Default
    + Debug
    + Sized
    + ConvSimple<Self>
{
}

impl<
        T: Copy
            + Add<Output = Self>
            + AddAssign
            + Sub<Output = Self>
            + SubAssign
            + Mul<Output = Self>
            + MulAssign
            + Div<Output = Self>
            + DivAssign
            + PartialOrd
            + PartialEq
            + HasConstants<Self>
            + Default
            + Debug
            + Sized
            + ConvSimple<Self>,
    > Number for T
{
}

macro_rules! has_constants_impl {
    ($t: ident) => {
        impl HasConstants<$t> for $t {
            // TODO: remove `std` for new rust version..
            const MAX: $t = std::$t::MAX;
            const MIN: $t = std::$t::MIN;
            const ZERO: $t = 0;
            const ONE: $t = 1;
            const TWO: $t = 2;
        }

        impl ConvSimple<$t> for $t {
            fn from_i32(val: i32) -> $t {
                val as $t
            }

            fn to_i32(self) -> i32 {
                self as i32
            }

            fn to_f64(self) -> f64 {
                self as f64
            }
        }
    };
}

has_constants_impl!(i32);
has_constants_impl!(i64);
has_constants_impl!(i128);
has_constants_impl!(u32);
has_constants_impl!(u64);
has_constants_impl!(u128);
has_constants_impl!(usize);
has_constants_impl!(u8);

impl ConvSimple<Self> for f64 {
    fn from_i32(val: i32) -> Self {
        val as f64
    }

    fn to_i32(self) -> i32 {
        self as i32
    }

    fn to_f64(self) -> f64 {
        self
    }
}

impl HasConstants<Self> for f64 {
    const MAX: Self = Self::MAX;
    const MIN: Self = -Self::MAX;
    const ZERO: Self = 0.0;
    const ONE: Self = 1.0;
    const TWO: Self = 2.0;
}

impl<T: Number + Ord> Signum for T {
    fn signum(&self) -> i32 {
        match self.cmp(&T::ZERO) {
            Ordering::Greater => 1,
            Ordering::Less => -1,
            Ordering::Equal => 0,
        }
    }
}
}
pub mod rec_function {
// Copied from https://github.com/EgorKulikov/rust_algo/blob/master/algo_lib/src/misc/recursive_function.rs

use std::cell::UnsafeCell;
use std::marker::PhantomData;

macro_rules! recursive_function {
    ($name: ident, $trait: ident, ($($type: ident $arg: ident,)*)) => {
        pub trait $trait<$($type, )*Output> {
            fn call(&mut self, $($arg: $type,)*) -> Output;
        }

        pub struct $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            f: UnsafeCell<F>,
            $($arg: PhantomData<$type>,
            )*
            phantom_output: PhantomData<Output>,
        }

        impl<F, $($type, )*Output> $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            pub fn new(f: F) -> Self {
                Self {
                    f : f.into(),
                    $($arg: Default::default(),
                    )*
                    phantom_output: Default::default(),
                }
            }
        }

        impl<F, $($type, )*Output> $trait<$($type, )*Output> for $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            fn call(&mut self, $($arg: $type,)*) -> Output {
                let ptr = self.f.get();
                unsafe { (*ptr)(self, $($arg, )*) }
            }
        }
    }
}

recursive_function!(RecursiveFunction0, Callable0, ());
recursive_function!(RecursiveFunction, Callable, (Arg arg,));
recursive_function!(RecursiveFunction2, Callable2, (Arg1 arg1, Arg2 arg2,));
recursive_function!(RecursiveFunction3, Callable3, (Arg1 arg1, Arg2 arg2, Arg3 arg3,));
recursive_function!(RecursiveFunction4, Callable4, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,));
recursive_function!(RecursiveFunction5, Callable5, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5,));
recursive_function!(RecursiveFunction6, Callable6, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6,));
recursive_function!(RecursiveFunction7, Callable7, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7,));
recursive_function!(RecursiveFunction8, Callable8, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8,));
recursive_function!(RecursiveFunction9, Callable9, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8, Arg9 arg9,));
}
}
}
fn main() {
    let input = algo_lib::io::input::Input::new_stdin();
    let mut output = algo_lib::io::output::Output::new_stdout();
    crate::solution::run(input, output);
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 2136kb

input:

1
HALT; PUSH 1 GOTO 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 2360kb

input:

5
POP 1 GOTO 2; PUSH 1 GOTO 2
HALT; PUSH 1 GOTO 3
POP 1 GOTO 4; PUSH 2 GOTO 4
POP 1 GOTO 2; PUSH 2 GOTO 4
HALT; PUSH 99 GOTO 4

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: 0
Accepted
time: 0ms
memory: 2132kb

input:

1
POP 1 GOTO 1; PUSH 1 GOTO 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 2148kb

input:

61
POP 62 GOTO 61; PUSH 30 GOTO 60
POP 1 GOTO 3; PUSH 62 GOTO 61
POP 2 GOTO 61; PUSH 62 GOTO 61
POP 4 GOTO 7; PUSH 2 GOTO 61
POP 62 GOTO 61; PUSH 3 GOTO 4
POP 62 GOTO 61; PUSH 3 GOTO 5
POP 5 GOTO 10; PUSH 3 GOTO 6
POP 62 GOTO 61; PUSH 4 GOTO 7
POP 62 GOTO 61; PUSH 4 GOTO 8
POP 6 GOTO 12; PUSH 4 GOTO...

output:

150994941

result:

ok 1 number(s): "150994941"

Test #5:

score: 0
Accepted
time: 0ms
memory: 2276kb

input:

60
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 51 GOTO 3; PUSH 51 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 52 GOTO 5; PUSH 52 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 53 GOTO 7; PUSH 53 GOTO 6
POP 4 GOTO 8; PUSH 4 GOTO 1
POP 54 GOTO 9; PUSH 54 GOTO 8
POP 5 GOTO 10; PUSH 5 GOTO 1
POP 55 GOTO 11; PUSH 55 GOTO 10
POP ...

output:

150994941

result:

ok 1 number(s): "150994941"

Test #6:

score: 0
Accepted
time: 1ms
memory: 2988kb

input:

119
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 259 GOTO 5; PUSH 259 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 5 GOTO 7; PUSH 5 GOTO 1
POP 6 GOTO 8; PUSH 6 GOTO 1
POP 7 GOTO 9; PUSH 7 GOTO 1
POP 8 GOTO 10; PUSH 8 GOTO 1
POP 264 GOTO 11; PUSH 264 GOTO 10
POP 9...

output:

944833405

result:

ok 1 number(s): "944833405"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

198
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 257 GOTO 3; PUSH 257 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 258 GOTO 5; PUSH 258 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 259 GOTO 7; PUSH 259 GOTO 6
POP 4 GOTO 8; PUSH 4 GOTO 1
POP 260 GOTO 9; PUSH 260 GOTO 8
POP 5 GOTO 10; PUSH 5 GOTO 1
POP 6 GOTO 11; PUSH 6 GOTO ...

output:

795829251

result:

ok 1 number(s): "795829251"

Test #8:

score: 0
Accepted
time: 3ms
memory: 6240kb

input:

505
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 257 GOTO 3; PUSH 257 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 258 GOTO 5; PUSH 258 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 259 GOTO 7; PUSH 259 GOTO 6
POP 4 GOTO 8; PUSH 4 GOTO 1
POP 260 GOTO 9; PUSH 260 GOTO 8
POP 5 GOTO 10; PUSH 5 GOTO 1
POP 261 GOTO 11; PUSH 261 G...

output:

134514797

result:

ok 1 number(s): "134514797"

Test #9:

score: 0
Accepted
time: 0ms
memory: 6036kb

input:

512
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 257 GOTO 3; PUSH 257 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 258 GOTO 5; PUSH 258 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 259 GOTO 7; PUSH 259 GOTO 6
POP 4 GOTO 8; PUSH 4 GOTO 1
POP 260 GOTO 9; PUSH 260 GOTO 8
POP 5 GOTO 10; PUSH 5 GOTO 1
POP 261 GOTO 11; PUSH 261 G...

output:

339814067

result:

ok 1 number(s): "339814067"

Test #10:

score: 0
Accepted
time: 0ms
memory: 2196kb

input:

19
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 51 GOTO 3; PUSH 51 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 52 GOTO 5; PUSH 52 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 54 GOTO 8; PUSH 54 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 55 GOTO 10; PUSH 55 GOTO 9
POP 6 GOTO 11; PUSH 6 GOTO 1
POP 56 ...

output:

1919

result:

ok 1 number(s): "1919"

Test #11:

score: 0
Accepted
time: 0ms
memory: 2300kb

input:

21
POP 22 GOTO 21; PUSH 6 GOTO 20
POP 1 GOTO 3; PUSH 22 GOTO 21
POP 2 GOTO 21; PUSH 22 GOTO 21
POP 22 GOTO 21; PUSH 2 GOTO 21
POP 4 GOTO 7; PUSH 2 GOTO 4
POP 22 GOTO 21; PUSH 3 GOTO 5
POP 5 GOTO 10; PUSH 3 GOTO 6
POP 22 GOTO 21; PUSH 4 GOTO 7
POP 22 GOTO 21; PUSH 4 GOTO 8
POP 6 GOTO 14; PUSH 4 GOTO ...

output:

1919

result:

ok 1 number(s): "1919"

Test #12:

score: 0
Accepted
time: 0ms
memory: 2272kb

input:

21
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 52 GOTO 4; PUSH 52 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 53 GOTO 6; PUSH 53 GOTO 5
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 56 GOTO 10; PUSH 56 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
POP 8 GOT...

output:

11451

result:

ok 1 number(s): "11451"

Test #13:

score: 0
Accepted
time: 0ms
memory: 2144kb

input:

25
POP 26 GOTO 25; PUSH 9 GOTO 24
POP 1 GOTO 3; PUSH 26 GOTO 25
POP 2 GOTO 25; PUSH 26 GOTO 25
POP 26 GOTO 25; PUSH 2 GOTO 25
POP 4 GOTO 7; PUSH 2 GOTO 4
POP 26 GOTO 25; PUSH 3 GOTO 5
POP 5 GOTO 9; PUSH 3 GOTO 6
POP 26 GOTO 25; PUSH 4 GOTO 7
POP 6 GOTO 11; PUSH 4 GOTO 8
POP 26 GOTO 25; PUSH 5 GOTO 9...

output:

11451

result:

ok 1 number(s): "11451"

Test #14:

score: 0
Accepted
time: 0ms
memory: 2344kb

input:

30
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 53 GOTO 5; PUSH 53 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 5 GOTO 7; PUSH 5 GOTO 1
POP 55 GOTO 8; PUSH 55 GOTO 7
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 56 GOTO 10; PUSH 56 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
POP 8 GOT...

output:

1234567

result:

ok 1 number(s): "1234567"

Test #15:

score: 0
Accepted
time: 0ms
memory: 2192kb

input:

38
POP 39 GOTO 38; PUSH 13 GOTO 37
POP 1 GOTO 3; PUSH 39 GOTO 38
POP 2 GOTO 38; PUSH 39 GOTO 38
POP 4 GOTO 7; PUSH 2 GOTO 38
POP 39 GOTO 38; PUSH 3 GOTO 4
POP 39 GOTO 38; PUSH 3 GOTO 5
POP 5 GOTO 10; PUSH 3 GOTO 6
POP 39 GOTO 38; PUSH 4 GOTO 7
POP 39 GOTO 38; PUSH 4 GOTO 8
POP 6 GOTO 12; PUSH 4 GOTO...

output:

1234567

result:

ok 1 number(s): "1234567"

Test #16:

score: 0
Accepted
time: 0ms
memory: 2216kb

input:

41
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 51 GOTO 3; PUSH 51 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 52 GOTO 5; PUSH 52 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 54 GOTO 8; PUSH 54 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 6 GOTO 10; PUSH 6 GOTO 1
POP 56 GOTO 11; PUSH 56 GOTO 10
POP 7 ...

output:

123456789

result:

ok 1 number(s): "123456789"

Test #17:

score: 0
Accepted
time: 0ms
memory: 2088kb

input:

53
POP 54 GOTO 53; PUSH 22 GOTO 52
POP 1 GOTO 3; PUSH 54 GOTO 53
POP 2 GOTO 53; PUSH 54 GOTO 53
POP 54 GOTO 53; PUSH 2 GOTO 53
POP 54 GOTO 53; PUSH 2 GOTO 4
POP 4 GOTO 8; PUSH 2 GOTO 5
POP 54 GOTO 53; PUSH 3 GOTO 6
POP 5 GOTO 11; PUSH 3 GOTO 7
POP 54 GOTO 53; PUSH 4 GOTO 8
POP 54 GOTO 53; PUSH 4 GOT...

output:

123456789

result:

ok 1 number(s): "123456789"

Test #18:

score: 0
Accepted
time: 0ms
memory: 2392kb

input:

59
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 51 GOTO 3; PUSH 51 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 52 GOTO 5; PUSH 52 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 53 GOTO 7; PUSH 53 GOTO 6
POP 4 GOTO 8; PUSH 4 GOTO 1
POP 54 GOTO 9; PUSH 54 GOTO 8
POP 5 GOTO 10; PUSH 5 GOTO 1
POP 55 GOTO 11; PUSH 55 GOTO 10
POP ...

output:

150994939

result:

ok 1 number(s): "150994939"

Test #19:

score: 0
Accepted
time: 0ms
memory: 2424kb

input:

61
POP 62 GOTO 61; PUSH 25 GOTO 60
POP 1 GOTO 3; PUSH 62 GOTO 61
POP 2 GOTO 61; PUSH 62 GOTO 61
POP 4 GOTO 8; PUSH 2 GOTO 61
POP 62 GOTO 61; PUSH 3 GOTO 4
POP 62 GOTO 61; PUSH 3 GOTO 5
POP 62 GOTO 61; PUSH 3 GOTO 6
POP 5 GOTO 11; PUSH 3 GOTO 7
POP 62 GOTO 61; PUSH 4 GOTO 8
POP 62 GOTO 61; PUSH 4 GOT...

output:

150994941

result:

ok 1 number(s): "150994941"

Test #20:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

106
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 515 GOTO 5; PUSH 515 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 518 GOTO 10; PUSH 518 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

547101648

result:

ok 1 number(s): "547101648"

Test #21:

score: 0
Accepted
time: 3ms
memory: 7400kb

input:

339
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 515 GOTO 5; PUSH 515 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 5 GOTO 7; PUSH 5 GOTO 1
POP 6 GOTO 8; PUSH 6 GOTO 1
POP 518 GOTO 9; PUSH 518 GOTO 8
POP 7 GOTO 10; PUSH 7 GOTO 1
POP 8 GOTO 11; PUSH 8 GOTO 1
POP 9 ...

output:

761576546

result:

ok 1 number(s): "761576546"

Test #22:

score: 0
Accepted
time: 3ms
memory: 8124kb

input:

381
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 514 GOTO 4; PUSH 514 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 518 GOTO 10; PUSH 518 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

722131913

result:

ok 1 number(s): "722131913"

Test #23:

score: 0
Accepted
time: 3ms
memory: 8092kb

input:

381
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 514 GOTO 4; PUSH 514 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 518 GOTO 10; PUSH 518 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

722131911

result:

ok 1 number(s): "722131911"

Test #24:

score: 0
Accepted
time: 3ms
memory: 14620kb

input:

765
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 514 GOTO 4; PUSH 514 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 518 GOTO 10; PUSH 518 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

685576713

result:

ok 1 number(s): "685576713"

Test #25:

score: 0
Accepted
time: 7ms
memory: 14720kb

input:

765
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 514 GOTO 4; PUSH 514 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 518 GOTO 10; PUSH 518 GOTO 9
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

685576715

result:

ok 1 number(s): "685576715"

Test #26:

score: 0
Accepted
time: 8ms
memory: 18072kb

input:

969
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 515 GOTO 5; PUSH 515 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 517 GOTO 9; PUSH 517 GOTO 8
POP 6 GOTO 10; PUSH 6 GOTO 1
POP 7 GOTO 11; PUSH 7 GOTO 1
PO...

output:

921893460

result:

ok 1 number(s): "921893460"

Test #27:

score: 0
Accepted
time: 8ms
memory: 18100kb

input:

994
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 515 GOTO 5; PUSH 515 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 6 GOTO 9; PUSH 6 GOTO 1
POP 7 GOTO 10; PUSH 7 GOTO 1
POP 8 GOTO 11; PUSH 8 GOTO 1
POP 52...

output:

96242942

result:

ok 1 number(s): "96242942"

Test #28:

score: 0
Accepted
time: 0ms
memory: 2148kb

input:

64
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO 1...

output:

932051909

result:

ok 1 number(s): "932051909"

Test #29:

score: 0
Accepted
time: 0ms
memory: 2236kb

input:

128
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO ...

output:

299560063

result:

ok 1 number(s): "299560063"

Test #30:

score: 0
Accepted
time: 1ms
memory: 3016kb

input:

256
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO ...

output:

169907033

result:

ok 1 number(s): "169907033"

Test #31:

score: 0
Accepted
time: 4ms
memory: 6224kb

input:

512
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO ...

output:

60241439

result:

ok 1 number(s): "60241439"

Test #32:

score: 0
Accepted
time: 13ms
memory: 18656kb

input:

1023
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO...

output:

796722581

result:

ok 1 number(s): "796722581"

Test #33:

score: 0
Accepted
time: 14ms
memory: 18604kb

input:

1024
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO...

output:

595200810

result:

ok 1 number(s): "595200810"

Test #34:

score: 0
Accepted
time: 9ms
memory: 18624kb

input:

1024
POP 1 GOTO 1; PUSH 1023 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 2
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 2
POP 7 GOTO 8; PUSH 7 GOTO 2
POP 8 GOTO 9; PUSH 8 GOTO 2
POP 9 GOTO 10; PUSH 9 GOTO 2
POP 10 GOTO 11; PUSH 10 GOTO 2
POP 11 G...

output:

694574278

result:

ok 1 number(s): "694574278"

Test #35:

score: 0
Accepted
time: 4ms
memory: 18760kb

input:

1023
POP 1 GOTO 1; PUSH 1023 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 2
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 2
POP 7 GOTO 8; PUSH 7 GOTO 2
POP 8 GOTO 9; PUSH 8 GOTO 2
POP 9 GOTO 10; PUSH 9 GOTO 2
POP 10 GOTO 11; PUSH 10 GOTO 2
POP 11 G...

output:

91626451

result:

ok 1 number(s): "91626451"

Test #36:

score: 0
Accepted
time: 9ms
memory: 18756kb

input:

1022
POP 1 GOTO 1; PUSH 1023 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 2
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 2
POP 7 GOTO 8; PUSH 7 GOTO 2
POP 8 GOTO 9; PUSH 8 GOTO 2
POP 9 GOTO 10; PUSH 9 GOTO 2
POP 10 GOTO 11; PUSH 10 GOTO 2
POP 11 G...

output:

693013925

result:

ok 1 number(s): "693013925"

Test #37:

score: 0
Accepted
time: 14ms
memory: 18656kb

input:

1022
POP 1 GOTO 1; PUSH 1023 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 2
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 2
POP 7 GOTO 8; PUSH 7 GOTO 2
POP 8 GOTO 9; PUSH 8 GOTO 2
POP 9 GOTO 10; PUSH 9 GOTO 2
POP 10 GOTO 11; PUSH 10 GOTO 2
POP 11 G...

output:

894858942

result:

ok 1 number(s): "894858942"

Test #38:

score: 0
Accepted
time: 7ms
memory: 18516kb

input:

1022
POP 1 GOTO 1; PUSH 1023 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 2
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 2
POP 7 GOTO 8; PUSH 7 GOTO 2
POP 8 GOTO 9; PUSH 8 GOTO 2
POP 9 GOTO 10; PUSH 9 GOTO 2
POP 10 GOTO 11; PUSH 10 GOTO 2
POP 11 G...

output:

327292712

result:

ok 1 number(s): "327292712"

Test #39:

score: 0
Accepted
time: 0ms
memory: 2224kb

input:

1024
POP 1 GOTO 51; PUSH 1 GOTO 558
POP 1 GOTO 782; PUSH 1 GOTO 139
POP 1 GOTO 459; PUSH 1 GOTO 318
HALT; PUSH 1 GOTO 334
POP 1 GOTO 724; PUSH 1 GOTO 937
POP 1 GOTO 176; PUSH 1 GOTO 302
POP 1 GOTO 488; PUSH 1 GOTO 750
POP 1 GOTO 312; PUSH 1 GOTO 701
POP 1 GOTO 66; PUSH 1 GOTO 216
HALT; PUSH 1 GOTO 3...

output:

-1

result:

ok 1 number(s): "-1"

Test #40:

score: 0
Accepted
time: 0ms
memory: 2280kb

input:

1024
POP 2 GOTO 856; PUSH 1 GOTO 307
HALT; PUSH 1 GOTO 2
POP 2 GOTO 351; PUSH 2 GOTO 360
POP 1 GOTO 398; PUSH 1 GOTO 724
POP 1 GOTO 789; PUSH 2 GOTO 606
POP 1 GOTO 253; PUSH 2 GOTO 459
POP 1 GOTO 615; PUSH 1 GOTO 834
POP 2 GOTO 802; PUSH 2 GOTO 120
POP 2 GOTO 836; PUSH 1 GOTO 45
POP 1 GOTO 701; PUSH...

output:

-1

result:

ok 1 number(s): "-1"

Test #41:

score: 0
Accepted
time: 0ms
memory: 2284kb

input:

1024
POP 3 GOTO 638; PUSH 2 GOTO 57
POP 3 GOTO 805; PUSH 1 GOTO 504
POP 3 GOTO 589; PUSH 2 GOTO 100
POP 1 GOTO 312; PUSH 1 GOTO 84
POP 3 GOTO 627; PUSH 1 GOTO 706
HALT; PUSH 2 GOTO 616
POP 3 GOTO 741; PUSH 2 GOTO 917
POP 2 GOTO 268; PUSH 3 GOTO 562
POP 2 GOTO 583; PUSH 3 GOTO 898
POP 2 GOTO 953; PUS...

output:

-1

result:

ok 1 number(s): "-1"

Test #42:

score: 0
Accepted
time: 0ms
memory: 2272kb

input:

1024
POP 2 GOTO 1013; PUSH 1 GOTO 257
HALT; PUSH 1 GOTO 884
POP 1 GOTO 934; PUSH 1 GOTO 813
POP 2 GOTO 198; PUSH 1 GOTO 289
POP 2 GOTO 566; PUSH 1 GOTO 639
HALT; PUSH 1 GOTO 771
POP 1 GOTO 786; PUSH 1 GOTO 470
POP 2 GOTO 654; PUSH 1 GOTO 613
POP 2 GOTO 941; PUSH 1 GOTO 974
POP 1 GOTO 567; PUSH 2 GOT...

output:

-1

result:

ok 1 number(s): "-1"

Test #43:

score: 0
Accepted
time: 0ms
memory: 2360kb

input:

1024
POP 3 GOTO 93; PUSH 3 GOTO 186
POP 3 GOTO 134; PUSH 3 GOTO 465
HALT; PUSH 3 GOTO 296
POP 2 GOTO 34; PUSH 1 GOTO 121
POP 2 GOTO 742; PUSH 2 GOTO 347
POP 1 GOTO 194; PUSH 2 GOTO 686
POP 1 GOTO 925; PUSH 3 GOTO 785
POP 2 GOTO 207; PUSH 3 GOTO 285
POP 3 GOTO 545; PUSH 1 GOTO 246
POP 2 GOTO 60; PUSH...

output:

-1

result:

ok 1 number(s): "-1"

Test #44:

score: 0
Accepted
time: 0ms
memory: 18348kb

input:

1024
POP 444 GOTO 458; PUSH 498 GOTO 347
HALT; PUSH 235 GOTO 270
POP 378 GOTO 912; PUSH 333 GOTO 478
POP 574 GOTO 942; PUSH 618 GOTO 1005
POP 517 GOTO 595; PUSH 656 GOTO 1007
POP 734 GOTO 1024; PUSH 1010 GOTO 212
POP 248 GOTO 4; PUSH 67 GOTO 997
POP 995 GOTO 914; PUSH 236 GOTO 210
POP 540 GOTO 614; ...

output:

-1

result:

ok 1 number(s): "-1"

Test #45:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

1024
POP 66 GOTO 580; PUSH 64 GOTO 956
POP 52 GOTO 1001; PUSH 97 GOTO 165
HALT; PUSH 15 GOTO 344
POP 69 GOTO 87; PUSH 31 GOTO 85
POP 71 GOTO 970; PUSH 12 GOTO 342
POP 85 GOTO 386; PUSH 4 GOTO 518
POP 83 GOTO 534; PUSH 58 GOTO 259
POP 38 GOTO 621; PUSH 16 GOTO 252
POP 38 GOTO 216; PUSH 87 GOTO 225
PO...

output:

-1

result:

ok 1 number(s): "-1"

Test #46:

score: 0
Accepted
time: 0ms
memory: 2224kb

input:

1024
POP 1 GOTO 1008; PUSH 1 GOTO 51
HALT; PUSH 1 GOTO 163
HALT; PUSH 1 GOTO 139
HALT; PUSH 1 GOTO 974
POP 1 GOTO 803; PUSH 1 GOTO 334
HALT; PUSH 1 GOTO 906
HALT; PUSH 1 GOTO 213
HALT; PUSH 1 GOTO 176
HALT; PUSH 1 GOTO 735
HALT; PUSH 1 GOTO 750
HALT; PUSH 1 GOTO 658
HALT; PUSH 1 GOTO 18
POP 1 GOTO 2...

output:

5

result:

ok 1 number(s): "5"

Test #47:

score: 0
Accepted
time: 0ms
memory: 2256kb

input:

1024
POP 2 GOTO 825; PUSH 2 GOTO 856
POP 2 GOTO 2; PUSH 1 GOTO 794
HALT; PUSH 2 GOTO 351
HALT; PUSH 2 GOTO 209
POP 2 GOTO 118; PUSH 2 GOTO 611
HALT; PUSH 1 GOTO 606
HALT; PUSH 1 GOTO 834
POP 1 GOTO 829; PUSH 1 GOTO 855
POP 2 GOTO 902; PUSH 2 GOTO 570
HALT; PUSH 2 GOTO 311
HALT; PUSH 1 GOTO 836
POP 1...

output:

-1

result:

ok 1 number(s): "-1"

Test #48:

score: 0
Accepted
time: 0ms
memory: 2208kb

input:

1024
POP 3 GOTO 643; PUSH 3 GOTO 638
POP 1 GOTO 118; PUSH 3 GOTO 805
HALT; PUSH 3 GOTO 31
HALT; PUSH 2 GOTO 100
HALT; PUSH 1 GOTO 90
HALT; PUSH 3 GOTO 787
POP 1 GOTO 706; PUSH 2 GOTO 130
HALT; PUSH 3 GOTO 859
POP 2 GOTO 917; PUSH 3 GOTO 872
HALT; PUSH 3 GOTO 268
HALT; PUSH 1 GOTO 283
HALT; PUSH 3 GO...

output:

-1

result:

ok 1 number(s): "-1"

Test #49:

score: 0
Accepted
time: 0ms
memory: 2220kb

input:

1024
POP 1 GOTO 299; PUSH 2 GOTO 1013
POP 2 GOTO 884; PUSH 1 GOTO 317
POP 1 GOTO 813; PUSH 2 GOTO 560
HALT; PUSH 1 GOTO 198
POP 2 GOTO 719; PUSH 2 GOTO 566
POP 2 GOTO 771; PUSH 1 GOTO 197
POP 1 GOTO 470; PUSH 2 GOTO 135
HALT; PUSH 1 GOTO 654
POP 1 GOTO 481; PUSH 2 GOTO 941
HALT; PUSH 1 GOTO 851
HALT...

output:

3

result:

ok 1 number(s): "3"

Test #50:

score: 0
Accepted
time: 0ms
memory: 2240kb

input:

1024
POP 2 GOTO 1022; PUSH 3 GOTO 93
HALT; PUSH 3 GOTO 823
POP 1 GOTO 140; PUSH 1 GOTO 218
HALT; PUSH 3 GOTO 922
POP 2 GOTO 999; PUSH 2 GOTO 24
HALT; PUSH 3 GOTO 347
HALT; PUSH 1 GOTO 301
HALT; PUSH 1 GOTO 338
POP 3 GOTO 785; PUSH 1 GOTO 312
HALT; PUSH 3 GOTO 207
POP 3 GOTO 101; PUSH 3 GOTO 545
HALT...

output:

-1

result:

ok 1 number(s): "-1"

Test #51:

score: 0
Accepted
time: 2ms
memory: 18324kb

input:

1024
POP 953 GOTO 498; PUSH 444 GOTO 458
POP 758 GOTO 270; PUSH 235 GOTO 190
HALT; PUSH 333 GOTO 912
HALT; PUSH 551 GOTO 574
HALT; PUSH 942 GOTO 1005
HALT; PUSH 517 GOTO 656
POP 1007 GOTO 734; PUSH 162 GOTO 1010
HALT; PUSH 212 GOTO 869
HALT; PUSH 67 GOTO 4
POP 422 GOTO 236; PUSH 995 GOTO 914
HALT; P...

output:

-1

result:

ok 1 number(s): "-1"

Test #52:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1024
POP 93 GOTO 684; PUSH 66 GOTO 580
HALT; PUSH 31 GOTO 328
POP 41 GOTO 62; PUSH 13 GOTO 243
HALT; PUSH 4 GOTO 345
POP 43 GOTO 389; PUSH 41 GOTO 443
HALT; PUSH 42 GOTO 342
POP 85 GOTO 386; PUSH 4 GOTO 518
HALT; PUSH 83 GOTO 866
HALT; PUSH 23 GOTO 822
HALT; PUSH 16 GOTO 621
HALT; PUSH 90 GOTO 374
P...

output:

-1

result:

ok 1 number(s): "-1"

Test #53:

score: 0
Accepted
time: 0ms
memory: 2232kb

input:

3
POP 1 GOTO 3; PUSH 1 GOTO 1
HALT; PUSH 2 GOTO 2
POP 1 GOTO 2; PUSH 1 GOTO 1

output:

-1

result:

ok 1 number(s): "-1"

Test #54:

score: 0
Accepted
time: 11ms
memory: 18664kb

input:

1024
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 29 GOTO 3; PUSH 29 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 30 GOTO 5; PUSH 30 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 31 GOTO 8; PUSH 31 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 32 GOTO 10; PUSH 32 GOTO 9
POP 6 GOTO 11; PUSH 6 GOTO 1
POP 7...

output:

421359732

result:

ok 1 number(s): "421359732"

Test #55:

score: 0
Accepted
time: 0ms
memory: 2500kb

input:

35
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 513 GOTO 3; PUSH 513 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 514 GOTO 5; PUSH 514 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 516 GOTO 8; PUSH 516 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 517 GOTO 10; PUSH 517 GOTO 9
POP 6 GOTO 11; PUSH 6 GOTO 1...

output:

0

result:

ok 1 number(s): "0"

Test #56:

score: 0
Accepted
time: 0ms
memory: 2372kb

input:

36
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 513 GOTO 3; PUSH 513 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 514 GOTO 5; PUSH 514 GOTO 4
POP 3 GOTO 6; PUSH 3 GOTO 1
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 516 GOTO 8; PUSH 516 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 517 GOTO 10; PUSH 517 GOTO 9
POP 6 GOTO 11; PUSH 6 GOTO 1...

output:

998244352

result:

ok 1 number(s): "998244352"

Test #57:

score: 0
Accepted
time: 0ms
memory: 18172kb

input:

997
POP 1024 GOTO 1; PUSH 1 GOTO 2
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 31 GOTO 4; PUSH 31 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 2
POP 32 GOTO 6; PUSH 32 GOTO 5
POP 4 GOTO 7; PUSH 4 GOTO 2
POP 5 GOTO 8; PUSH 5 GOTO 2
POP 33 GOTO 9; PUSH 33 GOTO 8
POP 6 GOTO 10; PUSH 6 GOTO 2
POP 34 GOTO 11; PUSH 34 GOTO 10
PO...

output:

0

result:

ok 1 number(s): "0"

Test #58:

score: 0
Accepted
time: 6ms
memory: 18768kb

input:

1023
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 2
POP 3 GOTO 4; PUSH 3 GOTO 2
POP 4 GOTO 5; PUSH 4 GOTO 3
POP 5 GOTO 6; PUSH 5 GOTO 2
POP 6 GOTO 7; PUSH 6 GOTO 4
POP 7 GOTO 8; PUSH 7 GOTO 7
POP 8 GOTO 9; PUSH 8 GOTO 6
POP 9 GOTO 10; PUSH 9 GOTO 8
POP 10 GOTO 11; PUSH 10 GOTO 10
POP 11 GOT...

output:

446955861

result:

ok 1 number(s): "446955861"

Test #59:

score: 0
Accepted
time: 6ms
memory: 18044kb

input:

988
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 3
POP 4 GOTO 5; PUSH 4 GOTO 4
POP 5 GOTO 6; PUSH 5 GOTO 4
POP 1019 GOTO 7; PUSH 1019 GOTO 6
POP 6 GOTO 8; PUSH 6 GOTO 2
POP 7 GOTO 9; PUSH 7 GOTO 8
POP 8 GOTO 10; PUSH 8 GOTO 6
POP 9 GOTO 11; PUSH 9 GOTO 2
POP 10 G...

output:

-1

result:

ok 1 number(s): "-1"

Test #60:

score: 0
Accepted
time: 5ms
memory: 14280kb

input:

751
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 1022 GOTO 4; PUSH 1022 GOTO 3
POP 3 GOTO 5; PUSH 3 GOTO 2
POP 1020 GOTO 6; PUSH 1020 GOTO 5
POP 4 GOTO 7; PUSH 4 GOTO 2
POP 5 GOTO 8; PUSH 5 GOTO 3
POP 6 GOTO 9; PUSH 6 GOTO 3
POP 7 GOTO 10; PUSH 7 GOTO 5
POP 1015 GOTO 11; PUSH 1015 GOT...

output:

-1

result:

ok 1 number(s): "-1"

Test #61:

score: 0
Accepted
time: 11ms
memory: 18504kb

input:

1023
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO...

output:

398361292

result:

ok 1 number(s): "398361292"

Test #62:

score: 0
Accepted
time: 14ms
memory: 18608kb

input:

1024
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 4 GOTO 5; PUSH 4 GOTO 1
POP 5 GOTO 6; PUSH 5 GOTO 1
POP 6 GOTO 7; PUSH 6 GOTO 1
POP 7 GOTO 8; PUSH 7 GOTO 1
POP 8 GOTO 9; PUSH 8 GOTO 1
POP 9 GOTO 10; PUSH 9 GOTO 1
POP 10 GOTO 11; PUSH 10 GOTO 1
POP 11 GOTO...

output:

796722583

result:

ok 1 number(s): "796722583"

Test #63:

score: 0
Accepted
time: 0ms
memory: 3292kb

input:

73
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 513 GOTO 3; PUSH 513 GOTO 2
POP 2 GOTO 4; PUSH 2 GOTO 1
POP 3 GOTO 5; PUSH 3 GOTO 1
POP 515 GOTO 6; PUSH 515 GOTO 5
POP 4 GOTO 7; PUSH 4 GOTO 1
POP 516 GOTO 8; PUSH 516 GOTO 7
POP 5 GOTO 9; PUSH 5 GOTO 1
POP 517 GOTO 10; PUSH 517 GOTO 9
POP 6 GOTO 11; PUSH 6 GOTO 1...

output:

0

result:

ok 1 number(s): "0"

Test #64:

score: 0
Accepted
time: 7ms
memory: 13368kb

input:

686
POP 1 GOTO 2; PUSH 1 GOTO 1
POP 2 GOTO 3; PUSH 2 GOTO 1
POP 3 GOTO 4; PUSH 3 GOTO 1
POP 515 GOTO 5; PUSH 515 GOTO 4
POP 4 GOTO 6; PUSH 4 GOTO 1
POP 516 GOTO 7; PUSH 516 GOTO 6
POP 5 GOTO 8; PUSH 5 GOTO 1
POP 517 GOTO 9; PUSH 517 GOTO 8
POP 6 GOTO 10; PUSH 6 GOTO 1
POP 518 GOTO 11; PUSH 518 GOTO ...

output:

0

result:

ok 1 number(s): "0"

Extra Test:

score: 0
Extra Test Passed