Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dictionary := make(map[string][]int)

	for {
		var word string
		var page int
		fmt.Scanf("%s %d", &word, &page)

		if word == "" || page == 0 {
			break
		}

		pages := dictionary[word]
		pages = append(pages, page)
		dictionary[word] = pages
	}

	words := make([]string, 0)
	for i := range dictionary {
		words = append(words, i)
	}

	sort.Strings(words)

	for _, v := range words {
		sort.Ints(dictionary[v])
		fmt.Println(v)
		for i, page := range dictionary[v] {
			if i == len(dictionary[v])-1 {
				fmt.Printf("%d\n", page)
			} else {
				fmt.Printf("%d ", page)
			}
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string name[111], a;
	int na, kazu[111], date[111][111], b;
	for (int i = 1; i <= 101; i++) {
		kazu[i] = 0;
	}
	na = 0;
	while (cin >> a >> b) {
		for (int i = 1; i <= na; i++) {
			if (name[i] == a) {
				kazu[i] = kazu[i] + 1;
				date[i][kazu[i]] = b;
				goto a;
			}
		}
		na = na + 1;
		name[na] = a;
		kazu[na] = 1;
		date[na][kazu[na]] = b;
	a:;
	}
	string aa;
	int bb,min,mi;
	for (int i = 1; i <= na; i++) {
		aa = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz";
		for (int z = 1; z <= na; z++) {
			if (aa >= name[z]) {
				aa = name[z];
				bb = z;
			}
		}
		cout << aa << endl;
		name[bb] = "zzzzzzzzzzzzzzzzzzzzzzzz";
		for (int z = 1; z <= kazu[bb]; z++) {
			min = 9999;
			for (int m = 1; m <= kazu[bb]; m++) {
				if (date[bb][m] <= min) {
					min = date[bb][m];
					mi = m;
				}
			}
			cout << min << " ";
			date[bb][mi] = 9999;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int main(){

  /* map<string, int(doubleÅà½Åà¢¢)> M;
           1      2
          Y    l

1©çQðQÆÅ«éæ¤É·éB
string s;
s = "abcd";

M[s] = 3;
cout << M[s] < endl;
oÍ
R
  */

  string s[1000];
  int n;
  int i =0;
    
  map<string, int> M;
  
  while(cin >> s[i] >> n){

    M[s[i]] = n;
    // cout << "M[s[i]] =="<< M[s[i]] << endl;
    i++;
  }

  sort(s,s+i);

    for(int j = 0; j < i; j++){
      if(j != 0 && s[j] == s[j-1]){
	cout << " "<< M[s[j]];
      }else if(j != 0){
	cout << endl << s[j] << endl <<M[s[j]];
      }else{
	cout <<s[j]<< endl << M[s[j]];
      }
    }

    cout << endl;


    return 0;

}

C++: #include<iostream>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
	map < string, vector<int> > index;

	string sbuf;
	int ibuf;

	while (cin>>sbuf>>ibuf)
	{
		index[sbuf].push_back(ibuf);
	}

	for (auto &elem : index)
	{
		sort(elem.second.begin(), elem.second.end());
		cout << elem.first << endl;
		for (auto vecElem : elem.second)
		{
			cout << vecElem;
			if (vecElem != *(elem.second.end() - 1))
			{
				cout<<" ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <map>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string S[100], T[100]; int val, cnt, size_;
map<string, vector<int> > M;
int main() {
	while(cin >> S[cnt++]) {
		scanf("%d", &val);
		M[S[cnt - 1]].push_back(val);
	}
	sort(S, S + cnt);
	T[size_++] = S[0];
	for(int i = 1; i < cnt; i++) {
		if(S[i - 1] != S[i]) {
			T[size_++] = S[i];
		}
	}
	for(int i = 1; i < size_; i++) {
		printf("%s\n", T[i].c_str());
		sort(M[T[i]].begin(), M[T[i]].end());
		for(int j = 0; j < M[T[i]].size(); j++) {
			if(j) printf(" ");
			printf("%d", M[T[i]][j]);
		}
		printf("\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

#define MAX 1000

typedef pair<string, vector<int> > pp;

int main()
{
    string s;
    int n;
    vector<pp> ind;
    vector<int> emp;

    while(cin >> s >> n)
    {
        bool found = false;
        REP(ind.size() )if(ind[i].first == s){ ind[i].second.push_back(n); found = true; break; }
        if(found)continue;

        ind.push_back(pp(s,emp));
        ind[ind.size() - 1].second.push_back(n);
    }
    sort(ind.begin(), ind.end());


    REP(ind.size())
    {
        sort(ind[i].second.begin(), ind[i].second.end());
        cout << ind[i].first << endl;
        rep(j, ind[i].second.size())
        {
            cout << ind[i].second[j] ;
            if(j == ind[i].second.size() - 1) break;
            cout << " " ;
        }

        cout << endl ;
    }
    return 0;
}

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

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

using namespace std;

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

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int main()
{
  int n;
  string s;
  map<string,vector<int> > book;
  map<string,vector<int> >::iterator it;
    while(cin>>s>>n)
    {
      book[s].push_back(n);
    }
    for(it=book.begin();it!=book.end();it++)
      {
	sort(it->second.begin(),it->second.end());
	cout<<it->first<<endl;
	for(vector<int>::iterator it2=it->second.begin();it2!=it->second.end();)
	  {
	    	cout<<*it2;
		it2++;
		if(it2!=it->second.end())
		  cout<<" ";
		else
		  cout<<endl;
	  }
	//	cout<<*it<<endl;
      }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int dp[101][101];
int num[101][101];
bool comp(string a,string b){
	for(int i=0;i<min(a.size(),b.size());i++){
		if(a[i]-'a'<b[i]-'a'){
			return true;
		}else if(b[i]-'a'<a[i]-'a'){
			return false;
		}
	}
	return a.size()<b.size();
}
map<string,vector<int> >ma;
int main(){
	int cou=0;
	string str;
	int n;
	while( cin >> str !='\0'){
		scanf("%d",&n);
		ma[str].push_back(n);
	}
	map<string,vector<int> >::iterator ite;
	for(ite=ma.begin();ite!=ma.end();++ite){
		cout << ite->first << endl;
		vector<int>yu=ite->second;
		sort(yu.begin(),yu.end());
		cout << yu[0];
		for(int i=1;i<yu.size();i++){
			cout <<" " << yu[i];
		}
		cout << endl;
	}
}