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 <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int a[86400]={};
	
	int n;
	while(cin>>n&&n!=0){
	
		for(int i=0;i<n;i++){
			string s,t;
			cin>>s;
			int from= ((s[0]-'0')*10+ (s[1]-'0'))*3600
					+ ((s[3]-'0')*10+ (s[4]-'0'))*60
					+ ((s[6]-'0')*10+ (s[7]-'0'));
			cin>>t;
			int to= ((t[0]-'0')*10+ (t[1]-'0'))*3600
					+ ((t[3]-'0')*10+ (t[4]-'0'))*60
					+ ((t[6]-'0')*10+ (t[7]-'0'));
			for(int j=from;j<to;j++){
				a[j]++;
			}
		}
		
		sort(a,a+86400);
		cout<<a[86399]<<endl;
		
	}
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;
    while(cin>>n,n){
        vector<int> imos(100000,0);
        for(int i=0;i<n;i++){
            string s,t;cin>>s>>t;
            int tmp=0;
            tmp+=(s[0]-'0')*36000;tmp+=(s[1]-'0')*3600;
            tmp+=(s[3]-'0')*600;tmp+=(s[4]-'0')*60;
            tmp+=(s[6]-'0')*10;tmp+=(s[7]-'0');
            imos[tmp]++;
            tmp=0;
            tmp+=(t[0]-'0')*36000;tmp+=(t[1]-'0')*3600;
            tmp+=(t[3]-'0')*600;tmp+=(t[4]-'0')*60;
            tmp+=(t[6]-'0')*10;tmp+=(t[7]-'0');
            imos[tmp]--;
        }
        for(int i=1;i<=99999;i++) imos[i]+=imos[i-1];
        int res=0;
        for(int i=0;i<100000;i++) res=max(res,imos[i]);
        cout<<res<<endl;
    }
}

C++: #include <algorithm>/*{{{*/
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define SZ(a) ((int)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define F first
#define S second
#define MP(a, b) make_pair(a, b)
#define BIT(n) (1ULL << (n))

static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

using namespace std;
typedef long long int LL;
typedef pair<int,int> P;/*}}}*/

bool starts[24][60][60];
bool arrivals[24][60][60];

int main(int argc, char const* argv[])
{
	int N;
	while (cin >> N, N) {
		FOR(i, 0, 24) {
			FOR(j, 0, 60) {
				FOR(k, 0, 60) {
					starts[i][j][k] = false;
					arrivals[i][j][k] = false;
				}
			}
		}
		FOR(i, 0, N) {
			int h, m, s;
			char buf;
			cin >> h >> buf >> m >> buf >> s;
			starts[h][m][s] = true;
			cin >> h >> buf >> m >> buf >> s;
			arrivals[h][m][s] = true;
		}

		int ans = 0;
		int stock = 0;
		FOR(i, 0, 24) {
			FOR(j, 0, 60) {
				FOR(k, 0, 60) {
					if (arrivals[i][j][k]) {
						//printf("arrive at %d:%d:%d\n", i, j, k);
						++stock;
					}
					if (starts[i][j][k] && stock == 0) {
						//printf("starts at %d:%d:%d\n", i, j, k);
						++ans;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N;
	while(cin >> N && N)
	{
		vector< pair<int,int> > train( N, {0,0} );
	
		int hh,mm,ss;
		rep(nth,N)
		{
			scanf("%d:%d:%d",&hh,&mm,&ss);
			train[nth].first = (hh*10000) + (mm*100) + (ss);

			scanf("%d:%d:%d",&hh,&mm,&ss);
			train[nth].second = (hh*10000) + (mm*100) + (ss);
		}

		vector<int> route(240000,0);
		rep(i,train.size()){
			REP(j,train[i].first, train[i].second){
				route[j] += 1;
			}
		}

		cout << *max_element(ALL(route)) << endl;

}
	return 0;
}