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])
	}
}

Python: N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
AandB = sorted(A & B)
AorB = sorted(A | B)
print(len(AandB), len(AorB))
for x in AandB:
    print(x)
for x in AorB:
    print(x)

Python: n, m = map(int, input().split())
a = set(map(int, input().split()))
b = set(map(int, input().split()))

a_and_b = list(a & b)
a_or_b = list(a | b)

a_and_b.sort()
a_or_b.sort()

print(len(a_and_b), len(a_or_b))

for p in a_and_b:
    print(p)

for q in a_or_b:
    print(q)

Python: import sys
sys.setrecursionlimit(int(1e7))
from collections import deque
def inpl(): return list(map(int, input().split()))

input()
A = set(inpl())
B = set(inpl())
ands = sorted(A&B)
ors = sorted(A|B)

print(len(ands), len(ors))
if len(ands):
    print(*ands,sep="\n")
if len(ors):
    print(*ors, sep="\n")

Python: n,m = map(int,input().split())
a = set(map(int,input().split()))
b = set(map(int,input().split()))
i = sorted(a&b)
u = sorted(a|b)
print(len(i),len(u))
for x in i:
    print(x)
for x in u:
    print(x)

Python: #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
n,m = LI()
a = LI()
b = LI()
li = list(set(a)|set(b))
li2 = list(set(a)&set(b))
li.sort()
li2.sort()
print(len(li2),len(li))
for i in li2:
    print(i)
for i in li:
    print(i)
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Python: n,m=map(int,input().split())
a = list(map(int,input().split()))+[1000000001]
b = list(map(int,input().split()))+[1000000001]
andlis=[]
orlis=[]
cura=0
curb=0
for _ in range(n+m):
    if a[cura]>b[curb]:
        orlis.append(b[curb])
        curb+=1
    elif a[cura]==b[curb]:
        andlis.append(a[cura])
        cura+=1
    elif a[cura]<b[curb]:
        orlis.append(a[cura])
        cura+=1
print(len(andlis),len(orlis))
for i in andlis:
    print(i)
for i in orlis:
    print(i)

Python: n, m = [int(i) for i in input().split()]
a = {int(i) for i in input().split()}
b = {int(i) for i in input().split()}

A = a & b
B = a | b

print('{} {}'.format(len(A),len(B)))
for a in sorted(A):
    print(a)
for b in sorted(B):
    print(b)

Python: #!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


def main():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = set(A)
    B = list(map(int, input().split()))
    B = set(B)

    intersection = A & B
    union = A | B

    print(len(intersection), len(union))
    for i in sorted(list(intersection)):
        print(i)
    for u in sorted(list(union)):
        print(u)


if __name__ == '__main__':
    main()

Python: n,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

and_list = set(a) & set(b)
or_list = (set(a) ^ set(b)) ^ set(and_list)

print(len(and_list), len(or_list))
for i in sorted(and_list):
    print(i)
for i in sorted(or_list):
    print(i)

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    set<int> a, b;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        a.insert(x);
    }
    for(int i = 0; i < m; i++)
    {
        int x; cin >> x;
        b.insert(x);
    }
    set<int> s, t;
    for(auto x : a)
    {
        if(b.count(x)) s.insert(x);
        t.insert(x);
    }
    for(auto x : b) t.insert(x);
    cout << s.size() << " " << t.size() << endl;
    for(auto x : s) cout << x << endl;
    for(auto x : t) cout << x << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

signed main(){
  int n,q;cin>>n>>q;
  map<int,int> m;
  for(int i=0;i<n+q;i++){
    int a;cin>>a;m[a]++;
  }
  std::vector<int> ans;
  int c=0;
  for(auto p:m){
    if(p.second==2)ans.push_back(p.first);c++;
  }
  cout<<ans.size()<<" "<<c<<endl;
  for(int p:ans)cout<<p<<endl;
  for(auto p:m)cout<<p.first<<endl;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int arr[200001], arr2[200001], arr3[400001], reps[200001];

int main()
{
    int n, m, len, s1, s2, idx, idx2;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    for (int i = 0; i < m; i++) scanf("%d", &arr2[i]);

    len = n + m, s1 = s2 = idx = idx2 = 0;
    while (s1 < n && s2 < m) {
        if (arr[s1] == arr2[s2]) { reps[idx2++] = arr[s1]; arr3[idx++] = arr[s1++]; s2++; }
        else if (arr[s1] < arr2[s2]) arr3[idx++] = arr[s1++];
        else if (arr2[s2] < arr[s1]) arr3[idx++] = arr2[s2++];
    }
    if (s1 <= n - 1) while (s1 < n) arr3[idx++] = arr[s1++];
    if (s2 <= m - 1) while (s2 < m) arr3[idx++] = arr2[s2++];
    printf("%d %d\n", idx2, len - idx2);
    for (int i = 0; i < idx2; i++) printf("%d\n", reps[i]);
    for (int i = 0; i < idx; i++) printf("%d\n", arr3[i]);
     return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int n, m;
set<int>a, b, ors, ands;

int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int aa; cin >> aa; a.insert(aa);
		ors.insert(aa);
	}
	for (int j = 0; j < m; ++j) {
		int aa; cin >> aa; b.insert(aa);
		ors.insert(aa);
	}
	for (int elm : a) {
		if (b.count(elm)) {
			ands.insert(elm);
		}
	}
	int A = ands.size();
	int B = ors.size();
	cout << A << " " << B << endl;
	for (int elm : ands) {
		cout << elm;
		cout << endl;
	}
	for (int elm : ors) {
		cout << elm;
		cout << endl;
	}
	return 0;
}