Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func printArr(arr []string) {
	fmt.Println(strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]"))
}

func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	x := make([]int, 2019+1)
	for i := range x {
		x[i] = -1
	}
	for i := 0; i < n; i++ {
		p, _ := nextInt()
		x[p] = i + 1
	}
	m, _ := nextInt()
	a := make([]int, m)
	for i := 0; i < m; i++ {
		a[i], _ = nextInt()
	}

	for i := 0; i < m; i++ {
		ai := a[i]
		//		fmt.Println(a, ai, x[0:10])
		for j := 1; j < 2019; j++ {
			if (x[j] == ai) && (x[j+1] == -1) {
				x[j] = -1
				x[j+1] = ai
				break
			}
		}
	}

	for i := 1; i <= 2019; i++ {
		for j := 1; j <= 2019; j++ {
			if x[j] == i {
				fmt.Println(j)
				break
			}
		}
	}
}

C++: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> X(n);
  vector<bool> s(2025,false);
  rep(i,n) {
    cin >> X[i];
    s[X[i]] = true;
  }

  int m;
  cin >> m;
  rep(i,m) {
    int a;
    cin >> a;
    --a;
    if( X[a] == 2019 ) continue;
    if( s[X[a]+1] ) continue;
    s[X[a]+1] = true;
    s[X[a]] = false;
    ++X[a];
  }
  rep(i,n) {
    cout << X[i] << endl;
  }
  compute();
  return 0;
}

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

int main(){
    int ans=0;
    int xi;
    int n,m;
    cin >> n;
    vector < pair<int,int> > koma;

    for (int i = 1; i <= n; i++){
        cin >>xi;
        koma.push_back(make_pair(i,xi));
    }
    cin >>m;

    for (int i = 0; i < m; i++){
        cin >>xi;xi--;

        if(xi==n-1){
            if(!(koma[xi].second==2019))koma[xi].second++;
        }else{
            if(!(koma[xi].second + 1 == koma[xi+1].second))koma[xi].second++;
        }
    }
    
    for (int i = 0; i < n; i++){
        cout <<koma[i].second<< '\n';
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}

C++: #include <iostream>
using namespace std;

int N, X[100009], M, Q[100009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i];
	cin >> M;
	for (int i = 1; i <= M; i++) {
		cin >> Q[i];
		if (X[Q[i]] == 2019 || X[Q[i]] + 1 == X[Q[i] + 1]) continue;
		X[Q[i]]++;
	}
	for (int i = 1; i <= N; i++) cout << X[i] << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, m; cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    cin >> m;
    vector<bool> p(2020, false);
    rep(i, n) p[x[i]] = true;
    
    int a;
    rep(i, m){
        cin >> a;
        a--;
        if(x[a]==2019) continue;
        if(p[x[a]+1]) continue;
        swap(p[x[a]], p[x[a]+1]);
        x[a]++;
    }

    FOR(i, 0, n) cout << x[i] << endl;
    return 0;
}

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

int main() {
	int n,m,i,j;
	cin >> n;
	vector<int> x(n+1);
	for(i=0; i<n; i++){
		cin >> x[i];
	}
	x[n]=2020;
	cin >> m;
	for(j=0; j<m; j++){
		cin >> i; i--;
		if(x[i]+1<x[i+1]){
			x[i]++;
		}
	}
	for(i=0; i<n; i++){
		cout << x[i] << endl;
	}
}