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 <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int TIME = 60 * 60 * 24 + 60;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n && n){
	int data[TIME];
		fill(data, data + TIME, 0);
		
		int a, b, c;
		for(int i = 0; i < n; ++i){
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] ++;
			
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] --;
		}
	
		int ans = 0, acc = 0;
		for(int i = 0; i < TIME; ++i){
			acc += data[i] += data[i - 1];
			ans = max(ans, acc);
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		int imos[86410] = {};
		for (int i = 0; i < n; i++) {
			int a, b, c, d, e, f;
			scanf("%d:%d:%d", a, b, c);
			scanf("%d:%d:%d", d, e, f);
			imos[a * 3600 + b * 60 + c]++;
			imos[d * 3600 + e * 60 + f]--;
		}
		int ans = imos[0];
		for (int i = 1; i <= 86400; i++) {
			imos[i] += imos[i - 1];
			ans = max(ans, imos[i]);
		}
		cout << ans << endl;
	}
}

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

struct E {
    int t;
    char type;
    E(int t, char type) : t(t), type(type) {}
    bool operator<(const E& o) const {
        return (t == o.t ? type < o.type : t < o.t);
    }
};

int main() {
    int n;
    while (scanf("%d", &n), n != 0) {
        vector<E> es;
        for (int i = 0; i < n; i++) {
            int h, m, s;
            int _h, _m, _s;
            scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &_h, &_m, &_s);
            es.push_back(E(h*3600+m*60+s, 'o'));
            es.push_back(E(_h*3600+_m*60+_s, 'i'));
        }
        sort(es.begin(), es.end());
        int cnt = 0;
        int total = 0;
        for (int i = 0; i < es.size(); i++) {
            //cout << es[i].t << ':' << es[i].type << ' ';
            if (es[i].type == 'o') {
                cnt++;
                total = max(total, cnt);
            } else {
                cnt--;
            }
        }
        cout << total << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#define M  24*60*60
int table[M];

using namespace std;

int main(){
  int n;
  string str;
  while(cin >> n, n){
    for(int i = 0; i < M; i++){
      table[i] = 0;
    }
    for(int i = 0; i < n; i++){
      cin >> str;
      int s = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[s]++;
      cin >> str;
      int e = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[e]--;
    }
    for(int i = 1; i < M; i++){
      table[i] += table[i-1];
    }
    int max = 0;
    for(int i = 0; i < M; i++){
      if(max < table[i]) max = table[i];
    }
    cout << max << endl;
  }


}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};

int main()
{
	for(int n;scanf("%d",&n),n;){
		FenwickTree ft(86400);
		while(n--){
			int h[2],m[2],s[2];
			rep(i,2) scanf("%d:%d:%d",h+i,m+i,s+i);
			int b=h[0]*3600+m[0]*60+s[0];
			int e=h[1]*3600+m[1]*60+s[1];
			ft.AddRange(b,e,1);
		}
		int res=0;
		rep(i,86400)
			res=max(res,ft.Get(i));
		printf("%d\n",res);
	}
	
	return 0;
}