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++: // AOJ2013
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

struct name{
    tuple<int,int,int> bunkai(string s){
        int a=check(s[0],s[1]),b=check(s[3],s[4]),c=check(s[6],s[7]);
        return forward_as_tuple(a,b,c);
    }
    int check(char a,char b){
        int s;
        if(a=='0'){
            s=b-'0';
        }else{
            s=(a-'0')*10+(b-'0');
        }
        return s;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    int max_=25*60*60;
    name me;
    while(cin>>n){
        if(n==0) break;
        vector<int> imos(max_,0);
        rep(i,n){
            string s,t;
            cin>>s>>t;
            int a,b,c;
            tie(a,b,c)=me.bunkai(s);
            imos[a*60*60+b*60+c]++;
            tie(a,b,c)=me.bunkai(t);
            imos[a*60*60+b*60+c]--;
        }
        int ans=imos[0];
        for(int i=1;i<max_;i++){
            imos[i]+=imos[i-1];
            ans=max(ans,imos[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct Train {
	ll t;
	int is_in;
	Train(ll _t, int _is_in) :t(_t), is_in(_is_in) {}
	bool operator< (const Train& tr) {
		if (t == tr.t) {
			return is_in < tr.is_in;
		}
		else {
			return t < tr.t;
		}
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		vector<Train> vt;
		vt.reserve(n * 2);
		for (ll i = 0; i < n; i++) {
			ll sh, sm, ss, eh, em, es;
			char c;
			cin >> sh >> c >> sm >> c >> ss >> eh >> c >> em >> c >> es;
			vt.emplace_back(sh * 3600 + sm * 60 + ss, 1);
			vt.emplace_back(eh * 3600 + em * 60 + es, 0);
		}
		sort(vt.begin(), vt.end());
		n *= 2;
		ll res = 0;
		ll now = 0;
		for (ll i = 0; i < n; i++) {
			if (vt[i].is_in) {
				now++;
				chmax(res, now);
			}
			else {
				now--;
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}

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

#define	mp	make_pair

using namespace std;

typedef	pair<int,bool>	pib;

int main(){
	for(int n;scanf("%d",&n),n;){
		static pib event[20000];
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				int h,m,s;	scanf("%d%*c%d%*c%d",&h,&m,&s);
				event[2*i+j]=mp(3600*h+60*m+s,!j);	// departure: 1, arrival: 0
			}
		}

		sort(event,event+2*n);

		int train=0,maxtrain=0;
		for(int i=0;i<2*n;i++){
			if(event[i].second)	train++;
			else	train--;
			maxtrain=max(maxtrain,train);
		}

		printf("%d\n",maxtrain);
	}

	return 0;
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> imos(90000);
		while (n--) {
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			imos[3600 * h + 60 * m + s]++;
			scanf("%d:%d:%d", &h, &m, &s);
			imos[3600 * h + 60 * m + s]--;
		}
		int ans = imos[0];
		for (int i = 1; i < 90000; ++i) {
			imos[i] += imos[i - 1];
			ans = max(ans, imos[i]);
		}
		cout << ans << endl;
	}

	return 0;
}