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<cstdio>
#include<algorithm>
#include<functional>
#include<iostream>
#include<string>
#include<vector>
#define F1 first.first
#define F2 first.second
#define F3 second
using namespace std;
typedef pair<string,int> pp;
int main(void)
{
	int i,j,k,num[1001],n,cnt=0;
	string c;
	vector<pp> s;
	while(cin>>c>>n) {
		s.push_back(pp(c,n));
		cnt++;
	}
	sort(s.begin(),s.end());
	for(i=0;i<cnt;i++) {
		if(!i) cout<<s[i].first<<endl<<s[i].second;
		if(i>0) {
			if(s[i-1].first==s[i].first) cout<<" "<<s[i].second;
			else cout<<endl<<s[i].first<<endl<<s[i].second;
		}
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int a;
  map<string,vector<int>> m;
  while(cin >> s >> a){
    m[s].pb(a);
  }
  for(auto it = m.begin(); it != m.end(); ++ it){
    sort(all((*it).second));
    cout << it->fi<<endl;
    rep(i,(*it).second.size()-1){
      cout << it->second[i] << " ";
    }
    cout << it->second[it->se.size()-1] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> d[101];
int ptop[101];
int p[101][101];
int main(){
	string a;
	int q,top;
	top=0;
	while(cin>>a>>q){
		bool news=true;
		for(int i=0;i<top;i++){
			if(d[i].first==a){
				p[i][ptop[i]]=q;
				ptop[i]++;
				news=false;
			}
		}
		if(news){
			d[top].first=a;
			d[top].second=top;
			ptop[top]=1;
			p[top][0]=q;
			top++;
		}
	}
	sort(d,d+top);
	for(int i=0;i<top;i++)sort(p[i],p[i]+ptop[i]);
	for(int i=0;i<top;i++){
		cout<<d[i].first<<endl;
		cout<<p[d[i].second][0];
		for(int j=1;j<ptop[d[i].second];j++){
			cout<<" "<<p[d[i].second][j];
		}
		cout<<endl;
	}
	getchar();
	getchar();
	return 0;
}

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

typedef map<string,vector<int> > P;

int main()
{
    P p;
    string str;
    int t = 0;
    while (cin >> str >> t)
        p[str].push_back(t);
    for (auto it = p.begin(); it != p.end(); it++) {
        sort(it->second.begin(), it->second.end());
        cout << it->first  << endl << it->second[0];
        for (int j = 1; j < it->second.size(); j++)
            cout << " " << it->second[j];
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  string s;
  int p;
  map<string,vector<int> > m;
  while(cin>>s>>p,!cin.eof())m[s].push_back(p);
  map<string,vector<int> >::iterator m_it = m.begin();
  while(m_it!=m.end()){
    cout<<(*m_it).first<<endl;
    vector<int> v = (*m_it).second;
    sort(v.begin(),v.end());
    vector<int>::iterator v_it = v.begin();
    while(v_it!=v.end())cout<<*v_it,v_it++,v_it==v.end()?cout<<endl:cout<<" ";
    m_it++;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	map<string,priority_queue<int,vector<int>,greater<int> > > latte;
	string S;
	int P;
	while(cin>>S>>P){
		latte[S].push(P);
	}
	map<string,priority_queue<int,vector<int>,greater<int> > >::iterator itr = latte.begin();
	while(itr!=latte.end()){
		cout<<itr->first<<endl;
		printf("%d",itr->second.top()); itr->second.pop();
		while(!itr->second.empty()){
			printf(" %d",itr->second.top()); itr->second.pop();
		}puts("");
		itr++;
	}
}

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

    map<string,vector<int> > M;
    string str;
    while(cin>>str){
        int p;
        cin>>p;
        M[str].push_back(p);
    }
    map<string,vector<int> >::iterator it = M.begin();
    for(;it != M.end();it++){
        sort((*it).second.begin(),(*it).second.end());
        cout<<(*it).first<<endl;
        cout<<(*it).second[0];
        for(int i = 1;i < (*it).second.size();i++){
            cout<<" "<<(*it).second[i];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<string.h>

#include<stdio.h>

int main(){
  typedef struct {
    char s[31];
    int a;
  } book;
  
  book b[100];
  int i=0;
  while(scanf("%s %d", b[i].s, &b[i].a) != EOF){
    i++;
  }
  
  int j,k;
  for(j=0;j<i-1;j++){
    for(k=0;k<i-1;k++){
      if(strcmp(b[k].s, b[k+1].s)>0)
	{int p;char q[31];
	  p=b[k].a;b[k].a=b[k+1].a;b[k+1].a=p;
	  strcpy(q,b[k].s);strcpy(b[k].s,b[k+1].s);strcpy(b[k+1].s,q);
	}
    }
  }


  for(j=0;j<i-1;j++){
    for(k=0;k<i-1;k++){
      if(strcmp(b[k].s, b[k+1].s)==0){
	if(b[k].a > b[k+1].a){
	  int p;
	  p=b[k].a;b[k].a=b[k+1].a;b[k+1].a=p;
	}
      }
    }
  }

  printf("%s \n%d", b[0].s, b[0].a);
  for(j=1;j<i;j++){
    if(strcmp(b[j].s, b[j-1].s) != 0){
      printf("\n");
      printf("%s \n%d ", b[j].s, b[j].a);
    }
    else{
      printf("%d ", b[j].a);
    }
  }
  printf("\n");
  /*
  for(j=0;j<i;j++){
      printf("%s %d\n", b[j].s, b[j].a);
    }
  */
  return 0;
}