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=0;
                break;
            }
        }
        if(num!=0){
            str[sen]=s;
            page[sen][0]=num;
            sen++;
        }
    }
    for(int i=0;i<sen;i++){
        for(int j=0;j<sen;j++)if(str[num]>str[j])num=j;
        cout<<str[num]<<endl;
        str[num]=123;
        for(int j=0;j<nu[num];j++){
            for(int k=nu[num];k>j;k--){
                if(page[num][k]<page[num][k-1]){
                    int 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 <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

  for (auto i : index) {
    cout << i.first << endl;
    sort(i.second.begin(), i.second.end());
    for (auto j = i.second.begin(); j != i.second.end() -1; j++)
      cout << *j << " ";
    cout << *(i.second.end() -1) << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

using namespace std;

typedef vector<int> vi;

int main(){
    map<string, vi> m;
    string s; int n;
    while (cin >> s >> n){
        m[s].push_back(n);
    }
    for (auto e : m){
        sort(all(e.second));
        cout << e.first << endl;
        rep(i, e.second.size() - 1){
            cout << e.second[i] << " ";
        }
        cout << e.second.back() << endl;
    }
}

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

int StringComp(const string &s1, const string &s2){
	return s1.compare(s2);
}

int main(void){
	map< string, vector< int > > m;
	while( true ){
		string word;
		int page;

		cin >> word >> page;
		if( cin.eof() ) break;

		m[word].push_back(page);
	}
	map< string, vector< int > >::iterator itM = m.begin();
	while(itM != m.end()){
		sort(itM->second.begin(), itM->second.end());
		cout << itM->first << '\n';
		cout << itM->second[0];
		for(unsigned int i = 1; i < itM->second.size(); i++){
			cout << ' ' << itM->second[i];
		}
		cout << endl;
		itM++;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
typedef struct{
  string first;
  int second;
}SI;
int main(){
  SI pa[101];
  int k=0;
  
  while(cin >> pa[k].first >> pa[k].second){
    k++;
  }

  for(int i=0;i<k-1;i++){
    for(int j=i+1;j<k;j++){
      if(pa[i].first > pa[j].first){
	  SI temp = pa[i];
	  pa[i] = pa[j];
	  pa[j] = temp;
      } else if(pa[i].first == pa[j].first && pa[i].second > pa[j].second){
	SI temp = pa[i];
	pa[i] = pa[j];
	pa[j] = temp;
      }
    }
  }

 
  cout << pa[0].first << endl << pa[0].second;
  for(int i=1;i<k;i++){
    if(pa[i-1].first == pa[i].first) cout << ' ' << pa[i].second;
    else cout << endl << pa[i].first << endl << pa[i].second;
  }
  cout << endl;
  return (0);
}

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

C++: #include <iostream>
#include<string>
#include<utility>
using namespace std;
int main() {
    pair<string,int> go[100000];
    int i=0;
    while(cin>>go[i].first>>go[i].second){
        i++;
    }
    int at;
    string fir;
    at=0;
    for(int l=0;l<i;++l){
        fir="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for(int j=l;j<i;++j){
            if(go[j].first<=fir){
                fir=go[j].first;
                at=j;
            }
        }
        swap(go[at],go[l]);
    }
    fir=go[0].first;
    for(int k=1;k<i;++k){
        if(go[k].first!=fir){
        fir=go[k].first;
        }
        else{
            go[k].first="-1";
        }
    }
    int min=100000;
    
    for(int k=0;k<i;++k){
        at=k;
        min=100000;
        for(int l=k;l<i;++l){
            if(l!=k&&go[l].first!="-1"){
                break;
            }
            if(go[l].second<min){
                min=go[l].second;
                at=l;
            }
        }
        swap(go[k].second,go[at].second);
    }
    for(int k=0;k<i;++k){
        if(go[k].first=="-1"){
            cout<<" "<<go[k].second;
        }
        else{
            cout<<endl<<go[k].first<<endl<<go[k].second;
        }
    }
    cout<<endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
set<pair<string,int> >RB;set<pair<string,int> >::iterator it,ot;string T;int N;
int main() {
    while (cin>>T>>N) {RB.insert(make_pair(T,N));} it=ot=RB.begin();cout<<(it->first)<<endl<<(it->second);it++;
    while (it!=RB.end()) {if ((ot->first)==(it->first)) cout<<" "<<(it->second); else cout<<endl<<(it->first)<<endl<<(it->second);it++,ot++;}
    cout<<endl;return 0;}

C++: #include <iostream>
#include <map>
#include <string>
#include <set>

using namespace std;

int main(){
	int n;
	string str;	
	map<string, set<int> > m;

	while(cin >> str >> n){
		m[str].insert(n);
	}
	for(auto it = m.begin(); it != m.end(); it++){
		cout << it->first << endl;
		for(auto its =  it->second.begin(); its != it->second.end(); its++){
			cout << *its << " ";
		}
		cout << endl;
	}
}

C++: #include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int main()
{
	int n = 0;
	vector<pair<string, int> > v = vector<pair<string, int> >(100);
	while (cin >> v[n].first >> v[n].second)
		n++;
	n++;
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			if (v[i].first > v[j].first || (v[i].first == v[j].first && v[i].second > v[j].second))
			{
				pair<string, int> r = v[i];
				v[i] = v[j];
				v[j] = r;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		int fin = n;
		for (int j = i; j < n; j++)
		{
			if (v[i].first != v[j].first)
			{
				fin = j;
				break;
			}
		}
		cout << v[i].first << endl;
		for (int j = i; j < fin - 1; j++)
			cout << v[j].second << " ";
		cout << v[fin - 1].second << endl;
		i = fin;
	}

	return 0;
}