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>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------



int main() {

  int n, m;
  int x[101], a[101];
  int flag[2019];

  rep(i, 2019) flag[i] = 0;

  cin >> n;
  rep(i, n) {
    cin >> x[i];
    --x[i];
    flag[x[i]] = 1;
  }

  cin >> m;
  rep(i, m) {
    cin >> a[i];
    --a[i];
    if(x[a[i]]+1<=2018&&flag[x[a[i]]+1]==0) {
      flag[x[a[i]]] = 0;
      flag[x[a[i]]+1] = 1;
      ++x[a[i]];
    }
  }

  rep(i, 2019) {
    if(flag[i]==1) cout << i+1 << endl;
  }

  return 0;
}

C++: #include<stdio.h>

int main(void){
int A,N,M,X[105],i;
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( A==N ){ X[A]++; }
   else {
         if( X[A+1]>X[A]+1){X[A]++;}
      }
  if( X[A] > 2019 ){X[A] = 2019 ;}
   }

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

C++: #include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    int n, m, t;
    cin >> n;
    vector<int> M(2020, 0);
    vector<int> P(n + 1, 0);
    rep(i, 1, n + 1) {
        cin >> t;
        M[t] = i;
        P[i] = t;
    }
    cin >> m;
    rep(i, m) {
        cin >> t;
        if(P[t] != 2019 && M[P[t] + 1] == 0) {
            M[P[t]] = 0;
            M[P[t] + 1] = t;
            P[t]++;
        }
    }

    rep(i, 1, n + 1) { cout << P[i] << "\n"; }
}

C++: #include <iostream>

#define GOAL 2019
#define MAX 100

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  int X[MAX+1];
  int P[GOAL+2] = {0};
  for(int i = 1; i <= N; i++) {
    cin >> X[i];
    P[X[i]] = 1;
  }
  int M;
  cin >> M;
  int A[MAX];
  for(int i = 0; i < M; i++) cin >> A[i];

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

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

  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  int m; cin >> m;
  for (int i = 0; i < m; i ++) {
    int t; cin >> t;
    t --;
    if ((a[t] + 1 == a[t + 1] && t < n) || a[t] == 2019) continue;
    a[t] ++;
  }

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

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

int N;
int X[1000] = {0};
int M;
int A;


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

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n), used(2020, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        used[v[i]] = 1;
    }
    int m; cin >> m;
    for(int i = 0; i < m; i++)
    {
        int x; cin >> x;
        x--;
        if(used[v[x] + 1] || v[x] + 1 >= 2020) continue;
        swap(used[v[x]], used[v[x] + 1]);
        v[x]++;
    }
    for(int i = 0; i < n; i++) cout << v[i] << endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std; 
int main(void){
	int n;
	int x[101];
	int m;
	int a[101];
	cin>>n;
	int i;
	for(i=1;i<=n;i++){
		cin>>x[i];
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		if(x[a[i]]+1!=x[a[i]+1]&&x[a[i]]+1!=2020){
			x[a[i]]++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<x[i]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    int m; cin >> m;
    REP(i,m) {
        int a; cin >> a;
        a--;
        if (find(ALL(v),v[a]+1) == v.end() && v[a] != 2019) v[a]++;
    }

    REP(i,v.size()) cout << v[i] << endl;

    return 0;
}

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

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

using namespace std;
int main(){
  int N,M,x,a;
  vector<int> X;
  vector<int> A;

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

  cin >> M;
  for(int i=0;i<M;i++){
    cin >> a;
    A.push_back(a);
  }


  for(int i=0;i<M;i++){
    bool bo=true;
    int sub=A[i]-1;

    for(int j=0;j<N;j++){
      if((X[sub]+1)==X[j]){
	bo=false;
      }
    }
    if((X[sub])==2019){
      bo=false;
    }

    else if(bo==true){
      X[sub]+=1;
    }

  }


  for(int i=0;i<N;i++){
    cout << X[i] << "\n";
  }
}

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

#define GOAL 2019

int main(void){
  int x[200]={0};
  int n,m;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int t;
    cin >> t;
    x[i]=t;
  }
  cin >> m;
  for (int i=0; i<m; i++){
    int a;
    cin >> a; a--;
    if (x[a]!=GOAL && x[a+1]-x[a]!=1){
      x[a]++;
    }
  }
  for (int i=0; i<n; i++){
    cout << x[i] << endl;
  }
  return 0;
}