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 <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
#include <map>
#include <cstdio>
using namespace std;
int N;
int t[86400];
int main() {
   while(cin >> N, N){
       int t[86400+1]={0};
       for(int i=0; i<N; ++i){
           int h, m, s;
           int start, end;
            scanf("%d:%d:%d", &h, &m, &s);
            start = h*3600+m*60+s;
            scanf("%d:%d:%d", &h, &m, &s);
            end = h*3600 + m*60 + s;
            for(int i=start; i<end; ++i) t[i]++;
           
       }
       int ans = 0;
       for(int i=0; i<86400+1; ++i) ans = max(ans, t[i]);
       cout << ans << endl;
   }
   return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 30
#define S second
#define F first
using namespace std;

int main(){
  int n;
  char str1[16], str2[16];
  while(scanf("%d", &n) && n){
    vector<pair<int, int> >time(n);
    rep(i, n){
      int a = 0, b = 0;
      scanf("%s%s", str1, str2);
      a += ((str1[0]-'0')*10+(str1[1]-'0')) *60*60;
      b += ((str2[0]-'0')*10+(str2[1]-'0')) *60*60;
      a += ((str1[3]-'0')*10+(str1[4]-'0')) *60;
      b += ((str2[3]-'0')*10+(str2[4]-'0')) *60;
      a += ((str1[6]-'0')*10+(str1[7]-'0'));
      b += ((str2[6]-'0')*10+(str2[7]-'0'));
      time[i] = make_pair(a, b);
    }
    int res = 0;
    rep(i, n){
      int c = 0;
      rep(j, n) if((time[i].F < time[j].F && time[j].F < time[i].S) ||
		   (time[j].F < time[i].F && time[i].F < time[j].S) ||
		   (time[i].F == time[j].F && time[i].S == time[j].S)) c++;
      res = max(res, c);
    }
    printf("%d\n", res);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};

int main(){
  while(true){
    int n; cin>>n;
    if(n==0) return 0;
    vector<int> t(400000);
    rep(i,n){
      string s,e; cin>>s>>e;
      int t0=0,t1=0;
      t0+=(s[0]-'0')*36000+(s[1]-'0')*3600+(s[3]-'0')*600+(s[4]-'0')*60+(s[6]-'0')*10+(s[7]-'0');
      t1+=(e[0]-'0')*36000+(e[1]-'0')*3600+(e[3]-'0')*600+(e[4]-'0')*60+(e[6]-'0')*10+(e[7]-'0');
      t[t0]++; t[t1]--;
    }
    rep(i,370000) t[i+1]+=t[i];
    int ans=0;
    rep(i,370000) ans=max(ans,t[i]);
    cout<<ans<<endl;
  }
}

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

#define mk(x, y) make_pair(x, y)
#define X first
#define Y second
#define SEC(h, m, s) (h * 3600 + m * 60 + s)

using namespace std;

typedef pair<int, int> pii;

int main( void )
{
	int T[10000];
	pii S[10000];
	int n;
	while(cin >> n, n) {
		fill(T, T+n, 0);
		memset(S, 0, sizeof(S));
		int ans = 0;
		for(int i=0; i < n; ++i) {
			int h1, m1, s1, h2, m2, s2;
			scanf("%d:%d:%d", &h1, &m1, &s1);
			scanf("%d:%d:%d", &h2, &m2, &s2);
			S[i].X = SEC(h1, m1, s1);
			S[i].Y = SEC(h2, m2, s2);
		}
		sort(S, S+n);
		for(int i=0; i < n; ++i) {
			for(int j=0; j < n; ++j) {
				if(T[j] <= S[i].X) {
					T[j] = S[i].Y;
					ans = max(ans, j+1);
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}