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>

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int m;
  cin >> m;

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

    if (v[tmp] == 2019) continue;
    if (v[tmp] + 1 == v[tmp + 1]) continue;
    v[tmp]++;
  }

  for (auto e : v) {
    cout << e << endl;
  }
}

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

int main() {
  int N, M;
  vector<int> X;
  int A;

  cin >> N;

  for(int i = 0; i < N; i++) {
    int	x;
    cin >> x;
    X.push_back(x);
  }

  cin >> M;
  for(int i = 0; i < M; i++) {
    int	flag = 0;
    cin >> A;
    if(X[A-1] == 2019) continue;
    for(int j = 0; j < N; j++) {
      if((X[A-1]+1) == X[j]) {
        flag = 1;
        break;
      }
    }
    if(flag != 1)
      X[A-1]++;
  }

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

C++: #include <iostream>

int main()
{
  int X[102];
  int A[100];

  int N;
  std::cin >> N;
  for (int i = 1; i <= N; ++i)
  {
    std::cin >> X[i];
  }
  X[N + 1] = 2020;

  int M;
  std::cin >> M;
  for (int i = 0; i < M; ++i)
  {
    std::cin >> A[i];
  }

  for (int i = 0; i < M; ++i)
  {
    if (X[A[i] + 1] != X[A[i]] + 1)
    {
      ++X[A[i]];
    }
  }

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

  return 0;
}

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

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int M;
    cin >> M;
    vector<int> A(M);
    for(int i = 0;i < M;i++) {
        cin >> A.at(i);
    }
    for(int i = 0;i < M;i++) {
        if((A.at(i) == N && vec.at(A.at(i) - 1) != 2019) || (A.at(i) != N && vec.at(A.at(i) - 1) + 1 != vec.at(A.at(i)))) {
            vec.at(A.at(i) - 1)++;
        }
    }
    for(int i = 0;i < N;i++) {
        cout << vec.at(i) << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    v.emplace_back(2020);
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x; x--;
        if(v[x]+1 < v[x+1]) v[x]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << v[i] << "\n";
    }
    return 0;
}

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

int main() {
	int N;
	cin >> N;

	vector<int> p( N );
	for( auto& v: p ) { cin >> v; }

	int M;
	cin >> M;

	for( int i = 0; i < M; ++i ) {
		int A;
		cin >> A;

		auto& p1 = p.at( A-1 );
		if( p1 == 2019 ) {
			continue;
		}

		bool stop = false;

		for( int j = 0; j < N; ++j ) {
			if( p1+1 == p.at( j ) ) {
				stop = true;
				break;
			}
		}

		if( !stop ) {
			p1 += 1;
		}
	}

	for( auto& v: p ) {
		cout << v << endl;
	}
}

C++: //id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    int n,m;
    int A[2021]= {0}; //1~2019とさいご
    int B[2021]= {0};
    cin >> n;
    REP(i,n){
        int x;
        cin>>x;
        B[i+1]= x; //ここに入ってる
        A[x]=1;
    } 
    A[2020]=1;
    cin >> m;
    REP(i,m){
        int x;
        cin >> x;
        // cout << A[B[x]] << endl;
        swap(A[B[x]],A[B[x]+1]);
        if(A[B[x]]==0) B[x]++;

  
    }
    REP(i,2020){
        if(A[i]==1){
            cout << i << endl;
        } 
    }
}

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

int place(int i,int* sugoroku);

int main(void){
    int sugoroku[2020]={0};
    int X;
    int A;
    int N,M;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>X;
        sugoroku[X]=1;
    }
    int p;
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>A;
        p=place(A,sugoroku);
        if(p==2019);
        else if(sugoroku[p+1]==0){
            sugoroku[p]=0;
            sugoroku[p+1]=1;
        }
    }
    for(int i=1;i<=N;i++){
        cout<<place(i,sugoroku)<<endl;
    }
    return 0;
}

int place(int i,int* sugoroku){
    int count=0;
    for(int j=0;j<2020;j++){
        count+=sugoroku[j];
        if(count==i){return j;}
    }
}

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

using namespace std;

int main(){
	int board[2020];
	for(int i = 0; i < 2020; i++){
		board[i] = 0;
	}
	int N;
	cin >> N;
	int tkn[N];
	for(int i = 0; i < N; i++){
		int p = 0;
		cin >> p;
		tkn[i] = p;
		board[p] = i + 1;
	}
	int M;
	cin >> M;
	for(int i = 0; i < M; i++){
		int move;
		cin >> move;
		if(tkn[move-1] != 2019){
			if(board[tkn[move-1]+1] == 0){
				board[tkn[move-1]+1] = move;
				board[tkn[move-1]] = 0;
			}
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 2020; j++){
			if(board[j] == i){
				cout << j << "\n";
				break;
			}
		}
	}
}

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

using namespace std;
int main(void){
    // Your code here!
    int a,b,d;
    int c[100]={};
    
    cin>>a;
    for(int z=1;z<=a;z++){
        cin>>c[z];
    }
    cin>>b;
    for(int z=1;z<=b;z++){
        cin>>d;
        if(c[d]+1!=c[d+1]){
            if(c[d]!=2019){
                c[d]++;
            }
        }
    }
    for(int z=1;z<=a;z++){
        cout<<c[z]<<endl;
    }
    
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
int X[110], A[110];
int pos[110];
int mark[2020];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    memset(mark, 0xff, sizeof(mark));
    cin >> N;
    REP(i, N) {
        cin >> X[i];
        --X[i];
        mark[X[i]] = i;
        pos[i] = X[i];
    }
    cin >> M;
    REP(i, M) {
        cin >> A[i];
        --A[i];
        if (~mark[pos[A[i]] + 1]) continue;
        mark[pos[A[i]]] = -1;
        pos[A[i]] = min(2018LL, pos[A[i]] + 1);
        mark[pos[A[i]]] = A[i];
    }
    REP(i, N) cout << pos[i] + 1 << endl;
}