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 FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    int m;
    cin >> m;
    REP(i,m){
        int t;
        cin >> t;
        if(t==n && a[n-1]<2019){
            a[n-1]++;
        }
        else if(t!= n && a[t]-a[t-1]>1){
            a[t-1]++;
        }
    }
    REP(i,n){
        cout << a[i] << endl;
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  vector<int> v(2020);

  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    v[x] = i;
  }

  int m, a;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a;
    int t = 0;
    while (v[t] != a && t < 2020) t++;
    if (t == 2019 || v[t + 1]) continue;
    v[t + 1] = v[t];
    v[t] = 0;
  }

  for (int i = 1; i <= n; i++) {
    int t = 0;
    while (v[t] != i && t < 2020) t++;
    cout << t << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,X[100],M,A[100];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>X[i];
    }
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>A[i];
    }
    for(int i=0;i<M;i++)
    if(X[A[i]-1]+1==X[A[i]]||X[A[i]-1]==2019){
        
    }else{
        X[A[i]-1]++;
    }
    for(int i=0;i<N;i++){
        cout<<X[i]<<endl;
    }
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> grid(n);
  for(int i=0;i<n;++i) cin >> grid[i];
  int m,a; cin >> m;
  for(int i=0;i<m;++i){
    cin >> a; a--;
    if(grid[a]+1!=grid[a+1] && grid[a]!=2019) grid[a]++;
  }
  for(int i=0;i<n;++i)
    cout << grid[i] << endl;

  return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> x(n+1, 0);
	for (int i = 1; i < n+1; i++) {
		cin >> x[i];
	}
	int m;
	cin >> m;
	vector<int> a(m+1, 0);
	for (int i = 1; i < m+1; i++) {
		cin >> a[i];
	}

	int kariposi = 0;
	for (int i = 1; i < m+1; i++) {
		kariposi = x[a[i]]+1;
		for (int j = 1; j < n+1; j++) {
			if (kariposi == x[j] || kariposi == 2020) {
				kariposi--;
				break;
			}
		}
		x[a[i]] = kariposi;
	}

	for (int i = 1; i < n+1; i++) {
		cout << x[i] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0, a, x, m, ans = 0;
	int test[101] = { 0 }; int uiop[2020] = { 0 };
	cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		test[h] = a;
		uiop[a]++;
	}
	cin >> m;
	for (int h = 1; h <= m; h++) {
		cin >> x;
		if (uiop[test[x] + 1] == 0) {
			uiop[test[x]] = 0;
			uiop[test[x] + 1]++;
			test[x]++;
		}
	}
	for (int h = 1; h <= n; h++) {
		cout << test[h] << endl;
	}
	cin >> n;
}

C++: #include <iostream>
using namespace std;
int main(void){
    
    int N;
    int X[101] = {};
    int M;
    int A[101]= {};
    
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> X[i];
    }

    cin >> M;
    for(int i = 1; i <= M; i++){
        cin >> A[i];
        //cout << X[A[i]]+1 <<" != " << X[A[i]+1] << "  &&  " << X[A[i]]+1 <<" != " << 2020 << endl;
        if(X[A[i]]+1 != X[A[i]+1] && X[A[i]]+1 != 2020) {
            X[A[i]]++;
        }
        
    }
    
    for(int i = 1; i <= N; i++){
        cout << X[i] << endl;
    }
    
}

C++: #include <iostream>

#define SQUARE_NUM  2019

using namespace std;

int main(void){
    int numPiece;
    cin >> numPiece;
    int piecePosition[numPiece];
    for(int i = 0; i < numPiece; i++){
        cin >> piecePosition[i];
    }
    int numAction;
    cin >> numAction;
    int whichPiece[numAction];
    for(int i = 0; i < numAction; i++){
        cin >> whichPiece[i];
    }
    
    //指定されたピースの位置が2019ならそれ以上進まない
    //指定されたピースの一つ前のマスにピースがあるなら進まない
    for(int i = 0; i < numAction; i++){
        if(whichPiece[i] < numPiece){
            if((piecePosition[whichPiece[i] - 1] + 1) == piecePosition[whichPiece[i]])    continue;
        }
        else if(piecePosition[whichPiece[i] - 1] == SQUARE_NUM)   continue;
        
        //進むための条件を達している場合
        piecePosition[whichPiece[i] - 1] += 1;
    }
    
    for(int i = 0; i < numPiece; i++){
        cout << piecePosition[i] << '\n';
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>

using namespace std;


int main() {
	int N, M;
	int x[105], mp[2030] = {};

	cin >> N;
	rep(i, N) {
		cin >> x[i];
		mp[x[i]]++;
	}
	cin >> M;
	rep(i, M) {
		int a;
		cin >> a; a--;
		if (mp[x[a] + 1] == 0 && x[a] < 2019) {
			mp[x[a] + 1]++;
			mp[x[a]]--;
			x[a]++;
		}
	}

	rep(i, N) {
		cout << x[i] << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int X[N];
  for (int i=0; i<N; i++) {
    cin >> X[i];
  }
  int M;
  cin >> M;
  int a[M];
  for (int i=0; i<M; i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0; i<M; i++){
    if( (X[a[i]]+1)!=X[a[i]+1] && X[a[i]]!=2019) {
      X[a[i]]++;
    }
  }
  for (int i=0; i<N; i++) {
    cout << X[i] << endl;
  }
}