Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	mm := make(map[int]bool)
	am := make(map[int]bool)
	om := make(map[int]bool)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		mm[a] = true
		om[a] = true
	}
	for i := 0; i < m; i++ {
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		if bl, ok := mm[b]; ok && bl {
			am[b] = true
		}
		om[b] = true
	}
	fmt.Printf("%d %d\n", len(am), len(om))
	as := make([]int, 0)
	for k := range am {
		as = append(as, k)
	}
	sort.Sort(sort.IntSlice(as))
	os := make([]int, 0)
	for k := range om {
		os = append(os, k)
	}
	sort.Sort(sort.IntSlice(os))
	for i := range as {
		fmt.Println(as[i])
	}
	for i := range os {
		fmt.Println(os[i])
	}
}

C++: #include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(set<T> s) {
	auto itr = s.begin();
	if (itr == s.end())return;
	cout << *(itr++);
	while (itr != s.end()) {
		cout << "\n" << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	set<int> sta;
	set<int> stb;
	set<int> stor;
	set<int> stand;
	vector<int> vand;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		sta.insert(a);
		stor.insert(a);
	}
	for (int i = 0; i < m; ++i) {
		int b;
		cin >> b;
		stb.insert(b);
		stor.insert(b);
	}
	for (auto it = stor.begin(); it != stor.end();++it) {
		if (sta.find(*it) != sta.end() && stb.find(*it) != stb.end()) {
			stand.insert(*it);
		}
	}
	cout << stand.size() << " " << stor.size() << endl;
	say(stand);
	say(stor);
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int64 n, m;
	vector<int64> r1, r2;
	cin >> n >> m;
	map<int64, int64> mp;
	REP(i, n) {
		int64 a;
		cin >> a;
		mp[a]++;
	}
	REP(i, m) {
		int64 a;
		cin >> a;
		if (mp[a]) r1.push_back(a);
	}
	for (auto x : mp) {
		r2.push_back(x.fs);
	}
	cout << r1.size() << " " << r2.size() << endl;
	REP(i, r1.size()) cout << r1[i] << endl;
	REP(i, r2.size()) cout << r2[i] << endl;
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m;
    cin >> n >> m;
    set<int> a, b;
    rep(i, n) {
        int x;
        cin >> x;
        a.insert(x);
    }
    rep(i, m) {
        int x;
        cin >> x;
        b.insert(x);
    }
    set<int> x, y;
    for(auto&& i : a) x.insert(i);
    for(auto&& i : b) x.insert(i);
    for(auto&& i : a) if(b.count(i)) y.insert(i);
    cout << y.size() << " " << x.size() << endl;
    for(auto&& i : y) cout << i << endl;
    for(auto&& i : x) cout << i << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n, m, i, j, n_and, n_xor;
    cin >> n >> m;
    int a[n], b[m], logand[n > m ? n : m], logxor[n + m];
    for(int k = 0; k < n; k++) cin >> a[k];
    for(int k = 0; k < m; k++) cin >> b[k];

    i = j = n_and = n_xor = 0;
    while(i < n && j < m){
        if(a[i] == b[j]){
            logand[n_and++] = a[i++];
            j++;
        } else if(a[i] > b[j]){
            logxor[n_xor++] = b[j++];
        } else {
            logxor[n_xor++] = a[i++];
        }
    }
    for(int k = i; k < n; k++) logxor[n_xor++] = a[k];
    for(int k = j; k < m; k++) logxor[n_xor++] = b[k];

    cout << n_and << " " << n_and + n_xor << endl;
    for(int k = 0; k < n_and; k++) cout << logand[k] << endl;
    i = j = 0;
    while(i < n_and && j < n_xor){
        if(logand[i] < logxor[j]) cout << logand[i++] << endl;
        else cout << logxor[j++] << endl;
    }
    for(int k = i; k < n_and; k++) cout << logand[k] << endl;
    for(int k = j; k < n_xor; k++) cout << logxor[k] << endl;

    return 0;   
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    int a[n];
    int b[m];
    vector<int> dup,all;
    
    for(int i=0;i<n;i++){
        cin >> a[i];     
    }
    for(int j=0;j<m;j++){
        cin >> b[j];
    }

    int ap=0;
    int bp=0;
    int i=0;
    int a_s=0;
    int b_s=0;
    while(ap!=n or bp!=m){
        i++;
        
        if(a[ap]==i and b[bp]==i) a_s++;
        if(a[ap]==i or b[bp]==i) b_s++;

        while(a[ap]<=i and ap!=n) ap++;
        while(b[bp]<=i and bp!=m) bp++;
    }
    
    cout << a_s <<" "<< b_s << endl;
    
    while(ap!=n or bp!=m){
        i++;
        
        if(a[ap]==i and b[bp]==i) cout<<i<<endl;

        while(a[ap]<=i and ap!=n) ap++;
        while(b[bp]<=i and bp!=m) bp++;
    }
    
    while(ap!=n or bp!=m){
        i++;
        
        if(a[ap]==i or b[bp]==i) cout<<i<<endl;

        while(a[ap]<=i and ap!=n) ap++;
        while(b[bp]<=i and bp!=m) bp++;
    }
    
    return 0;
}