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 <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int table[100000];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < 100000; i++) table[i] = 0;
        for (int i = 0; i < n; i++) {
            string s, t;
            cin >> s >> t;
            // 最初の時間を求める
            {
                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');
                table[h*3600+m*60+ss]++;
            }
            // 到着の時間を求める
            {
                int h = (t[0]-'0') * 10 + (t[1]-'0');
                int m = (t[3]-'0') * 10 + (t[4]-'0');
                int ss = (t[6]-'0') * 10 + (t[7]-'0');
                table[h*3600+m*60+ss]--;
            }
        }
        int cur = 0, ans = 0;
        for (int i = 0; i < 100000; i++) {
            cur += table[i];
            ans = max(ans, cur);
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000
#define T_MAX 24*60*60

int main(){
  vector<int> v(T_MAX);

  while(true){
    int n;
    cin >> n;

    if(n==0) break;

    rep(i,T_MAX) v[i]=0;

    int h,m,s;
    rep(i,n){
      scanf("%d:%d:%d", &h, &m, &s);// dbg(h);dbg(m);dbg(s);
      int t1 = (h*60+m)*60+s;
      scanf("%d:%d:%d", &h, &m, &s);// dbg(h);dbg(m);dbg(s);
      int t2 = (h*60+m)*60+s;
      v[t1]++;
      v[t2]--;
    }

    int current=0, res=0;
    rep(i, T_MAX){
      current += v[i];
      res = max(res, current);
    }

    cout << res << endl;
  }
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,ma,sum;
	string s,t;
	vector<P> box;
	while(cin>>n,n){
		ma=0;
		for(int i=0;i<n;i++){
			cin>>s>>t;
			box.push_back(P(((s[0]-'0')*10+s[1]-'0')*3600+((s[3]-'0')*10+s[4]-'0')*60+(s[6]-'0')*10+s[7]-'0',((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 i=0;i<n;i++){
			sum=1;
			for(int j=0;j<n;j++){
				if(i!=j&&!(box[j].second<=box[i].first||box[i].second<=box[j].first))
				sum++;
			}
			if(sum>ma)
			ma=sum;
		}
		cout<<ma<<endl;
		box.clear();
	}
	return 0;
}

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

int main(){
  int t,train,max;
  int n;
  int dep[10000],arr[10000];
  int h,m,s;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      scanf("%d:%d:%d ",&h,&m,&s);
      dep[i] = h*24*60 + m*60 + s;
      scanf("%d:%d:%d ",&h,&m,&s);
      arr[i] = h*24*60 + m*60 + s;
    }

    train = 0;
    max = 0;
    for(t = 0;t <= 86400;t++){
      for(int i=0;i<n;i++){
	if(dep[i] == t)train++;
	if(arr[i] == t)train--;
      }
      if(train>max)max = train;
    }

    cout << max << endl;
  }
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(24 * 60 * 60 + 1, 0);
		REP(i, n) {
			int h, m, s;
			char c;
			cin >> h >> c >> m >> c >> s;
			v[h * 24 * 60 + m * 60 + s]++;
			cin >> h >> c >> m >> c >> s;
			v[h * 24 * 60 + m * 60 + s]--;
		}
		REP(i, 24 * 60 * 60) {
			v[i + 1] += v[i];
		}
		cout << *max_element(ALL(v)) << endl;
	}
	return 0;
}