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 n, m, x[2000], a[101];

int main(){
    cin >> n;
    for (int i = 0; i < n; i++)cin >> x[i];
    cin >> m;
    for (int i = 0; i < m; i++){
        cin >> a[i];
        a[i]--;
        if (a[i] + 1 == n)x[a[i]] = min(x[a[i]] + 1, 2019);
        else if (x[a[i]] + 1 < x[a[i] + 1])x[a[i]]++;
    }
    for (int i = 0; i < n; i++)cout << x[i] << endl;
}

C++: // Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin>>X[i];
  int M; cin >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) cin>>A[i];
  
  for (int i = 0; i < M; i++) {
    int ok = 1;
    for (int j = 0; j < N; j++) {
      if (X[A[i]-1]+1 == X[j]) {
        ok = 0;
        break;
      }
    }
    if (ok && X[A[i]-1] != 2019) {
      X[A[i]-1]++;
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << X[i] << endl;
  }
}

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

int main(void){
  int N;
  cin >> N;
  int X[N];
  for(int i = 0; i < N; i++)
    cin >> X[i];
  int M;
  cin >> M;
  int A[M];
  for(int i = 0; i < M; i++)
    cin >> A[i];
  for(int i = 0; i < M; i++){
    if(X[A[i]-1]+1 == X[A[i]]){
      continue;
    }
    else{
      if(X[A[i]-1] == 2019){
	continue;
      }
      else{
	X[A[i]-1] += 1;
      }
    }
  }
  for(int i = 0; i < N; i++){
    cout << X[i] << "\n";
  }
  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n;
    cin >> n;

    map<int, int> mp;
    set<pair<int, int>> cont;
    vector<int> v(2019 + 1);
    for (int i = 1; i <= n; ++i) {
        int tp;
        cin >> tp;

        v[tp] = i;
        cont.insert({i, tp});
        mp[i] = tp;
    }

    int m;
    cin >> m;

    for (int i = 1; i <= m; i++) {
        int a;
        cin >> a;

        int tp = a;
        a = mp[a];
        if (a + 1 > 2019)
            continue;
        if (v[a + 1] != 0) {
            continue;
        } else {
            cont.erase({v[a], a});
            v[a + 1] = v[a];
            v[a] = 0;
            mp[tp] = a + 1;
            cont.insert({v[a + 1], a + 1});
        }
    }
    vector<int> ans;
    for (auto x: cont)
        ans.push_back(x.second);
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i != ans.back())
            cout << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main() {
    int n,m,d,i=0,j=0;
    cin>>n;
    int xnAll[n+1];
    xnAll[n]=2020;
    while(i<n){
        cin>>d;
        xnAll[i]=d;
        i++;
    }
    cin>>m;
    while(j<m){
        cin>>d;
        if(xnAll[d-1]+1!=xnAll[d]){
            xnAll[d-1]++;
        }
        j++;
    }
    for (int k = 0; k < n; k++)
    {
        cout << xnAll[k] << endl;
    }
    return 0;
}

C++: /* --- Sugoroku and Pieces ---
とにかく、足す.
足したときに、
i) (A_i) + 1 ≠ (A_i+1)であること.
ii) A_i ≠ 2019であること.
この２つの条件が満たされているかを確かめる.　←　この処理をmoveとする.

まとめると:
	N個の駒がある.　→　それぞれの駒の座標を格納できる「配列」Aを用意. 長さはNである.
	そのあと、M個のクエリが寄せられる.(たぶんクエリじゃない)　→　そのクエリ(?)を格納する「配列」Bを用意. 長さはMである.
	A.at(B.at(i) - 1)について、上記の処理moveを行う.
*/
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int>X(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> X.at(i);
	}
	int M; cin >> M;
	vector<int>A(M);
	for (int i = 0; i < M; i++) {
		cin >> A.at(i);
		if (X.at(A.at(i) - 1) + 1 != X.at(A.at(i)) && 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;
	}
}

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

int main()
{
    vector<int> P(2020, 0);

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

    int M;
    cin >> M;
    for (int j = 0; j < M; j++)
    {
        int A;
        cin >> A;
        int p = X[A];
        if (p < 2019 && P[p + 1] == 0)
        {
            P[p] = 0;
            P[p + 1] = A;
            X[A] += 1;
        }
    }

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

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,m,a;
    deque<int> deq;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>x;
        deq.emplace_back(x);
    }
    cin>>m;
    for (int j=0;j<m;j++) {
        cin>>a;
        if (deq[a-1]==2019) {
            continue;
        } else if (find(deq.begin(),deq.end(),deq[a-1]+1)!=deq.end()) {
            continue;
        } else {
            deq[a-1]++;
        }
    }
    for (int k=0;k<deq.size();k++) {
        cout<<deq[k]<<endl;
    }
}

C++: #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map> 
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  map<int,bool> pos;
  for(int i = 0;i < n;i++){
    cin >> x[i];
    pos[x[i]] = true;
  }

  int m;
  cin >> m;
  for(int i = 0;i < m;i++){
    int a;
    cin >> a;
    a--;
    if(x[a] == 2019)continue;

    if(pos[x[a]+1] == false){
      pos[x[a]] = false;
      pos[x[a]+1] = true;
      x[a]++;
    }
    else continue;
  }

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

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

int main() {
    int n, m, pos[100];
    bool masu[2020]{};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> pos[i];
        masu[pos[i]] = true;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        a--;
        if(pos[a] < 2019 && !masu[pos[a]+1]){
            masu[pos[a]] = false;
            masu[pos[a]+1] = true;
            pos[a]++;
        }
    }
    for(int i=0;i<n;i++){
        cout << pos[i] << endl;
    }
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> koma(N);
	for (int i = 0; i < N; i++)
		cin >> koma[i];
	int M;
	cin >> M;

	int num = 0;
	for(int i = 0; i < M; i++) {
		cin >> num;
		if(num<N) {
			if(koma[num-1] < 2019 && koma[num-1]+1 < koma[num])
				koma[num-1]++;
		} else {
			if(koma[num-1] < 2019)
				koma[num-1]++;
		}
	}

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

C++: // 2019/07/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	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;
}