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++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    V<int> x(n);
    cinf(n,x);
    int m;
    cin>>m;
    V<int> a(m);
    for(int i=0;i<m;i++){
        cin>>a[i];
        a[i]--;
    }
    V<bool> ok(2021,0);
    int t=0;
    for(int i=1;i<=2019;i++){
        if(i==x[t]){
            t++;
            ok[i]=1;
            if(t==n) break;
        }
    }
    for(int i=0;i<m;i++){
        if(x[a[i]]==2019||ok[x[a[i]]+1]) continue;
        ok[x[a[i]]]=0;
        x[a[i]]++;
        ok[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(){
    int n,x[100],a;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    cin>>a;
    while(cin>>a)
        if(x[a-1]!=2019&&x[a-1]+1!=x[a])
            x[a-1]++;
    for(int i=0;i<n;i++)
        cout<<x[i]<<endl;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 3005
const int INF = 1e9 + 7;

int used[ARRAY_MAX];

int main() {

	int n, m;
	cin >> n;
	auto a = make_v<int>(n + 10);
	fill_v(a, 0);

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

	cin >> m;

	for (int i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		if (used[a[tmp] + 1] == 0)
		{
			used[a[tmp] + 1]++;
			used[a[tmp]]--;
			a[tmp] = min(a[tmp]+1, 2019);
		}
	}

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

C++: #include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
//pi = 3.14159265358979323846

int main() {

    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n){
        cin >> vec.at(i);
    }
    int m;
    cin >> m;
    rep(i, m){
        int wa;
        cin >> wa;
        int vecsin = vec.at(wa - 1) + 1;
        if(find(vec.begin(), vec.end(), vecsin) == vec.end() && vecsin <= 2019) vec.at(wa - 1) += 1;
        
    }
    rep(i, n){
        cout << vec.at(i) << endl;
    }

}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, m;
	cin >> n;
	int x[2020];
	for (int i = 1; i <= n; i++){
		cin >> x[i];
	}
	cin >> m;
	int a[2020];
	for (int j = 1; j <= m; j++){
		cin >> a[j];
		x[a[j]] += 1;
		if (x[a[j]] == 2020)x[a[j]]--;
		if (x[a[j]] == x[a[j] + 1])x[a[j]]--;
	}
	for (int l = 1; l <= n; l++){
		cout << x[l] << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
signed main() {
	int n, m, x[123];
	cin >> n; for (int i = 0; i < n; i++)cin >> x[i]; cin >> m;
	x[n] = 2020;
	for (int i = 0; i < m; i++) {
		int p; cin >> p;
		p--;
		x[p] = min(x[p] + 1, x[p + 1] - 1);
	}
	for (int i = 0; i < n; i++)cout << x[i] << endl;
}

C++: /*
17D8101013F 森田　匡博
JOI0653.cpp 2019/10/31
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

int main() 
{
  int N;
  std::cin >> N;

  int X[N];
  for(int i = 0; i < N; i++) {
    std::cin >> X[i];
  }

  int M;
  std::cin >> M;

  int A[M];
  for(int i = 0; i < M; i++) {
    std::cin >> A[i];
  }

  for(int i = 0; i < M; i++) {
    X[A[i]-1]++;
    if(X[A[i]-1] == X[A[i]]) {
      X[A[i]-1]--;
    }
    if(X[A[i]-1] >= 2019) {
      X[A[i]-1] = 2019;
    }
  }

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

  return 0;
}

C++: #include<cstdio>
using namespace std;
int main()
{
	int n,x[101],m,a,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	scanf("%d",&m);
	for(i=1;i<=m;i++){
		scanf("%d",&a);
		if(x[a]+1!=x[a+1]&&x[a]!=2019){
			x[a]++;
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long int ll;
using namespace std;

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