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()
	}
}

Python: w=[]
while True:
    try:
        s,n=input().split()
    except:
        break
    ch=True
    for i in range(len(w)):
        if w[i][0]==s:
            w[i].append(int(n))
            ch=False
            break
    if ch:
        w.append([s,int(n)])
w.sort()
for i in range(len(w)):
    print(w[i][0])
    p=sorted(w[i][1:])
    print(*p)

Python: import sys
d={}
for e in sys.stdin:
 k,v=e.split()
 if k not in d:d[k]=[]
 d[k]+=[int(v)]
for k in sorted(d):
 print(k)
 print(*sorted(d[k]))

Python: import sys
d={}
for e in sys.stdin:
 k,v=e.split()
 d.setdefault(k,[])
 d[k]+=[int(v)]
for k in sorted(d):
 print(k)
 print(*sorted(d[k]))

Python: import sys
a={}
for i in sys.stdin:
	b,c=i.split()
	a.setdefault(b, []).append(c)
	if c=='18':break
for a,b in sorted(a.items(), key=lambda x: x[0]):
    print(a)
    print(*sorted(map(int,b)))

Python: dic = {}
while True:
    try:
        word, pgn = input().split()

        if word in dic.keys():
            dic[word].append(int(pgn))
        else:
            dic[word] = [int(pgn)]
    except:
        break

for k, v in sorted(dic.items()):
    print(k)
    print(' '.join(map(str, sorted(v))))

Python: index = {}
while True:
  try:
    word,page = input().split()
    page = int(page)
    index[word].append(page)
  except KeyError:
    index[word] = [page]
  except EOFError:
    break

for (key,value) in sorted(index.items()):
  print(key)
  value = list(map(str,sorted(value)))
  print(" ".join(value))

Python: if __name__ == '__main__':

	dic = {}

	while True:
		try:
			s,n = input().split()
			dic.setdefault(s,[]).append(int(n))
		except EOFError:
			break

#	print(dic)

	tmp = sorted(list(dic))
	for word in tmp:
		print(word)
		print(*sorted(dic[word]))

Python: import sys
l=[i.split() for i in sys.stdin]
d={}
for i in l:
  if i[0] not in d:
    d[i[0]]=[i[1]]
  else:
    d[i[0]].append(i[1])
for i in sorted(d.keys()):
  print(i)
  print(" ".join(d[i]))

Python: #!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import bisect
import collections
import sys


if __name__ == "__main__":
    pre_dict = collections.defaultdict(lambda: array.array("I"))
    for line in sys.stdin:
        [word, page0] = line.split()
        page = int(page0)
        bisect.insort(pre_dict[word], page)
    sorted_dict = collections.OrderedDict(sorted(pre_dict.items(), key=lambda i: i[0]))
    for k, v in sorted_dict.items():
        print(k)
        print(*v)

Python: c={}
while 1:
    try:
        a,b=input().split()
        if a in c:c[a].append(int(b))
        else: c[a]=[int(b)]
    except:
        for i,j in sorted(c.items()):
            print(i)
            print(*sorted(j))
        break

Python: import sys

dictionary = {}

for line in sys.stdin:
    line = line[:-1]

    word, page = line.split(" ")
    page = int(page)

    if word in dictionary:
        dictionary[word].append(page)
    else:
        dictionary[word] = [page]

keys = list(dictionary)
keys.sort()

output = []

for key in keys:
    output.append(key)
    pages = sorted(dictionary[key])
    pages = [str(item) for item in pages]
    pages = " ".join(pages)
    output.append(pages)

print("\n".join(output))

C++: // index
#include <iostream>
#include <string>
// #include <algorithm>
#include <set>
#include <map>
using namespace std;

int main(){
  map< string, set<int> > index;
  string word;
  int page;

  while (cin >> word >> page){
    index[word].insert( page );
  }
  map< string, set<int> >::iterator it1 = index.begin();
  set<int>::iterator it2;
  while( it1 != index.end() ){
    cout << (*it1).first << endl;
    it2 = index[(*it1).first].begin();
    while( it2 != index[(*it1).first].end() ){
      cout << *it2 << ' ';
      it2++;
    }
    cout << endl;
    it1++;
  }
  return 0;
}

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

int main(){
	map< string , vector<int> > index;
	int page;
	string s;

	while( cin >> s >> page ){
		index[s].push_back( page );
	}
	
	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 << " " ;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	string S;
	int N;
	multimap<string, int> mp;
	while( cin >> S >> N )
	{
		mp.emplace( make_pair( S, N ) );
	}
	string tmp;
	bool flag = true;
	for( auto x : mp )
	{
		if( x.first == tmp )cout << " ";
		if( x.first != tmp )
		{
			if( !tmp.empty() )
			{
				cout << endl;
			}
			tmp = x.first;
			cout << x.first << endl;
		}
		cout << x.second;
	}
	return 0;
}

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

int main(){
    unordered_map<string, int> mp;
    vector<vector<int>> index(1,vector<int>());
    string str;
    vector<string> what;
    int page, pages = 1;
    while(cin >> str >> page){
        if(mp[str] == 0){
            mp[str] = pages;
            vector<int> newin(1, page);
            index.push_back(newin);
            what.push_back(str);
            pages++;
        }
        else{
            index[mp[str]].push_back(page);
        }
    }
    sort(what.begin(), what.end());
    for(int i = 0;i<what.size();i++){
        str = what[i];
        sort(index[mp[str]].begin(), index[mp[str]].end());
        cout << str << endl;
        for (int i = 0; i < index[mp[str]].size();i++){
            if(i == index[mp[str]].size()-1){
                cout << index[mp[str]][i] << endl;
            }
            else{
                cout << index[mp[str]][i] << " ";
            }
        }
    }
    return 0;
}

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

typedef map<string,priority_queue<int,vector<int>,greater<int> > >Book;

int main(){
  int value;
  string str;
  Book book;
  int flag;
  while(cin>>str>>value){
    book[str].push(value);
  }
  for(Book::iterator it=book.begin();it!=book.end();++it){
    cout<<it->first<<endl;
    flag=0;
    while(!(it->second.empty())){
      if(flag)cout<<" ";
      flag=1;
      cout<<it->second.top();
      it->second.pop();
    }
    cout<<endl;
  }
  return 0;
}