Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	index := make(map[string]string)
	keys := []string{}
	for stdin.Scan() {
		l := strings.Split(stdin.Text(), " ")
		if l[0] == "0" {
			break
		}
		if index[l[0]] == "" {
			keys = append(keys, l[0])
		}
		index[l[0]] += l[1] + " "
	}
	sort.Strings(keys)
	for _, k := range keys {
		fmt.Println(k)
		p := strings.Split(strings.TrimRight(index[k], " "), " ")
		pages := []int{}
		for _, v := range p {
			i, _ := strconv.Atoi(v)
			pages = append(pages, i)
		}
		sort.Ints(pages)
		for i, v := range pages {
			if i > 0 {
				fmt.Printf(" ")
			}
			fmt.Printf("%d", v)
		}
		fmt.Println()
	}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    map<string, vector<int> > m;
    string s; int p;
    while(cin >> s >> p){
        m[s].push_back(p);
    }
    map<string, vector<int> >::iterator it = m.begin();
    while( it != m.end() ){
        cout << (*it).first << endl;
        sort(all((*it).second));
        for(int i=0; i < (*it).second.size(); i++){
            if(i != 0) cout << " " << (*it).second[i];
            else cout << (*it).second[i];
        }
        cout << endl;
        ++it;
    }
}

C++: #include <cstdio>
#include <utility>
#include <map>
#include <set>
#include <string>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
bool scan(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
vo(const string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo


int main() {
	map<string, set<int>> m;
	for (string s; scan(s);)
		m[s].insert(in());

	for (auto i: m) {
		out(i.first, '\n');
		int c = 0;
		for (int n: i.second)
			out(c++ ? " ": "", n);
		out('\n');
	}
}

C++: #include <bits/stdc++.h>
using namespace std;pair<string,int> a[100];int main(){int t=0,g,i;string f,b;while(cin>>a[t].first>>a[t].second)t++;sort(a,a+t);b=a[0].first;cout<<b<<endl<<a[0].second;for(i=1;i<t;i++){bool n=0;f=a[i].first,g=a[i].second;if(i)if(f==b)n=1;if(n)cout<<" "<<g;else cout<<endl<<f<<endl<<g;b=f;}cout<<endl;return 0;}

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

class cob{
public:
	string str;
	vector<int> num;
	cob(string str):str(str){}

	bool operator < (const cob &ano){
		if(str != ano.str)
			return str < ano.str;
		else
			return false;
	}

	void S()
	{
		sort(num.begin(), num.end());
	}
};



int main(void)
{
	string instr;
	int num;
	vector<cob> index;

	bool f = false;
	while(cin >> instr >> num, !cin.eof()){
		for(int i = 0; i < index.size(); i++){
			if(index[i].str == instr){			
				index[i].num.push_back(num);
				f = true;
				break;
			}
		}
		if(!f){
			index.push_back(cob(instr));
			index.back().num.push_back(num);
		}
	}

	sort(index.begin(), index.end() );
	for(int i = 0; i < index.size(); i++){
		index[i].S();

		cout << index[i].str << endl;
		cout << index[i].num[0];
		for(int j = 1; j < index[i].num.size(); j++)
			cout << ' ' << index[i].num[j];
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	map<string, vector<int>>l;
	vector<string>str;
	while (!cin.eof()){
		string s;
		int n;
		cin >> s >> n;
		l[s].push_back(n);
		sort(l[s].begin(), l[s].end());
		if (find(str.begin(), str.end(), s) == str.end()) {
			str.push_back(s);
		}
	}
	sort(str.begin(), str.end());
	for (string i : str){
		cout << i << endl;
		for (int j = 0; j < l[i].size(); j++){
			cout << l[i][j];
			if (j != l[i].size() - 1)cout << ' ';
		}
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
using namespace std;
priority_queue<int, vector<int>, greater<int> > pq[101];

int main()  {

    int t, idx = 0;
    char str[31];
    map<string, int> m;
    string stra;

    while(scanf("%s %d", str, &t) != EOF) {
        stra = str;
        if (stra == ".") break;
        if (m.find(stra) == m.end()) {
            m.insert({stra, idx});
            pq[idx++].push(t);
        } else {
            pq[m[stra]].push(t);
        }
    }

    for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
        cout << it->first << endl;
        idx = 0;
        while (!pq[it->second].empty()) {
            if (idx) cout << " ";
            cout << pq[it->second].top(); pq[it->second].pop();
            idx++;
        }
        cout << endl;
    }


    return 0;
}

C++: #include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;

map<string,set<int>> p;

int main()
{
    string str;
    int t;
    while (cin >> str >> t) p[str].insert(t);
    for (auto it = p.begin(); it != p.end(); it++) {
        auto s = it->second.bigen();
        cout << it->first  << endl << *s;
        for (++s; s != it->second.end(); s++)
            cout << " " << *s;
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	map< string, vector<int> > table;
	string word;
	int n;
	while(cin>>word>>n){
		table[word].push_back(n);
	}
	for(map<string, vector<int> >::iterator it = table.begin();it!=table.end();++it){
		cout<<it->first<<endl;
		vector<int> tmp = it->second;
		sort(tmp.begin(),tmp.end());
		int x = 0;
		for(;x<tmp.size()-1;++x){
			cout<<tmp[x]<<" ";
		}
		cout<<tmp[x]<<endl;
	
	}
	return 0;		
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef priority_queue<int,vector<int>,greater<int> > Q;

int p;
string s;
map<string,Q> m;

int main(){
	while(cin>>s>>p){
		m[s].push(p);
	}
	map<string,Q>::iterator ite;
	for(ite=m.begin();ite!=m.end();ite++){
		cout<<ite->first<<endl;
		Q q=ite->second;
		bool f=0;
		while(!q.empty()){
			p=q.top();q.pop();
			if(f)cout<<" ";
			cout<<p;
			f=1;
		}
		cout<<endl;
	}
}