QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#208641#7522. Sequence ShiftqLAC ✓312ms23836kbC++1415.6kb2023-10-09 19:34:372023-10-09 19:34:38

Judging History

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

  • [2023-10-09 19:34:38]
  • 评测
  • 测评结果:AC
  • 用时:312ms
  • 内存:23836kb
  • [2023-10-09 19:34:37]
  • 提交

answer

#include<cstdio>
#include<utility>
#include<cstdlib>
#include<type_traits>
#include<array>
#include<algorithm>
/**
 * 写得死烂,又长又慢。
 * Author:qL
 * todo:
 * Better modInt
 * frac
 * More Poly
 * fix bug of radix_sort
 * new IO
 * turn std::enable_if into static_assert 
*/
namespace QL{
	/**
	 * 图方便用的
	*/
	namespace{
		using ll=long long;
		using ull=unsigned long long;
		using uint=unsigned int;
		using db=double;
		using ld=long double;
#if _GLIBCXX_USE_INT128
		using lll=__int128;
		using ulll=unsigned __int128;
#else
		using lll=long long;
		using ulll=unsigned long long;
#endif
#if _GLIBCXX_NUMERIC&&(__cplusplus>=201703L)
		template<typename _Tp>
		constexpr _Tp Inf=std::numeric_limits<_Tp>::max()/2;
#else
		constexpr int Inf=0x3f3f3f3f;
		constexpr long long llInf=0x3f3f3f3f3f3f3f3f;
		constexpr double dbInf=1e17;
		constexpr long double ldInf=1e22;
#endif
#ifndef _GLIBCXX_CMATH
	#define sqrt __builtin_sqrt
	#define sqrtf __builtin_sqrtf
	#define sqrtl __builtin_sqrtl
	#define ceil __builtin_ceil
	#define ceilf __builtin_ceilf
	#define ceill __builtin_ceill
	#define floor __builtin_floor
	#define floorf __builtin_floorf
	#define floorl __builtin_floorl
	#define log2 __builtin_log2
	#define log __builtin_log
	#define cos __builtin_cos
	#define sin __builtin_sin
	#define tan __builtin_tan
	#define acos __builtin_acos
#endif
#ifndef _GLIBCXX_CSTRING
	#define memset __builtin_memset
	#define memcpy __builtin_memcpy
	#define strlen __builtin_strlen
	#define strcmp __builtin_strcmp
#endif
#ifndef _GLIBCXX_CSTDIO
	#define fwrite __builtin_fwrite
	#define putchar __builtin_putchar
	#define fputc __builtin_fputc
	#define fputs __builtin_fputs
#endif
#ifndef likely
	#define likely(x) __builtin_expect(!!(x),1)
#endif
#ifndef unlikely
	#define unlikely(x) __builtin_expect(!!(x),0)
#endif
	}
	/**
	 * 不想多加头文件了……
	*/
	namespace Error{
		constexpr void make_re(int _seed_=114514){
			std::exit(_seed_);
		}
#ifndef _GLIBCXX_CASSERT
		constexpr bool assert(bool x,const char *reason="Assert: RE"){
			if(unlikely(!x)){
				fputs(reason,stderr);
				fputs(reason,stdout);
				make_re();
			}
			return false;
		}
		constexpr bool assert(bool x,char *reason){
			return assert(x,const_cast<const char *>(reason));
		}
#endif
	}
}
namespace QL{
	/**
	 * 这坨代码最让人难以理解的地方:没逝乱靠元编程库
	*/
	namespace Traits_Tools{
		template<typename _Tp>
		class has_member_swap{
		private:
			template<typename T>
			static auto Check(void)->decltype(std::declval<T>().swap(),std::true_type());
			template<typename T>
			static std::false_type Check(...);
		public:
			enum{value=std::is_same<decltype(Check<_Tp>(nullptr)),std::true_type>::value};
		};
		#define Operator_Check_Helper(name,opt) \
				template<typename _Tp1,typename _Tp2> \
				class has_operator_##name{ \
				private: \
					template<typename T1,typename T2> \
					static auto Check(void)->decltype(std::declval<T1,T2>().operator opt (),std::true_type()); \
					template<typename T1,typename T2> \
					static std::false_type Check(...); \
				public: \
					enum{value=std::is_same<decltype(Check<_Tp1,_Tp2>(nullptr)),std::true_type>::value}; \
				};
		Operator_Check_Helper(plus,+)
		Operator_Check_Helper(subtract,-)
		Operator_Check_Helper(multiply,*)
		Operator_Check_Helper(divide,/)
		Operator_Check_Helper(mod,%)
		Operator_Check_Helper(and,&)
		Operator_Check_Helper(or,|)
		Operator_Check_Helper(xor,^)
		#undef Operator_Check_Helper
		template<typename _Tp,typename std::enable_if<std::is_integral<_Tp>::value>::type* =nullptr>
		struct to_upper_type;
		#define To_Upper_Helper(_type_,_upper_) \
		template<> \
		struct to_upper_type< _type_ >{ \
			using type=_upper_; \
		}; \
		template<> \
		struct to_upper_type< u##_type_ >{ \
			using type=u##_upper_; \
		};
		To_Upper_Helper(int,ll)
		To_Upper_Helper(ll,lll)
		#undef To_Upper_Helper
	}
}
namespace QL{
	namespace rel_ops{
		namespace Calc_Self{
			#define Calc_Self_Helper(opt) \
			template<typename _Tp1,typename _Tp2> \
			constexpr _Tp1 &operator opt##=(_Tp1 &lhs,const _Tp2 &rhs){ \
				return lhs=(lhs opt rhs); \
			}
			Calc_Self_Helper(+)
			Calc_Self_Helper(-)
			Calc_Self_Helper(*)
			Calc_Self_Helper(/)
			Calc_Self_Helper(%)
			Calc_Self_Helper(&)
			Calc_Self_Helper(|)
			Calc_Self_Helper(^)
			#undef Calc_Self_Helper
		}
		namespace Compare{
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator!=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs==rhs);
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator<=(const _Tp1 &lhs,const _Tp2 &rhs){
				return (lhs==rhs)||(lhs<rhs);
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator>(const _Tp1 &lhs,const _Tp2 &rhs){
				return !((lhs==rhs)||(lhs<rhs));
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator>=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs<rhs);
			}
		}
	}
}
/**
 * todo:
 * rebuild
 */
namespace QL{
	namespace Base_Tools{
		template<typename _Tp>
		static constexpr std::size_t integer_length=sizeof(_Tp)*10/sizeof(int);
		bool is_space(char ch){
			return ch==' ';
		}
		bool is_eoln(char ch){
#if (linux||__linux__||__linux)
			return ch=='\n'||ch=='\r';
#else
			return ch=='\n';
#endif
		}
		bool is_blank(char ch){
			return is_space(ch)||is_eoln(ch);
		}
		bool is_digit(char ch){
			switch(ch){
				case '0' ... '9': return true;
				default: return false;
			}
		}
		bool is_eof(char ch){
			return ch==EOF;
		}
	}
	namespace IO{
		using Base_Tools::integer_length;
		using Base_Tools::is_digit;
		using Base_Tools::is_space;
		using Base_Tools::is_eoln;
		using Base_Tools::is_blank;
		using Base_Tools::is_eof;
		/**
		 * fread+fwrite,-DLOACL for debug
		 * support:integer,floating,string,...
		 * todo:other
 		*/
		class IOstream{
		protected:
			using LIST=std::initializer_list<int>;
#ifndef LOCAL
			std::FILE *IN;
			std::FILE *OUT;
			static constexpr int SIZE=1<<15;
			char buf[SIZE]{},*p1{buf},*p2{buf},obuf[SIZE]{},*p3{obuf};
		public:
			char pull(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,IN),p1==p2)?(Ch=EOF):*p1++;}
			void push(char ch){((p3-obuf)==SIZE&&(flush(false),0)),*p3++=ch;}
			template<std::size_t L>
			std::FILE *set_in(const char (&name)[L]){
				static char in[L+5]={};
				std::sprintf(in,"%s.in",name);
				return std::fopen(in,"r");
			}
			template<std::size_t L>
			std::FILE *set_out(const char (&name)[L]){
				static char out[L+5];
				std::sprintf(out,"%s.out",name);
				return std::fopen(out,"w");
			}
#else
		protected:
		public:
			char pull(){return std::getchar();}
			void push(char ch){putchar(ch);}
			void err(char ch){fputc(ch,stderr);}
			template<std::size_t L>
			void set_in(const char(&name)[L]){
				static char in[L+5]={};
				std::sprintf(in,"%s.in",name);
				std::freopen(in,"r",stdin);
			}
			template<std::size_t L>
			void set_out(const char(&name)[L]){
				static char out[L+5];
				std::sprintf(out,"%s.out",name);
				std::freopen(out,"w",stdout);
			}
#endif
		public:
#ifndef LOCAL
			IOstream():IN{stdin},OUT{stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(const char(&name)[L]):IN{set_in(name)},OUT{set_out(name)},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(const char(&name)[L],bool in,bool out):IN{in?set_in(name):stdin},OUT{out?set_out(name):stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(char(&name)[L]):IN{set_in(name)},OUT{set_out(name)},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(char(&name)[L],bool in,bool out):IN{in?set_in(name):stdin},OUT{out?set_out(name):stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			~IOstream(){flush();}
			void flush(bool _flush_=false){
				if(likely(p3!=obuf))
					fwrite(obuf,1,p3-obuf,OUT),p3=obuf;
				if(_flush_) std::fflush(stdout);
			}
#else
			IOstream(){}
			template<std::size_t L>
			IOstream(const char(&name)[L]):Ch{'\n'}{reset_stdin(name),reset_stdout(name);}
			template<std::size_t L>
			IOstream(const char(&name)[L],bool in,bool out):Ch{'\n'}{in&&(reset_stdin(name),0),out&&(reset_stdout(name),0);}
			template<std::size_t L>
			IOstream(char(&name)[L]):Ch{'\n'}{reset_stdin(name),reset_stdout(name);}
			template<std::size_t L>
			IOstream(char(&name)[L],bool in,bool out):Ch{'\n'}{in&&(reset_stdin(name),0),out&&(reset_stdout(name),0);}
			void flush(bool _flush_=true){
				if(_flush_) std::fflush(stdout);
			}
#endif
			template<typename T>
			T read(){
				T x;
				read(x);
				return x;
			}
protected:
			char Ch='\n';
public:
			bool eof(void)const{
				return Ch==EOF;
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_signed<T>::value,void>::type* =nullptr){
				x=0;bool flag=0;
				for(;!is_digit(Ch)&&!is_eof(Ch);Ch=pull()) if(Ch=='-') flag=1;
				if(is_eof(Ch)) return;
				if(flag) for(;is_digit(Ch);Ch=pull()) x=x*10-(Ch&15);
				else for(;is_digit(Ch);Ch=pull()) x=x*10+(Ch&15);
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_unsigned<T>::value,void>::type* =nullptr){
				x=0;
				for(;!is_digit(Ch)&&!is_eof(Ch);Ch=pull());
				if(is_eof(Ch)) return;
				for(;is_digit(Ch);Ch=pull()) x=x*10+(Ch&15);
			}
			void read(char *str){
				for(;is_blank(Ch);Ch=pull());
				if(is_eof(Ch)) return (void)(*str='\0');
				for(;!is_blank(Ch)&&!is_eof(Ch);Ch=pull()) *str++=Ch;
				*str='\0';
			}
			void read(char &c){
				c=Ch;
				for(;is_blank(c)&&!is_eof(c);c=pull());
				if(is_eof(c)) return;
				Ch=pull();
			}
			void read(bool &x){
				for(;Ch!='0'&&Ch!='1'&&!is_eof(Ch);Ch=pull());
				if(is_eof(Ch)) return void(x=false);
				x=Ch=='1';
				Ch=pull();
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_floating_point<T>::value,void*>::type* =nullptr){
				static char str[114];
				read(str);
				x=std::atof(str);
			}
			template<typename T>
			void read(T &x){read(std::move(x));}
		protected:
			void(IOstream::*outchar)(char)=&IO::IOstream::push;
			template<typename T>
			void out(T x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_signed<T>::value,void>::type* =nullptr){
				static char sta[integer_length<T>];
				int top=0;
				if(x<0){
					(this->*outchar)('-');
					do sta[top++]=((-x)%10)|48,x/=10;
					while(x);
				}
				else{
					do sta[top++]=(x%10)|48,x/=10;
					while(x);
				}
				while(top) (this->*outchar)(sta[--top]);
			}
			template<typename T>
			void out(T x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_unsigned<T>::value,void>::type* =nullptr){
				static char sta[integer_length<T>];
				int top=0;
				do sta[top++]=(x%10)|48,x/=10;
				while(x);
				while(top) (this->*outchar)(sta[--top]);
			}
			void out(bool x){(this->*outchar)(x?'1':'0');}
			void out(char x){(this->*outchar)(x);}
			void out(char *str){
				out(reinterpret_cast<const char *>(str));
			}
			void out(const char *str){
				while(*str!='\0') (this->*outchar)(*str++);
			}
			/**
			 * ssprintf is awful...
			 */
			void out(float x){
				static char str[114];
				std::sprintf(str,"%f",x);
				out(str);
			}
			void out(double x){
				static char str[114];
				std::sprintf(str,"%f",x);
				out(str);
			}
			void out(long double x){
				static char str[114];
				std::sprintf(str,"%Lf",x);
				out(str);
			}
			void out(std::pair<int,float> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%df",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void out(std::pair<int,double> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%df",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void out(std::pair<int,long double> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%dLf",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void set_std_out(){outchar=&IO::IOstream::push;}
#ifdef LOCAL
			void set_err_out(){outchar=&IO::IOstream::err;}
#endif
		public:
			template<typename...Args>
			void read(Args &&...args){(void)LIST{(read(args),0)...};}
			template<typename...Args>
			void write(Args...args){set_std_out(),(void)LIST{(out(args),0)...};}
			template<typename...Args>
			void writeln(Args...args){write(args...),push('\n');}
#ifdef LOCAL
			template<typename...Args>
			void error(Args...args){set_err_out(),(void)LIST{(out(args),0)...};}
			template<typename...Args>
			void errorln(Args...args){error(args...),err('\n');}
#endif
		};
	}
}
namespace QL{
	namespace Base_Tools{
		template<typename _Tp1,typename _Tp2>
		constexpr auto min(_Tp1 x,_Tp2 y){
			return x<y?x:y;
		}
		template<typename _Tp,typename ...Args>
		constexpr auto min(_Tp x,Args ...args){
			return min(x,min(args...));
		}
		template<typename _Tp1,typename _Tp2>
		constexpr auto max(_Tp1 x,_Tp2 y){
			return y<x?x:y;
		}
		template<typename _Tp,typename ...Args>
		constexpr auto max(_Tp x,Args ...args){
			return max(x,max(args...));
		}
		template<typename _Tp1,typename _Tp2>
		constexpr bool chkmin(_Tp1 &x,_Tp2 y){
			return y<x?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		constexpr bool chkmin(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmin(x,y)|chkmin(x,args...);
		}
		template<typename _Tp1,typename _Tp2>
		constexpr bool chkmax(_Tp1 &x,_Tp2 y){
			return x<y?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		constexpr bool chkmax(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmax(x,y)|chkmax(x,args...);
		}
		template<typename _Tp,
		typename std::enable_if<!Traits_Tools::has_member_swap<_Tp>::value&&!std::is_integral<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			_Tp tmp;
			tmp=x,x=y,y=tmp;
		}
		template<typename _Tp,typename std::enable_if<std::is_integral<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			x!=y&&(x^=y^=x^=y);
		}
		template<typename _Tp>
		constexpr void swap(_Tp *&x,_Tp *&y){
			_Tp *tmp;
			tmp=x,x=y,y=tmp;
		}
		template<typename _Tp,typename std::enable_if<Traits_Tools::has_member_swap<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			x.swap(y);
		}
		template<typename _Tp>
		constexpr _Tp abs(const _Tp &x){
			return x<0?-x:x;
		}
	}
}
namespace MAIN{
	using namespace QL;
	IO::IOstream lq;
    constexpr int N=1e6+5;
    int n,q,b[N*2],ans[N*2];
	struct{int x,id;} a[N];
	void _main_(void){
        lq.read(n,q),q+=n;
		int lim=1e9*Base_Tools::max(2-7/sqrt(n),0);
        for(int i=1;i<=n;++i) lq.read(a[i].x),a[i].id=i;
		std::sort(a+1,a+n+1,[](auto x,auto y){return x.x>y.x;});
		for(int i=1;i<=q;++i){
			lq.read(b[i]),b[i]^=ans[i-1];
			for(int j=1,tmp,p;j<=n;++j)
				if((tmp=a[j].x+b[i])<lim) break;
				else if((p=i-a[j].id+n)>=n&&p<=q) Base_Tools::chkmax(ans[p],tmp);
			if(unlikely(i<n)) continue;
			if(!ans[i]) for(int j=1;j<=n;++j) Base_Tools::chkmax(ans[i],a[j].x+b[a[j].id+i-n]);
			lq.writeln(ans[i]);
		}
		return;
	}
}
signed main(){
	return MAIN::_main_(),0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7756kb

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:

11
13
16
25

result:

ok 4 lines

Test #2:

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

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

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

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

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

input:

1 10
700282491
332230980
90825676
1630266999
644973380
262379760
2122877054
1851957134
1370195232
110993724
1319359505
1883523208

output:

1032513471
1654684398
759763732
888538827
1695749302
1163465539
1425605448
789576931
1397740634
1202288326
1638577353

result:

ok 11 lines

Test #5:

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

input:

1000 100000
438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...

output:

1962871590
1986083253
1967509108
1973351244
1974354421
1956371849
1976394149
1995721753
1946870160
1984280254
1961237540
1955903880
1944520591
1937726835
1993563403
1927000559
1951483558
1979133252
1979156812
1941301401
1922284543
1980597785
1963663583
1946961524
1933606347
1953947075
1953071855
194...

result:

ok 100001 lines

Test #6:

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

input:

10000 10000
760845880 236665988 765352292 817854026 789863420 399953246 270535243 932350041 48814223 670950468 456660682 416165008 999681497 666880584 56581573 134567049 403285848 144814129 973325555 23519957 518449311 738687225 345716065 2309498 477743569 555951695 911860717 920761968 569179690 349...

output:

1990514380
1974843876
1992500750
1994731468
1983411218
1986646709
1979643361
1990060423
1988174297
1983373232
1995134632
1989936349
1993187026
1988927807
1971595730
1988272839
1990590966
1981928791
1987819156
1987483957
1979800700
1986611531
1973877196
1995735988
1985734454
1987573480
1988935268
199...

result:

ok 10001 lines

Test #7:

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

input:

10000 100000
682604470 430466819 955519058 186918998 587587373 201134122 473675328 586747694 132807628 255672373 504315038 137082392 753499284 586570202 133549919 570424589 87103369 2142325 895908281 852456682 239920694 443878018 717067433 437134318 39426086 82137124 698018668 518394430 430778732 56...

output:

1984544998
1988859370
1989789541
1976833784
1995823502
1972653611
1991119857
1993356707
1986981779
1995476314
1995610828
1993831190
1996638827
1986403811
1989382087
1993806832
1989374332
1994121941
1983565702
1985256743
1996937615
1982877527
1995705250
1986803258
1991586243
1985584711
1989505176
199...

result:

ok 100001 lines

Test #8:

score: 0
Accepted
time: 12ms
memory: 7836kb

input:

100000 1000
765888053 833515469 84953776 797547408 412620563 765574495 334638552 473705288 279331343 321129745 718689650 778307179 205668791 48820839 279108389 210915881 711034474 688831194 230042027 856832739 427928795 151766103 505848143 403162288 459045522 979683261 59438197 871004123 755234923 6...

output:

1998969019
1997756723
1990964658
1992180114
1991311226
1996318953
1999238402
1997012356
1996382741
1993901604
1990703168
1997121645
1996347278
1990978439
1993663588
1996287457
1998005763
1997236433
1994552013
1995785880
1997513392
1998761277
1994793469
1993807193
1997817922
1990146164
1997588498
199...

result:

ok 1001 lines

Test #9:

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

input:

100000 10000
155192094 32355226 10722958 680788712 355467230 837266625 393682487 504944520 573979360 618892727 168735423 928295170 158663199 129313725 187722419 800899194 169961946 297789942 3327780 993559861 568700692 901642218 989795879 846649116 947423253 851741191 365690710 469648703 903510759 7...

output:

1998324839
1998650520
1996715356
1996337565
1994069244
1994071960
1994680032
1995482692
1995353396
1996020788
1998370988
1994450866
1997311656
1992935357
1998022252
1998633241
1998507677
1997594278
1996419001
1997075873
1997413924
1995735160
1995881483
1995263027
1997718803
1998739520
1997494429
199...

result:

ok 10001 lines

Test #10:

score: 0
Accepted
time: 23ms
memory: 10268kb

input:

100000 100000
38413036 456923902 821971466 586909482 636298728 158178471 84422915 632002470 34405999 882453211 922025994 294603996 207311349 526030511 417456448 362917277 456078308 435018316 47342069 47738636 642863127 189926256 40263985 58857249 119358305 864464366 83617839 485428518 305918980 9423...

output:

1996429420
1996287202
1997245731
1997158288
1998410767
1992680343
1996866185
1991187990
1993994382
1993278697
1998519189
1996981873
1996505587
1999396980
1996368678
1994926892
1995154606
1996246700
1998278411
1995699098
1998553319
1996046134
1996078476
1994270984
1993675913
1998307200
1994292194
199...

result:

ok 100001 lines

Test #11:

score: 0
Accepted
time: 309ms
memory: 23188kb

input:

1000000 1000000
681721767 150525996 385619734 237403201 784389657 667934330 103476610 977301142 659915560 343444475 784049915 969172199 251161944 919517420 927740574 885570202 531822081 391391357 889183133 954725705 921897422 339841876 886216126 698710851 968534847 834323464 33830362 168121355 74737...

output:

1998411706
1999115826
1999454117
1998836657
1998794667
1998269776
1999755051
1999381591
1998357039
1998230113
1999809722
1999320829
1999229409
1999798765
1998535400
1998709328
1999265546
1997784237
1998664760
1999789557
1998603617
1999595456
1999705003
1998179238
1999135621
1998190124
1998561110
199...

result:

ok 1000001 lines

Test #12:

score: 0
Accepted
time: 312ms
memory: 23196kb

input:

1000000 1000000
859805191 724074841 684432991 968065382 763738910 62670003 683505489 25517834 880849716 625748657 18118867 880475047 43737843 944343853 294935089 108242311 520102508 250671619 762613856 393989946 773993874 814765461 401323635 360776723 990848704 704633672 746924583 748546216 62586244...

output:

1999153565
1998922375
1997721720
1999093273
1998838958
1999407641
1998418249
1998250909
1998448991
1998131598
1999503251
1999133323
1999668728
1996876504
1998997127
1998456693
1998474784
1998680486
1998444192
1999742746
1999261645
1997944942
1998714408
1999571606
1998009280
1998932514
1999539785
199...

result:

ok 1000001 lines

Test #13:

score: 0
Accepted
time: 303ms
memory: 23252kb

input:

1000000 1000000
37888615 592590981 983246249 993694860 743088164 607148780 708244769 663669119 101783871 203020135 692379306 642034791 686570637 118913390 516905412 890722932 508382934 550143369 931011874 538286891 771314519 434913239 771206953 582651106 718195265 574943880 460018804 34003781 649576...

output:

1999040870
1998389768
1998486987
1998750065
1999570046
1998999846
1998466959
1998597646
1998651765
1998920821
1999606259
1999460166
1998879438
1998432387
1998655595
1998499939
1999399124
1999009605
1999576501
1999096183
1998399197
1999426537
1999444674
1998133711
1998313687
1998704116
1998625599
199...

result:

ok 1000001 lines

Test #14:

score: 0
Accepted
time: 306ms
memory: 23212kb

input:

1000000 1000000
921004743 166139826 722250995 314291633 577213225 446594852 288273648 711885811 27750731 190357022 366639746 403594534 624370727 143739823 884099927 968170849 936854848 409423632 99409892 832326940 918378268 55061017 286314462 99492785 740509122 5062601 173113025 54620130 528066880 5...

output:

1998252814
1999088948
1999154632
1998556605
1998012909
1997580019
1997826212
1997205871
1999347521
1998550231
1998806656
1998616565
1997661919
1999357225
1999738820
1999207108
1998644513
1998636528
1998692736
1998182183
1999138033
1997755290
1999060027
1998904028
1998479869
1999490247
1998535527
199...

result:

ok 1000001 lines

Test #15:

score: 0
Accepted
time: 299ms
memory: 23252kb

input:

1000000 1000000
99088167 444721374 316031548 190178007 851529775 136297821 18045631 55069799 248684886 472661204 745932889 165154278 562170817 318309361 106070250 45618767 220102571 708895382 972840614 976623884 65442016 235017306 96389267 321367168 762822979 580405513 181174542 635044991 846748488 ...

output:

1999808816
1999546408
1999511887
1997972111
1999525416
1999177742
1998895382
1999301427
1998683427
1998451107
1999708795
1998116472
1998978702
1997379027
1999468104
1999286658
1996653439
1998936965
1998503852
1998407411
1999250564
1997961935
1998789825
1998485755
1997761086
1997724392
1998570689
199...

result:

ok 1000001 lines

Test #16:

score: 0
Accepted
time: 311ms
memory: 23256kb

input:

1000000 1000000
277171591 168013322 760068998 215807485 685654837 680776598 188009103 398253787 469619041 754965386 420193329 221681318 205003612 48168498 473264766 123066684 353607189 568175644 846271336 270663933 917538469 855165084 316529481 838208847 490169540 450715721 894268763 920502556 57549...

output:

1998494838
1998423114
1999462821
1998426456
1998295744
1998682373
1999287674
1998826960
1997988135
1999740840
1999768385
1998924526
1998971787
1998394666
1998840068
1998843231
1998076944
1999414593
1997932895
1999093937
1998722730
1997826457
1997776964
1999737748
1999633669
1996811057
1999941569
199...

result:

ok 1000001 lines

Test #17:

score: 0
Accepted
time: 292ms
memory: 23252kb

input:

1000000 1000000
160287719 741562167 353849551 946469666 665004090 520222671 622813790 741437775 395585901 37269569 799486473 838016869 142803702 222738035 695235089 345738793 636854912 867647394 159893546 709928174 209826409 770280158 686412798 205307423 217516101 321025929 607362985 941118905 45398...

output:

1997970576
1999041782
1998693968
1997547266
1999353061
1998266739
1998901397
1998259083
1997873026
1998269849
1998703020
1998473742
1998956498
1997667670
1998060349
1997725444
1999041853
1998424607
1998915353
1997257162
1998930679
1998683778
1999496409
1999416754
1998303929
1998215765
1997695222
199...

result:

ok 1000001 lines

Test #18:

score: 0
Accepted
time: 302ms
memory: 23272kb

input:

1000000 1000000
338371143 610078307 92854297 972099144 644353344 209925640 352585773 84621763 616520056 319573751 768714208 599576613 375571088 247564468 212172708 423186710 770359530 21894953 33324268 854225119 356890158 245203744 201520307 427181806 239829958 46111946 615424502 521543766 772667233...

output:

1999160607
1998430363
1998998115
1999454864
1999104431
1997495013
1999600913
1998339017
1999666999
1998257302
1999257565
1999686551
1998223010
1998816615
1998756577
1998268448
1999761220
1998054789
1998032099
1999441216
1998054189
1998884323
1998450136
1999063624
1999134388
1998203599
1997868958
199...

result:

ok 1000001 lines

Test #19:

score: 0
Accepted
time: 54ms
memory: 13732kb

input:

1 1000000
578672810
419797124
955694590
114438853
1974869425
1959945244
1927637197
1101442047
298533757
2067317911
1312256868
996312379
968422904
538077951
661569152
562935822
527918651
1849610139
1330912793
231329643
1825667949
1506793409
1569459513
712734026
660132679
611759151
260054040
146588537...

output:

998469934
636724602
1168076905
1386694274
1223883592
1553296431
1068605562
1358478257
1312708560
579272030
1013076239
676887969
717746184
807872306
875067366
1306323591
1180696006
730446985
1220430988
1189941387
1101045748
1051356023
927921895
848559690
962798351
1499535297
817663405
691960660
12546...

result:

ok 1000001 lines

Test #20:

score: 0
Accepted
time: 75ms
memory: 15756kb

input:

10 1000000
412404504 959367531 853741030 979998953 816180343 505781888 557161191 467855804 907689526 113976695
243508775 706286682 610345322 152830884 131824124 427535402 688950222 663666590 304749988 966727699
1105317253
1301863305
1161843706
1918183860
1731636677
1258959907
1122466348
2067064725
1...

output:

1665654213
1874417225
1505130565
1668949175
1643665543
1782908042
1946726652
1820468729
1926095230
1540676011
1715088304
1445262634
1737865031
1901683641
1775425718
1881052219
1776431759
1766766309
1794277902
1793799451
1684922576
1848741186
1722483263
1866587329
1740329406
1845955907
1620215955
176...

result:

ok 1000001 lines

Test #21:

score: 0
Accepted
time: 112ms
memory: 15836kb

input:

100 1000000
691408775 169951905 880198113 701227169 216170826 699717434 809172837 933379198 807720110 750733849 165256909 123997639 62834222 606642949 776317137 6409227 776410206 32641528 737625980 972937295 71557730 975566754 526910637 756716940 735949428 788513251 849236121 933195566 334241377 180...

output:

1853853837
1888965452
1797686587
1883652189
1852312425
1803403567
1917108490
1952291388
1908981270
1924586096
1800379735
1833715098
1831316151
1959849463
1951352458
1957220004
1948722999
1766587239
1796226270
1892346173
1790913007
1889716714
1763118525
1793744177
1906660501
1908707356
1943890254
191...

result:

ok 1000001 lines

Test #22:

score: 0
Accepted
time: 116ms
memory: 13712kb

input:

200 1000000
635974463 367630090 292321372 28582904 97332372 376196553 794003840 811986355 714856617 191727655 434550311 94648848 530359179 107883101 157674238 298333117 858241705 596506793 665851992 580497831 646550361 770893259 418361514 193983361 864885074 832507274 966649615 74249284 892197680 57...

output:

1927838542
1941377289
1964222348
1831714043
1944687219
1892634161
1932438878
1903819673
1994786198
1910873851
1948856835
1965829801
1928426777
1953391559
1964584039
1976666375
1962118594
1798516626
1960432454
1960872832
1940760048
1972766509
1891380915
1964001737
1916441283
1959759008
1965835586
192...

result:

ok 1000001 lines

Test #23:

score: 0
Accepted
time: 102ms
memory: 15704kb

input:

400 1000000
230138545 472538075 676376401 538070183 449590054 19603173 473217462 278752283 969321119 368682561 712814810 35951268 760376387 255587596 475678040 27405089 462096193 873980426 77593615 676001878 531694408 656513567 940940963 803674988 977532175 625528023 496443898 506099823 12629198 373...

output:

1906932367
1913666800
1936032678
1909621937
1941912967
1849348171
1943713017
1930085577
1959747700
1961462250
1932287591
1971805117
1891507666
1940839087
1943074973
1880492571
1924146169
1939621783
1947063912
1873471876
1932527863
1890266521
1958290321
1898564916
1954968905
1939592742
1874617752
196...

result:

ok 1000001 lines

Test #24:

score: 0
Accepted
time: 110ms
memory: 13796kb

input:

800 1000000
418466708 682354046 594229564 411820549 4362316 605902622 122093090 357508332 333025931 277881973 974376513 213523402 955569588 845963883 851363341 195100648 524580975 129441483 200563071 691659701 861791014 688076486 836356757 877834050 497793673 801504112 850999760 515025093 838907914 ...

output:

1971691326
1960003154
1994757840
1914276242
1947992912
1939687912
1911825707
1955510431
1939440780
1944494247
1980762094
1976367379
1969498139
1954605014
1979520922
1962478443
1945093341
1978939998
1996164201
1931256640
1952150367
1932799436
1944892572
1970765324
1968657315
1948351099
1938021635
193...

result:

ok 1000001 lines

Test #25:

score: 0
Accepted
time: 98ms
memory: 15772kb

input:

1600 1000000
868247234 425589291 572701163 237847884 983771877 366736883 260409332 901752551 805830369 79797723 976966364 755002355 352059038 807156872 896114382 159443496 504392869 423584736 597306580 613947580 337049764 55704974 294018399 989939950 838537710 463364994 597481667 68082303 760506872 ...

output:

1958369256
1996732493
1974836020
1986237158
1965535761
1949613823
1958201870
1960076139
1944014723
1970348964
1967008166
1970248346
1942981999
1986791916
1950545930
1971827049
1947281173
1947977346
1956080648
1954554329
1932890237
1986880624
1956537641
1961718917
1976090773
1968270910
1976145603
194...

result:

ok 1000001 lines

Test #26:

score: 0
Accepted
time: 106ms
memory: 15768kb

input:

3000 1000000
319936735 570409302 662193651 151254359 641350297 780518988 310215377 936863458 387057025 582808242 737260188 347847439 235343745 110904830 640762272 112093061 638157667 70608168 506344266 692637616 422238040 709934382 477064365 503260990 695261556 174630800 656670975 20958372 137683503...

output:

1978414218
1979432710
1994514202
1961894584
1990155115
1961523283
1982645960
1976060706
1974455686
1968955302
1951385459
1972384629
1977253676
1976106018
1996289095
1993704871
1976929268
1967895526
1972314091
1968391567
1965733264
1993066521
1981188611
1965540490
1996444047
1980647288
1985412839
199...

result:

ok 1000001 lines

Test #27:

score: 0
Accepted
time: 103ms
memory: 15852kb

input:

5000 1000000
703861584 175177461 348561627 298155374 205958661 834072571 128302160 962206742 586452996 466940376 597188727 764599779 689063053 152733570 79099266 406220558 878453222 805855891 390284521 442298034 867891160 431090120 783138279 405465423 629604400 149860740 890658811 269386058 16660307...

output:

1979819237
1978643708
1976861884
1991632278
1975631757
1984581965
1994653641
1985003005
1996981701
1989994369
1981738706
1967650110
1991890026
1989938992
1983566729
1971004886
1990263220
1955645768
1972436622
1986768936
1978374585
1987729289
1983572750
1977264265
1984306627
1998336759
1962132249
199...

result:

ok 1000001 lines

Test #28:

score: 0
Accepted
time: 110ms
memory: 15768kb

input:

7000 1000000
233010626 484978323 329896899 150089093 770567026 742401962 651421647 542839627 490881670 56105214 897308753 36127928 847815066 194562310 662660451 550604951 678557290 690846717 129000583 191958452 168320089 152245858 649020705 602637152 414204141 830123385 684455160 517813744 195522640...

output:

1972688892
1990901573
1978345424
1980298597
1984578759
1993371864
1996356780
1969571920
1982415650
1987300048
1982699616
1976641580
1979555949
1982767601
1975889606
1994160504
1972264729
1984939003
1980950913
1969972304
1983720444
1988862144
1969299707
1964904756
1963448133
1982694583
1976533297
197...

result:

ok 1000001 lines

Test #29:

score: 0
Accepted
time: 105ms
memory: 15704kb

input:

20000 1000000
494017548 109254189 319376923 990538076 947156597 373873462 131226440 163397664 970444719 184684940 530535032 556141658 736676653 389893499 73222994 137000151 475926506 251752049 116557120 8219079 25110755 511179646 371644913 56747838 889363864 834300379 834237914 7072692 236489359 700...

output:

1989934907
1986533354
1995023567
1985252331
1993082904
1992773695
1996918866
1989952358
1996845827
1993385806
1995481074
1989588775
1992061182
1990348236
1991881922
1991607146
1995880417
1995394701
1993171325
1995915531
1993298834
1989580674
1987443276
1988827401
1986114447
1981743538
1998334284
199...

result:

ok 1000001 lines

Test #30:

score: 0
Accepted
time: 120ms
memory: 15768kb

input:

40000 1000000
598925534 493309219 828864201 342795759 885530514 493278572 38183857 417862166 852432329 462949440 766804748 786158867 884381149 2864598 952038070 740854639 603657035 813236776 476902383 893363126 615763767 738791799 981336540 464362235 682384613 364094662 411312645 272728402 32108097 ...

output:

1990937909
1996586376
1991221870
1993091593
1993313282
1995333091
1995183520
1994180519
1992707343
1997559374
1994186386
1989458568
1991772861
1994999481
1993152562
1995454580
1993848382
1995656269
1993633493
1998205452
1994738137
1992687022
1997333033
1996263713
1993241484
1996341679
1999164680
199...

result:

ok 1000001 lines

Test #31:

score: 0
Accepted
time: 159ms
memory: 17876kb

input:

300000 1000000
842020952 69061061 147081081 534556002 56511737 330276486 551070839 980822265 361525307 487394818 783733622 261126224 34665678 872981534 741758746 916916113 95252074 92244324 788505417 488939462 964151877 274915202 680922543 36867424 671678878 669545931 485979706 662623923 233143862 1...

output:

1997231708
1996917788
1998896141
1997098111
1995750444
1998097114
1998018191
1997427018
1998418868
1999131411
1998004605
1996809634
1998367010
1998915230
1997955057
1997010572
1997964162
1998706704
1996939280
1999288628
1999090362
1997918101
1997796298
1997984462
1997499181
1993949113
1997573310
199...

result:

ok 1000001 lines

Test #32:

score: 0
Accepted
time: 231ms
memory: 23836kb

input:

650000 1000000
438831058 838654854 716022352 817402355 192328519 253181260 881642827 770853284 817820981 545560969 336989734 382068144 891798475 767947474 787793633 216643024 169452539 249254429 623889539 4959324 670001662 803056455 118266771 657931475 194206669 404821905 878439071 887465047 3048539...

output:

1998556936
1997481399
1998292096
1998431001
1999179656
1999249338
1998384944
1999427815
1998479872
1998746266
1997220482
1998593108
1997744027
1998439952
1998222017
1999638372
1998840896
1999833783
1998129314
1998485716
1999226935
1999276735
1998716874
1998235313
1998671513
1996398398
1996881027
199...

result:

ok 1000001 lines

Test #33:

score: 0
Accepted
time: 46ms
memory: 11784kb

input:

5000 500000
221096187 706457905 666586614 847742136 904674395 779160158 554175973 974176009 325255635 855494087 152665596 566499584 606562085 302150891 688385686 217453891 168662762 567290425 901617191 448502956 937702670 67821462 858308531 993483977 985423695 36482780 969262932 9184863 687347649 30...

output:

1976192973
1984307775
1983058789
1980732426
1983456129
1979988080
1979274449
1988074474
1995057480
1997355295
1991250913
1989605371
1989301845
1975624037
1971736183
1982728062
1986317909
1977969060
1980677658
1991329471
1983952241
1976387536
1985861825
1987632201
1999347434
1980293168
1965124473
198...

result:

ok 500001 lines

Test #34:

score: 0
Accepted
time: 32ms
memory: 10976kb

input:

3000 300000
329548773 318101391 688367503 938379575 463328979 626266258 377480477 714260356 391577511 361516357 470193490 448242259 953056186 918176680 845397380 340677423 392028665 855712116 736277976 665459867 636298087 821855891 745552331 793139339 645164441 633770404 31854252 489346279 596930360...

output:

1992782527
1983419142
1986535668
1979720681
1967048746
1983304809
1963042550
1989622252
1962567006
1989612423
1985493467
1982107000
1979341048
1975968834
1994802909
1957788760
1985990486
1988569374
1980782286
1979454556
1993249433
1995394565
1974573826
1984197372
1967434284
1997233836
1987972210
199...

result:

ok 300001 lines