Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	B := sc.nextIntSlice(M)
	And := []int{}
	Or := []int{}
	setOr := make(map[int]bool)
	for _, a := range A {
		setOr[a] = true
	}
	for _, b := range B {
		if setOr[b] {
			And = append(And, b)
		}
		setOr[b] = true
	}
	for k, _ := range setOr {
		Or = append(Or, k)
	}
	sort.Ints(Or)
	sort.Ints(And)

	fmt.Fprintln(wtr, len(And), len(Or))
	for _, v := range And {
		fmt.Fprintln(wtr, v)
	}
	for _, v := range Or {
		fmt.Fprintln(wtr, v)
	}
	wtr.Flush()
}

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