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 <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <stdio.h>

using namespace std;

struct Page {
    string name;
    vector<int> p;

    Page(string _name, int v) {
        name = _name;
        p = vector<int>();
        p.push_back(v);
    }

    bool operator<(const Page& p) const {
        return name < p.name;
    }
};

vector<Page> v;

int main(void) {
    string style;

    v.clear();

    int i, j, page;
    while(cin >> style >> page) {
        int index = -1;
        for(i = 0; i < (int) v.size(); i++) {
            if(v[i].name == style) {
                index = i;
                v[i].p.push_back(page);
                break;
            }
        }
        if(index == -1) {
            v.push_back(Page(style, page));
        }
    }
    sort(v.begin(), v.end());

    for(i = 0; i < (int) v.size(); i++) {
        cout << v[i].name << endl;
        sort(v[i].p.begin(), v[i].p.end());
        for(j = 0; j < (int) v[i].p.size() - 1; j++) {
            cout << v[i].p[j] << " ";
        }
        cout << v[i].p[j] << endl;
    }
    return 0;
}

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

int main(){

  int n, m, num, w[100], len;
  string str, word[100];
  vector<int> vc[100];

  num = 0;
  while(cin >> str >> n){
    for(int i=0; i<=num; i++){
      if(i == num){
        word[i] = str;
        vc[i].push_back(n);
        num++;
        break;
      }
      else if(word[i] == str){
        vc[i].push_back(n);
        break;
      }
    }
  }

  fill(w, w+100, 0);
  for(int i=0; i<num; i++){
    for(int j=0; j<num; j++){
      if(w[j] == 0){
        str = word[j];
        break;
      }
    }

    for(int j=0; j<num; j++){
      if(w[j] == 0 && word[j].compare(str) <= 0){
        str = word[j];
        m = j;
      }
    }

    len = vc[m].size();
    sort(&vc[m][0], &vc[m][0+len]);
    cout << word[m] << endl << vc[m][0];
    for(int j=1; j<len; j++){
      cout << " " << vc[m][j];
    }
    cout << endl;
    w[m] = 1;
  }

  return 0;

}

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

typedef pair<string,int> P;
typedef pair<int,string> P2;

int main() {
  string s;
  P2 a[101];
  int cnt=0;
  while(cin >> s) {
    int n;
    cin >> n;
    a[cnt]=P2(n,s);
    cnt++;
  }
  sort(a,a+cnt);
  P b[cnt];
  for(int i=0; i<cnt; i++) b[i]=P(a[i].second,a[i].first);
  sort(b,b+cnt);
  
  string name="";
  bool ck=false;
  for(int i=0; i<cnt; i++) {
    if(b[i].first!=name) {
      if(ck) cout << endl;
      cout << b[i].first << endl;
      name=b[i].first;
      ck=false;
    }
    if(ck) cout << " ";
    cout << b[i].second;
    ck=true;
  }
  cout << endl;
  return 0;
}

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

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

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> d[100];
int ptop[100];
int p[100][100];
int main(){
	string a;
	int q,top;
	top=0;
	int u=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++;
		}
		u++;//***
		if(u==8)break;//***
	}
	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;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<string,int> Pairsi;

int main(){
	priority_queue<Pairsi,vector<Pairsi>,greater<Pairsi> > q;
	Pairsi psi;
	vector<int> tn;
//	int tn[1000],tni=0;
	int c=0,n;
	string s,ts;


//input
	while(1){
		cin >> s >> n;
		q.push(make_pair(s,n));
		c++;
		if(cin.eof())break;
	}

//output
/*
	for(int i=0;i<c;i++){
		psi = q.top();
		q.pop();

		if(i==0){
	
		}else if(ts==psi.first){
			cout << "equal";
		}else{
			cout << ts << endl;

			for(int j=0;j<tn.size();j++){
				cout << tn[j] << ' ';
			}
			tn.clear();
			cout << endl;
		}

		ts = psi.first;
		tn.push_back(psi.second);
//		tn[tni++] = psi.second;

	}*/
	for(int i=0;i<c;i++){
		psi = q.top();
		q.pop();

		if(ts==psi.first){
			cout << psi.second << " ";
		}else{
			if(i!=0){
				cout << endl;
			}
			cout << psi.first << endl;
			cout << psi.second << " ";
		}

		ts = psi.first;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
	map< string, vector<int> > m;
	int n, i;
	string s;
	while (cin >> s)
	{
		if (cin.eof()) break;
		cin >> n;
		m[s].push_back(n);
	}
	map< string, vector<int> >::iterator it = m.begin();
	while (it != m.end())
	{
		cout << (*it).first << endl;
		for (i = 0; i < (*it).second.size(); i++)
		{
			cout << (*it).second[i];
			if (i < (*it).second.size()-1)
				cout << " ";
			else
				cout << endl;
		}
		it++;
	}
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<string,int> Pairsi;

int main(){
	priority_queue<Pairsi,vector<Pairsi>,greater<Pairsi> > q;
	Pairsi psi;
	vector<int> tn;
//	int tn[1000],tni=0;
	int c=0,n;
	string s,ts;


//input
	while(1){
		cin >> s >> n;
		if(cin.eof())break;
		q.push(make_pair(s,n));
		c++;
	}

//output
/*
	for(int i=0;i<c;i++){
		psi = q.top();
		q.pop();

		if(i==0){
	
		}else if(ts==psi.first){
			cout << "equal";
		}else{
			cout << ts << endl;

			for(int j=0;j<tn.size();j++){
				cout << tn[j] << ' ';
			}
			tn.clear();
			cout << endl;
		}

		ts = psi.first;
		tn.push_back(psi.second);
//		tn[tni++] = psi.second;

	}*/
	for(int i=0;i<c;i++){
		psi = q.top();
		q.pop();

		if(ts==psi.first){
			cout << psi.second << " ";
		}else{
			if(i!=0){
				cout << endl;
			}
			cout << psi.first << endl;
			cout << psi.second << " ";
		}

		ts = psi.first;
	}

	return 0;
}