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;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int q;cin>>q;
  for(int i = 0; q > i; i++){
    int t;cin>>t;
    if(a[t-1]+1!=a[t])a[t-1]=min(a[t-1]+1,2019);
  }
  for(int i = 0; n > i; i++){
    cout << a[i] << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{

  int N;
  cin>>N;
  vector<bool> data(2019,0);
  vector<int> input(N);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    A--;
    data[A] = true;
    input[i] = A;
  }
  int M;
  cin>>M;
  for (int q = 0; q < M; q++)
  {
    int A,B;
    cin>>B;
    B--;
    A = input[B];
    if(A != 2018 && data[min(A+1,(int)2018)] != true)
    {
      data[A] = false;
      data[A+1] = true;
      input[B]++;
      // DEBUG(A);
    }
  }

  for (int i = 0; i < 2019; i++)
  {
    if(data[i] == true)
    {
      cout<<i+1<<endl;
    }
  }
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        T val;
        cin >> val;
        vec1.push_back(val);
    }
    return move(vec1);
}

int main()
{
    const int          N(cin2var<int>());
    const vec1<int>    X(cin2vec<int>(N));
    const int          M(cin2var<int>());
    const vec1<int>    A(cin2vec<int>(M));
    vector<int>        player_place;
    unordered_set<int> place;
    for (int x : X) {
        player_place.push_back(x);
        place.insert(x);
    }
    for (int a : A) {
        const int now  = player_place[a - 1];
        const int next = now + 1;
        if (next > 2019) {
            continue;
        }
        if (place.count(next)) {
            continue;
        }
        player_place[a - 1] = next;
        place.erase(now);
        place.insert(next);
    }
    for (int p : player_place) {
        cout << p << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define GOAL 2019
#define NUM 105

int N,M;
int loc[NUM];
bool check[GOAL+1];

int main(){

	scanf("%d",&N);

	for(int i = 1; i <= GOAL; i++){

		check[i] = false;
	}

	for(int i = 1; i <= N; i++){

		scanf("%d",&loc[i]);
		check[loc[i]] = true;
	}

	scanf("%d",&M);

	int tmp;

	for(int loop = 0; loop < M; loop++){

		scanf("%d",&tmp);

		if(loc[tmp] == GOAL)continue;
		if(check[loc[tmp]+1])continue;

		check[loc[tmp]] = false;
		loc[tmp]++;
		check[loc[tmp]] = true;
	}

	for(int i = 1; i <= N; i++){

		printf("%d\n",loc[i]);
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int m;
    cin >> m;
    while (m--) {
        int a;
        cin >> a;
        a--;
        if (x[a] != 2019 && (a == n-1 || x[a]+1 < x[a+1]))
            x[a]++;
    }
    for (int xx : x) cout << xx << endl;
    return 0;
}

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

using namespace std;

int main(){

  int N;
  int M;

  cin >> N;

  vector<int> X(N + 1);
  
  for(int i = 1;i < N + 1;++i)
    cin >> X[i];

  cin >> M;

  vector<int> A(M + 1);
  
  for(int i = 1;i < M + 1;++i){

    bool flag = true;
    
    cin >> A[i];

    if(X[A[i]] == 2019)
      continue;
    
    for(int j = 1;j < N + 1;++j){
      if(X[A[i]] + 1 == X[j]){
	flag = false;
	break;
      }
    } 
    if(flag == true)
      X[A[i]] = X[A[i]] + 1;
  }

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

C++: #include<cstdio>


int main(){
    int n,m,a;
    scanf("%d",&n);
    int x[n+1];
    x[n] = 2020;
    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]++;
    }
    for(int i = 0;i < n;++i) printf("%d\n",x[i]);
}

C++: #include <iostream>
using namespace std;
int main(void){
    int N, M, X[100]={}, A[100]={}, i, j;
    
    cin >> N;
    for(i=1; i<=N; i++){
        cin >> X[i];
    }
    cin >> M;
    for(j=1; j<=M; j++){
        cin >> A[j];
    }
    
    for(j=1; j<=M; j++){
        if((X[A[j]]!=2019) && (X[A[j]]+1)!=X[A[j]+1]){
            X[A[j]]++;
        }
    }
    
    for(i=1; i<=N; i++){
        cout << X[i] << endl;
    }
    return 0;
}

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