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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    for(;;){
        int n;
        cin >> n;
        if(n==0)break;
        int res = 0;
        int ans = 0;
        vector<pair<int,pair<int, pair<int, int> > > > hoge;
        for (int i=0; i<n; i++) {
            string s,g;
            cin >> s>>g;
            int sh,sm,ss,gh,gm,gs;
            sh = ((int)s[0]-(int)'0')*10+(int)s[1]-(int)'0';
            sm = ((int)s[3]-(int)'0')*10+(int)s[4]-(int)'0';
            ss = ((int)s[6]-(int)'0')*10+(int)s[7]-(int)'0';
            gh = ((int)g[0]-(int)'0')*10+(int)g[1]-(int)'0';
            gm = ((int)g[3]-(int)'0')*10+(int)g[4]-(int)'0';
            gs = ((int)g[6]-(int)'0')*10+(int)g[7]-(int)'0';
            hoge.push_back({sh,{sm,{ss,2}}});
            hoge.push_back({gh,{gm,{gs,1}}});
        }
        sort(hoge.begin(),hoge.end());
        for (int i=0; i<hoge.size(); i++) {
            if (hoge[i].second.second.second==1) {
                res++;
            }else{
                if (res>0) {
                    res--;
                }else{
                    ans++;
                }
            }
        }
        cout << ans <<endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}



int main() {
    while(true) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<int>s(90000,0);
        
        rep(i,n) {
            string start,arrived;
            cin >> start >> arrived;
            int hour = (start[0]-'0')*10+(start[1]-'0');
            hour *= 3600;
            int minute = (start[3]-'0')*10+(start[4]-'0');
            minute *= 60;
            int second = (start[6]-'0')*10+(start[7]-'0');
            s[hour+minute+second]++;
            
            hour = (arrived[0]-'0')*10+(arrived[1]-'0');
            hour *= 3600;
            minute = (arrived[3]-'0')*10+(arrived[4]-'0');
            minute *= 60;
            second = (arrived[6]-'0')*10+(arrived[7]-'0');
            s[hour+minute+second]--;
            
        }
        rep(i,87000) {
            s[i+1] += s[i];
        }
        
        int ans = 0;
        rep(i,87000) {
            ans = max(ans,s[i]);
        }
        cout << ans << endl;
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int cumsum[60 * 60 * 24];
int to_sec(string S){
  return stoi(S.substr(0, 2)) * 60 * 60 + stoi(S.substr(3, 2)) * 60 + stoi(S.substr(6,2));
}

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){
      break;
    }

    for(int i = 0; i < 60 * 60 * 24; i++){
      cumsum[i] = 0;
    }

    for(int i = 0; i < n; i++){
      string s1;
      string s2;
      cin >> s1 >> s2;
      cumsum[to_sec(s1)] ++;
      cumsum[to_sec(s2)] --;
    }

    for(int i = 1; i < 60 * 60 * 24; i++){
      cumsum[i] += cumsum[i - 1];
    }

    int ans = 0;
    for(int i = 0; i < 60 * 60 * 24; i++){
      ans = max(ans, cumsum[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>

#define secondMAX (23*60*60+59*60+59)
using namespace std;

int main(){

	int n;
	int h,m,s;
	char gav;
	int table[secondMAX+1];
	int max;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<=secondMAX;i++) table[i]=0;
		for(int i=0;i<n;i++){
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]+=1;
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]-=1;
		}
		for(int i=1;i<=secondMAX;i++) table[i]+=table[i-1];
		max=0;
		for(int i=0;i<=secondMAX;i++){
			if(max<table[i]) max=table[i];
		}

		cout<<max<<endl;
	}

	return 0;
}