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>

using namespace std;

typedef struct{
	int start,end;
	bool labelFlag;
}jikan;

int jikanShori(int h,int m,int s){
	return h*3600+m*60+s;
}

int main(){
	int n,cnt;
	int h,m,s;
	jikan interval[10000];
	
	for(int i=0;i<10000;i++){
		interval[i].start=0;
		interval[i].end=0;
		interval[i].labelFlag=false;
	}
	while(cin>>n,n){
		cnt=1;
		for(int i=0;i<10000;i++){
			interval[i].start=0;
			interval[i].end=0;
		}
		
		for(int i=0;i<n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].start=jikanShori(h,m,s);
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].end=jikanShori(h,m,s);
		}
		
		for(int i=0;i<n;i++){
			if(!interval[i].labelFlag){
				interval[i].labelFlag=true;
				for(int j=i+1;j<n;j++){
					if(interval[i].end>=interval[j].start && 
									!interval[j].labelFlag){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
		}
		
		cout<<cnt<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

int N;

int input() {
  string S;
  cin >> S;
  int h, m, s;
  h = (S[0] - '0') * 10 + (S[1] - '0');
  m = (S[3] - '0') * 10 + (S[4] - '0');
  s = (S[6] - '0') * 10 + (S[7] - '0');
  return h * 3600 + m * 60 + s;
}

int main(void) {
  while(cin >> N, N) {
    pii T[20000];
    REP(i, 0, N) {
      T[i * 2] = pii(input(), 1);
      T[i * 2 + 1] = pii(input(), 0);
    }

    sort(T, T + N * 2);

    // REP(i, 0, N * 2) {
    //   cout << T[i].fi << " " << T[i].se << endl;
    // }
    // cout << endl;

    int ans = 0, cnt = 0;
    REP(i, 0, N * 2) {
      if(T[i].se == 0) cnt--;
      if(T[i].se == 1) cnt++;
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define MAX 24*60*60

int main(){

  int train[MAX];
  int N;

  while(1){

    cin >> N;
    if(N == 0) break;
    int ans = 0;
    for(int i = 0 ; i < MAX ; i++){
      train[i] = 0;
    }    

    int h1,m1,s1,h2,m2,s2;
    char tmp;

    for(int i = 0; i < N ; i++){
    
      cin  >> h1 >> tmp >> m1 >> tmp >> s1 >> h2 >> tmp >> m2 >> tmp >> s2;
      //  cout << h1 << " " << m1 << " " << s1 << " " << h2 << " " << m2 << " " << s2 << endl;
      //    cout << "train[2:59:59] train[3:00:00] = " << train[3*60*60 -1] << " " << train[3*60*60] << endl;


      //列車を増やすとき
      if(train[s1 + 60*m1 + 60*60*h1] <= 0){
	ans++;
	for(int i = 0 ; i < s1 + 60*m1 + 60*60*h1 ;i++){
	  train[i]++;
	} 
	for(int i = s2 + 60*m2 + 60*60*h2 ; i < MAX ;i++){
	  train[i]++;
	} 
      } 
      //足りているとき
      else{
	for(int i =  s1+60*m1+60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	  if(train[i] != 0) train[i]--;
	} 
      }
    }
    cout << ans << endl;
  }  
  return 0;
}

C++: /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int rui[240001];

int main() {
    int N; cin >> N;
    vector<int> ans;
    while(N != 0){
        vector<P> retu(N);
        for(int i = 0;i<240001;i++)rui[i] = 0;
        for(int i = 0;i<N;i++){
            string S,T;cin >> S >> T;
            string h = S.substr(0,2);
            string m = S.substr(3,2);
            string s = S.substr(6,2);
            int Hour = stoi(h)*10000;
            int Min = stoi(m)*100;
            int Sec = stoi(s);
            retu.at(i).first = Hour+Min+Sec;

            h = T.substr(0,2);
            m = T.substr(3,2);
            s = T.substr(6,2);
            Hour = stoi(h)*10000; Min = stoi(m)*100; Sec = stoi(s);
            retu.at(i).second = Hour+Min+Sec;
        }
        int count = 0;
        for(int i = 0;i<N;i++){
            rui[retu.at(i).first]++;
            rui[retu.at(i).second]--;
        }
        for(int i = 1;i<240001;i++){
            rui[i] += rui[i-1];
            count = max(count,rui[i]);
        }
        ans.push_back(count);
        cin >> N;
    }

    for(int i = 0;i<ans.size();i++)cout << ans.at(i) << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}