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++: #! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            log = [0 for _ in xrange(24 * 60 * 60)]
            for i in range(n):
                dept, arr = raw_input().split()
                dept = dept.split(':')
                arr = arr.split(':')
                dept = 24 * 60 * int(dept[0]) + 60 * int(dept[1]) + int(dept[2])
                arr = 24 * 60 * int(arr[0]) + 60 * int(arr[1]) + int(arr[2])
                log[dept+1] += 1
                log[arr+1] -= 1
            for i in range(len(log)-1):
                log[i+1] += log[i]
            print max(log)
            
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int n;
int s[1000010];
void solve(){
    rep(i,1000000) s[i] = 0;
    rep(i,n){
        int sh,sm,ss;
        int eh,em,es;
        scanf("%d:%d:%d", &sh,&sm,&ss);
        scanf("%d:%d:%d", &eh,&em,&es);
        int sta = sh * 3600 + sm * 60 + ss;
        int end = eh * 3600 + em * 60 + es;
        s[sta] += 1;
        s[end] -= 1;
    }
    rep(i,1000000) s[i+1] += s[i];
    cout << *max_element(s, s+1000000) << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    while(scanf("%d", &n), n){
        solve();
    }
    return 0;
}

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

typedef long long ll;

ll f(string s){
    string s1,s2,s3;
    s1 = s.substr(0,2);
    s2 = s.substr(3,2);
    s3 = s.substr(6,2);

    int h = stoi(s1)*3600;
    int m = stoi(s2)*60;
    int ss = stoi(s3)*1;

    return h+m+ss;
}

void solve(int n){
    vector<int> v(60*60*60+3600+60+10,0);
    for(int i=0;i<n;i++){
        string s1,s2;
        cin >> s1 >> s2;
        ll s=f(s1);
        ll t=f(s2);
        v[s]++;
        v[t]--;
    }
    for(int i=1;i<60*60*60+60*60+60;i++){
        v[i] = v[i] + v[i-1];
    }
    int ans = -1;
    for(int i=1;i<60*60*60+60*60+60;i++){
        ans = max(ans,v[i]);
        if(v[i] == 6)  cout << i << endl;
    }
    cout << ans << endl;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        vector<int> imos(86402, 0);
        rep(i, N) {
            int fh, fm, fs, th, tm, ts;
            scanf("%d:%d:%d %d:%d:%d", &fh, &fm, &fs, &th, &tm, &ts);
            int secf = fh * 3600 + fm * 60 + fs;
            int sect = th * 3600 + tm * 60 + ts;
            imos[secf]++; imos[sect]--;
        }

        repd(i, 1, imos.size()) {
            imos[i] += imos[i - 1];
        }

        int res = 0;
        rep(i, imos.size()) {
            chmax(res, imos[i]);
        }

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