Go: package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc}
}

func (sc *Scanner) NextInt() int {
	sc.sc.Scan()
	i, err := strconv.Atoi(sc.sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()

	mp := map[int]int{}
	for i := 0; i < n; i++ {
		mp[sc.NextInt()]++
	}
	for i := 0; i < m; i++ {
		mp[sc.NextInt()]++
	}
	var and, or []int
	for k, v := range mp {
		if v >= 1 {
			or = append(or, k)
		}
		if v == 2 {
			and = append(and, k)
		}
	}
	sort.Ints(and)
	sort.Ints(or)
	fmt.Println(len(and), len(or))
	for _, v := range and {
		fmt.Println(v)
	}
	for _, v := range or {
		fmt.Println(v)
	}
}

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;
}