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

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)
  d[i]=list(map(int,d[i]))
  print(" ".join(map(str,sorted(d[i]))))

Python: # Aizu Problem 0105: Book Index
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


index = {}
for line in sys.stdin:
    word, page = line.split()
    if word not in index:
        index[word] = []
    index[word].append(int(page))

for word in sorted(index.keys()):
    print(word)
    print(' '.join([str(page) for page in sorted(index[word])]))

Python: dic = {}
while True:
    try:
        key,num = input().split()
        dic.setdefault(key,[]).append(int(num))
    except:
        break

dic = sorted(dic.items())
for tup in dic:
    print(tup[0])
    tup[1].sort()
    for i in tup[1]:
        if i != tup[1][-1]:
            print(i,end=" ")
        else:
            print(i)

Python: d = {}
while True:
    try:
        word, page = input().split()
    except:
        break
    d[word] = [page] if word not in d else d[word] + [page]
for word, pages in sorted(d.items(), key=lambda x: x[0]):
    print(word)
    print(*sorted(pages))

Python: d  = {}
l = []
while True:
  try:
    s,n = input().split()
    if s in d:
      d[s].append(int(n))
    else:
      d[s] = [int(n)]
      l.append(s)
  except:
    break
l.sort()
for s in l:
  print(s)
  d[s].sort()
  d[s] = [str(s) for s in d[s]]
  print(' '.join(d[s]))

Python: dic = {}
while True:
    try:
        s, i = input().split()
        if s in dic:dic[s].append(int(i))
        else:dic[s] = [int(i)]
    except:break
for k, v in sorted(dic.items()):
    print(k)
    print(*sorted(v))

Python: import sys

dic = {}
while True:
	try:
		a,b = map(str,input().split())
		page = int(b)

		if a not in dic:
			dic[a] = [page]
		else:
			dic[a].append(page)

	except EOFError:
		names = sorted(dic.keys())
		for i in range(len(names)):
			print(names[i])
			pages = sorted(dic[names[i]])
			for j in range(len(pages)):
				if j == len(pages)-1:
					print(pages[j])
				else:
					sys.stdout.write(str('{:} '.format(pages[j])))
		break

Python: d = {}
while True:
    try:
        w, p = input().split()
        if w in d:
            d[w].append(int(p))
        else:
            d[w] = [int(p)]
    except:
        break
for k in sorted(d.items(), key=lambda x: x[0]):
    print(k[0])
    print(*sorted(k[1]))

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

Python: # AOJ 0105 Book Index
# Python3 2018.6.17 bal4u

from collections import defaultdict
index = defaultdict(list)

while True:
	try: w, p = list(input().split())
	except EOFError: break
	index[w].append(p)

index = dict(sorted(index.items()))
for x in index:
	print(x)
	print(*sorted(map(int, index[x])))

Python: dic = {}
while(True):
    try:
        key, page = input().split()
        page = int(page)
    except:
        break
    try:
        dic[key].append(page)
    except:
        dic[key] = [page]
a = list(dic.keys())
a.sort()
for b in a:
    print(b)
    print(" ".join(str(e) for e in sorted(dic[b])))

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(*b.sort())

Python: book = []
while True :
    try :
        A = list(input().split())
    except EOFError :
        break
    
    new_word = "ON"
    for i in range(len(book)) :
        if A[0] in book[i] :
            book[i].append(A[1])
            new_word = "OFF"
    if new_word == "ON" :
        book.append([A[0], A[1]])
    
book.sort()
for i in range(len(book)) :
    print(book[i][0])
    page = list(int(book[i][j]) for j in range(1, len(book[i])))
    print(*sorted(page))

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: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
N.sort()

N1,N2 = N[0].split()
word = N1
pnum = []
pnum.append(int(N2))

for l in range(1, len(N)):
    N1,N2 = N[l].split()

    if word != N1:
        print(word)
        pnum.sort()
        print(pnum[0], end="")
        for i in range(1, len(pnum)):
            print(" ", end="")
            print(pnum[i], end="")
        print("")
        word = N1
        pnum.clear()
        pnum.append(int(N2))
    else:
        pnum.append(int(N2))

print(word)
pnum.sort()
print(pnum[0], end="")
for i in range(1, len(pnum)):
    print(" ", end="")
    print(pnum[i], end="")

Python: import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    index = dict()
    for line in sys.stdin:
        word,page = line.split(' ')
        pages = index.get(word,list())
        pages.append(int(page))
        index[word] = pages
    keys = list(index.keys())
    keys.sort()
    for key in keys:
        print(key)
        pages = index[key]
        pages.sort()
        print(" ".join(map(str,pages)))
solve()

Python: import sys

d = {}

for i in sys.stdin.readlines():
    s, n = i.split()
    if s in d:
        d[s].append(int(n))
    else:
        d[s] = [int(n)]

d = sorted(d.items())
for i in d:
    print(i[0])
    print(*sorted(i[1]))

Python: key_list=[]
page_list=[]
while 1:
    try:
        key,page=map(str,input().split())
        if key in key_list:
            page_list[key_list.index(key)].append(int(page))
        else:
            key_list.append(key)
            page_list.append([int(page)])
    except:break
key_list_sort=key_list[:]
key_list_sort.sort()
for i in key_list_sort:
    print(i)
    ans=page_list[key_list.index(i)][:]
    ans.sort()
    print(' '.join(map(str,ans)))

Python: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
N.sort()

N1,N2 = N[0].split()
word = N1
pnum = []
pnum.append(int(N2))

for l in range(1, len(N)):
    N1,N2 = N[l].split()

    if word != N1:
        print(word)
        pnum.sort()
        print(pnum[0], end="")
        for i in range(1, len(pnum)):
            print(" ", end="")
            print(pnum[i], end="")
        print("")
        word = N1
        pnum.clear()
        pnum.append(int(N2))
    else:
        pnum.append(int(N2))

print(word)
pnum.sort()
print(pnum[0], end="")
for i in range(1, len(pnum)):
    print(" ", end="")
    print(pnum[i], end="")
print("")

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(*b)