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++: //1508
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

#define LIM 24*60*60
int n;
int in[LIM+10];
int out[LIM+10];

int main(){
	
	int n;
	
	while(cin >> n, n){
	
		CLR(in);
		CLR(out);
	
		for(int i=0; i<n; ++i){
			int hh, mm, ss;
			scanf("%d:%d:%d", &hh, &mm, &ss);
			in[hh*60*60 + mm*60 + ss]++;
			scanf("%d:%d:%d", &hh, &mm, &ss);
			out[hh*60*60 + mm*60 + ss]++;
		}
		
		int res = 0;
		int t = 0;
		
		for(int i=0; i<LIM; ++i){
			
			t += in[i];
			t -= out[i];
			res = max(res, t);

		}
			
		cout << res << endl;	
	}
	
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

template <class T1, class T2>
struct pair_first_less {
	bool operator()(const std::pair<T1, T2> &x, const std::pair<T1, T2> &y) const {
		return x.first < y.first;
	}
};

template <class T1, class T2>
struct pair_second_less {
	bool operator()(const std::pair<T1, T2> &x, const std::pair<T1, T2> &y) const {
		return x.second < y.second;
	}
};

void input(std::vector< std::pair<int, int> > *t, int n)
{
	for (int i = 0; i < n; ++i) {
		int h0, m0, s0, h1, m1, s1;
		scanf("%02d:%02d:%02d %02d:%02d:%02d", &h0, &m0, &s0, &h1, &m1, &s1);
		const int t0 = (h0 * 60 + m0) * 60 + s0;
		const int t1 = (h1 * 60 + m1) * 60 + s1;
		t->push_back(std::pair<int, int>(t0, t1));
	}
}

int answer(const std::vector< std::pair<int, int> > &t)
{
	std::vector< std::pair<int, int> > f;	// 
	for (std::vector< std::pair<int, int> >::const_iterator it = t.begin(); it != t.end(); ++it) {
		if (it->first > it->second) { continue; }
		f.push_back(std::pair<int, int>(it->first, 1));
		f.push_back(std::pair<int, int>(it->second, -1));
	}
	std::sort(f.begin(), f.end(), pair_second_less<int, int>());
	std::stable_sort(f.begin(), f.end(), pair_first_less<int, int>());
	int n_max = 0, n = 0;
	for (std::vector< std::pair<int, int> >::iterator it = f.begin(); it != f.end(); ++it) {
		n += it->second;
		if (n > n_max) { n_max = n; }
	}
	return n_max;
}

int main()
{
	int n;
	while (scanf("%d", &n), n > 0) {
		std::vector< std::pair<int, int> > t;
		input(&t, n);
		printf("%d\n", answer(t));
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main()
{
	int n;
	char stime[10001][7];
	char gtime[10001][7];
	char *tmp;
	int sh[10001], sm[10001], ss[10001];
	int gh[10001], gm[10001], gs[10001];
	int count;

	gh[0] = 25;
	while(true){
		cin >> n;
		if(n == 0) break;
		count = 0;
		for(int i = 0; i < n; i++){
			cin >> stime[i];
			cin >> gtime[i];
			//printf("%s\n", stime[i]);

			tmp = strtok(stime[i], ":");
			sh[i] = atoi(tmp);
			//printf("%d\n", sh[i]);
			tmp = strtok(NULL, ":");
			sm[i] = atoi(tmp);
			//printf("%d\n", sm[i]);
			tmp = strtok(NULL, ":");
			ss[i] = atoi(tmp);
			//printf("%d\n", ss[i]);
			tmp = strtok(gtime[i], ":");
			gh[i] = atoi(tmp);
			//printf("%d\n", gh[i]);
			tmp = strtok(NULL, ":");
			gm[i] = atoi(tmp);
			tmp = strtok(NULL, ":");
			gs[i] = atoi(tmp);

			if(i == 0) count++;
			else{
			for(int j = 0; j < i; j++){
				/*if((gh[j] > sh[i]) || (gh[j] == sh[i] && gm[j] > sm[i]) || 
						(gh[j] == sh[i] && gm[j] == sm[i] && gs[j] >= ss[i])){
					count++;
					break;
				}*/
				//printf("%d %d\n", gh[j], sh[i]);
				if(gh[j] < sh[i] || (gh[j] == sh[i] && gm[j] <= sm[i]) ||
						 (gh[j] == sh[i] && gm[j] == sm[i] && gs[j] <= ss[i])){
							gh[j] = 25;
							//sm[j] = sm[i];
							//ss[j] = ss[i];
							break;
				}
				if(j == i - 1){
					count++;
					//printf("%d %d\n", i, j);
					break;
				}
			}
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int imos[90000];

int time_split(char Tens_Place,char One_Place){
    int return_num;
    string s = {Tens_Place, One_Place};
    stringstream ss;
    ss << s;
    ss >> return_num;
    return return_num;
}

int main() {

    while(1) {

        int n;

        cin >> n;

        if(n==0){
            break;
        }

        for(int i=0; i<90000; i++){
            imos[i] = 0;
        }

        for (int i = 0; i < n; i++) {
            string start, goal;
            cin >> start >> goal;
            int h, m, s;
            h = time_split(start[0], start[1]);
            m = time_split(start[3], start[4]);
            s = time_split(start[6], start[7]);
            imos[h * 24 * 60 + m * 60 + s]++;
            h = time_split(goal[0], goal[1]);
            m = time_split(goal[3], goal[4]);
            s = time_split(goal[6], goal[7]);
            imos[h * 24 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < 90000; i++) {
            imos[i] += imos[i - 1];
        }

        int ans = 0;

        for (int i = 0; i < 90000; i++) {
            ans = max(ans, imos[i]);
        }

        cout << ans << endl;

    }

    return 0;
}