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 <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;

		vector<pii> vp;
		rep(i,0,n) {
			int h,m,s;
			scanf("%d:%d:%d", &h, &m, &s);
			vp.push_back(pii(h*3600 + m*60 + s, 1));
			scanf("%d:%d:%d", &h, &m, &s);
			vp.push_back(pii(h*3600 + m*60 + s, -1));
		}

		sort(vp.begin(), vp.end());
		int ans = 0, tmp = 0;
		rep(i,0,vp.size()) {
			tmp += vp[i].second;
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int t[24][60][60];

void read_time(int& h, int& m, int& s) {
    string str;
    cin >> str;
    replace(ALL(str), ':', ' ');
    stringstream ss(str);
    ss >> h >> m >> s;
}

int main() {
    int n;
    while (cin >> n, n) {
        fill_n((int *)t, 24*60*60, 0);
        REP(i, n) {
            int sh, sm, ss, eh, em, es;
            read_time(sh, sm, ss);
            read_time(eh, em, es);
            bool ok = false;
            REP(h, 24) {
                REP(m, 60) {
                    REP(s, 60) {
                        if (h == sh && m == sm && s == ss) {
                            ok = true;
                        }
                        if (h == eh && m == em && s == es) {
                            goto NEXT;
                        }
                        if (ok) t[h][m][s]++;
                    }
                }
            }
NEXT: {}
        }
        int ma = 0;
        REP(h, 24) {
            REP(m, 60) {
                REP(s, 60) {
                    ma = max(ma, t[h][m][s]);
                }
            }
        }
        cout << ma << endl;
    }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int tim(string s){
  int h=(s[0]-'0')*10+(s[1]-'0');
  int m=(s[3]-'0')*10+(s[4]-'0');
  int ss=(s[6]-'0')*10+(s[7]-'0');
  return 3600*h+60*m+ss;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<int> count(86402,0);
    for(int i=0;i<n;i++){
      string s,t;
      cin >> s >> t;
      count[tim(s)]++;
      count[tim(t)]--;
    }
    int ma=count[0];
    for(int i=1;i<86402;i++){
      count[i]+=count[i-1];
      ma=max(ma,count[i]);
    }
    cout << ma << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, ans, k, t[6];
  vector< pair<int, int> > T;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      scanf("%d:%d:%d %d:%d:%d",&t[0],&t[1],&t[2],&t[3],&t[4],&t[5]);
      T.push_back(make_pair(t[0]*3600+t[1]*60+t[2], 1));
      T.push_back(make_pair(t[3]*3600+t[4]*60+t[5], -1));
    }
    ans = 0;
    k = 0;
    sort(T.begin(), T.end());
    for (int i = 0; i < 2*n; ++i) {
      k += T[i].second;
      ans = max(ans, k);
    }
    cout << ans << endl;
    T.erase(T.begin(), T.end());
  }
  return 0;
}