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<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,M,a,b;

int main(){
    cin>>N>>M;
    set<int> s,co;
    rep(i,N){
        cin>>a;
        s.insert(a);
    }
    rep(i,M){
        cin>>b;
        auto it = s.end();
        if(it != s.find(b))co.insert(b);
        s.insert(b);
    }
    cout<<co.size()<<" "<<s.size()<<endl;
    for(int tmp:co)out(tmp);
    for(int tmp:s)out(tmp);
    
    
}

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

int N, K;
vector<int> u, v;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[m];
    map<int, int> mp;
    map<int, int> mpp;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
        mpp[a[i]]++;
        u.push_back(a[i]);
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
        if (mp[b[i]] == 1)
            v.push_back(b[i]);
        if (mpp[b[i]] == 0)
            u.push_back(b[i]);
    }
    cout << v.size() << " " << u.size() << endl;
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    for (int i = 0; i < u.size(); i++)
    {
        cout << u[i] << endl;
    }
    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;

    vector<int> And,Or;

    map<int,int> mp;

    for(int i=0;i<N+M;i++){
        int p; cin >> p;
        mp[p]++;
    }

    for(auto p : mp){
        if(p.second > 1) And.emplace_back(p.first);
        Or.emplace_back(p.first);
    }

    cout << And.size() << " " << Or.size() << endl;
    for(size_t i=0;i<And.size();i++) cout << And[i] << endl;
    for(size_t i=0;i<Or.size();i++) cout << Or[i] << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

#define N_MAX 2000000
#define M_MAX 2000000

using namespace std;
using ll = long long;

int n, m;

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

    std::cin >> n >> m;
    set<int> or_s;
    vector<int> and_v;
    REP(i, n) {
        int a;
        std::cin >> a;
        or_s.insert(a);
    }
    REP(i, m) {
        int b;
        std::cin >> b;
        auto itr = or_s.find(b);
        if(itr != or_s.end()) {
            and_v.push_back(b);
        }
        or_s.insert(b);
    }

    std::cout << and_v.size()
              << " "
              << or_s.size() << std::endl;
    REP(i, and_v.size()) {
        std::cout << and_v[i] << std::endl;
    }
    for(auto s : or_s) {
        std::cout << s << std::endl;
    }

    return 0;
}