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>

using namespace std;

int read_time() {
    int h, m, s;
    cin >> h;
    cin.ignore(1);
    cin >> m;
    cin.ignore(1);
    cin >> s;
    cin.ignore(1);
    return 3600*h+60*m+s;
}

int main() {
    int n, time;
    int count = 0;
    int max_count = 0;
    int table[24*3600+1];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<24*3600+1; i++) {
            table[i] = 0;
        }
        for (int i=0; i<n; i++) {
            time = read_time();
            table[time] += 1;
            time = read_time();
            table[time] -= 1;
        }
        for (int i=0; i<24*3600+1; i++) {
            count += table[i];
            max_count = max(count, max_count);
        }
        cout << max_count << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
using namespace std;
/*
3
05:47:15 09:54:40
12:12:59 12:13:00
16:30:20 21:18:53
6
00:00:00 03:00:00
01:00:00 03:00:00
02:00:00 03:00:00
03:00:00 04:00:00
03:00:00 05:00:00
03:00:00 06:00:00
0
 */
int strtotime(string str){
	int hour = stoi(str.substr(0,2));
	int minute = stoi(str.substr(3,2));
	int second = stoi(str.substr(6,2));
	return(hour*3600+minute*60+second);
}

int main(int argc, char* argv[]){
	int n;
	vector<vector<string>> strarray;
	vector<int> answers;
	while(1){
		char tmp[100];
		scanf("%s", tmp);
		string str = tmp;
		if(str=="0") break;
		n = stoi(str);
		vector<tuple<int, int>> timearray;
		for(int i=0; i<n;i++){
			scanf("%s", tmp);
			string str1 = tmp;
			int start=strtotime(str1);
			scanf("%s", tmp);
			string str2 = tmp;
			int end=strtotime(str2);
			tuple<int, int> times = make_tuple(start, end);
			timearray.push_back(times);
		}
		sort(timearray.begin(), timearray.end());
		for(int i=0; i<n; i++){
//			printf("%d %d\n", get<0>(timearray[i]), get<1>(timearray[i]));
		}
		vector<int> train;
		train.push_back(0);
		int answer=1;
		for(int i=1; i<n; i++){
			bool flag=true;
			for(int j=0; j<(int)train.size(); j++){
				if(get<0>(timearray[i])>=get<1>(timearray[train[j]])){
//					printf("%d %d\n", get<0>(timearray[i]), get<1>(timearray[train[j]]));
					train[j] = i;
					flag=false;
					break;
				}
			}
			if(flag){
				train.push_back(i);
				for(int j=0; j<(int)train.size(); j++){
//				printf("input %d-%d %d\n", i,j, train[j]);
				}
				answer++;
			}
		}
		//			answers.push_back(timearray[0][0]);
		answers.push_back(answer);
		//		}
	}
	for(int i=0; i<(int)answers.size(); i++){
		printf("%d\n", answers[i]);
	}


	return 0;
}

/*
17
06:29:57 16:50:58
10:09:29 13:15:10
00:44:54 17:56:18
22:41:06 22:49:38
15:38:18 20:34:49
05:29:50 07:49:22
10:05:07 19:16:07
16:24:46 22:55:23
15:59:49 21:50:02
03:03:25 04:43:01
16:59:19 21:40:48
22:10:01 22:42:14
16:52:37 21:53:40
09:36:38 10:10:44
12:47:47 14:09:22
09:41:52 19:41:01
02:09:53 09:56:06
0
 */

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    pii v[10000];
    string s;
    rep(i,n){
      int a,b;
      cin>>s;
      a=(s[0]-'0')*10+(s[1]-'0');
      a*=60;
      a+=(s[3]-'0')*10+(s[4]-'0');
      a*=60;
      a+=(s[6]-'0')*10+(s[7]-'0');
      cin>>s;
      b=(s[0]-'0')*10+(s[1]-'0');
      b*=60;
      b+=(s[3]-'0')*10+(s[4]-'0');
      b*=60;
      b+=(s[6]-'0')*10+(s[7]-'0');
      v[i].first=a;
      v[i].second=b; 
   }
    sort(v,v+n);
    priority_queue<int> q;
    q.push(-v[0].second);
    loop(i,1,n){
      if(q.top()>=-v[i].first)q.pop();
      q.push(-v[i].second);
    }
    cout<<q.size()<<endl;
  }
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
#define max_t 24 * 60 * 60

int main(){
    int n;
    while( cin >> n, n ){
        int list[max_t] = {};
        while( n-- ){
            int d_h, d_m, d_s;      // the departure time
            int a_h, a_m, a_s;      // the arrival time
            //cin >> d_h >> ":" >> d_m >> ":" >> d_s;
            //cin >> a_h >> ":" >> a_m >> ":" >> a_s;
            scanf("%d:%d:%d", &d_h, &d_m, &d_s );
            scanf("%d:%d:%d", &a_h, &a_m, &a_s );
            int s, e;
            s = d_h * 60 * 60 + d_m * 60 + d_s;
            e = a_h * 60 * 60 + a_m * 60 + a_s;
            cout << s << " " << e << endl;
            for( int i = s + 1; i < e; i++ ){
                list[i]++;
            }
        }
        int max = 0;
        for( int i = 0; i < max_t; i++ ){
            if( max < list[i] ) max = list[i];
        }
        cout << max << endl;
    }
}