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 INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

ll SmallerThanWeekP(ll a, ll b, ll c) {
    //if (c <= a) return 1;
    if (7 * a < c) return 7;
    else if (c % a != 0) return ll(c / a) + 1;
    else return c / a;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n;
    cin >> n;
    auto x = Read(n);
    int  m;
    cin >> m;
    auto a = Read(m);

    REP(i, m) {
        if (x[a[i]-1] + 1 != x[a[i]] && x[a[i]-1] != 2019) x[a[i]-1] += 1;
    }

    DumpRow(x);

    return 0;
}

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

int main() {
    int n, m;
    std::cin >> n;
    std::vector<int> vec;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        vec.push_back(x);
    }
    std::cin >> m;
    int moves[m];
    for (int i = 0; i < m; i++) {
        std::cin >> moves[i];
    }
    for (int i = 0; i < m; i++) {
        int t = moves[i] - 1;
        if (std::find(vec.begin(), vec.end(), vec[t]+1) == vec.end() && vec[t] != 2019) {
            vec[t] += 1;
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << vec[i] << std::endl;
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> X(N+2);
    for (int i = 1; i <= N; ++i) cin >> X[i];
    X[N+1] = 2020;
    int M; cin >> M;

    int i = 0; 
    bool flag = true;

    for (int i = 0; i < M; ++i) {
        int key;
        cin >> key;
         // keyの駒を動かす
        if (X[key] + 1 == X[key+1] || X[key] == 2019) 
            continue;
        X[key]++;
    }

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

    return 0;
}

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

using namespace std;

bool exist[2021];

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        exist[x[i]] = true;
    }
    exist[2020] = true;
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        --a;
        if (!exist[x[a] + 1]) {
            exist[x[a]] = false;
            ++x[a];
            exist[x[a]] = true;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << x[i] << '\n';
    }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int N, M, A, X[100];
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &X[i]);
    }
    scanf("%d", &M);
    for(int i = 0; i < M; i++){
        scanf("%d", &A);
        if(X[A-1] != X[A]-1 && X[A-1] != 2019) X[A-1] += 1;
    }
    
    for(int i = 0; i < N; i++){
        printf("%d\n", X[i]);
    }
    return 0;
}

C++: #include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
	int n,i,m,x[101],a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&x[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++)	{
		scanf("%d",&a);
		if(x[a+1]!=x[a]+1 && x[a]!=2019)	x[a]++;
	}
	for(i=1;i<=n;i++)	printf("%d\n",x[i]);
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n;
	int x[n+1]={};
	x[n]=2020;
	for(int p=0;p<n;p++){
		cin>>x[p];
	}
	//for(int p=0;p<n+1;p++){
	//	cout<<x[p]<<endl;
	//}
	cin>>m;
	int t;
	for(int p=0;p<m;p++){
		cin>>t;
		t--;
		if(x[t]+1<x[t+1]){
			x[t]++;
		}
	}
	for(int p=0;p<n;p++){
		cout<<x[p]<<endl;
	}
}

C++: #include <stdio.h>
#include <string.h>

#define MASU_MAX	(2019)
#define KOMA_MAX	(100)

int N;
int M;
int A;
int X[KOMA_MAX];

int main(void) {

	scanf("%d", &N);

	int tmp = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp);
		X[i] = tmp;
	}

	scanf("%d", &M);
	for (int j = 0; j < M; j++) {
		scanf("%d", &A);
		if (X[A - 1] == 2019) {	// ゴールにいる場合は進めない
			continue;
		}
		int pos = X[A - 1] + 1;
		int exist = 0;
		for (int i = 0; i < N; i++) {
			if (i == A - 1) {	// 自分は見ない
				continue;
			}
			if (X[i] == pos) {
				exist = 1;
				break;
			}
		}
		if (exist == 0) {	// 移動先にいない場合は進める
			X[A - 1]++;
		}
	}

	for (int i = 0; i < N; i++) {
		printf("%d\n", X[i]);
	}

	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[2030],c[110];

int main(void){
	          int i;

	          cin.tie(0);  ios_base::sync_with_stdio(false);

	          int N,M;
	          cin >> N;
	          for(i=1;i<=N;i++){
	        	  int x;
	        	  cin >> x;
	        	  a[x]=i;
	        	  c[i]=x;
	          }

	          cin >> M;
	          for(i=1;i<=M;i++){
	        	  int n;
	        	  cin >> n;
	        	  if(a[c[n]+1]==0 && (c[n]+1)!=2020 ){
	        		 a[c[n]+1]=n;
	        		 a[c[n]]=0;
	        		 c[n]++;
	        	  }
	          }

	          for(i=1;i<=N;i++) cout << c[i] << endl;

	          return 0;
}

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

using namespace std;

int main(){
	ll n, m, i;
	bool b[2020]={0};
	
	cin>>n;
	
	vector < ll > x(n+1);
	
	for(i=1; i<=n; i++){
		cin>>x[i];
		b[x[i]]=1;
	}
	
	cin>>m;
	
	ll a;
	
	for(i=1; i<=m; i++){
		cin>>a;
		if(x[a]<2019 && b[x[a]+1]==0){
			b[x[a]]=0;
			b[x[a]+1]=1;
			x[a]++;
		}
	}
	
	for(i=1; i<=n; i++){
		cout<<x[i]<<"\n";	
	}
	
	return 0;
}