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<bits/stdc++.h>
using namespace std;
int main()
{
    int sen=0,num,page[1000][100]={},nu[1000]={};
    memset(nu,0,sizeof(nu));
    string str[1000],s;
    while(cin>>s>>num){
        for(int i=0;i<=sen;i++){
            if(str[i]==s){
                nu[i]++;
                page[i][nu[i]]=num;
                num=-1;
            }
        }
        if(num!=-1){
            str[sen]=s;
            page[sen][0]=num;
            sen++;
        }
    }
    int kawa;
    for(int i=0;i<sen;i++){
        num=0;
        for(int j=0;j<sen;j++){
            if(str[j]!="zzzzzzzzzzzzzzz"&&str[num]>str[j])num=j;
        }
        cout<<str[num]<<endl;
        str[num]="zzzzzzzzzzzzzzzzzzzzz";
        for(int j=0;j<nu[num];j++){
            for(int k=nu[num]-1;k>0;k--){
                if(page[num][k]<page[num][k-1]){
                    kawa=page[num][k-1];
                    page[num][k-1]=page[num][k];
                    page[num][k]=kawa;
                }
            }
        }
        cout<<page[num][0];
        for(int j=1;j<=nu[num];j++)cout<<" "<<page[num][j];
        cout<<endl;
    }
}

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

int main()
{
  string word;
  int page;
  map<string, vector<int> > index;
  while (cin >> word >> page)
    index[word].push_back(page);

  for (map<string, vector<int> >::iterator it = index.begin(); it != index.end(); ++it) {
    vector<int>& pages = it->second;
    sort(pages.begin(), pages.end());
    cout << it->first << endl;
    for (int i = 0; i < pages.size()-1; ++i)
      cout << pages[i] << " ";
    cout << pages[pages.size()-1] << endl;
  }
  return 0;
}

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

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    std::map<std::string, std::vector<int>> mp;
    std::string s;
    int p;
    while (std::cin >> s >> p) { mp[s].push_back(p); }

    for (auto m : mp) {
        std::cout << m.first << std::endl;
        std::sort(m.second.begin(), m.second.end());
        int c = 0;
        for (auto x : m.second) {
            if (c++ == 0)
                std::cout << x;
            else
                std::cout << ' ' << x;
        }
        std::cout << std::endl;
    }
}

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<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 << " ";
		}
		cout <<"\b"<< endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main() {
	map<string, vector<int> > D;
	string w;
	int n;
	while(cin >> w >> n) {
		D[w].push_back(n);
	}
	map<string, vector<int> >::iterator it = D.begin();
	for(; it != D.end(); it++) {
		cout << it->first << endl;
		int size = it->second.size();
		sort(it->second.begin(),it->second.end());
		for(int i = 0; i < size - 1; i++){
			cout << it->second[i] << " ";
		}
		cout << it->second[size-1] << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string str;
	ll p;
	map<string, priority_queue<ll, vector<ll>, greater<ll>>>mp;
	while (cin >> str >> p) {
		mp[str].push(p);
	}
	REPC(i, mp) {
		cout << i.first << endl;
		REP(j, i.second.size()) {
			if (j != 0)cout << ' ';
			cout << i.second.top();
			i.second.pop();
		}
		cout << endl;
	}
}

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

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

using namespace std;

struct Data{
  string name;
  int num;
  bool operator < ( const Data &data) const {
    if( name==data.name ){
      if(num < data.num)return true;
      else return false;
    }else{
      if(name < data.name)return true;
      else return false;
    }
  }
};

int main(){
  
  Data a[100000];
  int n=0;
  string str;
  int id;
  while( cin>>str>>id ){
    a[n]= (Data){ str, id };
    n++;
  }
  sort(a,a+n);

  string key="";
  
  for(int i=0;i<n;i++){
    if(key!=a[i].name){
      key=a[i].name;
      if(i>0){
        cout<<endl;
      }
      cout<<key<<endl;
      cout<<a[i].num;
    }else{
      cout<<' '<<a[i].num;
    }
  }

  cout<<endl;
  
  return 0;
}