Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		accum := make([]int, 86401)
		for i := 0; i < n; i++ {
			s, e := io.Next(), io.Next()
			hs, _ := strconv.Atoi(s[:2])
			ms, _ := strconv.Atoi(s[3:5])
			ss, _ := strconv.Atoi(s[6:8])
			accum[hs*60*60+ms*60+ss]++
			he, _ := strconv.Atoi(e[:2])
			me, _ := strconv.Atoi(e[3:5])
			se, _ := strconv.Atoi(e[6:8])
			accum[he*60*60+me*60+se]--
		}
		ans := 0
		for i := 1; i < 86401; i++ {
			accum[i] += accum[i-1]
			ans = intMax(accum[i], ans)
		}
		io.Println(ans)
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
#define max_t 24 * 60 * 60

int main(){
    int n;
    while( cin >> n, n ){
        int list[max_t] = {};
        while( n-- ){
            int d_h, d_m, d_s;      // the departure time
            int a_h, a_m, a_s;      // the arrival time
            //cin >> d_h >> ":" >> d_m >> ":" >> d_s;
            //cin >> a_h >> ":" >> a_m >> ":" >> a_s;
            scanf("%d:%d:%d", &d_h, &d_m, &d_s );
            scanf("%d:%d:%d", &a_h, &a_m, &a_s );
            int s, e;
            s = d_h * 60 * 60 + d_m * 60 + d_s;
            e = a_h * 60 * 60 + a_m * 60 + a_s;
            //cout << s << " " << e << endl;
            for( int i = s + 1; i < e; i++ ){
                list[i]++;
            }
        }
        int max = 0;
        for( int i = 0; i < max_t; i++ ){
            if( max < list[i] ) max = list[i];
        }
        cout << max << endl;
    }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL


typedef struct{
	int s,g;
}Time;

void swap_Time(Time *x, Time *y) {
	Time tmp = *x;
	*x = *y;
	*y = tmp;
}

void sort_by_s(Time a[], int n) {
	for (int i = 0; i < n - 1; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j - 1].s > a[j].s)swap_Time(&a[j - 1], &a[j]);
		}
	}
}


int main() {
	int   hhs, mms, sss, hhg, mmg, ssg, cnt = 1;
	Time yamanote[10000];
	bool f[10000];
	for (int n; cin >> n&&n;) {
		for (int i = 0; i < n; i++) {
			char c;
			cin >> hhs >> c >> mms >> c >> sss >> hhg >> c >> mmg >> c >> ssg;

			yamanote[i].s = 3600 * hhs + 60 * mms + sss;
			yamanote[i].g = 3600 * hhg + 60 * mmg + ssg;
		}

		sort_by_s(yamanote, n);

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i;) {
				//cout << "j" << endl;
				if (f[j] == 1) { j++; continue; }
				if (yamanote[i].s >= yamanote[j].g) {
					f[j] = 1;
					break;
				}
				j++;
				if (j == i)cnt++;
			}
			//cout << "i" << endl;
		}
		//cout << "h" << endl;
		cout << cnt << endl;
		cnt = 1;

	}
	return 0;
}

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

#define MAX 1000

int to_int(char c) {
    return 9 - (int)('9' - c);
}

int to_num(string s) {
    int t = 0;
    //cout << "{" << s[0] << "," << to_int(s[0]) << "}" << endl;
    t += (to_int(s[0]) * 10 + to_int(s[1])) * 100 * 100;
    t += (to_int(s[3]) * 10 + to_int(s[4])) * 100;
    t += (to_int(s[6]) * 10 + to_int(s[7]));
    return t;
}

int enable_train_index(int list[], int now_list_max, int t1) {
    sort(list, list+now_list_max);
    for(int i=now_list_max-1; i>=0; i--) {
        if (list[i] == -1) { continue; }
        if (list[i] <= t1) { return i; }
    }
    return -1;
}

int main(void) {
    int n;
    string s;
    while (cin >> n, n) {
        int list[MAX];
        int now_list_max = 0;
        int train_num = 0;
        for(int i=0; i<n; i++) {
            list[i] = -1;
        }
        for(int i=0; i<n; i++) {
            cin >> s;
            int t1 = to_num(s);
            cin >> s;
            int t2 = to_num(s);
            int index = enable_train_index(list, now_list_max, t1);
            //cout << "[" << t1 << "," << t2 << "]" << endl;
            if (index != -1) {
                list[index] = -1;
                for (int j=0; j<now_list_max-1; j++) {
                    if (list[j] == -1) {
                        list[j] = list[now_list_max-1];
                        break;
                    }
                }
                now_list_max--;
            } else {
                train_num++;
            }
            list[now_list_max] = t2;
            now_list_max++;
        }
        cout << train_num;
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int s[24 * 60 * 60];
	for (int n; cin >> n&&n;) {
		memset(s, 0, sizeof(s));

		for (int i = 0; i < n; i++) {
			char c;
			int shh, smm, sss, ghh, gmm, gss;
			cin >> shh >> c >> smm >> c >> sss;
			cin >> ghh >> c >> gmm >> c >> gss;

			int ss = shh * 60 * 60 + smm * 60 + sss;
			int gs = ghh * 60 * 60 + gmm * 60 + gss;

			for (int j = ss; j < gs; j++) {
				s[j]++;
			}
		}

		cout << *max_element(s, s + 24 * 60 * 60) << endl;

	}
	return 0;
}