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 <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    set<int> a, o, s, t;
    
    rep(i, n){
        int l;
        cin >> l;
        t.insert(l);
        o.insert(l);
    }
    
    rep(i, m){
        int l;
        cin >> l;
        s.insert(l);
        o.insert(l);
    }
    
    repi(i, s){
        if(t.find(*i) != t.end()){
            a.insert(*i);
        }
    }
    cout << a.size() << " " << o.size() << endl;
    repi(i, a){
        cout << *i << endl;
    }
    repi(i, o){
        cout << *i << endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    REP (i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    REP (i, m) {
        int b;
        cin >> b;
        mp[b]++;
    }
    vector<int> v, u;
    for (auto p : mp) {
        if (p.second == 2) v.push_back(p.first);
        u.push_back(p.first);
    }
    cout << v.size() << " " << u.size() << endl;
    for (int vv : v) cout << vv << endl;
    for (int uu : u) cout << uu << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

C++: #include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    set<int> a, o, s, t;
    
    rep(i, n){
        int l;
        cin >> l;
        t.insert(l);
        o.insert(l);
    }
    
    rep(i, m){
        int l;
        cin >> l;
        s.insert(l);
        o.insert(l);
    }
    
    repi(i, s){
        if(t.find(*i) != t.end()){
            a.insert(*i);
        }
    }
    cout << a.size() << " " << o.size() << endl;
    repi(i, a){
        cout << *i << endl;
    }
    repi(i, o){
        cout << *i << endl;
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  map<ll,ll>MP;
  ll an=0,o=0;
  set<ll> anv,ov;
  for(int i=0;i<n;i++){ll a;cin>>a;MP[a]++;}
  for(int j=0;j<m;j++){ll a;cin>>a;MP[a]++;}
  for(auto a:MP){
    if(a.S==1){o++;ov.insert(a.F);}
    else {o++;an++;ov.insert(a.F);anv.insert(a.F);}
  }
  cout<<an<<" "<<o<<endl;
  for(auto a:anv)cout<<a<<endl;
  for(auto a:ov)cout<<a<<endl;
  return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    set<int> OR;
    set<int> AND;
    set<int> a;
    set<int> b;
    for(int i = 1; i <= n; i++) {
        int in;
        cin >> in;
        a.insert(in);
        OR.insert(in);
    }
    for(int i = 1; i <= m; i++) {
        int in;
        cin >> in;
        OR.insert(in);
        if(a.find(in) != a.end()) AND.insert(in);
    }
    cout << AND.size() << " " << OR.size() << endl;
    for(auto itr = AND.begin(); itr != AND.end(); itr++) {
        cout << *itr << endl;
    }
    for(auto itr = OR.begin(); itr != OR.end(); itr++) {
        cout << *itr << 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;
    while(ap!=n or bp!=m){
        i++;
        
        if(a[ap]==i and b[bp]==i) dup.push_back(i);
        if(a[ap]==i or b[bp]==i) all.push_back(i);

        while(a[ap]<=i and ap!=n) ap++;
        while(b[bp]<=i and bp!=m) bp++;
    }
    
    cout << dup.size() <<" "<< all.size()  << endl;
    
    for(auto itr = dup.begin(); itr != dup.end(); ++itr) {
        cout << *itr << endl;
    }
    for(auto itr = all.begin(); itr != all.end(); ++itr) {
        cout << *itr << endl;
    }

    return 0;
}

C++: //↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


long long a, b, k[200005], l[200005], mon;
queue<long long>ans;
set<long long>s;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
		s.insert(k[i]);
	}

	for (int i = 0; i < b; ++i) {
		cin >> l[i];
		s.insert(l[i]);
	}

	for (int i = 0; i < a; ++i) {
		while (mon < b&&l[mon] < k[i]) { ++mon; }
		if (mon == b) { break; }
		if (l[mon] == k[i]) {
			ans.push(k[i]);
			++mon;
		}
	}

	cout << ans.size() << " " << s.size() << endl;

	while (!ans.empty()) {
		cout << ans.front() << endl;
		ans.pop();
	}
	for (auto i : s) { cout << i << endl; }
}