#include<iostream>
#include<queue>
using namespace std;
int n , a[100000] , t ,  v , q;
string s[10000] ;
priority_queue<int, vector<int> , greater<int> > pq ;
int main(){
	cin >>n;
	for(int i=0 ; i!=n ; i++){
		cin >> s[i] ;

		if(s[i] == "insert"){
			cin >>a[i] ;
			pq.push(a[i]) ;
		}
		else if(s[i] == "removeMin")
			pq.pop() ;
		else{
			cin >>a[i] ;
			t = a[i] ;
		}

	}

	if(t == 0){
		cout<<n<<endl;
		for(int i=0 ; i!=n ; i++){
			if(i!=n-1)
				if(s[i] == "insert")
					cout<<s[i]<<" "<<a[i]<<endl;
				else
					cout<<s[i]<<endl;
			else
				if(s[i] == "insert")
					cout<<s[i]<<" "<<a[i];
				else
					cout<<s[i];
		}
		return 0;
	}

	v = n ;
	while(!pq.empty() && pq.top() < t && t != 0){
		pq.pop() ;
		q += 1;
	}
	cout<<v + q + 1<<endl;
	for(int i=0 ; i!=n-1 ; i++){
		if(s[i] == "removeMin")
			cout<<s[i]<<endl ;
		else
			cout<<s[i]<<" "<<a[i]<<endl ;
	}
	for(int i=0 ; i!=q ; i++)
		cout<<"removeMin"<<endl ;

	cout<<"insert"<<" "<<t <<endl;
	cout<<"getMin"<<" "<<t ;

}


#include<iostream>
#include<queue>
using namespace std;
long long a[200000]  , ansa[200000] , n , t , v ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans[200010] ;
int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				ans[t] = "removeMin" ;
				t += 1;
			}

		}

		else{
			cin >>v ;
			while(!pq.empty() && pq.top() < v){
				ans[t] = "removeMin" ;
				t += 1;
				pq.pop() ;
			}
			if(!pq.empty() && pq.top() == v){
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
 			}
 			else {
 				ans[t] = "insert" ;
				ansa[t] = v ;
				pq.push(v) ;
				t += 1;
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
			}

		}

	}
	cout<<t<<endl ;
	for(long long i=0 ; i!=t-1 ; i++){
		cout<<ans[i];
		if(ans[i] != "removeMin")
			cout<<" "<<ansa[i] <<endl;
		else
			cout<<endl;

	}
	cout<<ans[t-1] ;
	if(ans[t-1] != "removeMin")
		cout<<" "<<ansa[t-1];

}


#include<iostream>
#include<queue>
#include<bits/stdc++.h>
using namespace std;
long long a[200000]  , n , t , v ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans , h ;

string chand(int a){
	string d , s;
	while(a!=0){
		d = d + char(a%10 + 48) ;
		a /= 10 ;
	}
	reverse(d.begin() , d.end()) ;
	return d;
}

int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans = ans + "insert" + " " + chand(a[i]) + '\n';
			t += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans = ans + "removeMin" + '\n';
				t += 1;
			}
			else{
				ans = ans + "insert 0" + '\n' ;
				t += 1;
				ans = ans + "removeMin" + '\n';
				t += 1;
			}

		}

		else{
			cin >>v ;
			while(!pq.empty() && pq.top() < v){
				ans = ans + "removeMin" + '\n';
				t += 1;
				pq.pop() ;
			}
			if(!pq.empty() && pq.top() == v){
				ans = ans + "getMin" + " " + chand(v) + '\n';
				t += 1;
 			}
 			else {
 				ans = ans + "insert" + " " + chand(v) + '\n';
				pq.push(v) ;
				t += 1;
				ans = ans + "getMin" + " " + chand(v) + '\n';
				t += 1;
			}

		}

	}
	cout<<t<<endl ;

	cout<<ans;
}


#include<iostream>
#include<queue>
using namespace std;
long long a[200000]  , ansa[200000] , n , t , v ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans[200010] , h;
int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				ans[t] = "removeMin" ;
				t += 1;
			}

		}

		else{
			cin >>v ;
			h = "";
			while(!pq.empty() && pq.top() < v){
				h = h + "removeMin" + '\n';
				pq.pop() ;
			}
 			ans[t] = h;
 			t += 1;
 			ans[t] = "insert" ;
			ansa[t] = v ;
			pq.push(v) ;
			t += 1;
			ans[t] = "getMin" ;
			ansa[t] = v ;
			t += 1;
		}

	}
	cout<<t<<endl ;
	for(int i=0 ; i!=t ; i++){
		cout<<ans[i];
		if(ans[i] == "getMin" || ans[i] == "insert")
			cout<<" "<<ansa[i] <<endl;
		else
			cout<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
priority_queue<long long> pq;
long long n , v , t;
string s[1000000] , ans;
string chand(long long a){
	int b= 0 ;
	if(a == 0)
		return "0" ;
	string d ;
	if(a < 0){
		b = 1;
		a = -1 * a;
	}
	while(a!=0){
		d = d + char(a%10 + 48) ;
		a /= 10;
	}
	reverse(d.begin() , d.end()) ;
	if(b == 1)
		d = "-" + d;
	return d;
}

int main(){
	cin >>n;
	for(int i=0 ; i!=n ; i++){

		cin >>s[i] ;

		if(s[i] == "insert"){
			cin >>v ;
			pq.push(v) ;
			t += 1;
			ans = ans + "insert " + chand(v) + '\n' ;
			continue ;
		}
		if(s[i] == "removeMin"){
			if(!pq.empty()){
				pq.pop() ;
				ans = ans + "removeMin" + '\n' ;
				t += 1;
			}
			else{
				ans = ans + "insert 0" + '\n' + "removeMin" + '\n' ;
				t += 2 ;
			}
			continue ;
		}

		cin >>v ;
		while(!pq.empty() && pq.top() < v){
			ans = ans + "removeMin" + '\n' ;
			t += 1 ;
			pq.pop() ;
		}
		if(!pq.empty() && pq.top() == v){
			ans = ans + "getMin" + " " + chand(v) + '\n' ;
			t += 1;
		}
		else{
			pq.push(v) ;
			t += 2;
			ans = ans + "insert " + chand(v) + '\n' + "getMin " + chand(v) + '\n';
		}

	}
	cout<<t << endl <<ans ;
}


#include<iostream>
#include<queue>
using namespace std;
long long a[200000]  , ansa[200000] , n , t , v , u ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans[200010] , h;
int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				ans[t] = "removeMin" ;
				t += 1;
			}

		}

		else{
			cin >>v ;
			h = "";
			while(!pq.empty() && pq.top() < v){
				pq.pop() ;
				h = h + "removeMin" + '\n';
				u += 1;
			}
			if(h != ""){
 				ans[t] = h;
 				t += 1;
 			}
			if(!pq.empty() && pq.top() == v){
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
 			}
 			else {
 				ans[t] = "insert" ;
				ansa[t] = v ;
				pq.push(v) ;
				t += 1;
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
			}
		}

	}
	if(u == 0)
		u = 1;
	cout<<t+u-1<<endl ;
	for(int i=0 ; i!=t ; i++){
		cout<<ans[i];
		if(ans[i] == "getMin" || ans[i] == "insert")
			cout<<" "<<ansa[i] <<endl;
		else
			cout<<endl;

	}

}


#include<iostream>
#include<queue>
using namespace std;
long long a[200000]  , ansa[200000] , n , t , v , u ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans[200010] , h;
int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			u += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
				u += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				u += 1;
				ans[t] = "removeMin" ;
				t += 1;
				u += 1;
			}

		}

		else{
			cin >>v ;
			while(!pq.empty() && pq.top() < v){
				pq.pop() ;
				h = h + "removeMin" + '\n';
				u += 1;
			}
			if(h != ""){
 				ans[t] = h;
 				t += 1;
 			}
			if(!pq.empty() && pq.top() == v){
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
				u += 1;
 			}
 			else {
 				ans[t] = "insert" ;
				ansa[t] = v ;
				pq.push(v) ;
				t += 1;
				u += 1;
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
				u += 1;
			}
		}

	}
	cout<<u<<endl ;
	for(int i=0 ; i!=t ; i++){
		cout<<ans[i];
		if(ans[i] == "getMin" || ans[i] == "insert")
			cout<<" "<<ansa[i] <<endl;
		else
			cout<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
string chand(int a){
	int b= 0 ;
	if(a == 0)
		return "0" ;
	string d ;
	if(a < 0){
		b = 1;
		a = -a;
	}
	while(a!=0){
		d +=char(a%10 + '0') ;
		a /= 10;
	}
	reverse(d.begin() , d.end()) ;
	if(b == 1)
		d = "-" + d;
	return d;
}

int main(){
	string ans = "";
	priority_queue< int, vector<int>, greater<int> > pq;
	int n;
	long long t = 0;
	cin >>n;
	for(int i=0 ; i!=n ; i++){
		string s;
		cin >>s ;

		if(s == "insert"){
			int v;
			cin >>v ;
			pq.push(v) ;
			t ++ ;
			ans += s + " " + chand(v) + '\n' ;
			continue ;
		}
		if(s == "removeMin"){
			if(!pq.empty()){
				pq.pop() ;
				ans +=  s + '\n' ;
				t ++ ;
			}
			else{
				ans += "insert 0\n" + s + '\n' ;
				t += 2 ;
			}
			continue ;
		}
		int v;
		cin >>v ;
		while(!pq.empty() && pq.top() < v){
			ans += "removeMin\n"  ;
			t ++ ;
			pq.pop() ;
		}
		if(!pq.empty() && pq.top() == v){
			ans +=  s + " " + chand(v) + '\n' ;
			t ++ ;
		}
		else{
			pq.push(v) ;
			t += 2;
			ans +=  "insert " + chand(v) + '\n' + s + " " + chand(v) + '\n';
		}

	}
	cout<<t << endl <<ans ;
}


#include<iostream>
#include<queue>
using namespace std;
long long a[200000]  , ansa[200000] , n , t , v , u ;
priority_queue<long long , vector<long long> , greater<long long> > pq ;
string s[200000] , ans[200010] , h;
int main(){
	cin >>n;
	for(long long i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			u += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
				u += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				u += 1;
				ans[t] = "removeMin" ;
				t += 1;
				u += 1;
			}

		}

		else{
			cin >>v ;
			h = "";
			while(!pq.empty() && pq.top() < v){
				pq.pop() ;
				h = h + "removeMin" + '\n';
				u += 1;
			}
			if(h != ""){
 				ans[t] = h;
 				t += 1;
 			}
			if(!pq.empty() && pq.top() == v){
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
				u += 1;
 			}
 			else {
 				ans[t] = "insert" ;
				ansa[t] = v ;
				pq.push(v) ;
				t += 1;
				u += 1;
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
				u += 1;
			}
		}

	}
	cout<<u<<endl ;
	for(int i=0 ; i!=t ; i++){
		cout<<ans[i];
		if(ans[i] == "getMin" || ans[i] == "insert")
			cout<<" "<<ansa[i] <<endl;
		else
			cout<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
long long t;
string chand(long long a){
	int b= 0 ;
	if(a == 0)
		return "0" ;
	string d ;
	if(a < 0){
		b = 1;
		a = -1 * a;
	}
	while(a!=0){
		d = d + char(a%10 + 48) ;
		a /= 10;
	}
	reverse(d.begin() , d.end()) ;
	if(b == 1)
		d = "-" + d;
	return d;
}

int main(){
	string s;
	string ans;
	priority_queue< int, vector<int>, greater<int> > pq;
	int n;
	int v ;
	cin >>n;
	for(int i=0 ; i!=n ; i++){

		cin >>s ;

		if(s == "insert"){
			cin >>v ;
			pq.push(v) ;
			t += 1;
			ans = ans + "insert " + chand(v) + '\n' ;
			continue ;
		}
		if(s == "removeMin"){
			if(!pq.empty()){
				pq.pop() ;
				ans = ans + "removeMin" + '\n' ;
				t += 1;
			}
			else{
				ans = ans + "insert 0" + '\n' + "removeMin" + '\n' ;
				t += 2 ;
			}
			continue ;
		}

		cin >>v ;
		while(!pq.empty() && pq.top() < v){
			ans = ans + "removeMin" + '\n' ;
			t += 1 ;
			pq.pop() ;
		}
		if(!pq.empty() && pq.top() == v){
			ans = ans + "getMin" + " " + chand(v) + '\n' ;
			t += 1;
		}
		else{
			pq.push(v) ;
			t += 2;
			ans = ans + "insert " + chand(v) + '\n' + "getMin " + chand(v) + '\n';
		}

	}
	cout<<t << endl <<ans ;
}


#include<bits/stdc++.h>
using namespace std;
long long t;
string chand(int a){
	int b= 0 ;
	if(a == 0)
		return "0" ;
	string d ;
	if(a < 0){
		b = 1;
		a = -1 * a;
	}
	while(a!=0){
		d = d + char(a%10 + 48) ;
		a /= 10;
	}
	reverse(d.begin() , d.end()) ;
	if(b == 1)
		d = "-" + d;
	return d;
}

int main(){
	string ans = "";
	priority_queue< int, vector<int>, greater<int> > pq;
	int n;
	cin >>n;
	for(int i=0 ; i!=n ; i++){
		string s;
		cin >>s ;

		if(s == "insert"){
			int v;
			cin >>v ;
			pq.push(v) ;
			t += 1;
			ans = ans + s + " " + chand(v) + '\n' ;
			continue ;
		}
		if(s == "removeMin"){
			if(!pq.empty()){
				pq.pop() ;
				ans = ans + s + '\n' ;
				t += 1;
			}
			else{
				ans = ans + "insert 0" + '\n' + s + '\n' ;
				t += 2 ;
			}
			continue ;
		}
		int v;
		cin >>v ;
		while(!pq.empty() && pq.top() < v){
			ans = ans + "removeMin" + '\n' ;
			t += 1 ;
			pq.pop() ;
		}
		if(!pq.empty() && pq.top() == v){
			ans = ans + s + " " + chand(v) + '\n' ;
			t += 1;
		}
		else{
			pq.push(v) ;
			t += 2;
			ans = ans + "insert " + chand(v) + '\n' + s + " " + chand(v) + '\n';
		}

	}
	cout<<t << endl <<ans ;
}


#include<bits/stdc++.h>
using namespace std;
long long t;
string chand(int a){
	int b= 0 ;
	if(a == 0)
		return "0" ;
	string d ;
	if(a < 0){
		b = 1;
		a = -1 * a;
	}
	while(a!=0){
		d = d + char(a%10 + 48) ;
		a /= 10;
	}
	reverse(d.begin() , d.end()) ;
	if(b == 1)
		d = "-" + d;
	return d;
}

int main(){
	string ans = "";
	priority_queue< int, vector<int>, greater<int> > pq;
	int n;
	cin >>n;
	for(int i=0 ; i!=n ; i++){
		string s;
		cin >>s ;

		if(s == "insert"){
			int v;
			cin >>v ;
			pq.push(v) ;
			t += 1;
			ans = ans + s + chand(v) + '\n' ;
			continue ;
		}
		if(s == "removeMin"){
			if(!pq.empty()){
				pq.pop() ;
				ans = ans + s + '\n' ;
				t += 1;
			}
			else{
				ans = ans + "insert 0" + '\n' + s + '\n' ;
				t += 2 ;
			}
			continue ;
		}
		int v;
		cin >>v ;
		while(!pq.empty() && pq.top() < v){
			ans = ans + "removeMin" + '\n' ;
			t += 1 ;
			pq.pop() ;
		}
		if(!pq.empty() && pq.top() == v){
			ans = ans + s + " " + chand(v) + '\n' ;
			t += 1;
		}
		else{
			pq.push(v) ;
			t += 2;
			ans = ans + "insert " + chand(v) + '\n' + s + chand(v) + '\n';
		}

	}
	cout<<t << endl <<ans ;
}


#include<iostream>
#include<queue>
using namespace std;
int a[10000]  , ansa[10000] , n , t , v ;
priority_queue<int , vector<int> , greater<int> > pq ;
string s[10000] , ans[10000] ;
int main(){
	cin >>n;
	for(int i=0 ; i!=n ; i++){
		cin >>s[i] ;
		if(s[i] == "insert"){
			cin >>a[i] ;
			ans[t] = "insert" ;
			ansa[t] = a[i] ;
			t += 1;
			pq.push(a[i]) ;

		}

		else if(s[i] == "removeMin"){

			if(!pq.empty()){
				pq.pop() ;
				ans[t] = "removeMin" ;
				t += 1;
			}
			else{
				ans[t] = "insert" ;
				ansa[t] = 0 ;
				t += 1;
				ans[t] = "removeMin" ;
				t += 1;
			}

		}

		else{
			cin >>v ;
			while(!pq.empty() && pq.top() < v){
				ans[t] = "removeMin" ;
				t += 1;
				pq.pop() ;
			}
			if(!pq.empty() && pq.top() == v){
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
 			}
 			else {
 				ans[t] = "insert" ;
				ansa[t] = v ;
				t += 1;
				ans[t] = "getMin" ;
				ansa[t] = v ;
				t += 1;
			}

		}

	}
	cout<<t<<endl ;
	for(int i=0 ; i!=t ; i++){
		cout<<ans[i];
		if(i != t-1)
			if(ans[i] != "removeMin")
				cout<<" "<<ansa[i] <<endl;
			else
				cout<<endl;
		else
			if(ans[i] != "removeMin")
				cout<<" "<<ansa[i];

	}
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            auto tt = m.begin();
            auto it = *tt;
            auto ind = it.F;
            m[it.F]--;
            if(m[it.F] == 0)
                m.erase(it.F);
            query q;
            q.type = 1;
            ans.PB(q);
        }
        else if(s[0] == 'i'){
            cin>>a;
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
        }
        else{
            cin>>a;
            auto ind = m.begin();
            auto it = *ind;
            if(it.F != a){
                if(a < it.F){
                    m[a]++;
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                }
                else{
                    for(auto ele : m){
                        if(ele.F < a){
                            for(int i = 0;i<ele.S;i++){
                                query q;
                                q.type = 1;
                                ans.PB(q);
                            }
                        }
                        else{
                            break;
                        }
                    }
                    auto ind = m.begin();
                    auto it = *ind;
                    if(it.F != a){
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                query q;
                q.type = 2;
                q.d = 0;
                ans.PB(q);
                m[0]++;
                total++;
            }
            auto tt = m.begin();
            auto it = *tt;
            auto ind = it.F;
            m[it.F]--;
            if(m[it.F] == 0)
                m.erase(it.F);
            query q;
            q.type = 1;
            ans.PB(q);
            total--;
        }
        else if(s[0] == 'i'){
            cin>>a;
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(total == 0){
                query q;
                q.type = 2;
                q.d = a;
                ans.PB(q);
                total++;
                m[a]++;
            }
            else{
                auto ind = m.begin();
                auto it = *ind;
                if(it.F != a){
                    if(a < it.F){
                        m[a]++;
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                    else{
                        for(auto ele : m){
                            if(ele.F < a){
                                for(int i = 0;i<ele.S;i++){
                                    query q;
                                    q.type = 1;
                                    ans.PB(q);
                                    total--;
                                }
                                m.erase(ele.F);
                            }
                            else{
                                break;
                            }
                        }
                        auto ind = m.begin();
                        auto it = *ind;
                        if(it.F != a){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                            m[a]++;
                        }
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                query q;
                q.type = 2;
                q.d = 0;
                ans.PB(q);
                m[0]++;
                total++;
            }
            auto tt = m.begin();
            auto it = *tt;
            auto ind = it.F;
            m[it.F]--;
            if(m[it.F] == 0)
                m.erase(it.F);
            query q;
            q.type = 1;
            ans.PB(q);
            total--;
        }
        else if(s[0] == 'i'){
            cin>>a;
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(total == 0){
                query q;
                q.type = 2;
                q.d = a;
                ans.PB(q);
                total++;
                m[a]++;
            }
            else{
                auto ind = m.begin();
                auto it = *ind;
                if(it.F != a){
                    if(a < it.F){
                        m[a]++;
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                    else{
                        for(auto ele : m){
                            if(ele.F < a){
                                for(int i = 0;i<ele.S;i++){
                                    query q;
                                    q.type = 1;
                                    ans.PB(q);
                                    total--;
                                }
                                m.erase(ele.F);
                            }
                            else{
                                break;
                            }
                        }
                        if(total == 0){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                            if(m.find(a) == m.end())
                                m[a] =(LL) 0;
                            m[a]++;
                        }
                        auto ind = m.begin();
                        auto it = *ind;
                        if(it.F != a){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                            m[a]++;
                        }
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                query q;
                q.type = 2;
                q.d = 0;
                ans.PB(q);
                m[0]++;
                total++;
            }
            auto tt = m.begin();
            auto it = *tt;
            auto ind = it.F;
            m[it.F]--;
            if(m[it.F] == 0)
                m.erase(it.F);
            query q;
            q.type = 1;
            ans.PB(q);
            total--;
        }
        else if(s[0] == 'i'){
            cin>>a;
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(total == 0){
                query q;
                q.type = 2;
                q.d = a;
                ans.PB(q);
                total++;
            }
            else{
                auto ind = m.begin();
                auto it = *ind;
                if(it.F != a){
                    if(a < it.F){
                        m[a]++;
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                    else{
                        for(auto ele : m){
                            if(ele.F < a){
                                for(int i = 0;i<ele.S;i++){
                                    query q;
                                    q.type = 1;
                                    ans.PB(q);
                                    total--;
                                }
                            }
                            else{
                                break;
                            }
                        }
                        auto ind = m.begin();
                        auto it = *ind;
                        if(it.F != a){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                        }
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                query q;
                q.type = 2;
                q.d = 0;
                ans.PB(q);
                m[0]++;
                total++;
            }
            auto tt = m.begin();
            auto it = *tt;
            auto ind = it.F;
            m[it.F]--;
            if(m[it.F] == 0)
                m.erase(it.F);
            query q;
            q.type = 1;
            ans.PB(q);
            total--;
        }
        else if(s[0] == 'i'){
            cin>>a;
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(total == 0){
                query q;
                q.type = 2;
                q.d = a;
                ans.PB(q);
                total++;
                m[a]++;
            }
            else{
                auto ind = m.begin();
                auto it = *ind;
                if(it.F != a){
                    if(a < it.F){
                        m[a]++;
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                    else{
                        for(auto ele : m){
                            if(ele.F < a){
                                for(int i = 0;i<ele.S;i++){
                                    query q;
                                    q.type = 1;
                                    ans.PB(q);
                                    total--;
                                }
                                m.erase(ele.F);
                            }
                            else{
                                break;
                            }
                        }
                        if(total == 0){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                            m[a]++;
                        }
                        auto ind = m.begin();
                        auto it = *ind;
                        if(it.F != a){
                            query q;
                            q.type = 2;
                            q.d = a;
                            ans.PB(q);
                            total++;
                            m[a]++;
                        }
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <string>

using namespace std;

const int NO_X = 2e9;

const string REMOVE = "removeMin";
const string GET = "getMin";
const string INSERT = "insert";

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<pair<string, int> > ans;
    priority_queue<int> q;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == INSERT) {
            int x;
            cin >> x;
            q.push(x);
            ans.push_back(make_pair(s, x));
        } else if (s == GET) {
            int x;
            cin >> x;
            while (!q.empty() && q.top() < x) {
                q.pop();
                ans.push_back(make_pair(REMOVE, NO_X));
            }
            if (q.empty() || q.top() > x) {
                q.push(x);
                ans.push_back(make_pair(INSERT, x));
            }
            ans.push_back(make_pair(s, x));
        } else { // s == REMOVE
            if (q.empty()) {
                ans.push_back(make_pair(INSERT, 0));
            } else {
                q.pop();
            }
            ans.push_back(make_pair(s, NO_X));
        }
    }

    cout << ans.size() << "\n";
    for (auto& p : ans) {
        cout << p.first;
        if (p.second != NO_X) {
            cout << " " << p.second;
        }
        cout << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                pending++;
            }
            else{
                auto tt = m.begin();
                auto it = *tt;
                auto ind = it.F;
                m[it.F]--;
                if(m[it.F] == 0)
                    m.erase(it.F);
                query q;
                q.type = 1;
                ans.PB(q);
            }
        }
        else if(s[0] == 'i'){
            cin>>a;
            if(pending>0){
                rep(j,0,pending){
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                    total++;
                }
                pending = 0;
            }
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(pending>0){
                rep(j,0,pending){
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                    total++;
                }
                pending = 0;
            }
            auto ind = m.begin();
            auto it = *ind;
            if(it.F != a){
                if(a < it.F){
                    m[a]++;
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                }
                else{
                    for(auto ele : m){
                        if(ele.F < a){
                            for(int i = 0;i<ele.S;i++){
                                query q;
                                q.type = 1;
                                ans.PB(q);
                            }
                        }
                        else{
                            break;
                        }
                    }
                    auto ind = m.begin();
                    auto it = *ind;
                    if(it.F != a){
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef vector<LL>         VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
struct query
{
    LL type, d;
};
LL n;
vector<query> ans;
map<LL , LL > m;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    cin>>n;
    string s;
    LL a;
    LL total=0;

    LL pending = 0;
    rep(i,0,n){
        cin>>s;
        if(s[0] == 'r'){
            if(total == 0){
                pending++;
            }
            else{
                auto tt = m.begin();
                auto it = *tt;
                auto ind = it.F;
                m[it.F]--;
                if(m[it.F] == 0)
                    m.erase(it.F);
                query q;
                q.type = 1;
                ans.PB(q);
            }
        }
        else if(s[0] == 'i'){
            cin>>a;
            if(pending>0){
                rep(j,0,pending){
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                    total++;
                }
                pending = 0;
            }
            m[a]++;
            query q;
            q.type = 2;
            q.d = a;
            ans.PB(q);
            total++;
        }
        else{
            cin>>a;
            if(pending>0){
                rep(j,0,pending){
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                    total++;
                }
                pending = 0;
            }
            auto ind = m.begin();
            auto it = *ind;
            if(it.F != a){
                if(a < it.F){
                    m[a]++;
                    query q;
                    q.type = 2;
                    q.d = a;
                    ans.PB(q);
                }
                else{
                    for(auto ele : m){
                        if(ele.F < a){
                            for(int i = 0;i<ele.S;i++){
                                query q;
                                q.type = 1;
                                ans.PB(q);
                            }
                        }
                        else{
                            break;
                        }
                    }
                    auto ind = m.begin();
                    auto it = *ind;
                    if(it.F != a){
                        query q;
                        q.type = 2;
                        q.d = a;
                        ans.PB(q);
                        total++;
                    }
                }
            }
            query q;
            q.type = 3;
            q.d = a;
            ans.PB(q);
        }
    }
    if(pending > 0){
        rep(i,0,pending){
            query q;
            q.type = 2;
            q.d = 0;
            ans.PB(q);
        }
    }
    dout(SZ(ans));
    for(auto it : ans){
        if(it.type == 1){
            dout("removeMin");
        }
        else if(it.type == 2){
            cout<<"insert "<<it.d<<"\n";
        }
        else{
            cout<<"getMin "<<it.d<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <string>

using namespace std;

const int NO_X = 2e9;

const string REMOVE = "removeMin";
const string GET = "getMin";
const string INSERT = "insert";

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<pair<string, int> > ans;
    priority_queue<int> q;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == INSERT) {
            int x;
            cin >> x;
            q.push(-x);
            ans.push_back(make_pair(s, x));
        } else if (s == GET) {
            int x;
            cin >> x;
            while (!q.empty() && -q.top() < x) {
                q.pop();
                ans.push_back(make_pair(REMOVE, NO_X));
            }
            if (q.empty() || -q.top() > x) {
                q.push(-x);
                ans.push_back(make_pair(INSERT, x));
            }
            ans.push_back(make_pair(s, x));
        } else { // s == REMOVE
            if (q.empty()) {
                ans.push_back(make_pair(INSERT, 0));
            } else {
                q.pop();
            }
            ans.push_back(make_pair(s, NO_X));
        }
    }

    cout << ans.size() << "\n";
    for (auto& p : ans) {
        cout << p.first;
        if (p.second != NO_X) {
            cout << " " << p.second;
        }
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
                while(m.size()>0 && it->first<a)
                {
                   it=m.begin();
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
                v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<endl;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
void solve( )
{
    ll n,a,i;
    priority_queue <int, vector<int>, greater<int>> p;
    vector< string > v;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            p.push(a);
        }
        else if(s=="removeMin")
        {
            if(p.empty())
            {
                v.push_back("insert 0");
            }
            else
            p.pop();
            v.push_back(s);
        }
        else
        {
            while(!p.empty() && a>p.top())
            {
                p.pop();
                v.push_back("removeMin");
            }
            if(p.empty() || p.top()!=a)
            {
                v.push_back("insert "+to_string(a));
                p.push(a);
            }
            v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<"\n";
    for(i=0;i<v.size();++i)
        cout<<v[i]<<"\n";
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert"+to_string(a));
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                 v.push_back("insert"+to_string(a));
                m[a]++;
            }
            v.push_back(s+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                 v.push_back("insert "+to_string(a));
                m[a]++;
            }
            v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back({"insert",0});
            m[0]++;}
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
            }
            v.push_back({s,a});
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                 v.push_back("insert "+to_string(a));
                m[a]++;
            }
            v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<endl;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
            }
            v.push_back({s,a});
        }
    }
    cout<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
                while(m.size()>0 && it->first<a)
                {
                    it=m.begin();
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                it=m.begin();
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
                v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<endl;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0)
            v.push_back({"insert",0});
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
            }
            v.push_back({s,a});
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0)
            v.push_back({s,0});
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
            }
            v.push_back({s,a});
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
void solve( )
{
    ll n,a,i;
    priority_queue <int, vector<int>, greater<int>> p;
    vector< string > v;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            p.push(a);
        }
        else if(s=="removeMin")
        {
            if(p.empty())
            {
                v.push_back("insert 0");
            }
            p.pop();
            v.push_back(s);
        }
        else
        {
            while(!p.empty() && a>p.top())
            {
                p.pop();
                v.push_back("removeMin");
            }
            if(p.empty() || p.top()!=a)
            {
                v.push_back("insert "+to_string(a));
                p.push(a);
            }
            v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<"\n";
    for(i=0;i<v.size();++i)
        cout<<v[i]<<"\n";
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back({"insert",0});
            m[0]++;}
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
                m[a]++;
            }
            v.push_back({s,a});
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< pair< string, ll> > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back({s,a});
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            v.push_back({s,-1});
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
            it=m.begin();

            if(a>it->first)
            {
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back({"removeMin",-1});
                    m.erase(it->first);
                }
                //cout<<m.size()<<endl;
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back({"insert",a});
                    m[a]++;
                }
            }
            else if(a<it->first)
            {
                v.push_back({"insert",a});
            }
            v.push_back({s,a});
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        if(v[i].first=="removeMin")
            cout<<v[i].first<<endl;
        else
            cout<<v[i].first<<" "<<v[i].second<<"\n";
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t,y=0;
    //cin>>t;
    t=1;
   while(t--)
    {
        y++;
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
                while(m.size()>0 && it->first<a)
                {
                    it=m.begin();
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
                v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<endl;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <sstream>
#define ll long long
#define M 1000000000000000000
using namespace std;
/*ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {

        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}*/
void solve( )
{
    ll n,i,a,j;
    string s;
    vector< string > v;
    map< ll, ll> m;
    map< ll, ll>::iterator it;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s!="removeMin")
            cin>>a;
        if(s=="insert")
        {
            v.push_back(s+" "+to_string(a));
            m[a]++;;
        }
        else if(s=="removeMin")
        {
            if(m.size()==0){
            v.push_back("insert 0");
            m[0]++;}
            v.push_back(s);
            it=m.begin();
            it->second--;
            if(it->second==0)
                m.erase(it->first);
        }
        else
        {
                it=m.begin();
                while(m.size()>0 && it->first<a)
                {
                    for(j=0;j<it->second;++j)
                        v.push_back("removeMin");
                    m.erase(it->first);
                }
                if(m.size()==0 || it->first!=a)
                {
                    v.push_back("insert "+to_string(a));
                    m[a]++;
                }
                v.push_back(s+" "+to_string(a));
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();++i)
    {
        cout<<v[i]<<endl;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll t;
    //cin>>t;
    t=1;
   while(t--)
    {
      solve();
      cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 30;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000027;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                } else {
                    command.push_back (insert);
                    args.push_back (0);
                    ++m;
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    if (h_min != argument) {
        heap.Insert (argument);
        commands.push_back (insert);
        args.push_back (argument);
        col++;
    }

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
        if (right >= data.size())   right = left;
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}


#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 12;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000003;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = stdin; //fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    heap.Insert (argument);
    commands.push_back (insert);
    args.push_back (argument);
    col++;

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}


#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 12;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000003;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = stdin; //fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                } else {
                    command.push_back (insert);
                    args.push_back (0);
                    ++m;
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    if (h_min != argument) {
        heap.Insert (argument);
        commands.push_back (insert);
        args.push_back (argument);
        col++;
    }

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}


#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 30;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000027;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = stdin;//fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                } else {
                    command.push_back (insert);
                    args.push_back (0);
                    ++m;
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    if (h_min != argument) {
        heap.Insert (argument);
        commands.push_back (insert);
        args.push_back (argument);
        col++;
    }

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
        if (right >= data.size())   right = left;
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}


#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 12;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000003;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = stdin;//fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                } else {
                    command.push_back (insert);
                    args.push_back (0);
                    ++m;
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    heap.Insert (argument);
    commands.push_back (insert);
    args.push_back (argument);
    col++;

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}