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, m;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    cin >> m;
    int a[m];
    for(int i = 0; i < m; i++) cin >> a[i];
    
    
    
    for(int i = 0; i < m; i++){
        if(a[i] == n && x[a[i]-1] < 2019) x[a[i]-1]++;
        else{
            if(x[a[i]-1]+1 != x[a[i]] && x[a[i]-1] < 2019) x[a[i]-1]++; 
        }
    }
    
    for(int i = 0; i < n; i++) cout << x[i] << endl;
    
    return 0;
}

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;
				tkn[move-1]++;
			}
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 2020; j++){
			if(board[j] == i){
				cout << j << "\n";
				break;
			}
		}
	}
}

C++: /*
17D8101031C 杉山　祥吾 ID:keisei334 C++
*/

#include <iostream>

using namespace std;

#define N 100
#define M 100

int main(void){
  int X[N+1],A[M+1],n,m;

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

  cin>>m;
  for(int i=1;i<=m;i++){
    cin>>A[i];
  }

  for(int i=1;i<=m;i++){
    if(X[A[i]]!=2019 && X[A[i]+1]-X[A[i]]!=1){
      X[A[i]]++;
    }
  }

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

/*実行結果
3
2 3 6
2
1 3
2
3
7

2
1 2016
4
2 2 2 2
1
2019

4
1001 1002 1003 1004
7
1 2 3 4 3 2 1
1002
1003
1004
1005
*/

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

using namespace std;
int main(){
int n,m,cnt;
int x[2021];
int a[101];
cin >> n;
for(int i=1;i<=n;i++){
cin >> x[i];
}
cin >> m;
for(int i=1;i<=m;i++){
cin >> a[i];
}
for(int i=1;i<=m;i++){
	cnt=0;
	if(x[a[i]]==2019) continue;
	for(int j=1;j<=n;j++){
		if(x[a[i]]+1==x[j]){cnt++;}
	}	
	if(cnt==0) x[a[i]]++;
}
for(int i=1;i<=n;i++){
	cout << x[i] << endl;
}
return 0;
}

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

bool is_exist[2019] = {0};

int main()
{
    int piece_count = 0;
    std::cin >> piece_count;
    
    std::vector<int> pieces;
    pieces.reserve(piece_count);
    
    for(int i = 0 ; i < piece_count; ++i)
    {
        int value = 0;
        std::cin >> value;
        pieces.emplace_back(value - 1);
    }
    
    for(int piece : pieces)
    {
        is_exist[piece] = true;
    }
    
    int command_count = 0;
    std::cin >> command_count;
    
    std::vector<int> commands;
    commands.reserve(command_count);
    
    for(int i = 0; i < command_count; ++i)
    {
        int value = 0;
        std::cin >> value;
        commands.emplace_back(value - 1);
    }
    
    for(int command : commands)
    {
        if(pieces[command] + 1 < 2019 && is_exist[pieces[command] + 1] == false)
        {
            is_exist[pieces[command]] = false;
            is_exist[pieces[command] + 1] = true;
            ++(pieces[command]);
        }
    }
    
    for(int piece : pieces)
    {
        std::cout << piece + 1 << std::endl;
    }
    
    return 0;
}

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

bool gridfilled(int x[], int k, int n)
{
	for (int i = 0; i < n; i++) {
		if (x[i] == k) {
			return true;
		}
	}
	return false;
}

int main()
{
	int m, n;
	int x[MAX] = { 0 };
	int a[MAX] = { 0 };

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	for (int j = 0; j < m; j++) {
		if ((gridfilled(x, x[a[j] - 1] + 1, n)) || (x[a[j] - 1] + 1 == 2020)) {
			;
		}
		else
		{
			x[a[j] - 1]++;
		}
	}

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

	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
using namespace std;


int main()
{
	int N, M;
	cin >> N;//駒数

	vector<int> position(N);//駒の位置
	bool isHere[2020] = { false };//対象のマスに駒が存在しているか

	//駒の位置を入力
	for (int i = 0; i < N; i++) {
		cin >> position[i];

		//駒が存在してることのフラグ
		isHere[position[i]] = true;
	}

	cin >> M;//駒の前進回数

	//移動命令毎に処理
	for (int i = 0; i < M; i++) {
		int target;
		cin >> target;//移動対象の駒
		target -= 1;//配列の要素番号にする

		//移動元のマスがゴールでない場合 && 次のマスに駒が存在していない場合
		if (position[target] < 2019 && !isHere[position[target] + 1]) {
			isHere[position[target]] = false;//駒の存在フラグを消す
			position[target] += 1;//マス移動
			isHere[position[target]] = true;//駒の存在フラグを立てる
		}
	}

	for (int i = 0; i < position.size(); i++) {
		cout << position[i] << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi x(n);
  REP(i,n) cin >> x[i];
  int m;
  cin >> m;
  vi mp(2020,0);
  REP(i,n){
    mp[x[i]] = 1;
  }
  REP(i,m){
    int a;
    cin >> a;
    a--;
    if(x[a]+1<2020&&!mp[x[a]+1]){
      x[a]++;
      mp[x[a]] = 1;
      mp[x[a]-1] = 0;
    }
  }
  for(auto i:x) cout << i << endl;
}

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

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

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

int main()
{
	int n, m, x[100], key, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}

	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &key);
		if (x[key-1]+1 != x[key] && x[key-1] != 2019) x[key-1] = x[key-1] + 1;
	}

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