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;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int n, m;
int a[100], x[100];


int main() {
  cin >> n;
  rep(i, n) cin >> x[i];
  cin >> m;
  rep(i, m) cin >> a[i];

  rep(i, m) {
    int s = a[i] - 1;
    bool f = 1;
    REP(j, s + 1, n) {
      if(x[s] == x[j] - 1) {
        f = 0;
      }
    }
    if(f && x[s] != 2019) x[s]++;
  }

  rep(i, n) {
    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 repd(i,a,b) for (double i = (a); i < (b); i++)
typedef long long ll;

int main (void)
{
    int N;
    cin >> N;
    vector<int> X(N+1);
    rep(i, N)
    {
        cin >> X[i];
    }
    int M;
    cin >> M;
    rep(i, M)
    {
        int A;
        cin >> A;
        A--;
        if (X[A] != 2019)
            if (X[A]+1 != X[A+1])
                X[A]++;
    }
    rep(i, N)
    {
        cout << X[i] << endl;
    }
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N;
	vector<int>v(N + 2);
	for (int i = 1; i <= N; i++)cin >> v[i];
	v[N + 1] = 2020;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> K;
		if (v[K + 1] - v[K] != 1)v[K]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << v[i] << endl;
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

int main(){
//int W,H,x,y,r;
    int N,M;
    cin>>N;
    vector<int> X(N);

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

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[i]!=N){
        if(X.at(A.at(i)-1)+1 != X.at(A.at(i)))
        X.at(A.at(i)-1)++;
    }else{
        if(X.at(A.at(i)-1) !=2019)
        X.at(A.at(i)-1)++;   
    }
}  
  
  for(int i=0;i<N;i++){
  cout<<X.at(i)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  cin >> m;
  rep(i, m) {
    ll a;
    cin >> a;
    a--;
    if (a < n-1) {
      if (v.at(a)+1 == v.at(a+1)) {
        continue;
      } else {
        v.at(a)++;
      }
    } else {
      if (v.at(a) == 2019) {
        continue;
      } else {
        v.at(a)++;
      }
    }
  }
  rep(i, n) {
    cout << v.at(i) << endl;
  }
}

C++: /*JOI 君はすごろくを持っている．このすごろくは 2019 個のマスが横一列に並んだ形をしている．これらのマスには，左端のスタートマスから右端のゴールマスへと順に 1 から 2019 までの番号がついている．

   現在このすごろくの上には，N 個の駒が置かれている．これらの駒には，スタートに近い順に 1 から N までの番号がついている．駒 i (1≦i≦N) は，マス Xi に置かれている．すべての駒は異なるマスに置かれている．

   JOI 君はこれから M 回の操作を行う．j 回目 (1≦j≦M) の操作では，駒 Aj を 1 マス先へ進める．ただし，移動元のマスがゴールマスであった場合，もしくは移動先のマスに別の駒が置かれている場合，駒 Aj は進まず，位置は変わらない．

   すべての操作が終了した時点で，各駒が置かれているマスを求めよ．*/
#include <iostream>
using namespace std;

int main(int argc, char const *argv[]) {

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

        int M;
        cin >> M;

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

                if(X[A]==2019 || X[A+1]==X[A]+1)
                        continue;

                X[A]++;
        }

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

        return 0;
}

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

int main(){
    int n;
    cin >> n;
    int x[n];
    bool used[2100] = {};
    for(int i = 0; i < n; i++){
        cin >> x[i];
        used[x[i]] = true;
    }
    int m;
    cin >> m;
    while(m-- > 0){
        int k;
        cin >> k;
        k--;
        if(x[k] != 2019 && !used[x[k]+1]){
            used[x[k]++] = false;
            used[x[k]] = true;
        }
    }
    for(int i = 0; i < n; i++)  cout << x[i] << endl;
    return 0;
}

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

int main() {

    int kazu;
    int* koma;

    cin >> kazu;

    koma = new int[kazu];

    for (int i = 0; i < kazu; i++) {
        cin >> koma[i];
    }

    int ugoku;
    cin >> ugoku;

    int* ukoma = new int[ugoku];

    for (int i = 0; i < ugoku; i++) {
        cin >> ukoma[i];
        int hairetu = ukoma[i] - 1;
        if (hairetu != (kazu - 1)) {
            if (koma[hairetu + 1] != (koma[hairetu] + 1)) {
                koma[hairetu]++;
            }

        }
        else {
            koma[hairetu]++;
        }
        if (koma[hairetu] > 2019)koma[hairetu] = 2019;
    }

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


    delete[] koma;
    delete[] ukoma;
    return 0;
}