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 <iostream>
using namespace std;

int main() {
    int N, x[102], M, a, i, l;

    cin >> N;
    for(i = 1; i <= N; i++) {
        cin >> x[i];
    }
    cin >> M;
    for(l = 0; l < M; l++) {
        cin >> i;
        if(i == N) {
            if(x[i] < 2019) {
                x[i]++;
            }
        } else {
            if (x[i]+1 < x[i+1]) {
                x[i]++;
            }
        }
    }
    for(i = 1; i <= N; i++) {
        cout << x[i] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(){
  vector<bool> v(2020);
  int n;cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
    v[x[i]] = true;
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
    int a;cin>>a;
    if(!v[x[a-1]+1] && x[a-1]!=2019){
      v[x[a-1]+1] = true;
      v[x[a-1]] = false;
      x[a-1]++;
    }
  }
  for(int i=0;i<x.size();i++){
    cout<<x[i]<<endl;
  }
}

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

#define MAX 2020
#define P 101

int table[MAX];
int idxs[P];

void move(int pid) {
    if (table[idxs[pid]+1] == 0 && idxs[pid]+1 <= 2019) {
        table[idxs[pid]] = 0; table[idxs[pid]+1] = 1;
        idxs[pid]++;
    }
}


int main()
{
    int N, M, tmp;
    for (int i = 0; i < 2020; i++) {
        table[i] = 0;
    }

    std::scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        std::scanf("%d", &tmp);
        idxs[i] = tmp;
        table[tmp] = 1;
    }

    std::scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        std::scanf("%d", &tmp);
        move(tmp);
    }

    for (int i = 1; i <= N; i++) {
        std::printf("%d\n", idxs[i]);
    }



    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  map<int,int>mp1;
  map<int,int>mp2;
  rep(i,n){
    int x;
    cin >> x;
    mp1[i+1]=x;
    mp2[x]=i+1;
  }
  int m;
  cin >> m;
  rep(i,m){
    int a;
    cin >> a;
    if(mp1[a]==2019 ||mp2[mp1[a]+1]>0)continue;
    mp2[mp1[a]]=0;
    mp2[mp1[a]+1]=a;
    mp1[a]++;
  }
  for(auto p:mp1){
    cout << p.second << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 3005
const int INF = 1e9 + 7;

int used[ARRAY_MAX];

int main() {

	int n, m;
	cin >> n;
	auto a = make_v<int>(n + 10);
	fill_v(a, 0);

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		used[a[i]]++;
	}

	cin >> m;

	for (int i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		if (used[a[tmp] + 1] == 0)
		{
			used[a[tmp] + 1]++;
			used[a[tmp]]--;
			a[tmp] = min(a[tmp]+1, 2019);
		}
	}

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

C++: #include<iostream>
#include <vector>


int main() 
{
	int PIECE_NUM = 0;
	std::vector<int> piecePos;
	int opeNum = 0;

	auto haveSameNum = [&](int pos) -> bool
	{
		for (int pPos : piecePos) if (pPos == pos + 1) return true;
		return false;
	};
	

	std::cin >> PIECE_NUM;
	for (int i = 0; i < PIECE_NUM; ++i)
	{
		int pos = 0;
		std::cin >> pos;
		piecePos.emplace_back(pos);
	}
	std::cin >> opeNum;

	// 駒を動かす
	for (int i = 0; i < opeNum; ++i)
	{
		int no = 0;
		std::cin >> no;
		
		int pos = piecePos[no-1];

		if (pos == 2019) continue;
		else if(haveSameNum(pos)) continue;

		piecePos[no-1] ++;
	}	

	for (int pPos : piecePos) std::cout << pPos << std::endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
	int a,i,n,m,x[100];
	cin>>n;
	for(i=0;i<n;i++) cin>>x[i];
	cin>>m;
	for(i=0;i<m;i++){
		cin>>a;
		if((a==n || x[a]!=x[a-1]+1) && x[a-1]<2019) x[a-1]++;
	}
	for(i=0;i<n;i++) cout<<x[i]<<endl;
	return 0;
}

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

int main(){
    int n, m;
    bool board[2020] = {0};
    int x[101];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x[i];
        board[x[i]] = true;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        if(x[a]==2019 || board[x[a]+1]) continue;
        board[x[a]] = false;
        board[x[a]+1] = true;
        x[a]++;
    }

    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 rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
bool exist[2100];
map<int, int> pos;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        pos[i] = x;
        exist[pos[i]] = true;
    }

    cin >> m;
    for (int i = 1; i <= m; i++) {
        int a; cin >> a;
        if (exist[pos[a]+1] || pos[a] == 2019) continue;
        // printf("x%d: %d -> %d\n", a, pos[a], pos[a]+1);
        exist[pos[a]] = false;
        exist[pos[a+1]] = true;
        pos[a]++;
    }
    for (int i = 1; i <= n; i++) cout << pos[i] << endl;
}