結果

問題 No.2450 99-like Number
ユーザー masookamasooka
提出日時 2023-09-02 23:21:30
言語 Rust
(1.77.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 34,238 bytes
コンパイル時間 13,119 ms
コンパイル使用メモリ 385,576 KB
最終ジャッジ日時 2024-06-12 05:24:31
合計ジャッジ時間 13,897 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
error[E0659]: `proconio` is ambiguous
 --> src/main.rs:5:5
  |
5 | use proconio::input;
  |     ^^^^^^^^ ambiguous name
  |
  = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
  = note: `proconio` could refer to a crate passed with `--extern`
  = help: use `::proconio` to refer to this crate unambiguously
note: `proconio` could also refer to the module imported here
 --> src/main.rs:1:9
  |
1 | pub use __cargo_equip::prelude::*;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: consider adding an explicit import of `proconio` to disambiguate
  = help: or use `crate::proconio` to refer to this module unambiguously

For more information about this error, try `rustc --explain E0659`.
error: could not compile `main` (bin "main") due to 1 previous error

ソースコード

diff #

pub use __cargo_equip::prelude::*;

extern crate alloc;

use proconio::input;

fn main() {
    input! {
        n: String,
    }

    if n.chars().all(|c| c == '9') {
        println!("Yes");
    } else {
        println!("No");
    }
}

// The following code was expanded by `cargo-equip`.

///  # Bundled libraries
/// 
///  - `once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)` licensed under `MIT OR Apache-2.0` as `crate::__cargo_equip::crates::__once_cell_1_14_0`
///  - `proconio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)`   licensed under `MIT OR Apache-2.0` as `crate::__cargo_equip::crates::proconio`
/// 
///  # License and Copyright Notices
/// 
///  - `once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)`
/// 
///      ```text
///      Permission is hereby granted, free of charge, to any
///      person obtaining a copy of this software and associated
///      documentation files (the "Software"), to deal in the
///      Software without restriction, including without
///      limitation the rights to use, copy, modify, merge,
///      publish, distribute, sublicense, and/or sell copies of
///      the Software, and to permit persons to whom the Software
///      is furnished to do so, subject to the following
///      conditions:
/// 
///      The above copyright notice and this permission notice
///      shall be included in all copies or substantial portions
///      of the Software.
/// 
///      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
///      ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
///      TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
///      PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
///      SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
///      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
///      OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
///      IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
///      DEALINGS IN THE SOFTWARE.
///      ```
/// 
///  - `proconio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)`
/// 
///      ```text
///      The MIT License
///      Copyright 2019 (C) statiolake <statiolake@gmail.com>
/// 
///      Permission is hereby granted, free of charge, to any person obtaining a copy of
///      this software and associated documentation files (the "Software"), to deal in
///      the Software without restriction, including without limitation the rights to
///      use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
///      the Software, and to permit persons to whom the Software is furnished to do so,
///      subject to the following conditions:
/// 
///      The above copyright notice and this permission notice shall be included in all
///      copies or substantial portions of the Software.
/// 
///      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
///      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
///      FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
///      COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
///      IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
///      CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/// 
///      Copyright for original `input!` macro is held by Hideyuki Tanaka, 2019.  The
///      original macro is licensed under BSD 3-clause license.
/// 
///      Redistribution and use in source and binary forms, with or without
///      modification, are permitted provided that the following conditions are met:
/// 
///      1. Redistributions of source code must retain the above copyright notice, this
///         list of conditions and the following disclaimer.
/// 
///      2. Redistributions in binary form must reproduce the above copyright notice,
///         this list of conditions and the following disclaimer in the documentation
///         and/or other materials provided with the distribution.
/// 
///      3. Neither the name of the copyright holder nor the names of its contributors
///         may be used to endorse or promote products derived from this software
///         without specific prior written permission.
/// 
///      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
///      ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
///      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
///      DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
///      FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
///      DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
///      SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
///      CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
///      OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
///      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///      ```
#[cfg_attr(any(), rustfmt::skip)]
#[allow(unused)]
mod __cargo_equip {
    pub(crate) mod crates {
        pub mod __once_cell_1_14_0 {extern crate alloc;#[path="imp_std.rs"]mod imp{use std::{cell::{Cell,UnsafeCell},hint::unreachable_unchecked,marker::PhantomData,panic::{RefUnwindSafe,UnwindSafe},sync::atomic::{AtomicBool,AtomicPtr,Ordering},thread::{self,Thread},};use crate::__cargo_equip::crates::__once_cell_1_14_0::take_unchecked;#[derive(Debug)]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)struct OnceCell<T>{queue:AtomicPtr<Waiter>,_marker:PhantomData<*mut Waiter>,value:UnsafeCell<Option<T>>,}unsafe impl<T:Sync+Send>Sync for OnceCell<T>{}unsafe impl<T:Send>Send for OnceCell<T>{}impl<T:RefUnwindSafe+UnwindSafe>RefUnwindSafe for OnceCell<T>{}impl<T:UnwindSafe>UnwindSafe for OnceCell<T>{}impl<T>OnceCell<T>{pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)const fn new()->OnceCell<T>{OnceCell{queue:AtomicPtr::new(INCOMPLETE_PTR),_marker:PhantomData,value:UnsafeCell::new(None),}}pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)const fn with_value(value:T)->OnceCell<T>{OnceCell{queue:AtomicPtr::new(COMPLETE_PTR),_marker:PhantomData,value:UnsafeCell::new(Some(value)),}}#[inline]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn is_initialized(&self)->bool{self.queue.load(Ordering::Acquire)==COMPLETE_PTR}#[cold]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn initialize<F,E>(&self,f:F)->Result<(),E>where F:FnOnce()->Result<T,E>,{let mut f=Some(f);let mut res:Result<(),E> =Ok(());let slot:*mut Option<T> =self.value.get();initialize_or_wait(&self.queue,Some(&mut||{let f=unsafe{take_unchecked(&mut f)};match f(){Ok(value)=>{unsafe{*slot=Some(value)};true}Err(err)=>{res=Err(err);false}}}),);res}#[cold]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn wait(&self){initialize_or_wait(&self.queue,None);}pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)unsafe fn get_unchecked(&self)->&T{debug_assert!(self.is_initialized());let slot:&Option<T> =&*self.value.get();match slot{Some(value)=>value,None=>{debug_assert!(false);unreachable_unchecked()}}}pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn get_mut(&mut self)->Option<&mut T>{unsafe{&mut*self.value.get()}.as_mut()}#[inline]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn into_inner(self)->Option<T>{self.value.into_inner()}}const INCOMPLETE:usize=0x0;const RUNNING:usize=0x1;const COMPLETE:usize=0x2;const INCOMPLETE_PTR:*mut Waiter=INCOMPLETE as*mut Waiter;const COMPLETE_PTR:*mut Waiter=COMPLETE as*mut Waiter;const STATE_MASK:usize=0x3;#[repr(align(4))]struct Waiter{thread:Cell<Option<Thread>>,signaled:AtomicBool,next:*mut Waiter,}struct Guard<'a>{queue:&'a AtomicPtr<Waiter>,new_queue:*mut Waiter,}impl Drop for Guard<'_>{fn drop(&mut self){let queue=self.queue.swap(self.new_queue,Ordering::AcqRel);let state=strict::addr(queue)&STATE_MASK;assert_eq!(state,RUNNING);unsafe{let mut waiter=strict::map_addr(queue,|q|q&!STATE_MASK);while!waiter.is_null(){let next=(*waiter).next;let thread=(*waiter).thread.take().unwrap();(*waiter).signaled.store(true,Ordering::Release);waiter=next;thread.unpark();}}}}#[inline(never)]fn initialize_or_wait(queue:&AtomicPtr<Waiter>,mut init:Option<&mut dyn FnMut()->bool>){let mut curr_queue=queue.load(Ordering::Acquire);loop{let curr_state=strict::addr(curr_queue)&STATE_MASK;match(curr_state,&mut init){(COMPLETE,_)=>return,(INCOMPLETE,Some(init))=>{let exchange=queue.compare_exchange(curr_queue,strict::map_addr(curr_queue,|q|(q&!STATE_MASK)|RUNNING),Ordering::Acquire,Ordering::Acquire,);if let Err(new_queue)=exchange{curr_queue=new_queue;continue;}let mut guard=Guard{queue,new_queue:INCOMPLETE_PTR};if init(){guard.new_queue=COMPLETE_PTR;}return;}(INCOMPLETE,None)|(RUNNING,_)=>{wait(&queue,curr_queue);curr_queue=queue.load(Ordering::Acquire);}_=>debug_assert!(false),}}}fn wait(queue:&AtomicPtr<Waiter>,mut curr_queue:*mut Waiter){let curr_state=strict::addr(curr_queue)&STATE_MASK;loop{let node=Waiter{thread:Cell::new(Some(thread::current())),signaled:AtomicBool::new(false),next:strict::map_addr(curr_queue,|q|q&!STATE_MASK),};let me=&node as*const Waiter as*mut Waiter;let exchange=queue.compare_exchange(curr_queue,strict::map_addr(me,|q|q|curr_state),Ordering::Release,Ordering::Relaxed,);if let Err(new_queue)=exchange{if strict::addr(new_queue)&STATE_MASK!=curr_state{return;}curr_queue=new_queue;continue;}while!node.signaled.load(Ordering::Acquire){thread::park();}break;}}mod strict{#[must_use]#[inline]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn addr<T>(ptr:*mut T)->usize where T:Sized,{unsafe{core::mem::transmute(ptr)}}#[must_use]#[inline]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn with_addr<T>(ptr:*mut T,addr:usize)->*mut T where T:Sized,{let self_addr=self::addr(ptr)as isize;let dest_addr=addr as isize;let offset=dest_addr.wrapping_sub(self_addr);(ptr as*mut u8).wrapping_offset(offset)as*mut T}#[must_use]#[inline]pub(in crate::__cargo_equip::crates::__once_cell_1_14_0)fn map_addr<T>(ptr:*mut T,f:impl FnOnce(usize)->usize)->*mut T where T:Sized,{self::with_addr(ptr,f(addr(ptr)))}}}pub mod unsync{use core::{cell::{Cell,UnsafeCell},fmt,hint,mem,ops::{Deref,DerefMut},};use std::panic::{RefUnwindSafe,UnwindSafe};pub struct OnceCell<T>{inner:UnsafeCell<Option<T>>,}impl<T:RefUnwindSafe+UnwindSafe>RefUnwindSafe for OnceCell<T>{}impl<T:UnwindSafe>UnwindSafe for OnceCell<T>{}impl<T>Default for OnceCell<T>{fn default()->Self{Self::new()}}impl<T:fmt::Debug>fmt::Debug for OnceCell<T>{fn fmt(&self,f:&mut fmt::Formatter)->fmt::Result{match self.get(){Some(v)=>f.debug_tuple("OnceCell").field(v).finish(),None=>f.write_str("OnceCell(Uninit)"),}}}impl<T:Clone>Clone for OnceCell<T>{fn clone(&self)->OnceCell<T>{match self.get(){Some(value)=>OnceCell::with_value(value.clone()),None=>OnceCell::new(),}}fn clone_from(&mut self,source:&Self){match(self.get_mut(),source.get()){(Some(this),Some(source))=>this.clone_from(source),_=>*self=source.clone(),}}}impl<T:PartialEq>PartialEq for OnceCell<T>{fn eq(&self,other:&Self)->bool{self.get()==other.get()}}impl<T:Eq>Eq for OnceCell<T>{}impl<T>From<T>for OnceCell<T>{fn from(value:T)->Self{OnceCell::with_value(value)}}impl<T>OnceCell<T>{pub const fn new()->OnceCell<T>{OnceCell{inner:UnsafeCell::new(None)}}pub const fn with_value(value:T)->OnceCell<T>{OnceCell{inner:UnsafeCell::new(Some(value))}}pub fn get(&self)->Option<&T>{unsafe{&*self.inner.get()}.as_ref()}pub fn get_mut(&mut self)->Option<&mut T>{unsafe{&mut*self.inner.get()}.as_mut()}pub fn set(&self,value:T)->Result<(),T>{match self.try_insert(value){Ok(_)=>Ok(()),Err((_,value))=>Err(value),}}pub fn try_insert(&self,value:T)->Result<&T,(&T,T)>{if let Some(old)=self.get(){return Err((old,value));}let slot=unsafe{&mut*self.inner.get()};*slot=Some(value);Ok(match&*slot{Some(value)=>value,None=>unsafe{hint::unreachable_unchecked()},})}pub fn get_or_init<F>(&self,f:F)->&T where F:FnOnce()->T,{enum Void{}match self.get_or_try_init(||Ok::<T,Void>(f())){Ok(val)=>val,Err(void)=>match void{},}}pub fn get_or_try_init<F,E>(&self,f:F)->Result<&T,E>where F:FnOnce()->Result<T,E>,{if let Some(val)=self.get(){return Ok(val);}let val=f()?;assert!(self.set(val).is_ok(),"reentrant init");Ok(self.get().unwrap())}pub fn take(&mut self)->Option<T>{mem::replace(self,Self::default()).into_inner()}pub fn into_inner(self)->Option<T>{self.inner.into_inner()}}pub struct Lazy<T,F=fn()->T>{cell:OnceCell<T>,init:Cell<Option<F>>,}impl<T,F:RefUnwindSafe>RefUnwindSafe for Lazy<T,F>where OnceCell<T>:RefUnwindSafe{}impl<T:fmt::Debug,F>fmt::Debug for Lazy<T,F>{fn fmt(&self,f:&mut fmt::Formatter)->fmt::Result{f.debug_struct("Lazy").field("cell",&self.cell).field("init",&"..").finish()}}impl<T,F>Lazy<T,F>{pub const fn new(init:F)->Lazy<T,F>{Lazy{cell:OnceCell::new(),init:Cell::new(Some(init))}}pub fn into_value(this:Lazy<T,F>)->Result<T,F>{let cell=this.cell;let init=this.init;cell.into_inner().ok_or_else(||{init.take().unwrap_or_else(||panic!("Lazy instance has previously been poisoned"))})}}impl<T,F:FnOnce()->T>Lazy<T,F>{pub fn force(this:&Lazy<T,F>)->&T{this.cell.get_or_init(||match this.init.take(){Some(f)=>f(),None=>panic!("Lazy instance has previously been poisoned"),})}pub fn force_mut(this:&mut Lazy<T,F>)->&mut T{Self::force(this);Self::get_mut(this).unwrap_or_else(||unreachable!())}pub fn get(this:&Lazy<T,F>)->Option<&T>{this.cell.get()}pub fn get_mut(this:&mut Lazy<T,F>)->Option<&mut T>{this.cell.get_mut()}}impl<T,F:FnOnce()->T>Deref for Lazy<T,F>{type Target=T;fn deref(&self)->&T{Lazy::force(self)}}impl<T,F:FnOnce()->T>DerefMut for Lazy<T,F>{fn deref_mut(&mut self)->&mut T{Lazy::force(self);self.cell.get_mut().unwrap_or_else(||unreachable!())}}impl<T:Default>Default for Lazy<T>{fn default()->Lazy<T>{Lazy::new(T::default)}}}pub mod sync{use std::{cell::Cell,fmt,mem,ops::{Deref,DerefMut},panic::RefUnwindSafe,};use crate::__cargo_equip::crates::__once_cell_1_14_0::{imp::OnceCell as Imp,take_unchecked};pub struct OnceCell<T>(Imp<T>);impl<T>Default for OnceCell<T>{fn default()->OnceCell<T>{OnceCell::new()}}impl<T:fmt::Debug>fmt::Debug for OnceCell<T>{fn fmt(&self,f:&mut fmt::Formatter)->fmt::Result{match self.get(){Some(v)=>f.debug_tuple("OnceCell").field(v).finish(),None=>f.write_str("OnceCell(Uninit)"),}}}impl<T:Clone>Clone for OnceCell<T>{fn clone(&self)->OnceCell<T>{match self.get(){Some(value)=>Self::with_value(value.clone()),None=>Self::new(),}}fn clone_from(&mut self,source:&Self){match(self.get_mut(),source.get()){(Some(this),Some(source))=>this.clone_from(source),_=>*self=source.clone(),}}}impl<T>From<T>for OnceCell<T>{fn from(value:T)->Self{Self::with_value(value)}}impl<T:PartialEq>PartialEq for OnceCell<T>{fn eq(&self,other:&OnceCell<T>)->bool{self.get()==other.get()}}impl<T:Eq>Eq for OnceCell<T>{}impl<T>OnceCell<T>{pub const fn new()->OnceCell<T>{OnceCell(Imp::new())}pub const fn with_value(value:T)->OnceCell<T>{OnceCell(Imp::with_value(value))}pub fn get(&self)->Option<&T>{if self.0.is_initialized(){Some(unsafe{self.get_unchecked()})}else{None}}pub fn wait(&self)->&T{if!self.0.is_initialized(){self.0.wait()}debug_assert!(self.0.is_initialized());unsafe{self.get_unchecked()}}pub fn get_mut(&mut self)->Option<&mut T>{self.0.get_mut()}pub unsafe fn get_unchecked(&self)->&T{self.0.get_unchecked()}pub fn set(&self,value:T)->Result<(),T>{match self.try_insert(value){Ok(_)=>Ok(()),Err((_,value))=>Err(value),}}pub fn try_insert(&self,value:T)->Result<&T,(&T,T)>{let mut value=Some(value);let res=self.get_or_init(||unsafe{take_unchecked(&mut value)});match value{None=>Ok(res),Some(value)=>Err((res,value)),}}pub fn get_or_init<F>(&self,f:F)->&T where F:FnOnce()->T,{enum Void{}match self.get_or_try_init(||Ok::<T,Void>(f())){Ok(val)=>val,Err(void)=>match void{},}}pub fn get_or_try_init<F,E>(&self,f:F)->Result<&T,E>where F:FnOnce()->Result<T,E>,{if let Some(value)=self.get(){return Ok(value);}self.0.initialize(f)?;debug_assert!(self.0.is_initialized());Ok(unsafe{self.get_unchecked()})}pub fn take(&mut self)->Option<T>{mem::replace(self,Self::default()).into_inner()}pub fn into_inner(self)->Option<T>{self.0.into_inner()}}pub struct Lazy<T,F=fn()->T>{cell:OnceCell<T>,init:Cell<Option<F>>,}impl<T:fmt::Debug,F>fmt::Debug for Lazy<T,F>{fn fmt(&self,f:&mut fmt::Formatter)->fmt::Result{f.debug_struct("Lazy").field("cell",&self.cell).field("init",&"..").finish()}}unsafe impl<T,F:Send>Sync for Lazy<T,F>where OnceCell<T>:Sync{}impl<T,F:RefUnwindSafe>RefUnwindSafe for Lazy<T,F>where OnceCell<T>:RefUnwindSafe{}impl<T,F>Lazy<T,F>{pub const fn new(f:F)->Lazy<T,F>{Lazy{cell:OnceCell::new(),init:Cell::new(Some(f))}}pub fn into_value(this:Lazy<T,F>)->Result<T,F>{let cell=this.cell;let init=this.init;cell.into_inner().ok_or_else(||{init.take().unwrap_or_else(||panic!("Lazy instance has previously been poisoned"))})}}impl<T,F:FnOnce()->T>Lazy<T,F>{pub fn force(this:&Lazy<T,F>)->&T{this.cell.get_or_init(||match this.init.take(){Some(f)=>f(),None=>panic!("Lazy instance has previously been poisoned"),})}pub fn force_mut(this:&mut Lazy<T,F>)->&mut T{Self::force(this);Self::get_mut(this).unwrap_or_else(||unreachable!())}pub fn get(this:&Lazy<T,F>)->Option<&T>{this.cell.get()}pub fn get_mut(this:&mut Lazy<T,F>)->Option<&mut T>{this.cell.get_mut()}}impl<T,F:FnOnce()->T>Deref for Lazy<T,F>{type Target=T;fn deref(&self)->&T{Lazy::force(self)}}impl<T,F:FnOnce()->T>DerefMut for Lazy<T,F>{fn deref_mut(&mut self)->&mut T{Lazy::force(self);self.cell.get_mut().unwrap_or_else(||unreachable!())}}impl<T:Default>Default for Lazy<T>{fn default()->Lazy<T>{Lazy::new(T::default)}}fn _dummy(){}}pub mod race{use core::sync::atomic;use atomic::{AtomicUsize,Ordering};use core::num::NonZeroUsize;#[derive(Default,Debug)]pub struct OnceNonZeroUsize{inner:AtomicUsize,}impl OnceNonZeroUsize{#[inline]pub const fn new()->OnceNonZeroUsize{OnceNonZeroUsize{inner:AtomicUsize::new(0)}}#[inline]pub fn get(&self)->Option<NonZeroUsize>{let val=self.inner.load(Ordering::Acquire);NonZeroUsize::new(val)}#[inline]pub fn set(&self,value:NonZeroUsize)->Result<(),()>{let exchange=self.inner.compare_exchange(0,value.get(),Ordering::AcqRel,Ordering::Acquire);match exchange{Ok(_)=>Ok(()),Err(_)=>Err(()),}}pub fn get_or_init<F>(&self,f:F)->NonZeroUsize where F:FnOnce()->NonZeroUsize,{enum Void{}match self.get_or_try_init(||Ok::<NonZeroUsize,Void>(f())){Ok(val)=>val,Err(void)=>match void{},}}pub fn get_or_try_init<F,E>(&self,f:F)->Result<NonZeroUsize,E>where F:FnOnce()->Result<NonZeroUsize,E>,{let val=self.inner.load(Ordering::Acquire);let res=match NonZeroUsize::new(val){Some(it)=>it,None=>{let mut val=f()?.get();let exchange=self.inner.compare_exchange(0,val,Ordering::AcqRel,Ordering::Acquire);if let Err(old)=exchange{val=old;}unsafe{NonZeroUsize::new_unchecked(val)}}};Ok(res)}}#[derive(Default,Debug)]pub struct OnceBool{inner:OnceNonZeroUsize,}impl OnceBool{#[inline]pub const fn new()->OnceBool{OnceBool{inner:OnceNonZeroUsize::new()}}#[inline]pub fn get(&self)->Option<bool>{self.inner.get().map(OnceBool::from_usize)}#[inline]pub fn set(&self,value:bool)->Result<(),()>{self.inner.set(OnceBool::to_usize(value))}pub fn get_or_init<F>(&self,f:F)->bool where F:FnOnce()->bool,{OnceBool::from_usize(self.inner.get_or_init(||OnceBool::to_usize(f())))}pub fn get_or_try_init<F,E>(&self,f:F)->Result<bool,E>where F:FnOnce()->Result<bool,E>,{self.inner.get_or_try_init(||f().map(OnceBool::to_usize)).map(OnceBool::from_usize)}#[inline]fn from_usize(value:NonZeroUsize)->bool{value.get()==1}#[inline]fn to_usize(value:bool)->NonZeroUsize{unsafe{NonZeroUsize::new_unchecked(if value{1}else{2})}}}pub use self::once_box::OnceBox;mod once_box{use super::atomic::{AtomicPtr,Ordering};use core::{marker::PhantomData,ptr};use alloc::boxed::Box;pub struct OnceBox<T>{inner:AtomicPtr<T>,ghost:PhantomData<Option<Box<T>>>,}impl<T>core::fmt::Debug for OnceBox<T>{fn fmt(&self,f:&mut core::fmt::Formatter<'_>)->core::fmt::Result{write!(f,"OnceBox({:?})",self.inner.load(Ordering::Relaxed))}}impl<T>Default for OnceBox<T>{fn default()->Self{Self::new()}}impl<T>Drop for OnceBox<T>{fn drop(&mut self){let ptr=*self.inner.get_mut();if!ptr.is_null(){drop(unsafe{Box::from_raw(ptr)})}}}impl<T>OnceBox<T>{pub const fn new()->OnceBox<T>{OnceBox{inner:AtomicPtr::new(ptr::null_mut()),ghost:PhantomData}}pub fn get(&self)->Option<&T>{let ptr=self.inner.load(Ordering::Acquire);if ptr.is_null(){return None;}Some(unsafe{&*ptr})}pub fn set(&self,value:Box<T>)->Result<(),Box<T>>{let ptr=Box::into_raw(value);let exchange=self.inner.compare_exchange(ptr::null_mut(),ptr,Ordering::AcqRel,Ordering::Acquire,);if let Err(_)=exchange{let value=unsafe{Box::from_raw(ptr)};return Err(value);}Ok(())}pub fn get_or_init<F>(&self,f:F)->&T where F:FnOnce()->Box<T>,{enum Void{}match self.get_or_try_init(||Ok::<Box<T>,Void>(f())){Ok(val)=>val,Err(void)=>match void{},}}pub fn get_or_try_init<F,E>(&self,f:F)->Result<&T,E>where F:FnOnce()->Result<Box<T>,E>,{let mut ptr=self.inner.load(Ordering::Acquire);if ptr.is_null(){let val=f()?;ptr=Box::into_raw(val);let exchange=self.inner.compare_exchange(ptr::null_mut(),ptr,Ordering::AcqRel,Ordering::Acquire,);if let Err(old)=exchange{drop(unsafe{Box::from_raw(ptr)});ptr=old;}};Ok(unsafe{&*ptr})}}unsafe impl<T:Sync+Send>Sync for OnceBox<T>{}fn _dummy(){}}}unsafe fn take_unchecked<T>(val:&mut Option<T>)->T{match val.take(){Some(it)=>it,None=>{debug_assert!(false);std::hint::unreachable_unchecked()}}}}
        pub mod proconio {#![allow(clippy::needless_doctest_main,clippy::print_literal)]use crate::__cargo_equip::preludes::proconio::*;pub use crate::__cargo_equip::macros::proconio::*;pub mod marker{use crate::__cargo_equip::preludes::proconio::*;use crate::__cargo_equip::crates::proconio::source::{Readable,Source};use std::io::BufRead;pub enum Chars{}impl Readable for Chars{type Output=Vec<char>;fn read<R:BufRead,S:Source<R>>(source:&mut S)->Vec<char>{source.next_token_unwrap().chars().collect()}}pub enum Bytes{}impl Readable for Bytes{type Output=Vec<u8>;fn read<R:BufRead,S:Source<R>>(source:&mut S)->Vec<u8>{source.next_token_unwrap().bytes().collect()}}pub enum Usize1{}impl Readable for Usize1{type Output=usize;fn read<R:BufRead,S:Source<R>>(source:&mut S)->usize{usize::read(source).checked_sub(1).expect("attempted to read the value 0 as a Usize1")}}pub enum Isize1{}impl Readable for Isize1{type Output=isize;fn read<R:BufRead,S:Source<R>>(source:&mut S)->isize{isize::read(source).checked_sub(1).unwrap_or_else(||{panic!(concat!("attempted to read the value {} as a Isize1:"," the value is isize::MIN and cannot be decremented"),std::isize::MIN,)})}}}pub mod source{use crate::__cargo_equip::preludes::proconio::*;use std::any::type_name;use std::fmt::Debug;use std::io::BufRead;use std::str::FromStr;pub mod line{use crate::__cargo_equip::preludes::proconio::*;use super::Source;use crate::__cargo_equip::crates::proconio::source::tokens::Tokens;use std::io::BufRead;pub struct LineSource<R:BufRead>{tokens:Tokens,reader:R,}impl<R:BufRead>LineSource<R>{pub fn new(reader:R)->LineSource<R>{LineSource{tokens:"".to_owned().into(),reader,}}fn prepare(&mut self){while self.tokens.is_empty(){let mut line=String::new();let num_bytes=self.reader.read_line(&mut line).expect("failed to get linel maybe an IO error.");if num_bytes==0{return;}self.tokens=line.into();}}}impl<R:BufRead>Source<R>for LineSource<R>{fn next_token(&mut self)->Option<&str>{self.prepare();self.tokens.next_token()}fn is_empty(&mut self)->bool{self.prepare();self.tokens.is_empty()}}use std::io::BufReader;impl<'a>From<&'a str>for LineSource<BufReader<&'a[u8]>>{fn from(s:&'a str)->LineSource<BufReader<&'a[u8]>>{LineSource::new(BufReader::new(s.as_bytes()))}}}pub mod once{use crate::__cargo_equip::preludes::proconio::*;use super::Source;use crate::__cargo_equip::crates::proconio::source::tokens::Tokens;use std::io::BufRead;use std::marker::PhantomData;pub struct OnceSource<R:BufRead>{tokens:Tokens,_read:PhantomData<R>,}impl<R:BufRead>OnceSource<R>{pub fn new(mut source:R)->OnceSource<R>{let mut context=String::new();source.read_to_string(&mut context).expect("failed to read from source; maybe an IO error.");OnceSource{tokens:context.into(),_read:PhantomData,}}}impl<R:BufRead>Source<R>for OnceSource<R>{fn next_token(&mut self)->Option<&str>{self.tokens.next_token()}fn is_empty(&mut self)->bool{self.tokens.is_empty()}}use std::io::BufReader;impl<'a>From<&'a str>for OnceSource<BufReader<&'a[u8]>>{fn from(s:&'a str)->OnceSource<BufReader<&'a[u8]>>{OnceSource::new(BufReader::new(s.as_bytes()))}}}mod tokens{use crate::__cargo_equip::preludes::proconio::*;use std::{iter::Peekable,ptr::NonNull,str::SplitWhitespace};pub(super)struct Tokens{tokens:Peekable<SplitWhitespace<'static>>,_current_context:CurrentContext,}impl Tokens{pub(super)fn next_token(&mut self)->Option<&str>{self.tokens.next()}pub(super)fn is_empty(&mut self)->bool{self.tokens.peek().is_none()}}impl From<String>for Tokens{fn from(current_context:String)->Self{let current_context=CurrentContext::from(current_context);unsafe{let tokens=current_context.0.as_ref().split_whitespace().peekable();Self{tokens,_current_context:current_context,}}}}unsafe impl Send for Tokens{}unsafe impl Sync for Tokens{}struct CurrentContext(NonNull<str>);impl From<String>for CurrentContext{fn from(s:String)->Self{let s=s.into_boxed_str();Self(NonNull::new(Box::leak(s)).unwrap())}}impl Drop for CurrentContext{fn drop(&mut self){unsafe{Box::from_raw(self.0.as_mut())};}}}pub mod auto{use crate::__cargo_equip::preludes::proconio::*;#[cfg(debug_assertions)]pub use super::line::LineSource as AutoSource;#[cfg(not(debug_assertions))]pub use super::once::OnceSource as AutoSource;}pub trait Source<R:BufRead>{fn next_token(&mut self)->Option<&str>;#[allow(clippy::wrong_self_convention)]fn is_empty(&mut self)->bool;fn next_token_unwrap(&mut self)->&str{self.next_token().expect(concat!("failed to get the next token; ","maybe reader reached an end of input. ","ensure that arguments for `input!` macro is correctly ","specified to match the problem input."))}}impl<R:BufRead,S:Source<R>>Source<R>for&'_ mut S{fn next_token(&mut self)->Option<&str>{(*self).next_token()}fn is_empty(&mut self)->bool{(*self).is_empty()}}pub trait Readable{type Output;fn read<R:BufRead,S:Source<R>>(source:&mut S)->Self::Output;}impl<T:FromStr>Readable for T where T::Err:Debug,{type Output=T;fn read<R:BufRead,S:Source<R>>(source:&mut S)->T{let token=source.next_token_unwrap();match token.parse(){Ok(v)=>v,Err(e)=>panic!(concat!("failed to parse the input `{input}` ","to the value of type `{ty}`: {err:?}; ","ensure that the input format is collectly specified ","and that the input value must handle specified type.",),input=token,ty=type_name::<T>(),err=e,),}}}}use crate::__cargo_equip::crates::proconio::source::{auto::AutoSource,line::LineSource};use once_cell::sync::OnceCell;use std::io::{BufReader,Stdin};use std::{io::{self,BufRead},sync::Mutex,};pub use crate::__cargo_equip::crates::proconio::source::Readable as __Readable;pub enum StdinSource<R:BufRead>{Normal(AutoSource<R>),Interactive(LineSource<R>),Unknown(LineSource<R>),}impl<R:BufRead>source::Source<R>for StdinSource<R>{fn next_token(&mut self)->Option<&str>{match self{StdinSource::Normal(source)=>source.next_token(),StdinSource::Interactive(source)=>source.next_token(),StdinSource::Unknown(source)=>source.next_token(),}}fn is_empty(&mut self)->bool{match self{StdinSource::Normal(source)=>source.is_empty(),StdinSource::Interactive(source)=>source.is_empty(),StdinSource::Unknown(source)=>source.is_empty(),}}}pub static STDIN_SOURCE:OnceCell<Mutex<StdinSource<BufReader<Stdin>>>> =OnceCell::new();#[macro_export]macro_rules!__cargo_equip_macro_def_proconio_input{(@from[$source:expr]@rest)=>{};(@from[$source:expr]@rest mut$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::input!{@from[$source]@mut[mut]@rest$($rest)*}};(@from[$source:expr]@rest$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::input!{@from[$source]@mut[]@rest$($rest)*}};(@from[$source:expr]@mut[$($mut:tt)?]@rest$var:tt:$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::input!{@from[$source]@mut[$($mut)*]@var$var@kind[]@rest$($rest)*}};(@from[$source:expr]@mut[$($mut:tt)?]@var$var:tt@kind[$($kind:tt)*]@rest)=>{let$($mut)*$var=$crate::__cargo_equip::crates::proconio::read_value!(@source[$source]@kind[$($kind)*]);};(@from[$source:expr]@mut[$($mut:tt)?]@var$var:tt@kind[$($kind:tt)*]@rest,$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::input!(@from[$source]@mut[$($mut)*]@var$var@kind[$($kind)*]@rest);$crate::__cargo_equip::crates::proconio::input!(@from[$source]@rest$($rest)*);};(@from[$source:expr]@mut[$($mut:tt)?]@var$var:tt@kind[$($kind:tt)*]@rest$tt:tt$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::input!(@from[$source]@mut[$($mut)*]@var$var@kind[$($kind)*$tt]@rest$($rest)*);};(from$source:expr,$($rest:tt)*)=>{#[allow(unused_variables,unused_mut)]let mut s=$source;$crate::__cargo_equip::crates::proconio::input!{@from[&mut s]@rest$($rest)*}};($($rest:tt)*)=>{let mut locked_stdin=$crate::__cargo_equip::crates::proconio::STDIN_SOURCE.get_or_init(||{std::sync::Mutex::new($crate::__cargo_equip::crates::proconio::StdinSource::Normal($crate::__cargo_equip::crates::proconio::source::auto::AutoSource::new(std::io::BufReader::new(std::io::stdin())),))}).lock().expect(concat!("failed to lock the stdin; please re-run this program.  ","If this issue repeatedly occur, this is a bug in `proconio`.  ","Please report this issue from ","<https://github.com/statiolake/proconio-rs/issues>."));$crate::__cargo_equip::crates::proconio::input!{@from[&mut*locked_stdin]@rest$($rest)*}drop(locked_stdin);};}macro_rules!input{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_proconio_input!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_proconio_input_interactive{($($rest:tt)*)=>{let mut locked_stdin=$crate::__cargo_equip::crates::proconio::STDIN_SOURCE.get_or_init(||{std::sync::Mutex::new($crate::__cargo_equip::crates::proconio::StdinSource::Interactive($crate::__cargo_equip::crates::proconio::source::line::LineSource::new(std::io::BufReader::new(std::io::stdin())),))}).lock().expect(concat!("failed to lock the stdin; please re-run this program.  ","If this issue repeatedly occur, this is a bug in `proconio`.  ","Please report this issue from ","<https://github.com/statiolake/proconio-rs/issues>."));$crate::__cargo_equip::crates::proconio::input!{from&mut*locked_stdin,$($rest)*}drop(locked_stdin);};}macro_rules!input_interactive{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_proconio_input_interactive!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_proconio_read_value{(@source[$source:expr]@kind[[$($kind:tt)*]])=>{$crate::__cargo_equip::crates::proconio::read_value!(@array@source[$source]@kind[]@rest$($kind)*)};(@array@source[$source:expr]@kind[$($kind:tt)*]@rest)=>{{let len=<usize as$crate::__cargo_equip::crates::proconio::__Readable>::read($source);$crate::__cargo_equip::crates::proconio::read_value!(@source[$source]@kind[[$($kind)*;len]])}};(@array@source[$source:expr]@kind[$($kind:tt)*]@rest;$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::read_value!(@array@source[$source]@kind[$($kind)*]@len[$($rest)*])};(@array@source[$source:expr]@kind[$($kind:tt)*]@rest$tt:tt$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::read_value!(@array@source[$source]@kind[$($kind)*$tt]@rest$($rest)*)};(@array@source[$source:expr]@kind[$($kind:tt)*]@len[$($len:tt)*])=>{{let len=$($len)*;(0..len).map(|_|$crate::__cargo_equip::crates::proconio::read_value!(@source[$source]@kind[$($kind)*])).collect::<Vec<_>>()}};(@source[$source:expr]@kind[($($kinds:tt)*)])=>{$crate::__cargo_equip::crates::proconio::read_value!(@tuple@source[$source]@kinds[]@current[]@rest$($kinds)*)};(@tuple@source[$source:expr]@kinds[$([$($kind:tt)*])*]@current[]@rest)=>{($($crate::__cargo_equip::crates::proconio::read_value!(@source[$source]@kind[$($kind)*]),)*)};(@tuple@source[$source:expr]@kinds[$($kinds:tt)*]@current[$($curr:tt)*]@rest)=>{$crate::__cargo_equip::crates::proconio::read_value!(@tuple@source[$source]@kinds[$($kinds)*[$($curr)*]]@current[]@rest)};(@tuple@source[$source:expr]@kinds[$($kinds:tt)*]@current[$($curr:tt)*]@rest,$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::read_value!(@tuple@source[$source]@kinds[$($kinds)*[$($curr)*]]@current[]@rest$($rest)*)};(@tuple@source[$source:expr]@kinds[$($kinds:tt)*]@current[$($curr:tt)*]@rest$tt:tt$($rest:tt)*)=>{$crate::__cargo_equip::crates::proconio::read_value!(@tuple@source[$source]@kinds[$($kinds)*]@current[$($curr)*$tt]@rest$($rest)*)};(@source[$source:expr]@kind[])=>{compile_error!(concat!("Reached unreachable statement while parsing macro input.  ","This is a bug in `proconio`.  ","Please report this issue from ","<https://github.com/statiolake/proconio-rs/issues>."));};(@source[$source:expr]@kind[$kind:ty])=>{<$kind as$crate::__cargo_equip::crates::proconio::__Readable>::read($source)}}macro_rules!read_value{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_proconio_read_value!{$($tt)*})}pub fn is_stdin_empty()->bool{use source::Source;let mut lock=STDIN_SOURCE.get_or_init(||{Mutex::new(StdinSource::Unknown(LineSource::new(BufReader::new(io::stdin(),))))}).lock().expect(concat!("failed to lock the stdin; please re-run this program.  ","If this issue repeatedly occur, this is a bug in `proconio`.  ","Please report this issue from ","<https://github.com/statiolake/proconio-rs/issues>."));lock.is_empty()}}
    }

    pub(crate) mod macros {
        pub mod __once_cell_1_14_0 {}
        pub mod proconio {pub use crate::{__cargo_equip_macro_def_proconio_input as input,__cargo_equip_macro_def_proconio_input_interactive as input_interactive,__cargo_equip_macro_def_proconio_read_value as read_value};}
    }

    pub(crate) mod prelude {pub use crate::__cargo_equip::crates::*;}

    mod preludes {
        pub mod __once_cell_1_14_0 {}
        pub mod proconio {pub(in crate::__cargo_equip)use crate::__cargo_equip::crates::__once_cell_1_14_0 as once_cell;}
    }
}
0