QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213880#6556. Text Editorucup-team087#0 20ms121004kbC++2023.6kb2023-10-14 16:29:092023-10-14 16:29:11

Judging History

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

  • [2023-10-14 16:29:11]
  • 评测
  • 测评结果:0
  • 用时:20ms
  • 内存:121004kb
  • [2023-10-14 16:29:09]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

//fast IO by yosupo
//sc.read(string) だと append される
struct Scanner {
    FILE* fp = nullptr;
    char line[(1 << 15) + 1];
    size_t st = 0, ed = 0;
    void reread() {
        memmove(line, line + st, ed - st);
        ed -= st;
        st = 0;
        ed += fread(line + ed, 1, (1 << 15) - ed, fp);
        line[ed] = '\0';
    }
    bool succ() {
        while (true) {
            if (st == ed) {
                reread();
                if (st == ed) return false;
            }
            while (st != ed && isspace(line[st])) st++;
            if (st != ed) break;
        }
        if (ed - st <= 50) reread();
        return true;
    }
    template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        ref.clear();
        while (true) {
            size_t sz = 0;
            while (st + sz < ed && !isspace(line[st + sz])) sz++;
            ref.append(line + st, sz);
            st += sz;
            if (!sz || st != ed) break;
            reread();            
        }
        return true;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        ref = T(0);
        while (isdigit(line[st])) {
            ref = 10 * ref + (line[st++] - '0');
        }
        if (neg) ref = -ref;
        return true;
    }
    template <class T> bool read_single(vector<T>& ref) {
        for (auto& d : ref) {
            if (!read_single(d)) return false;
        }
        return true;
    }
    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }
    Scanner(FILE* _fp) : fp(_fp) {}
};

struct Printer {
  public:
    template <bool F = false> void write() {}
    template <bool F = false, class H, class... T>
    void write(const H& h, const T&... t) {
        if (F) write_single(' ');
        write_single(h);
        write<true>(t...);
    }
    template <class... T> void writeln(const T&... t) {
        write(t...);
        write_single('\n');
    }

    Printer(FILE* _fp) : fp(_fp) {}
    ~Printer() { flush(); }

  private:
    static constexpr size_t SIZE = 1 << 15;
    FILE* fp;
    char line[SIZE], small[50];
    size_t pos = 0;
    void flush() {
        fwrite(line, 1, pos, fp);
        pos = 0;
    }
    void write_single(const char& val) {
        if (pos == SIZE) flush();
        line[pos++] = val;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void write_single(T val) {
        if (pos > (1 << 15) - 50) flush();
        if (val == 0) {
            write_single('0');
            return;
        }
        if (val < 0) {
            write_single('-');
            val = -val;  // todo min
        }
        size_t len = 0;
        while (val) {
            small[len++] = char('0' + (val % 10));
            val /= 10;
        }
        for (size_t i = 0; i < len; i++) {
            line[pos + i] = small[len - 1 - i];
        }
        pos += len;
    }
    void write_single(const string& s) {
        for (char c : s) write_single(c);
    }
    void write_single(const char* s) {
        size_t len = strlen(s);
        for (size_t i = 0; i < len; i++) write_single(s[i]);
    }
    template <class T> void write_single(const vector<T>& val) {
        auto n = val.size();
        for (size_t i = 0; i < n; i++) {
            if (i) write_single(' ');
            write_single(val[i]);
        }
    }
    void write_single(long double d){
		{
			long long v=d;
			write_single(v);
			d-=v;
		}
		write_single('.');
		for(int _=0;_<8;_++){
			d*=10;
			long long v=d;
			write_single(v);
			d-=v;
		}
    }
};

Scanner sc(stdin);
Printer pr(stdout);

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

pi readpi(int off=0){
	int a,b;cin>>a>>b;
	return pi(a+off,b+off);
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?suc:2);
}

template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
	rep(i,v.size())
		print_single(v[i]+off,i==int(v.size())-1?suc:2);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?suc:2);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t>
bool bis(const vc<t>&v,const t&a){
	return binary_search(all(v),a);
}

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> readTree(int n){
	return readGraph(n,n-1);
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class t>
t MIN(const vc<t>&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t>
void pb(vc<t>&a,const vc<t>&b){
	a.insert(a.ed,all(b));
}

template<class t>
vc<t> cat(vc<t> a,const vc<t>&b){
	pb(a,b);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}

template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
	return a-=x;
}

//#define PAVLLAZY
//S_ bytes のバッファを確保
//ARC030D
//Copy and Paste
//FHC 2022 Round3 E2
//https://qiita.com/QCFium/items/3cf26a6dc2d49ef490d7
template<class N,int S_>
struct pavl{
	struct N2{
		using np=N2*;
		N v;
		np l,r;
		int h;
		//h は葉までの最長パスのノード数
		//null node で 0
		//v has no lazy data
		np upd(){
			v.single();
			h=0;
			if(l){
				v.updatel(l->v);
				chmax(h,l->h);
			}
			if(r){
				v.updater(r->v);
				chmax(h,r->h);
			}
			h++;
			return this;
		}
		np L(np x){l=x;return upd();}
		np R(np x){r=x;return upd();}
		np LR(np x,np y){l=x;r=y;return upd();}
	};
	static constexpr int S=S_/sizeof(N2);
	N2 buf[S];
	using np=N2*;
	int fix=0,used=0;
	np nn(N v){
		assert(used<S);
		buf[used]=N2{v,0,0,1};
		return buf+used++;
	}
	//a is not null
	np clone(np&a){
		if(a-buf<fix){
			assert(used<S);
			buf[used]=*a;
			a=buf+used++;
		}
		return a;
	}
	//a is not null
	np push(np&x){
		clone(x);
		#ifdef PAVLLAZY
		if(x->l)x->v.push(clone(x->l)->v);
		if(x->r)x->v.push(clone(x->r)->v);
		x->v.clear();
		#endif
		return x;
	}
	int hei(np x){return x?x->h:0;}
	N val(np x){return x?x->v:N();}
	int ok(int a,int b){return abs(a-b)<=1;}
	//x is already cloned
	//x needs upd
	//hei(res)==max(hei(x->l),hei(x->r))+(0 or 1)
	//O(|hei(x->r)-hei(x->r)|)
	np balance(np x){
		np a=x->l;
		np b=x->r;
		int dif=hei(a)-hei(b);
		if(inc(-1,dif,1)){
			return x->upd();
		}else if(dif<0){
			push(b);
			if(dif<-2){
				return Lb(b,Rb(x,b->l));
			}else if(ok(hei(b->l)+1,hei(b->r))){
				return b->L(x->R(b->l));
			}else{
				np y=push(b->l);
				return y->LR(x->R(y->l),b->L(y->r));
			}
		}else if(dif>0){
			push(a);
			if(dif>2){
				return Rb(a,Lb(x,a->r));
			}else if(ok(hei(a->l),hei(a->r)+1)){
				return a->R(x->L(a->r));
			}else{
				np y=push(a->r);
				return y->LR(a->R(y->l),x->L(y->r));
			}
		}else assert(false);
	}
	np Lb(np x,np a){x->l=a;return balance(x);}
	np Rb(np x,np a){x->r=a;return balance(x);}
	//hei(res)==max(hei(a),hei(b))+(0 or 1)
	//O(hei(a)+hei(b))
	np mergedfs(np a,np b){
		if(a==0)return b;
		if(b==0)return a;
		if(hei(a)<hei(b)){
			push(b);
			return Lb(b,mergedfs(a,b->l));
		}else{
			push(a);
			return Rb(a,mergedfs(a->r,b));
		}
	}
	template<class...Args>
	np merge(Args...args){
		fix=used;
		np res=0;
		for(auto x:{args...})res=mergedfs(res,x);
		return res;
	}
	template <class F,class... Args> 
	pair<np,np> max_right(np x,N cur,F f,Args&&... args){
		if(x==0)return mp(np(0),np(0));
		push(x);
		x->v.single();
		N nx=cur;
		nx.updater(val(x->l));
		nx.updater(val(x));
		if((nx.*f)(forward<Args>(args)...)){
			auto [a,b]=max_right(x->r,nx,f,forward<Args>(args)...);
			return mp(Rb(x,a),b);
		}else{
			auto [a,b]=max_right(x->l,cur,f,forward<Args>(args)...);
			return mp(a,Lb(x,b));
		}
	}
	template <class F,class... Args> 
	pair<np,np> max_right(np x,F f,Args&&... args){
		fix=used;
		return max_right(x,N(),f,forward<Args>(args)...);
	}
	//f(v,args)=true が左,false が右
	//not verified
	/*template <class F,class... Args>
	pair<np,np> split_by_cmp(np x,F f,Args&&... args){
		if(x==0)return mp(np(0),np(0));
		push(x);
		x->v.single();
		if(f(x->v,forward<Args>(args)...)){
			auto [a,b]=split_by_cmp(x->r,f,forward<Args>(args)...);
			return mp(Rb(x,a),b);
		}else{
			auto [a,b]=split_by_cmp(x->l,f,forward<Args>(args)...);
			return mp(a,Lb(x,b));
		}
	}*/
	//lower_bound の位置に insert
	//FHC 2022 Round3 E2 (without LAZY)
	template <class F>
	np insertdfs(np x,F f,const N&v){
		if(x==0)return nn(v);
		push(x);
		x->v.single();
		if(f(x->v,v)){
			return Rb(x,insertdfs(x->r,f,v));
		}else{
			return Lb(x,insertdfs(x->l,f,v));
		}
	}
	template <class F>
	np insert_by_cmp(np x,F f,const N&v){
		fix=used;
		return insertdfs(x,f,v);
	}
	//lower_bound の位置を erase
	//erase が実際に走ったかどうかが bool で返る
	//FHC 2022 Round3 E2 (without LAZY, all true)
	template <class F>
	pair<bool,np> erasedfs(np x,F f,const N&v){
		if(x==0)return mp(false,np(0));
		push(x);
		x->v.single();
		if(f(x->v,v)){
			auto [done,y]=erasedfs(x->r,f,v);
			return mp(done,Rb(x,y));
		}else{
			auto [done,y]=erasedfs(x->l,f,v);
			if(done)return mp(true,Lb(x,y));
			else return mp(true,merge(y,x->r));
		}
	}
	template <class F>
	pair<bool,np> erase_by_cmp(np x,F f,const N&v){
		fix=used;
		return erasedfs(x,f,v);
	}
	//lower_bound が存在するかどうかを bool で返す
	//存在するならノード情報も返す
	//FHC 2022 Round3 E2 (without LAZY)
	template <class F>
	pair<bool,N> lower_bound_by_cmp(np x,F f,N v){
		fix=used;
		np res=0;
		while(x){
			push(x);
			x->v.single();
			if(f(x->v,v)){
				x=x->r;
			}else{
				res=x;
				x=x->l;
			}
		}
		used=fix;
		if(res)return mp(true,res->v);
		else return mp(false,N());
	}
	np insert(np x,const N&v){return insert_by_cmp(x,less<N>(),v);}
	pair<bool,np> erase(np x,const N&v){return erase_by_cmp(x,less<N>(),v);}
	pair<bool,N> lower_bound(np x,const N&v){return lower_bound_by_cmp(x,less<N>(),v);}
	void clear(){fix=used=0;}
	template<class T>
	np build(const T&rw){
		fix=used;
		auto dfs=[&](auto self,int l,int r)->np{
			if(l==r)return 0;
			int m=(l+r)/2;
			np x=nn(rw[m]);
			return x->LR(self(self,l,m),self(self,m+1,r));
		};
		return dfs(dfs,0,si(rw));
	}
	vc<N> listup(np root){
		fix=used;
		vc<N> res;
		auto dfs=[&](auto self,np x)->void{
			if(x==0)return;
			push(x);
			self(self,x->l);
			res.pb(x->v);
			self(self,x->r);
		};
		dfs(dfs,root);
		return res;
	}
	void rebuild_if_needed(np&x,int maxlen){
		if(used+1000+maxlen>S){
			auto ls=listup(x);
			clear();
			x=build(ls);
		}
	}
};
//デフォルトコンストラクターが null node になっているべき (例えば len=0)
//reverse なし
//N::push
//副作用なし,1個の子にpush
//N::clear
//lazy tagを消去
//push/lazy は PAVLAZY がdefineされてなければ呼ばれない(これ定数倍変わる?)
//N::single
//ノード単体の情報を元に部分木情報を初期化
//N::updatel,updater
//N::ok
//max_right のノリで split をする
//ノード同士の比較関数でも split 可能(TODO)
//TODO 細かい実装の違いによる定数倍を検証

//Copy and Paste
template<class t>
struct SingleElement{
	t val;
	int len;
	SingleElement():val(0),len(0){}
	SingleElement(t v):val(v),len(1){}
	void single(){
		len=1;
	}
	void upd(const SingleElement&x){
		len+=x.len;
	}
	void updatel(const SingleElement&x){upd(x);}
	void updater(const SingleElement&x){upd(x);}
	bool ok_len(int x){
		return len<=x;
	}
};
using N=SingleElement<char>;

pavl<N,120*ten(6)> t;
using np=decltype(t)::np;

//https://stackoverflow.com/a/49091681
template<class Tuple>
auto tuple_pop_front(Tuple tuple) {
	return apply([](auto a,auto...rest){return mp(a,mt(rest...));},tuple);
}
tuple<np> cut_by_index(np a){
	return a;
}
template<class...Args>
auto cut_by_index(np x,int pos,Args...args){
	assert((!x&&pos==0)||inc(0,pos,x->v.len));
	auto [ab,c]=tuple_pop_front(cut_by_index(x,args...));
	return tuple_cat(t.max_right(ab,&N::ok_len,pos),c);
}

bool dbg=false;

np slv(string raw,bool isder){
	vc<np> roots{nullptr};
	int cur=0;
	np clip=nullptr;

	stringstream ss(raw);
	int n;ss>>n;
	
	auto insert=[&](){
		np root=roots[cur];
		
		int p;ss>>p;
		string s;ss>>s;
		auto [x,y]=cut_by_index(root,p);
		root=t.merge(x,t.build(s),y);
		
		roots.resize(++cur);
		roots.pb(root);
	};
	auto erase=[&](){
		np root=roots[cur];
		
		int l,r;ss>>l>>r;
		auto [x,y,z]=cut_by_index(root,l,r);
		root=t.merge(x,z);
		
		roots.resize(++cur);
		roots.pb(root);
	};
	auto copy=[&](){
		np root=roots[cur];
		
		int l,r;ss>>l>>r;
		auto [x,y,z]=cut_by_index(root,l,r);
		clip=y;
	};
	auto cut=[&](){
		np root=roots[cur];
		
		int l,r;ss>>l>>r;
		auto [x,y,z]=cut_by_index(root,l,r);
		root=t.merge(x,z);
		clip=y;
		
		roots.resize(++cur);
		roots.pb(root);
	};
	auto paste=[&](){
		np root=roots[cur];
		
		int p;ss>>p;
		auto [x,y]=cut_by_index(root,p);
		root=t.merge(x,clip,y);
		
		roots.resize(++cur);
		roots.pb(root);
	};
	auto print_ans=[&](){
		np root=roots[cur];
		
		int l,r;ss>>l>>r;
		if(isder)return;
		
		auto [x,y,z]=cut_by_index(root,l,r);
		auto ans=t.listup(y);
		
		for(auto c:ans)pr.write(c.val);
		pr.write("\n");
	};
	auto serialize=[&](){
		if(isder)return;
		
		//!0->space
		//!1->!
		string ser;
		for(auto c:raw){
			if(c==' '){
				ser+='!';
				ser+='0';
			}else if(c=='!'){
				ser+='!';
				ser+='1';
			}else{
				ser+=c;
			}
		}
		
		assert(si(ser)<=ten(7));
		pr.writeln(ser);
	};
	auto deserialize=[&](){
		string en;ss>>en;
		if(isder)return;
		
		string nx;
		for(int i=0;i<si(en);){
			char c=en[i];
			if(c=='!'){
				i++;
				if(en[i]=='0')nx+=' ';
				else if(en[i]=='1')nx+='!';
				else assert(0);
			}else{
				nx+=c;
			}
			i++;
		}
		
		np root=slv(nx,true);
		
		roots.resize(++cur);
		roots.pb(root);
	};
	rep(phase,n){
		string type;ss>>type;
		
		if(type=="insert"){
			insert();
		}else if(type=="erase"){
			erase();
		}else if(type=="print"){
			print_ans();
		}else if(type=="copy"){
			copy();
		}else if(type=="cut"){
			cut();
		}else if(type=="paste"){
			paste();
		}else if(type=="undo"){
			if(cur>0)cur--;
		}else if(type=="redo"){
			if(cur+1<si(roots))cur++;
		}else if(type=="serialize"){
			serialize();
		}else if(type=="deserialize"){
			deserialize();
		}else{
			dmp(type);
			assert(false);
		}
	}
	return roots[cur];
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	if(dbg){
		//while(1)slv();
	}else{
		//int t;cin>>t;rep(_,t)
		string raw;
		while(1){
			string s;
			if(sc.read_single(s)){
				raw+=" ";
				raw+=s;
			}
			else break;
		}
		slv(raw,false);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 120860kb

First Run Input

17
insert 0 abcdef
print 0 6
erase 4 5
print 0 5
copy 0 3
paste 1
print 0 8
cut 2 4
print 0 6
undo
print 0 8
paste 6
print 0 10
redo
redo
print 0 10
serialize

First Run Output

abcdef
abcdf
aabcbcdf
aabcdf
aabcbcdf
aabcbcbcdf
aabcbcbcdf
!017!0insert!00!0abcdef!0print!00!06!0erase!04!05!0print!00!05!0copy!00!03!0paste!01!0print!00!08!0cut!02!04!0print!00!06!0undo!0print!00!08!0paste!06!0print!00!010!0redo!0redo!0print!00!010!0serialize

Second Run Input

2
deserialize !017!0insert!00!0abcdef!0print!00!06!0erase!04!05!0print!00!05!0copy!00!03!0paste!01!0print!00!08!0cut!02!04!0print!00!06!0undo!0print!00!08!0paste!06!0print!00!010!0redo!0redo!0print!00!010!0serialize
print 0 10

Second Run Output

aabcbcbcdf

result:

ok stage 2 is ok!

Test #2:

score: 100
Accepted
time: 8ms
memory: 120852kb

First Run Input

1
serialize

First Run Output

!01!0serialize

Second Run Input

1
deserialize !01!0serialize

Second Run Output


result:

ok stage 2 is ok!

Test #3:

score: 100
Accepted
time: 8ms
memory: 120844kb

First Run Input

31
undo
redo
redo
undo
undo
undo
redo
undo
redo
undo
undo
undo
undo
undo
redo
redo
undo
undo
redo
undo
redo
redo
redo
undo
undo
undo
redo
undo
redo
redo
serialize

First Run Output

!031!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0redo!0undo!0undo!0undo!0undo!0undo!0redo!0redo!0undo!0undo!0redo!0undo!0redo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0redo!0redo!0serialize

Second Run Input

31
deserialize !031!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0redo!0undo!0undo!0undo!0undo!0undo!0redo!0redo!0undo!0undo!0redo!0undo!0redo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0redo!0redo!0serialize
redo
undo
redo
redo
redo
redo
redo
undo
undo
undo
redo
redo
undo
redo
undo
redo
undo
redo...

Second Run Output


result:

ok stage 2 is ok!

Test #4:

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

First Run Input

31
undo
redo
redo
undo
undo
redo
redo
redo
undo
undo
undo
redo
redo
undo
redo
undo
redo
undo
redo
redo
redo
undo
redo
undo
redo
redo
undo
undo
redo
undo
serialize

First Run Output

!031!0undo!0redo!0redo!0undo!0undo!0redo!0redo!0redo!0undo!0undo!0undo!0redo!0redo!0undo!0redo!0undo!0redo!0undo!0redo!0redo!0redo!0undo!0redo!0undo!0redo!0redo!0undo!0undo!0redo!0undo!0serialize

Second Run Input

31
deserialize !031!0undo!0redo!0redo!0undo!0undo!0redo!0redo!0redo!0undo!0undo!0undo!0redo!0redo!0undo!0redo!0undo!0redo!0undo!0redo!0redo!0redo!0undo!0redo!0undo!0redo!0redo!0undo!0undo!0redo!0undo!0serialize
undo
redo
undo
redo
redo
redo
undo
undo
undo
redo
undo
redo
undo
redo
undo
undo
redo
undo...

Second Run Output


result:

ok stage 2 is ok!

Test #5:

score: 100
Accepted
time: 8ms
memory: 120796kb

First Run Input

31
undo
undo
undo
redo
redo
redo
redo
undo
undo
redo
redo
undo
undo
undo
redo
redo
redo
redo
undo
redo
redo
undo
undo
undo
redo
undo
undo
undo
undo
redo
serialize

First Run Output

!031!0undo!0undo!0undo!0redo!0redo!0redo!0redo!0undo!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0redo!0redo!0redo!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0undo!0undo!0undo!0redo!0serialize

Second Run Input

31
deserialize !031!0undo!0undo!0undo!0redo!0redo!0redo!0redo!0undo!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0redo!0redo!0redo!0undo!0redo!0redo!0undo!0undo!0undo!0redo!0undo!0undo!0undo!0undo!0redo!0serialize
redo
redo
undo
undo
undo
redo
redo
redo
redo
redo
redo
redo
redo
redo
undo
undo
redo
undo...

Second Run Output


result:

ok stage 2 is ok!

Test #6:

score: 100
Accepted
time: 4ms
memory: 120904kb

First Run Input

1001
insert 0 u]^rGH]V+A3/VCu}4-dod,hyG&]WkL1)rg$W4\W0XL7sfyA[GNpfX2rx8Sc6$fmzW&x3E//Q0M\7=?Io7mupWV9Y4z6aY4E9ia$S{1KfioW29lST';?emw,Upk.b`^tl.O^btxvAx>:=&rC@6k`[GQCv;s[myKiSV1tp!Z)bj:
copy 0 170
paste 170
copy 0 340
paste 340
cut 415 652
copy 0 443
paste 443
cut 282 500
erase 0 576
copy 0 92
paste ...

First Run Output

/VCu}4-dod,hyG&]WkL1)rg)bj:/VCu}4-dyKlPm}+uRG&]WkL1)rg)bj:/V)bj:/VCu})bj:/)rg)bj:/VCG&]WkL1)rg)bj:/VCu}4-dyKlPm}+uRG&]WkL1)rg)bj:/V)
/VCu}4/VCu}4
4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}4/VCu}
Cu4//VCuCu}4//VCu}4/Cu}4//VCu}4/VCu}CuCu}4/u}4//VCu}4/VCu}CuC...

Second Run Input

1001
deserialize !01001!0insert!00!0u]^rGH]V+A3/VCu}4-dod,hyG&]WkL1)rg$W4\W0XL7sfyA[GNpfX2rx8Sc6$fmzW&x3E//Q0M\7=?Io7mupWV9Y4z6aY4E9ia$S{1KfioW29lST';?emw,Upk.b`^tl.O^btxvAx>:=&rC@6k`[GQCv;s[myKiSV1tp!1Z)bj:!0copy!00!0170!0paste!0170!0copy!00!0340!0paste!0340!0cut!0415!0652!0copy!00!0443!0paste!0443...

Second Run Output

4/}4/u}4/
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu...

result:

ok stage 2 is ok!

Test #7:

score: 100
Accepted
time: 20ms
memory: 120964kb

First Run Input

1001
insert 0 w,[bkd4hhpQ'MmMc:IK6O#ZVGwy`{iW,dmR]!Zo)u{|F*Y_"SI9dsR.a@Y@5YU[vEAya3.Y<C~U+JY66Co-HfJ*WN
undo
redo
erase 75 84
cut 3 78
paste 2
undo
erase 1 3
redo
erase 1 3
copy 0 1
cut 0 1
redo
redo
redo
undo
copy 0 1
paste 1
redo
undo
copy 0 1
undo
undo
copy 0 4
cut 1 5
undo
cut 0 5
redo
redo
undo...

First Run Output

w,[,[WNWN
bb{b{
NNNN
*
*
*
AERER
ERRKRR
!01001!0insert!00!0w,[bkd4hhpQ'MmMc:IK6O#ZVGwy`{iW,dmR]!1Zo)u{|F*Y_"SI9dsR.a@Y@5YU[vEAya3.Y<C~U+JY66Co-HfJ*WN!0undo!0redo!0erase!075!084!0cut!03!078!0paste!02!0undo!0erase!01!03!0redo!0erase!01!03!0copy!00!01!0cut!00!01!0redo!0redo!0redo!0undo!0copy!00!01!0pas...

Second Run Input

1001
deserialize !01001!0insert!00!0w,[bkd4hhpQ'MmMc:IK6O#ZVGwy`{iW,dmR]!1Zo)u{|F*Y_"SI9dsR.a@Y@5YU[vEAya3.Y<C~U+JY66Co-HfJ*WN!0undo!0redo!0erase!075!084!0cut!03!078!0paste!02!0undo!0erase!01!03!0redo!0erase!01!03!0copy!00!01!0cut!00!01!0redo!0redo!0redo!0undo!0copy!00!01!0paste!01!0redo!0undo!0copy...

Second Run Output

\HKrk`Qy`e6Jpyc/>5Kw}A,syx1^4Ej[]
p
pppp
pp
p
R[Gam_HY~-PG

result:

ok stage 2 is ok!

Test #8:

score: 100
Accepted
time: 12ms
memory: 120840kb

First Run Input

1001
insert 0 R9cgb7*%)7^_EA4jD9J^u<P0QmI/lYpy4J/L"?KY?_<-""SZH]`e)D=8'XLd5XF3l/BPwfQ6Pqd6x{[U``+lywj-r0AiLtCyIOw_(}rPBcgVg2,T\2YB0v#J)'Q2A$ZF@-t$.vKp~Z\c9rQY?js|<\Fl"um?oLARgQ`]q+Ci)Yh]|9bm-!t2/$@gC)p&e&{+T$mtW4TnoG_J\yBE@#1X9;S6swU#qBX"./2uUjc*rP6]{
copy 0 237
paste 0
copy 0 474
paste 0
undo
copy ...

First Run Output

{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{...

Second Run Input

1001
deserialize !01001!0insert!00!0R9cgb7*%)7^_EA4jD9J^u<P0QmI/lYpy4J/L"?KY?_<-""SZH]`e)D=8'XLd5XF3l/BPwfQ6Pqd6x{[U``+lywj-r0AiLtCyIOw_(}rPBcgVg2,T\2YB0v#J)'Q2A$ZF@-t$.vKp~Z\c9rQY?js|<\Fl"um?oLARgQ`]q+Ci)Yh]|9bm-!1t2/$@gC)p&e&{+T$mtW4TnoG_J\yBE@#1X9;S6swU#qBX"./2uUjc*rP6]{!0copy!00!0237!0paste!00!0...

Second Run Output

{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{...

result:

ok stage 2 is ok!

Test #9:

score: 100
Accepted
time: 8ms
memory: 120944kb

First Run Input

1001
insert 0 j#L3^;DU'OLTqzqjUI7#AK@2p~sohf~P~p\J1
copy 0 37
paste 37
copy 0 74
paste 74
copy 0 148
paste 148
copy 0 296
paste 296
paste 277
copy 157 175
cut 31 867
copy 0 52
paste 52
copy 0 104
paste 104
copy 0 208
paste 208
copy 0 416
paste 416
erase 439 824
copy 0 447
paste 447
undo
copy 0 447
p...

First Run Output

UI7#AK
~PJ1J1j#TqzqjUI7#AK@2p~sK@2f~PJ1j#Lj#L3UI7#AK@2p~sohf~UI7#AK@2p~sohf~PJ1j#TqzqjUI7#AK@2p~sK~sohf~PJ1j#TqzqjUI
#PJ1ohf~UI7#PJ1j#TqzqjUI7#AK@2p~sK@2j#hPJ@7#AK@2p~sK@AK@2hf~AK@2AK@2p~sohf~UI7#PJ1ohf~UI7#PJ
2j#hJ1ohf~UI7#PJ1j#T7#PJ
J1j#j#T7#PJ1jJ1j#j#T7#7#,esh-0szl7t6XCx9j#j#T7#PJ1jJ1j#j#T7#7#PJ1...

Second Run Input

1001
deserialize !01001!0insert!00!0j#L3^;DU'OLTqzqjUI7#AK@2p~sohf~P~p\J1!0copy!00!037!0paste!037!0copy!00!074!0paste!074!0copy!00!0148!0paste!0148!0copy!00!0296!0paste!0296!0paste!0277!0copy!0157!0175!0cut!031!0867!0copy!00!052!0paste!052!0copy!00!0104!0paste!0104!0copy!00!0208!0paste!0208!0copy!00...

Second Run Output

J17##
1J1J17##PJj17##PJJ1#jJ11J1J17##PJJJ1#jJ11J1J17##PJJ1#jJ1J1J1J17##PJj17##PJJ1#jJ11J1J17##PJJ1#j
J1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##P1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##jJ1J1J1J17##PJj17##j...

result:

ok stage 2 is ok!

Test #10:

score: 100
Accepted
time: 16ms
memory: 120840kb

First Run Input

1001
insert 0 U]_hFNe]96`ZG~m{f6KZ1%84w$UnC)nTUP`aVw,2hP^
cut 3 24
copy 9 16
undo
erase 5 35
paste 8
erase 2 20
erase 0 2
undo
erase 0 1
redo
redo
cut 0 1
undo
redo
redo
redo
redo
undo
erase 0 1
redo
undo
redo
redo
redo
redo
redo
redo
redo
redo
undo
redo
undo
cut 0 1
redo
undo
copy 0 1
paste 1
inser...

First Run Output

FFAkBNZvaU+gniVAnxa?b$xp?UIXJ'qx|%VAnxa?b$xp?UIXJ
d
d
dd
PIP
PP
PPPPPP
h5k%S=hV9}tHY/d2!]eR$)e6s@'Nhs'BwT9m+2)0$rAr(Qe)9}e|,h+KT[VMH.-.(,nNf-_sRln@m$GCB?hV=q9Y<c9nG.]
!01001!0insert!00!0U]_hFNe]96`ZG~m{f6KZ1%84w$UnC)nTUP`aVw,2hP^!0cut!03!024!0copy!09!016!0undo!0erase!05!035!0paste!08!0erase!02!020!0...

Second Run Input

1001
deserialize !01001!0insert!00!0U]_hFNe]96`ZG~m{f6KZ1%84w$UnC)nTUP`aVw,2hP^!0cut!03!024!0copy!09!016!0undo!0erase!05!035!0paste!08!0erase!02!020!0erase!00!02!0undo!0erase!00!01!0redo!0redo!0cut!00!01!0undo!0redo!0redo!0redo!0redo!0undo!0erase!00!01!0redo!0undo!0redo!0redo!0redo!0redo!0redo!0redo...

Second Run Output

O
*
***
EEEEXE
X
E
4

result:

ok stage 2 is ok!

Test #11:

score: 100
Accepted
time: 4ms
memory: 120884kb

First Run Input

1001
insert 0 s\qY89t=.
copy 0 9
paste 0
copy 0 18
paste 0
copy 0 36
paste 0
copy 0 72
paste 0
copy 0 144
paste 0
copy 0 288
paste 0
paste 73
redo
undo
undo
copy 0 288
paste 0
copy 17 512
cut 188 432
copy 0 332
paste 0
copy 176 185
paste 619
erase 191 578
copy 0 286
paste 0
undo
copy 0 286
paste 0
u...

First Run Output

.s=.s\qY8s\qY89
s\qY8s\qY89t=.s\qY89t=.s\qY89t=.s\qY89t=.s\qY89t=.s=.s\qY8s\qY89t=.s\qY89t=.s\qY89t\qY89s\qY89t=.s\qY89t=.s\qY89t=.s=.s\qY8s\qY8
qY89t=.s\qY89t=.s=.s\qY8s\qY89t=.s\qY89t=.s\qY89t\qY89s\qY89t=.s\qY89t=.s\qY89t=.s=.s\qY8s\qY89t=.s\qY89t=.s\qY89t=.s\qY89t=.s\qY89t=
t=.s=9t=.s=s=9t==.s=t...

Second Run Input

1001
deserialize !01001!0insert!00!0s\qY89t=.!0copy!00!09!0paste!00!0copy!00!018!0paste!00!0copy!00!036!0paste!00!0copy!00!072!0paste!00!0copy!00!0144!0paste!00!0copy!00!0288!0paste!00!0paste!073!0redo!0undo!0undo!0copy!00!0288!0paste!00!0copy!017!0512!0cut!0188!0432!0copy!00!0332!0paste!00!0copy!01...

Second Run Output

sssssssssssssssssssssssssssssssssssssssssssssssss
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssssssssssss
ssssss
sssss!ssssssssssssss!ss
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...

result:

ok stage 2 is ok!

Test #12:

score: 100
Accepted
time: 8ms
memory: 120944kb

First Run Input

1001
insert 0 {H\.We~<K@;u=Xv5m.ZhVjS;-0Q45o'WH!DY;CA
copy 0 39
paste 39
copy 0 78
paste 78
copy 0 156
paste 156
copy 0 312
paste 312
paste 337
erase 224 921
copy 0 239
paste 239
copy 0 478
paste 478
undo
copy 0 478
paste 478
copy 33 688
undo
copy 0 478
paste 478
erase 5 953
copy 0 8
paste 8
copy 0 ...

First Run Output

\.W;A{H\.WW;CA{H\.W;C\{H\\.W;C\.W{H\.W;A{H\.WW;CA{H\.W;C\.W{H
.WW;CA{H\.W;C\{{H\.W;A{H\.WW;CA{H;CA{H\.W;C\.W{H\.W;A{H\.WW{H;CA{H\.W;W;C\.W{H\.W;A{H\.WW{H;CA{H\.W;C\.W{H\.W;A{H\.WW;CA{H\.W;C\{{H\.W;A{H\.WW;CA{H;CA{H\.W;C\.W{H\.W;
;A{;W;\.W;C\.W{H\.W;A{;W;\.W;\.W;C\.W{H\.W;A{;W;\.W;C\.W{H
{;W;\.W;C\.W...

Second Run Input

1001
deserialize !01001!0insert!00!0{H\.We~<K@;u=Xv5m.ZhVjS;-0Q45o'WH!1DY;CA!0copy!00!039!0paste!039!0copy!00!078!0paste!078!0copy!00!0156!0paste!0156!0copy!00!0312!0paste!0312!0paste!0337!0erase!0224!0921!0copy!00!0239!0paste!0239!0copy!00!0478!0paste!0478!0undo!0copy!00!0478!0paste!0478!0copy!033!...

Second Run Output

W\.W;A{.{;W\WW;A{.{;W\WW;A{.W;WW;A{.W;A{;W;W{;W\.W
;A{;W;.W;A{;W;W{;W\.W;A{A{;W;W{;W\.W;A{.W;A{;W;.W
W;A{;W;W{.W;A{
A{{;W;W{;A{{;W;W{;A{{;W;W{;A{{;W;W{;A{{;W;W{;A{{
;W;W{;A{{;W;W{;A{{;W;W{;A{{;W;W{;A{W{;A{{;W;W{;
{;W{W;W{;W{;AW{W;W{A{{;W;W{;A{{;W;W{;A{{A;A{{;A{{A;A{{A{{;W;A{{;W;W{;W{;AW{W;W{A{{;W;W{...

result:

ok stage 2 is ok!

Test #13:

score: 100
Accepted
time: 12ms
memory: 120936kb

First Run Input

1001
insert 0 >z_KEL9ZY(#{ZS\@MS`>!h5.lOmCfGZ$eq=o:uyVYhMi<=Z}E"u9z/dh2D9EVC~a""z-yvX~Elg*O&Dt?5o)XiIlVyFqKAgFD:XL(/x!0J[S7q:+9xLN`s;7)`2#8[7R|_WZ#r`=VKspNXFo|DV;aZe&!EE6$P);2o&K[iCamZc&6)\Ndtr4w4CJxMi*C#<'GD+qE}7V+3Hgk]aFy"IK+c>[81qN\,u!AmbuIc={l>JT()R8WhDN"[NPfDrTPtGH<98j#^0'5huO}S~HPyGJo
copy 68 ...

First Run Output

>>>zJzJo
>>>zJzJ>>>zJzJo
#z~F(z~F(z~F(e45e45e4545Gz~F(e45f
#fI8T!#pf/L)/3\2nU="u0
#f"u0
,,,
MTM
!01001!0insert!00!0>z_KEL9ZY(#{ZS\@MS`>!1h5.lOmCfGZ$eq=o:uyVYhMi<=Z}E"u9z/dh2D9EVC~a""z-yvX~Elg*O&Dt?5o)XiIlVyFqKAgFD:XL(/x!10J[S7q:+9xLN`s;7)`2#8[7R|_WZ#r`=VKspNXFo|DV;aZe&!1EE6$P);2o&K[iCamZc&6)\Ndtr4w4...

Second Run Input

1001
deserialize !01001!0insert!00!0>z_KEL9ZY(#{ZS\@MS`>!1h5.lOmCfGZ$eq=o:uyVYhMi<=Z}E"u9z/dh2D9EVC~a""z-yvX~Elg*O&Dt?5o)XiIlVyFqKAgFD:XL(/x!10J[S7q:+9xLN`s;7)`2#8[7R|_WZ#r`=VKspNXFo|DV;aZe&!1EE6$P);2o&K[iCamZc&6)\Ndtr4w4CJxMi*C#<'GD+qE}7V+3Hgk]aFy"IK+c>[81qN\,u!1AmbuIc={l>JT()R8WhDN"[NPfDrTPtGH<98j...

Second Run Output

&
&&
?:jZk4vnEDT&q;Q&Ln{&
??mOEu*R?c-"x%V)MpO.6((udb4'OV)MpO.6((udb4'OX#+ytlj%XV)MpO.6((udb4'OX#+ytlj%#V)MpO.6((udb4'OX#+ytlj%+ytlj%vM\dxK^qN1F^^1!W:$l&HBilj%vM\?{
@h|;,sV(f:>r(0{=^$}^tUcGb^GU}7F93ZPK*Y>;o`[Ep[&jN
K
{%SDAEMp8
{

result:

ok stage 2 is ok!

Test #14:

score: 100
Accepted
time: 4ms
memory: 120936kb

First Run Input

1001
insert 0 gM8A1\odHL?'gDu[aD$Yz9X=8a%($HHtS'[coI=}r9l=`8fXH,qm(S^17>{P_Mp.6*ne{b$xkPfv7wXX02N;*\!S6$
copy 0 90
paste 0
copy 0 180
paste 0
copy 0 360
paste 0
copy 383 586
copy 21 567
erase 374 578
erase 449 460
copy 0 505
paste 0
erase 83 165
undo
redo
cut 726 847
copy 175 699
undo
redo
cut 325 5...

First Run Output

6$gS6$
gS6gS6$gS6$gS6$gS6$gS6$ggS6$gS6gS6$gS6$gS6$gS6$gS6
6$g6$g$gS6$gS$gS6$gS6$gS6gS6$gS6$gS6$g$gSS6$gS6$gS6$g$$g$gS6$gS$gS6$gS6$gS6gS6$gS6gS6$gS6$gS6$6$g$gS6$gS6$g6$g$gS6$gS$gS6$gS6$gS6gS6$gS6$gS6$g$gSS6$gS6$
S6S6$g$$g$gS6$gS$gS6$gS6$gS6gS6$gS6gS6$gS6$gS6$6$g$gS6$gS6$g6$g$gS6$gSgS6$gS6$gS6$6$g$gS6...

Second Run Input

1001
deserialize !01001!0insert!00!0gM8A1\odHL?'gDu[aD$Yz9X=8a%($HHtS'[coI=}r9l=`8fXH,qm(S^17>{P_Mp.6*ne{b$xkPfv7wXX02N;*\!1S6$!0copy!00!090!0paste!00!0copy!00!0180!0paste!00!0copy!00!0360!0paste!00!0copy!0383!0586!0copy!021!0567!0erase!0374!0578!0erase!0449!0460!0copy!00!0505!0paste!00!0erase!083!0...

Second Run Output

gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
ggggggggggggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
gggggggggggg
ggggggggggggggggggggggggggg...

result:

ok stage 2 is ok!

Test #15:

score: 100
Accepted
time: 8ms
memory: 120872kb

First Run Input

1001
insert 0 MCbGFkw(1DDDGg_*P./*!.)T9otQS:(_+X!NE{gm
copy 0 40
paste 40
copy 0 80
paste 80
copy 0 160
paste 160
copy 0 320
paste 320
erase 421 610
copy 0 451
paste 451
cut 174 606
copy 0 470
paste 470
redo
copy 92 380
cut 221 390
undo
undo
copy 0 470
paste 470
cut 126 714
copy 0 352
paste 352
copy...

First Run Output

G
G(*G(*G(*G(*DG(*((G((G(*G(*DG((G(*DG(*DG((G(*G(*G(*G(*DG(*DGG((
G(*G(*G(*G(*DG(*((G((G(*G(*DG((G(*DG(*DG((G(*G(*G(*G(*DG(*DGG((
*G(*G(G(*G(*G(*G(*DG(*DGG((G(*G(*G(*G
(G(*G(*G((*G(*G(*DGG((G(*G(*G(*G((*(*G(*G(*G((*DGG((G(*G(*G(*G(G(*G(*G((*G(*G(*DGG((G(*G(*DGG((G(*G(*G(*G((*DGG((G(*G(*G(*G(G(*G(*G(...

Second Run Input

1001
deserialize !01001!0insert!00!0MCbGFkw(1DDDGg_*P./*!1.)T9otQS:(_+X!1NE{gm!0copy!00!040!0paste!040!0copy!00!080!0paste!080!0copy!00!0160!0paste!0160!0copy!00!0320!0paste!0320!0erase!0421!0610!0copy!00!0451!0paste!0451!0cut!0174!0606!0copy!00!0470!0paste!0470!0redo!0copy!092!0380!0cut!0221!0390!0...

Second Run Output

G(*DGG((G(*G(*G(*DGG((G(*G(*GG(*G(*G(*DGG((G(*G(*G(*G(*G(G((G(*G(*G(*DGG((G(*G
*G(*GG(*G(G(*G(*GGG(*GG(*G(*G(*G(G*G(*G(G((G(*G(*G(*GG(*G(*G(*GG(*G(G(*G(*GGG(*GG(*G(*G(*G(G((G(*G(*G(*GG(*G(G(*G(*GGG(G(*GG(*G(*G(*G(G((G(*G(*G(*GG(*G(((G(*
(*G
*G*GG*G(*G*G*G*GG(*G(G(*G(*GGG(*GGG*GG(*G(G(*G(*GGG(GG(*GGG...

result:

ok stage 2 is ok!

Test #16:

score: 100
Accepted
time: 8ms
memory: 121004kb

First Run Input

1001
insert 0 DLnj}oW7KJ0mbJFS8s%Me#1YzBK0H$4+"E&{X?_g!4:g-eSm4Fdz)`+5uu7m{j*ys(FX|*NFOqp}'B~H81FIksm(o:|kpWc}456VTA"~'^@u/U)HqI~dwT$;-z7k+a+z7aMu]!rvj}3g]\-U.B-dZ"pq8>S>C8|'mWy;;TB6n/mu}OJ%co$WDmlT?ls}5@\:cx!DcR|ty#KWTOXu(wR[X?{aPgLMYgof;x}hI=pWJNT+/T?hr6tvgTI]{624b{]}7-Ba)uz@6J+\xB3.Ty0)Za;i=@js&3...

First Run Output

p%Va]*TDb%jWWjHTDb%*TDb%jDbjHpIHpp%Va]*TDb%jWWj
TDb%jDbjHpIHpp%Va]*TDb%jWWjHTDb%*TDb%jDbjHp
TDb%jWWjHTDb%*TDb%jDbjHpIHpp%Va]*TDb%jWWjHTDb%*Tpp%Va]*TDb%jWWjHTDb%*TDb%jDbjHpIHpp%jHTDb%*TDb
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD...

Second Run Input

1001
deserialize !01001!0insert!00!0DLnj}oW7KJ0mbJFS8s%Me#1YzBK0H$4+"E&{X?_g!14:g-eSm4Fdz)`+5uu7m{j*ys(FX|*NFOqp}'B~H81FIksm(o:|kpWc}456VTA"~'^@u/U)HqI~dwT$;-z7k+a+z7aMu]!1rvj}3g]\-U.B-dZ"pq8>S>C8|'mWy;;TB6n/mu}OJ%co$WDmlT?ls}5@\:cx!1DcR|ty#KWTOXu(wR[X?{aPgLMYgof;x}hI=pWJNT+/T?hr6tvgTI]{624b{]}7-Ba)...

Second Run Output

DDDDDDDDDDDDDD}Y*/DDDDDDDDDDDDDDDD}Y*
DDD}Y*/DDDDDDDDDDD
DDDDDDD}Y*/DDDDDD
DDDD}DDDDDDDDDDD}DDDDDDDDDDDDDDDD}DDDDDDDDDD}DDDDDDDDDDD}DDDDDDDDDDDDDDDD}DDDDDDDDDD}DDDDDDDDDDD}DDDDDDDDDDDDDDDD}DDDDDDDDDD}DDD
D}DDD}DDD}DDD}D}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}DDD}...

result:

ok stage 2 is ok!

Test #17:

score: 100
Accepted
time: 14ms
memory: 120912kb

First Run Input

1001
insert 0 r-*{2e+5<UZfk]0=fHw^0[b0N[YiZ4(}j'~g.-+AQ.,;RW3{u)6py36e0US:u1"%zYO#y7BNJanPV_d2*k]o(2DW3yKv3[U8SVYbH#iu#
undo
undo
redo
redo
redo
cut 43 85
paste 13
cut 4 102
erase 2 6
redo
paste 2
redo
redo
erase 19 58
erase 4 13
cut 16 51
erase 0 18
undo
paste 13
redo
undo
undo
erase 2 53
print 0 2...

First Run Output

r-
rrrrr
rrrrrrrrrr
rrrrr
{{
{{{{{{{{{{
rrra;a;
rrr
Hf`[%f*;f`[%f*sF~rr
!01001!0insert!00!0r-*{2e+5<UZfk]0=fHw^0[b0N[YiZ4(}j'~g.-+AQ.,;RW3{u)6py36e0US:u1"%zYO#y7BNJanPV_d2*k]o(2DW3yKv3[U8SVYbH#iu#!0undo!0undo!0redo!0redo!0redo!0cut!043!085!0paste!013!0cut!04!0102!0erase!02!06!0redo!0paste!02!0redo!0...

Second Run Input

1001
deserialize !01001!0insert!00!0r-*{2e+5<UZfk]0=fHw^0[b0N[YiZ4(}j'~g.-+AQ.,;RW3{u)6py36e0US:u1"%zYO#y7BNJanPV_d2*k]o(2DW3yKv3[U8SVYbH#iu#!0undo!0undo!0redo!0redo!0redo!0cut!043!085!0paste!013!0cut!04!0102!0erase!02!06!0redo!0paste!02!0redo!0redo!0erase!019!058!0erase!04!013!0cut!016!051!0erase!0...

Second Run Output

`%%fr`
j1p(sj}U\'<Vz"HrC41eow/V!dcZq}U\'<Vz"H}U\'<Vz"HrC41eow/V!dcrC41eow/V
RS66RRhSSSSSShSSSRhSSSSShh6
R
RRRRRRRRRRRR
C]Ijj
jjjj
jjjj

result:

ok stage 2 is ok!

Test #18:

score: 100
Accepted
time: 11ms
memory: 120868kb

First Run Input

1001
insert 0 }AZ0w~Djqtq/QL#p_=-~r|f|*h|@Wa$4muKRweQ1ETDt{7
copy 0 46
paste 0
copy 0 92
paste 0
copy 0 184
paste 0
copy 0 368
paste 0
undo
copy 0 368
paste 0
erase 331 374
copy 161 524
redo
redo
erase 194 558
copy 0 329
paste 0
cut 61 627
copy 0 92
paste 0
copy 0 184
paste 0
print 194 247
copy 0 36...

First Run Output

q/QL#p_=-~r|f|*h|@Wa$4muKRweQ1ETDt{7}AZ0w~Djqtq/QL#p_
~*h|@WaAZ0w~T@WaAZ0w~TDt{7}AZ0w~Dj~*hDj~*h}AZ0w~Dj~*hDj~*h|@WaAZ0w~T@WaAZ0w~TDt{7}AZ0w~D*hDj~*h|@WaAZ0w~T@WaAZ0w~TDt{7}AZ0w~Dj~*hDj~*h}AZ0w~Dj~*hDj~*h|@WaAZ0w~T@WaAZ0w~TDt{7}AZ0w~Dj~*hDj~*h}AZ0w~Dj~*hDj~*h|@WaAZ0w~T@WaAZ0w~TDt{7}AZ0w~Dj~*hDj~*h}A...

Second Run Input

1001
deserialize !01001!0insert!00!0}AZ0w~Djqtq/QL#p_=-~r|f|*h|@Wa$4muKRweQ1ETDt{7!0copy!00!046!0paste!00!0copy!00!092!0paste!00!0copy!00!0184!0paste!00!0copy!00!0368!0paste!00!0undo!0copy!00!0368!0paste!00!0erase!0331!0374!0copy!0161!0524!0redo!0redo!0erase!0194!0558!0copy!00!0329!0paste!00!0cut!06...

Second Run Output

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~
~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...

result:

ok stage 2 is ok!

Test #19:

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

First Run Input

1001
insert 0 GMuB=%kq&WPs8alf0p,Hjlv+EE&@Y|+`p)wpFjJcE`&T\Kj4b5e3)XI*N9XDm;0z>y/014(eV|.I2.l#U"s+'*9z+\b#2Qhk&ui&e4?z/MsZ:v"Cq:H/@OW{-nViTr5^nwor?R(&Ro&E1Qy+3(}l>#l$/'apLa:hCro$Y;SVF<]JM"X1F6cs"5WxMLk`J<$d
copy 0 192
paste 192
copy 0 384
paste 384
undo
copy 0 384
paste 384
undo
copy 0 384
paste 384...

First Run Output

$dGMuB=%kq&WPs8alf0p,WxMLk`&WPWxML
MdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$dGMdGd
$dGMdGdGMdGMWP$dGMdGMdGdGMGMdGdGMdGMWPMdGMWP$dGMdGdGMdGMWP$dGMdGdGMdGMWP$d
ddGMdGMdGdGdGMdGdGMWPMdGMddGMdGMdGdGGMdGdGMdG...

Second Run Input

1001
deserialize !01001!0insert!00!0GMuB=%kq&WPs8alf0p,Hjlv+EE&@Y|+`p)wpFjJcE`&T\Kj4b5e3)XI*N9XDm;0z>y/014(eV|.I2.l#U"s+'*9z+\b#2Qhk&ui&e4?z/MsZ:v"Cq:H/@OW{-nViTr5^nwor?R(&Ro&E1Qy+3(}l>#l$/'apLa:hCro$Y;SVF<]JM"X1F6cs"5WxMLk`J<$d!0copy!00!0192!0paste!0192!0copy!00!0384!0paste!0384!0undo!0copy!00!0384...

Second Run Output

GMMdGMdGdGGMdG
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
ddddddddddddddddddddddddddddddddddddddddd...

result:

ok stage 2 is ok!

Test #20:

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

First Run Input

1001
insert 0 _i|tWpuRpH$3ljHn4
cut 1 14
erase 0 4
undo
paste 2
undo
redo
redo
paste 17
paste 27
copy 11 42
redo
redo
paste 19
paste 56
erase 22 85
undo
copy 14 92
undo
erase 15 60
cut 0 28
undo
insert 21 O66K%+_}=?b1_!M;ib)zEyd3V~.u@FWm9B,B4&x>Tx((fM\EB;57%t%G}`)^FvMndzQ0K^2Rw*u{CIXlu_+PeT+GHn`PNG\...

First Run Output

jj
jj
3\
cfcc
/Uccfc99VJ[AbP/bCkOoomo(|J[AbP/bCkOoo
Gg]D#g]
#
##
gg
ggg
!01001!0insert!00!0_i|tWpuRpH$3ljHn4!0cut!01!014!0erase!00!04!0undo!0paste!02!0undo!0redo!0redo!0paste!017!0paste!027!0copy!011!042!0redo!0redo!0paste!019!0paste!056!0erase!022!085!0undo!0copy!014!092!0undo!0erase!015!060!0cut!0...

Second Run Input

1001
deserialize !01001!0insert!00!0_i|tWpuRpH$3ljHn4!0cut!01!014!0erase!00!04!0undo!0paste!02!0undo!0redo!0redo!0paste!017!0paste!027!0copy!011!042!0redo!0redo!0paste!019!0paste!056!0erase!022!085!0undo!0copy!014!092!0undo!0erase!015!060!0cut!00!028!0undo!0insert!021!0O66K%+_}=?b1_!1M;ib)zEyd3V~.u@...

Second Run Output

WWWWW
eeee
ss
]s]s]]see]s]se]s]ses]sese]s]se
]s
eeeeeeeeeeeeeeeee
e

result:

ok stage 2 is ok!

Test #21:

score: 100
Accepted
time: 10ms
memory: 120908kb

First Run Input

1001
insert 0 %)0/q]\>V;2k&l8&IY#)&vF-7mxAbLuJ-4_Ea|[B(Qc_3kr3y{d~oH(si+AGbL%T-bv[f|;j($w1Q9,1$!4Ll#^@/r!k<FX2$)?tx,nuG
copy 0 105
paste 0
copy 0 210
paste 0
copy 0 420
paste 0
erase 567 755
redo
redo
cut 20 504
copy 0 168
paste 0
copy 0 336
paste 0
cut 42 634
copy 0 80
paste 0
copy 0 160
paste 0
co...

First Run Output

nuG%[f|;j($G%)0/q]\>V;2k&l8&IY#)l#^@/r!k<FX2$)?tx,nuG%[f|;j($w1Q9,1$!4Ll#^@/
%)0/q]\0/q]\>V;2k&l8&IY#)l#^@/r!k<F
2$)?tG%)0/q]\>V;2k&k<FX2$)?tx,nuG%)0/q]\0/q]\>V;2k&l8&IY#)l#^@/r!k<FX2$)?tx,nuG%[f|;j($G%)0/q]\>V;2k&l8&IY#)l#^@/r!k<FX2$)?tx,nuG%[f|;j($w1Q9,1$!4Ll#^@/r!k<FX2$)?tG%)0/q]\>V;2k&k<FX2)0/q]...

Second Run Input

1001
deserialize !01001!0insert!00!0%)0/q]\>V;2k&l8&IY#)&vF-7mxAbLuJ-4_Ea|[B(Qc_3kr3y{d~oH(si+AGbL%T-bv[f|;j($w1Q9,1$!14Ll#^@/r!1k<FX2$)?tx,nuG!0copy!00!0105!0paste!00!0copy!00!0210!0paste!00!0copy!00!0420!0paste!00!0erase!0567!0755!0redo!0redo!0cut!020!0504!0copy!00!0168!0paste!00!0copy!00!0336!0pa...

Second Run Output

uGuGtGutGutGuXtGuGuGutGuGutGuGuXGtGutGutGuXtGuGuGutGGuGuGtGutGutGuXtGuGuGutGuGutGuG
GuGutGuGutGuGutGuGutGuGutGuGutGuGutGuutGuGutGuGutGuGutGuGutGuGuuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGutGuGut
GuGGutGuGuttGuGu
GGGutGuGuutGuGuttGuGuGGutGuGGutGGGutGuGuu...

result:

ok stage 2 is ok!

Test #22:

score: 100
Accepted
time: 8ms
memory: 120876kb

First Run Input

1001
insert 0 WglC#18D1R+wv)ps4Z,/1wI1M3KbX(S*Dy@8eFq\`R"NlA@C6g{:6Tq7%u<&3zau
copy 0 64
paste 64
copy 0 128
paste 128
copy 0 256
paste 256
erase 12 507
copy 0 17
paste 17
copy 0 34
paste 34
copy 0 68
paste 68
copy 0 136
paste 136
copy 0 272
paste 272
redo
erase 177 318
copy 0 403
paste 403
erase 30...

First Run Output

8D1R+w&3
l+wauWgl+3zauWgl+w&3zauWgl+w&3zauWgl+wuWgl+w&3zauWg&3zauWl+w&3zauWWgl+w&3zauWgl+w&3zauWgl+wauWgl+3zauWgl+w
3auzauWgl+w&3zauWgl+w&3zauWgl+wuWgl+w&3zauWg&3zauWl+w&3zauWWgl+w&3zaWgl+wuWgl+w&3zauWg&3zauWl+w&3auzauWgl+w&3zauWgl+w&3zauWgl+wuWgl+w&3zauWg&3zauWl+w&3zauWWgl+w&3zaWgl+wuWgl+w&3
z&zaWg...

Second Run Input

1001
deserialize !01001!0insert!00!0WglC#18D1R+wv)ps4Z,/1wI1M3KbX(S*Dy@8eFq\`R"NlA@C6g{:6Tq7%u<&3zau!0copy!00!064!0paste!064!0copy!00!0128!0paste!0128!0copy!00!0256!0paste!0256!0erase!012!0507!0copy!00!017!0paste!017!0copy!00!034!0paste!034!0copy!00!068!0paste!068!0copy!00!0136!0paste!0136!0copy!00!...

Second Run Output

WgzWgzWWgzWgzWWgzWgzWgzWgzWWgzWWgzWg
zWgzWgzWgzWWgzWg
WgzWWgzWgzWWgzWzWgzWgzWgzWWgzWgzWWgzWgzWgzWgzWWgzWWgzWgzWgzWgzWWgzWggzWWgzWgzWWgzWzWgzWgzWgzWWgzWgzWWgzWgzWgz
WggzWgzWWgzWgzWgzWgzWWgzWgzWWgzWgzWWgzWggzWWgzWggzWgzWWgzWgzWgzWgzWWgzWgzWWgzWgzWWgzWggzWWgzWggzWgzWWgzWgzWgzWgzWWgzWgzWWgzWgzWWgzWggzWW...

result:

ok stage 2 is ok!

Test #23:

score: 100
Accepted
time: 8ms
memory: 120896kb

First Run Input

1001
insert 0 }*}+p5r#{\OkA=|{2-'bZb*$-Akf*%/W(w?W#jUY9,iY~7W#$W~5w>,^65xP5S93>)FY5:FCmc#soYsk=58h;]MYV,c|P}4am6@pU0=#'qYir|j7Q/~2|2S(hD
erase 19 62
redo
undo
copy 4 86
cut 26 81
redo
paste 48
redo
erase 7 111
cut 0 14
undo
erase 12 13
redo
copy 0 11
redo
paste 17
erase 0 16
cut 2 12
cut 1 2
redo
un...

First Run Output

ii]
]
]]]]
]]]
es
vHuk
QQg-vo[k!k
!01001!0insert!00!0}*}+p5r#{\OkA=|{2-'bZb*$-Akf*%/W(w?W#jUY9,iY~7W#$W~5w>,^65xP5S93>)FY5:FCmc#soYsk=58h;]MYV,c|P}4am6@pU0=#'qYir|j7Q/~2|2S(hD!0erase!019!062!0redo!0undo!0copy!04!086!0cut!026!081!0redo!0paste!048!0redo!0erase!07!0111!0cut!00!014!0undo!0erase!012!013!...

Second Run Input

1001
deserialize !01001!0insert!00!0}*}+p5r#{\OkA=|{2-'bZb*$-Akf*%/W(w?W#jUY9,iY~7W#$W~5w>,^65xP5S93>)FY5:FCmc#soYsk=58h;]MYV,c|P}4am6@pU0=#'qYir|j7Q/~2|2S(hD!0erase!019!062!0redo!0undo!0copy!04!086!0cut!026!081!0redo!0paste!048!0redo!0erase!07!0111!0cut!00!014!0undo!0erase!012!013!0redo!0copy!00!01...

Second Run Output

Qg`S\E#rx-g`S\E#rx-Q\E#rx-QQg-vo[k!kQQg-vo[k!Q-vo[k!kQQg-vo[k!kg`S\E#rx-Qk
o[k!kg`S\E#rx-vo[k!kQQg-vo[k!Qg-vo[k!rx-g`S\E#rx-Q\E#rx-Qo[k!-QQg-vo[k!kQ#rx-vo[k!kQQg-vo[k!Qg-vo[k!rx-g`S\E#rx-Q\E#rx-Qo[k!-QQg-vo[k!kQQg-voE#-g`S
x-Qo[k!-QQg-vo[k!kQ#rx-vo[k!kQQg-vo[k!Qg-vo[k!rx-g`S\E#rx-Q\E#rx-Qo[k!-QQg-vo...

result:

ok stage 2 is ok!

Test #24:

score: 100
Accepted
time: 8ms
memory: 120836kb

First Run Input

1001
insert 0 y19#%EX)F?H%~`J`{O);0op)}(Aalh`Zx2AygE>YNTX
copy 0 43
paste 0
copy 0 86
paste 0
copy 0 172
paste 0
copy 0 344
paste 0
erase 553 688
cut 102 348
copy 0 307
paste 0
paste 149
cut 319 632
erase 250 520
copy 0 338
paste 0
paste 256
copy 19 941
erase 53 988
copy 0 79
paste 0
copy 0 158
past...

First Run Output

y1E>J`{O);0op)}(A);0op)}(Aalh`Zx2Aygy1E>J`{O);0op)}(A))}(A);0op)}(Aalh`Zx2Ayg
>J)T{~]vsJ)T{~]vsx1]0opTy1E>J)T{~]vsx1]0opTy1E>J)T{~]0opTy1E>J)T{~]vsx1]0opTy1E>J)1E>J)T{~]vsx1]0opTy
J)T{)T{~]0opTy1E>J)T{~]vsx1]0opTy1Esx1]0opTy1E>R!~~1E>J)T{~]vsx1]0opTy1E>J)T{~]vsx1]0opTy1E>J)T{~]vsx1]
1]0opTy1E>R!~~1E...

Second Run Input

1001
deserialize !01001!0insert!00!0y19#%EX)F?H%~`J`{O);0op)}(Aalh`Zx2AygE>YNTX!0copy!00!043!0paste!00!0copy!00!086!0paste!00!0copy!00!0172!0paste!00!0copy!00!0344!0paste!00!0erase!0553!0688!0cut!0102!0348!0copy!00!0307!0paste!00!0paste!0149!0cut!0319!0632!0erase!0250!0520!0copy!00!0338!0paste!00!0p...

Second Run Output

r#'bOlb7]L10opTy1E>R!~x1]0opTyopTy10opo
10opT10opT10opT10opT10opT10opT10opT10opT
^.Cy0V-1,Q$`#a6bITxUT(C_pT1T10oppT10opT10opT10o(6
0opT1T10T10pT1T10pT10opT10opT10o(6U!t^.Cy0UT6bITxUT10opT1oT10opT1oTT10opT1oT10opT1T10T10pT1T10pT10opT10opT10o(6U!t^.Cy0UT6bITxUT10opT1oT10opT1oTT10opT1oT10opT1T6U!t^.Cy0...

result:

ok stage 2 is ok!

Test #25:

score: 100
Accepted
time: 12ms
memory: 120856kb

First Run Input

1001
insert 0 aTUY*np'U0}\'C
copy 0 14
paste 14
copy 0 28
paste 28
copy 0 56
paste 56
copy 0 112
paste 112
copy 0 224
paste 224
copy 0 448
paste 448
undo
copy 0 448
paste 448
cut 30 249
paste 560
erase 290 478
erase 166 253
paste 281
cut 624 650
erase 60 428
copy 0 446
paste 446
undo
copy 0 446
past...

First Run Output

aTUY*np'U0}\'CaTUY*np'U0}\'CaT\'CaTUY*naTUY*np'U0}\'CaTUY*np'U0}\'CaTUp'U0}\'CaTUY*nUY*np'U0}\'CaTUY*np'U0}\'CaTUY*np'U0}\'CaTUY*np'U0}\'CaTUY*np'U0}\'CaT\'CaTUY*naTUY*np'U0}\'CaTUY*np'U0}\'CaTUp'U0}\'CaTUY*nUY*np'U0}\'CaTUY*np'U0}\'CaTUY*np'U0}\'C
C'C'C'C'C'C'C'C'C''C'C'C
'CC
'C'C'C'C'C'C'C'C'C'C'C...

Second Run Input

1001
deserialize !01001!0insert!00!0aTUY*np'U0}\'C!0copy!00!014!0paste!014!0copy!00!028!0paste!028!0copy!00!056!0paste!056!0copy!00!0112!0paste!0112!0copy!00!0224!0paste!0224!0copy!00!0448!0paste!0448!0undo!0copy!00!0448!0paste!0448!0cut!030!0249!0paste!0560!0erase!0290!0478!0erase!0166!0253!0paste!...

Second Run Output

'B*DQp[oF%d?W\B%db~u3qjSk+J],"wZe~{8z7*u1r"I(54Gq'B*DQp[oF%d?W\B%db~u3qjjSk+J],"wZe~{8z7*u1r"I(54Gqu3qjSk+J],"wZe~{8z7*u1r"I(543qjSk+J],"wZe~{8z7*u1r"I(54Gq'B*DQp[oF%
\~uW\\%db~uW\B%db~uW\B%db~uW\\B%db~u\B%db~
uW\\~uW\\%db~uW\BW\\B%db~uW\B%dW\db~uW\\~uW\\%db~uW\BW\\B%db~uW\B%dW\db~uW\~uW\\%db~uW\BW\...

result:

ok stage 2 is ok!

Test #26:

score: 100
Accepted
time: 7ms
memory: 120936kb

First Run Input

1001
insert 0 c;A(#8O6W$/TLL-mR$S7)4ZP(PV8U=H)
copy 0 32
paste 32
copy 0 64
paste 64
copy 0 128
paste 128
copy 0 256
paste 256
paste 87
undo
paste 235
redo
erase 138 283
paste 562
undo
undo
redo
undo
cut 551 660
paste 525
paste 136
paste 517
copy 739 955
insert 641 XDLbU`D"
cut 272 980
copy 0 286
pa...

First Run Output

W$/TLL-mR$S7)4ZP(PV8U=H)c;A(#8O6W$/TLL-mR$S7W$/TLL-mR$S7)4Z
A(#8O6W$/TLL-mR$S7)4ZP(PV8U=H)c;A(#8O6W$/TLL-mR$S7)4ZP(PV8U=H)c;A(#8O6W$/TLLL-mR$S7)4ZP(PV8U=H)c;A(#8O6W$/TLL-mR$S7)4ZP(PV8U=H)c;A(#8O6W$/TLL-mR$S7W$/TLL-mR$
=H)
H))=H))))=H))=H))=H=H=H))=H))=H))))=H))=H))=H=H))=H
)))=H))=H)=HH)=HH)=H)=HH=H...

Second Run Input

1001
deserialize !01001!0insert!00!0c;A(#8O6W$/TLL-mR$S7)4ZP(PV8U=H)!0copy!00!032!0paste!032!0copy!00!064!0paste!064!0copy!00!0128!0paste!0128!0copy!00!0256!0paste!0256!0paste!087!0undo!0paste!0235!0redo!0erase!0138!0283!0paste!0562!0undo!0undo!0redo!0undo!0cut!0551!0660!0paste!0525!0paste!0136!0pas...

Second Run Output

)HH)H)=H=HH))H))==HH=H))=H)=HH)=HH=HH))))=H)=HHH
H)=HH)))HH)H)=HH=HH))))==HH)))HH)H)=H))HH)H)=H=HH))H))==HH=H))=H)=HH)=HH=HH))))=H)=HHH=H))))=))=H))=H)H)=H)=HH)))HH)H)=H=HH))H))==HH=H))=H)=HH)=HH=HH))))==HH)))HH)H)=H))HH)
))))==HH)))HH)H)=H))HH)H)=H=HH))H))==HH=H))=H)==HH))H))==HH=H))=H)=HH)))HH)H)=...

result:

ok stage 2 is ok!

Test #27:

score: 100
Accepted
time: 8ms
memory: 120860kb

First Run Input

1001
insert 0 3K*a25D2;|vPgsE)L:$:q%{DGlK@C!|G6c[R;.SigBX:pB=30RL9&j"Yees'Nm"k&-Ch?-Bz)<#Q{F%<ld0+ccpV"SC{{%0!,.wi+0)0x;.d.dFu%{~;d5[9R2<4a|M"Xb~=cRTPQ@,[CXs)^mkCB^&sjv^Js+/|gBl)ie&~`WVT%>jSOSK)7Bb67.r=t'Iy]u;c#'9D[IO=
copy 28 154
redo
copy 71 107
paste 27
paste 60
paste 49
cut 247 262
paste 247
red...

First Run Output

[[[
[[[[[[[[[[[[[
[[[[[[[[[[[[[[[[[[[[[
^OUdm<S1##*!ckY~gYEJFd.rcdjvDMJW!P5K;V)WKVJ[[[[[[[[[[[lp<[8iQf<?+4NF!8Gd_Ol)uVl8<R0|i[8iQf<?+4NF!8Gd_Ol)uVl8<R0|i[[[[[/:ZLB0[
8l[88l
[8[88[8l[8[88[8l[8ll[8[88[8ll[8[88[l
VgOq40sziA5h@^"\'6|dQJDRJs*>~/o$`/2ml*aXS#Mh4f5ZrGo8x$q|-
Ho$`/2ml*aXS#Mh4f5ZrGo8x$q|-D3<v...

Second Run Input

1001
deserialize !01001!0insert!00!03K*a25D2;|vPgsE)L:$:q%{DGlK@C!1|G6c[R;.SigBX:pB=30RL9&j"Yees'Nm"k&-Ch?-Bz)<#Q{F%<ld0+ccpV"SC{{%0!1,.wi+0)0x;.d.dFu%{~;d5[9R2<4a|M"Xb~=cRTPQ@,[CXs)^mkCB^&sjv^Js+/|gBl)ie&~`WVT%>jSOSK)7Bb67.r=t'Iy]u;c#'9D[IO=!0copy!028!0154!0redo!0copy!071!0107!0paste!027!0paste!060...

Second Run Output

||NTGg`]NuXjh;K^9Y\4@Ht=l^:SCYniiOM})
bcm]!X'rAnU8@bcm]!X'rAnU8(,C#"F{.||w-:iOMTGg`]NuXjhuXjh;K^9Y\4@Ht=l^:SCYni6vc6QW,)@bcm]`]NuXjhuXjh;K^9Y\
m]!X'rA@bcm]!X'rAnU@XjhuXj]!X'jW,)
>v]}08o)
ccc&/kgccccc
*x8*=z'RdTktUGmc0;:qQFUPG7&yTT@XbyxeD
eDbY8OU*s/O5^p
bzDbZDbzDZ

result:

ok stage 2 is ok!

Test #28:

score: 100
Accepted
time: 8ms
memory: 120936kb

First Run Input

1001
insert 0 uTbE.H16aGS"0z<D?VE@z:{)-a2`8\"+rQ}mZ^Nryu}]_P|o;j
copy 0 50
paste 0
copy 0 100
paste 0
copy 0 200
paste 0
copy 0 400
paste 0
undo
copy 0 400
paste 0
cut 255 411
copy 112 587
print 347 413
redo
undo
erase 118 771
copy 0 147
paste 0
copy 0 294
paste 0
undo
copy 0 294
paste 0
cut 195 365...

First Run Output

E.H16aGS"0z<D?VE@z:{)-a2`8\"+rQ}mZ^Nryu}]_P|o;juTbE.H16aGS"0z<D?VE
T4-VR8QjujujujujuL,A[PT4-VR8QjujujujujujujujujujujuL,A[PT4-VR8Qj
uujujujuujujujujujujujjuujujujuujujujujujujujujujuuujuujujujuujujujuujujuujujuuuujuujujujuujujujuujujuujujujuujujujuujujujujujujujjuujujujuujujujujujujujujujuuujuujujuj...

Second Run Input

1001
deserialize !01001!0insert!00!0uTbE.H16aGS"0z<D?VE@z:{)-a2`8\"+rQ}mZ^Nryu}]_P|o;j!0copy!00!050!0paste!00!0copy!00!0100!0paste!00!0copy!00!0200!0paste!00!0copy!00!0400!0paste!00!0undo!0copy!00!0400!0paste!00!0cut!0255!0411!0copy!0112!0587!0print!0347!0413!0redo!0undo!0erase!0118!0771!0copy!00!01...

Second Run Output

ujuujjujujujuujjujujujuujjujujujuujjujjuujjujujujuujujjujuju
ujjujujujuujjjuujjujujujuujjujujujuujjjuujjujujujuujjujujujuujjjuujjujujujuujjujujujuj
ujuujjjuujjujujujuujjujujujuujuujjujuj
uujuujjujujujuujjjuujjujujujuujjujujuj
jujuujjjjuujujuujjjjuujujujuujujuujjjjjuujjjjuujujuujjjjuujujuuuujjjjuujuj...

result:

ok stage 2 is ok!

Test #29:

score: 100
Accepted
time: 8ms
memory: 120952kb

First Run Input

1001
insert 0 $VPn_^elO$:qA:48>]tTOcp{a/A/6lCkA,7QdqZn<P5E&'9eIB--7MeY0hE|0):/^F5s!lv]q}^b+k&;HLOo>$;ISYd'Dq*HT~Eaa5C~Hu,!"iJioc1FH)\\,Ud*qMOC).x):h%DJI,.vQkS:%h3qDk^qrtDUK>=~uvu(reB,!IDm;p~Q>kks!BpQ\>TZ)xx'\>{B:
copy 0 198
paste 198
copy 0 396
paste 396
cut 227 555
copy 0 464
paste 464
erase 86 229...

First Run Output

'\>{B:,!IDm;p~Q>kks!BpQ\>TZ)xx'\>{B:,!IDm;p~Q>kks!B
'\>{B:,!IDm;p~Q>kksm;p~Q>kks!BpQ\>TZ)xxIDm{B:,!IDm;p~Q>kks!Bpkks!BpQ\>TZ)xx'\>{B:,!\>{B:,!I\>{B:,!IDm;p~Q>kks!BpQ\>TZ)xx:,!\>{B:,!I\>{B:,!IDm;p~Q>kks!
;p~Q>kksm;p~Q>kks!BpQ\>TZ)xxIDm{B:,!IDm;p
I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I,!I...

Second Run Input

1001
deserialize !01001!0insert!00!0$VPn_^elO$:qA:48>]tTOcp{a/A/6lCkA,7QdqZn<P5E&'9eIB--7MeY0hE|0):/^F5s!1lv]q}^b+k&;HLOo>$;ISYd'Dq*HT~Eaa5C~Hu,!1"iJioc1FH)\\,Ud*qMOC).x):h%DJI,.vQkS:%h3qDk^qrtDUK>=~uvu(reB,!1IDm;p~Q>kks!1BpQ\>TZ)xx'\>{B:!0copy!00!0198!0paste!0198!0copy!00!0396!0paste!0396!0cut!0227...

Second Run Output

IBR//UWtrU'0T!IC51wTzf8,
I!!IC58,1IBR//,!!/UWtrTzf8,Tz/f,1IBRf8,1I!!IC58,f8,1I!!IC58,1IBR//,!!/UWtrTzf8,Tz/f,1IBRf8,1I!!IC58,f8,1I!!IC58,1IBR//,!!/UWt
rTzf8,Tz/f,1IBRf8,1I!!IC58,f8,1I!!IC58,1IBR//,!!/UWtrTzf8,Tz/f,1IBRf8,1I!//,!!/UWtrTzf8,Tz/f,1IBRf8,1I!!IC58,f8,UWtrTzf8,Tz/f,1IBRf8,1I!!IC58,f8,1I!!...

result:

ok stage 2 is ok!

Test #30:

score: 100
Accepted
time: 7ms
memory: 120816kb

First Run Input

1001
insert 0 2"`.-vfVhH[w/SKW%#GQ$W%8[0Az~.~U;#+K)MqV~6oo'{OA77G83+|^_,]RNJ0ih|JS(!6wpiXiHJ)-Bu!$g%Xn:&h+nZ9;4R_SEs`Tz4\!b08MWo.=k&0;]fP7&@F-qXB1|{"A*FR3n4ZwV?Y8IP)rnpkbot&D;gu^O/Q>'~<MtOdra@r7:"sPhhDC.M
copy 123 167
paste 9
redo
redo
insert 111 f9u~>":o!j4.>L5IytN$!8ZEFy(,
cut 43 234
paste 17
past...

First Run Output

)rn
)nr)n))nr)nrn)nrr)nr))nrr
****
********************
*******************************
*
************************
*******************************************************************************************************************************************
**
************************************
!0100...

Second Run Input

1001
deserialize !01001!0insert!00!02"`.-vfVhH[w/SKW%#GQ$W%8[0Az~.~U;#+K)MqV~6oo'{OA77G83+|^_,]RNJ0ih|JS(!16wpiXiHJ)-Bu!1$g%Xn:&h+nZ9;4R_SEs`Tz4\!1b08MWo.=k&0;]fP7&@F-qXB1|{"A*FR3n4ZwV?Y8IP)rnpkbot&D;gu^O/Q>'~<MtOdra@r7:"sPhhDC.M!0copy!0123!0167!0paste!09!0redo!0redo!0insert!0111!0f9u~>":o!1j4.>L5Iy...

Second Run Output

q#Oq"Wq"9Pa}zWq#Oq"+NO}
+"9PazW}Wq"9Pa}zzWWq
WazzzWWq
WWzWq
WzWWWzWWWzWzWzWWWWWzWWWWzWWWzWzWWzWWzWzWWWWzWWWzWzWWzWW
GGGGGGG
GGGGGGGGGGGG
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;up;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;up;;;;;;;;;;;;;;;;;;;;;
BE";;;;;;;;

result:

ok stage 2 is ok!

Test #31:

score: 100
Accepted
time: 7ms
memory: 120904kb

First Run Input

1001
insert 0 %Uka3giDyabJOwDCxgG>nM?|5)ghmJHq|]$cbb2$EI~JBH:0jHjG<H`2?W7&oKBDN"t}&tHag"be@t7clAKb5dz-QIds:(I]:;1yvB<S(?3GuLYp'dJtNJ_UJD<~m~REtKFUnS9Z0}D>dcl7.yJ`-@2|)-t_`5_&NFp:CaHRotnu3=!pz(z!o,m6~s;e0M&h8u?&Hnt9{r=%+pQK]U3v%(,-vf1:hXN#F6.4N"Nk>bv;i$+XTr.^lGOXvFGKNCyKgKwZ`'IZ}mZX>bw54nk0ZdO5{
copy...

First Run Output

}miDyat`'IZ}mZXbw54ndO5{%UXO5{%GKNCyKgKwZ`'IZ}mZXbw54ndO5{%Uka3giDyat`'IZ}mZXbw54ndO5{%Uka3giDyaGOXO5{%Uka3giDyatAKb5;iDyatO5{%Uka3giDyaGOXO5{%Uka3giDyaGOXO5{%GKNCyKgKwZ`'IZ}mZXbw54ndO5{%Uka3giDyat`'IZ}
G%G%G%G%G%G%G%%G%G%GG%G%G%G%G%G%G%G%G%G%G%G%GG%G%G%G%G%i5z|_w@#:kLjUR{na{!XURu^}c(I;W=4%G%G%
jUR{...

Second Run Input

1001
deserialize !01001!0insert!00!0%Uka3giDyabJOwDCxgG>nM?|5)ghmJHq|]$cbb2$EI~JBH:0jHjG<H`2?W7&oKBDN"t}&tHag"be@t7clAKb5dz-QIds:(I]:;1yvB<S(?3GuLYp'dJtNJ_UJD<~m~REtKFUnS9Z0}D>dcl7.yJ`-@2|)-t_`5_&NFp:CaHRotnu3=!1pz(z!1o,m6~s;e0M&h8u?&Hnt9{r=%+pQK]U3v%(,-vf1:hXN#F6.4N"Nk>bv;i$+XTr.^lGOXvFGKNCyKgKwZ`'...

Second Run Output

GGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...

result:

ok stage 2 is ok!

Test #32:

score: 100
Accepted
time: 14ms
memory: 120872kb

First Run Input

1001
insert 0 o5-A,7tBp,[M2]N#8tsFjCVf'[!J
copy 0 28
paste 28
copy 0 56
paste 56
copy 0 112
paste 112
copy 0 224
paste 224
copy 0 448
paste 448
cut 47 407
erase 68 491
copy 0 113
paste 113
copy 0 226
paste 226
copy 0 452
paste 452
erase 292 860
copy 0 336
paste 336
redo
erase 338 506
copy 0 504
past...

First Run Output

p,[M2]NJo5-A,7tBp,[M2]Jo5-AtBp,[M2]Bp,[Mo5-A,7tBp,[M2]NJo5-A,7tBp,[M2]Jo5-AtBp,[M2]Bp,[M2]N#8tsFsFjCVf'['[!Jo5-A,7tBp,[M2]NJo5-A,7tBp,[M2]Jo5-AtBp,[M2
A,7tBp,[M2]NJo5-A,7tB
-A,7tBp,[M2]NJo5-A,7tBp,[M2]Jo5-A
!Jo5-Ao5-A2'[!Jo5-o5'[!Jo5-A2'[!Jo5[!Jo5-A2'[!Jo5Jo5'[!Jo5[!Jo52'[!o5!Jo5-A2'[!Jo5-Ao5-A2'[!J...

Second Run Input

1001
deserialize !01001!0insert!00!0o5-A,7tBp,[M2]N#8tsFjCVf'[!1J!0copy!00!028!0paste!028!0copy!00!056!0paste!056!0copy!00!0112!0paste!0112!0copy!00!0224!0paste!0224!0copy!00!0448!0paste!0448!0cut!047!0407!0erase!068!0491!0copy!00!0113!0paste!0113!0copy!00!0226!0paste!0226!0copy!00!0452!0paste!0452!...

Second Run Output

8qceJETzLb5AVd'FEAZ\|#vQNQ3<_R0Um/[MXL@i*C8&bcf#np'J}u!gBI9_d#r^kEwe?RlismPd7Dia[Z0/iCCfg@0,cE(l}su/()Cc=L{<&*1?Ve?RlismPd7Dia[Z0/iCCfg@0,cE(l}su/()Cc=L{<&*1?VO2N<Jzs.j*9at'(bZ\u+VnZ,b+FzC%H[32)u}3J1T9E"ZQA8N,tSBfsgtv=&r0uXVEWAj+.]8(^_v;.EEGAE[k!XY}y#@7%5!oo5o5
qce1]q
1]1]qdu9U1
qce1]qdu9qdu9U1]q]qc...

result:

ok stage 2 is ok!

Test #33:

score: 100
Accepted
time: 3ms
memory: 120948kb

First Run Input

1001
insert 0 9uft>)w/O=y@=tj8,w)Y~MgA8eUC*V#5e`XfLel_9|<8VKU{zmaJ}LR:jjp.cQ8a4jV(<7:&qSs3p|3PO\'`];8l}+[VXB}J"[6Ig{]]Uwn^5~a%HnZ@b\kT[6,P)jVBYy(s^.C95t<z:BCU2o=WfR/q]=?KAl(bVxSF#.h|,%_}|]'|Wy_9p6/Ka$]=3uK|WLiz*B-2]']!1MG,}teLw5O:k[x=$&MKzWyii*pg/T*if[s~rL*Epnbb^|w>)\$eaOs!?/{n*&m.;_#Hx}ie|ZKd`K-@\H...

First Run Output

iNc"'''555{~<:`'51!;`
404
M
MM4M4M4MM4M44
4M4M4M4M4M4M4M4M444MM
M4M4M4M4
44444444444444
44444444444444444444444444444444444444444444
j**OgjO4M3O)W#j**OgjO4j**OgjO44
!01001!0insert!00!09uft>)w/O=y@=tj8,w)Y~MgA8eUC*V#5e`XfLel_9|<8VKU{zmaJ}LR:jjp.cQ8a4jV(<7:&qSs3p|3PO\'`];8l}+[VXB}J"[6Ig{]]Uwn^5~a%HnZ@...

Second Run Input

1001
deserialize !01001!0insert!00!09uft>)w/O=y@=tj8,w)Y~MgA8eUC*V#5e`XfLel_9|<8VKU{zmaJ}LR:jjp.cQ8a4jV(<7:&qSs3p|3PO\'`];8l}+[VXB}J"[6Ig{]]Uwn^5~a%HnZ@b\kT[6,P)jVBYy(s^.C95t<z:BCU2o=WfR/q]=?KAl(bVxSF#.h|,%_}|]'|Wy_9p6/Ka$]=3uK|WLiz*B-2]']!11MG,}teLw5O:k[x=$&MKzWyii*pg/T*if[s~rL*Epnbb^|w>)\$eaOs!1?/...

Second Run Output

de
ddddddddddd
-E}>@iTc>-O]J:je]$h:%G@K&}Zz3]0CE8l>K2IlyWdaxSs^Q)4"vox;;
ddd
ddd
ddd
RAG"7(ol\9~`3dJGOF+D%V-qv'.a)T
2Mf%YR4Cr2MfC`4`Rp?tv%Y
nnn
XXXXXXXXXXXXXXXXXX

result:

ok stage 2 is ok!

Test #34:

score: 100
Accepted
time: 15ms
memory: 120936kb

First Run Input

1001
insert 0 HDRZ,8GNzaP&hmes}d-hC1]HVc\94Q`5_~M.r-
copy 0 38
paste 0
copy 0 76
paste 0
copy 0 152
paste 0
copy 0 304
paste 0
undo
copy 0 304
paste 0
undo
copy 0 304
paste 0
paste 299
undo
undo
copy 0 304
paste 0
paste 33
cut 188 283
redo
paste 584
paste 130
undo
undo
undo
erase 101 798
copy 0 215
...

First Run Output

RZ,8Gs~M.r-H-HDRZ,8~M.r-HDRZGs~M.r-HDRZ,8Gs~M.r-H-HDRZ,8~M.r-HDRZGs~M.r-HDRZ,8Gs~M
M.r-HDRZ,8Gs~M.r-H-HDRZ,8~M.r-HDRZr-H-HDRZ,8~M.r-M.r-HDRZ,8~M.r-HDRZGs~M.r-HDRZ,8Gs~M.r-HZGs~M.r-HDRZ,8G
ZGs~M.r-HDRZ,8Gs~M.r-H-HDRZ,8~M.r-8~M.r,8Gs~M.r-H-HDRZ,8M.r-HZGs~8~M.r-HDRZr-H-HDRZ,8~M.r-M.r-HDRZ,8~M.r-HDRZGs~...

Second Run Input

1001
deserialize !01001!0insert!00!0HDRZ,8GNzaP&hmes}d-hC1]HVc\94Q`5_~M.r-!0copy!00!038!0paste!00!0copy!00!076!0paste!00!0copy!00!0152!0paste!00!0copy!00!0304!0paste!00!0undo!0copy!00!0304!0paste!00!0undo!0copy!00!0304!0paste!00!0paste!0299!0undo!0undo!0copy!00!0304!0paste!00!0paste!033!0cut!0188!02...

Second Run Output

---------
-----------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------...

result:

ok stage 2 is ok!

Test #35:

score: 100
Accepted
time: 4ms
memory: 120884kb

First Run Input

1001
insert 0 1z#?)(+eMySIB@BzpGbk1#EMk!{8wgA/wv^)_o'-AvU_]w{+ydZHPb|AP0-"}XCq&X\)iz0XS;m+$S;6l<[By>'_xmG<0p)byN/AN=Wy-~XSp,q<Fv
copy 0 114
paste 114
copy 0 228
paste 228
copy 0 456
paste 456
erase 215 749
copy 0 378
paste 378
undo
copy 0 378
paste 378
redo
copy 95 396
redo
cut 217 577
copy 0 396
pa...

First Run Output

eMySIB@<[By>'_xmG<0p)byN/AN=Wy-~XSp,q<Fv1`dd3SAT^d}_GV3\vkju~o
?)(+eMySI?)(+eMySIB@<[By>'_xmG<0p)byN/AN=Wy-1z#?)(+eMySIB@<[By>'_xmG<0p)byN/AN=Wy-1z#?)(+eMySIB@<[By>/AN=Wy-1z#?)(+eMySIB@<[By>'_xmG<0p)byN/AN=Wy-1z#?)(+eMySIB@<[By>'_xmG<0p)byN/AN=Wy-1z#?)(+
)(+eMy<0p)byN/AN=Wy)byN/AN=Wy-1z#?)(+eMy<0p)b...

Second Run Input

1001
deserialize !01001!0insert!00!01z#?)(+eMySIB@BzpGbk1#EMk!1{8wgA/wv^)_o'-AvU_]w{+ydZHPb|AP0-"}XCq&X\)iz0XS;m+$S;6l<[By>'_xmG<0p)byN/AN=Wy-~XSp,q<Fv!0copy!00!0114!0paste!0114!0copy!00!0228!0paste!0228!0copy!00!0456!0paste!0456!0erase!0215!0749!0copy!00!0378!0paste!0378!0undo!0copy!00!0378!0paste!...

Second Run Output

y-1
Wy-1-1W-1Wy-1-1W-1Wy-1-1Wy-1-1W-1Wy-1-1
11-1-1-1Wy-1-1W-1Wy-1-1W-1y-11y-1-1W-11-1-1-1Wy-1-1W-1Wy-1-1W-1y-11y-1-1W-W-11-1-1-1Wy-1-1W-1Wy-1-1W-1y-11y-1-1W-11-1-1-1Wy-1-1W-1Wy-1-1W-1y-11y-1-1W-11-1-1-1Wy-1-1W-1Wy-1-1W
-1W-1y-11y-1-1W-11-1-1-1Wy-1-1W-1Wy-1-1W-1y-11y-1-1W-W-11-1-1-1Wy-1-1W-1
*+BlD1y-...

result:

ok stage 2 is ok!

Test #36:

score: 0
Stage 1: Program answer Runtime Error

First Run Input

10000
insert 0 l#}22%sfm{&~wpi'9H*7*1;(|'a!aE5SaedgPq#7=bV'Cla^5WkBrT|Ci5O~S6PXwoQ(r(_?hvA1vv^14Dcq,(ObOCsuz^@p7`Ly^)o;7P8|$uxI-yTgBl29JI3|=1{)_fWM3{d_E9^XszAm<wN>,+mM$%}$n%V2UebniOr][Hd&/H=J2hw@!fRAn3V/BO6"$}k$Cn>>8R<X.Ie02f:{Spgq)]k?+2;E>2"E8bO#&3ojDH5ZEl`KwJwT"v>w#2C*+t8.X8ezv$[[QT2V^>}#Ca6m"\5a)...

First Run Output

qr]EGG"LR.Y]a&W~Yiv:;/q&I(AWR'k[w`T8bO|s90Ff,m)%[y1G[-ay1&5)xx`Q?yh*e{?}VW~Xh"$,CSAW`^rvUG*p$q46ZVy?pO"{J<jLwj^M,Otwg3bGo@VIojd>.4I+C$p~fc4f:D*7_qf4V'p:$M@T?%\2xQ6GFoy^,F@/CNlyL;m&gS8wh^G3oGRs/)Wga1Udy1+tZ$A7Ky'Mp!yd3R!6$#re:=A%2){?E"_BS,pVmRS~#FT7Lh89X[l2ae!'3P|Gi~z_pEYGJvg8H/!\0hakG-`8pGhH.dq@A)Gs...

Second Run Input


Second Run Output


result: