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<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	vector<string> words;
	vector<vector<int> > pages;
	string word; int page;
	for (int k = 0; k < 7; k++) {
		cin >> word >> page;
		bool is_there = false; int word_place;
		for (int i = 0; i < words.size(); i++) {
			if (word == words[i]) {
				is_there = true;
				word_place = i;
			}
		}
		if (is_there) {
			pages[word_place].push_back(page);
		}
		else {
			words.push_back(word);
			vector<int>* x = new vector<int>;
			pages.push_back(*x);
			pages[pages.size() - 1].push_back(page);
		}
	}
	for (int i = 0; i < words.size() - 1; i++) {
		for (int j = 0; j < words.size() - 1; j++) {
			if (words[j] > words[j + 1]) {
				string tmp_w=words[j];
				words[j] = words[j + 1];
				words[j + 1] = tmp_w;
				vector<int> tmp_p=pages[j];
				pages[j] = pages[j + 1];
				pages[j + 1] = tmp_p;
			}
		}
	}
	for (int i = 0; i < words.size(); i++) {
		for (int j = 0; j < pages[i].size()-1; j++) {
			for (int c = 0; c < pages[i].size()-1; c++) {
				if (pages[i][c] > pages[i][c + 1]) {
					int tmp=pages[i][c];
					pages[i][c] = pages[i][c + 1];
					pages[i][c + 1] = tmp;
					}
			}
		}
	}
	for (int i = 0; i < words.size(); i++) {
		cout << words[i] << ':';
		for (int m = 0; m < pages[i].size(); m++) {
			cout << pages[i][m]<<' ';
		}
		cout << endl;
	}
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define vi vector<int>
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "<debug " << x << endl;
#define inf 5000
using namespace std;

int main(){
    string word;
    int page;
    map<string,vector<int> > info;

    while(cin >> word >> page){
        info[word].pb(page);
    }
    map<string, vector<int> >::iterator it;
    for(it = info.begin(); it != info.end(); it++){
        vector<int> &pageList = it->second;
        cout << it->first << endl;
        sort(all(pageList));
        for(int i = 0; i < pageList.size(); i++){
            if(i) cout << ' ';
            cout << pageList[i];
        }
        cout << endl;
    }
}

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

int main()
{
	int i,flag=0;
	int j,count=0;
	string word,page;
	string index[1000];
	string num[1000];
	for(i=0;i<1000;i++)
	{
		index[i]="";
		num[i]="";
	}
	while(cin>>word>>page)
	{
		for(j=0;j<flag;j++)
		{
			if(word.compare(index[j])!=0)
			{
				count++;
			}
		}
		if(count==flag)
		{
			index[flag]=word;

			if(flag==0)
				num[count]=num[count]+page;
			else
				num[count]=num[count]+" "+page;
		}
		count=0;
	}
	for(i=0;i<flag;i++)
	{
		cout<<index[i]<<endl;
		cout<<num[i]<<endl;
	}
	return 0;
}

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]!="zzz"&&str[num]>str[j])num=j;
        cout<<str[num]<<endl;
        str[num]="zzz";
        for(int j=0;j<=nu[num];j++){
            for(int k=nu[num];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<list>
#include<map>
using namespace std;

int printIndex(){
    int number=0;
    string word;
    map<string,list<int> > index;
    
    while(!(cin>>word>>number).eof()){
        index[word].push_back(number);
        
    }
    map<string, list<int> >::iterator it = index.begin();
    while(it != index.end()){
        it->second.sort();
        list<int>::iterator ite = it->second.begin();
        cout << it->first << endl;
        while(ite!=it->second.end()){
            cout << *ite << " ";
            ite++;
        }
        cout << endl;
        it++;
    }
}

int main(){
    printIndex();
    return 0;
}

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

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

int main(){
  string str;
  string s[102];
  int n;
  map<string,vector<int> > word;
  int i=0;
  
  while(cin>>str>>n){
    if(!word.count(str)){
      word[str].push_back(n);
      s[i]=str;
      i++;
    }
    else word[str].push_back(n);
  }
  
  
  for(int cnt=0;cnt<i;cnt++)sort(word[s[cnt]].begin() , word[s[cnt]].end());
  
  for(int cnt=0;cnt<i;cnt++){
    for(int j=0;j<i-1;j++){
      if(s[j]>s[j+1])swap(s[j],s[j+1]);
    }
  }

  for(int cnt=0;cnt<i;cnt++){
    cout<<s[cnt]<<endl;
    for(int j=0;j<word[s[cnt]].size();j++){
      if(j)cout<<" ";
      cout<<word[s[cnt]][j];
    }
    cout<<endl;
  }

  return(0);
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <utility>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	map<string, set<int> > m;
	int x;
	while(1) {
		if(scanf("%s", s) == EOF) break;
		scanf("%d", &x);
		if(m.count(s) == 0) {
			set<int> v;
			v.insert(x);
			m.insert(make_pair(s, v));
		} else {
			set<int> v = m[s];
			v.insert(x);
		}
	}
	for(auto it = m.begin(); it != m.end(); ++it) {
		cout << (*it).first << endl;
		for(auto it2 = it->second.begin(); it2 != --(it->second).end(); ++it2) {
			cout << *it2 << " ";
		}
		cout << *--(it->second).end() << endl;
	}
	return 0;
}