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++:  #define _USE_MATH_DEFINES
 #define INF 100000000
 #include <iostream>
 #include <cstdio>
 #include <sstream>
 #include <cmath>
 #include <cstdlib>
 #include <algorithm>
 #include <queue>
 #include <stack>
 #include <limits>
 #include <map>
 #include <string>
 #include <cstring>
 #include <set>
 #include <deque>
 #include <bitset>
 #include <list>

 using namespace std;

 typedef long long ll;
 typedef pair <int,int> P;

 static const double EPS = 1e-8;

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

int main(){
   int n;
   while(~scanf("%d",&n)){
     if(n==0) break;

     vector<int> departure_times;
     vector<int> arrive_times;
     for(int i=0;i<n;i++){
       //hh:mm:ss hh:mm:ss 
       int hh[2],mm[2],ss[2];
       scanf("%d:%d:%d %d:%d:%d",
	     hh,mm,ss,hh+1,mm+1,ss+1);
       int departure_second = hour2second(hh[0],mm[0],ss[0]);
       int arrive_second = hour2second(hh[1],mm[1],ss[1]);

       departure_times.push_back(departure_second);
       arrive_times.push_back(arrive_second);
     }
     sort(departure_times.begin(),departure_times.end());
     sort(arrive_times.begin(),arrive_times.end());
     
     int dep_idx = 0;
     int res = 0;
     
     for(int arv_idx=0;arv_idx<arrive_times.size();arv_idx++){
       int count = 0;
       while(dep_idx<departure_times.size()){
	 if(departure_times[dep_idx] < arrive_times[arv_idx]){
	   count++;
	   dep_idx++;
	   res = max(res,count);
	 }
	 else{
	   break;
	 }
       }
     }
     printf("%d\n",res);
   }
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#define INF 1 << 28
using namespace std;

typedef pair<int,int> P;

int main ()
{
    int n;
    while (cin >> n, n) {
        string str1, str2;
        vector<P> time;
        while (n--) {
            cin >> str1 >> str2;
            for (int i = 0; i < str1.size(); i++) {
                if (str1[i] == ':') {
                    str1[i] = str2[i] = ' ';
                }
            }

            stringstream ss1, ss2;
            ss1 << str1;
            ss2 << str2;

            int t1, t2, t3;
            ss1 >> t1 >> t2 >> t3;
            int s = t1 * 60 * 60 + t2 * 60 + t3;
            ss2 >> t1 >> t2 >> t3;
            int e = t1 * 60 * 60 + t2 * 60 + t3;

            time.push_back(P(s,1));
            time.push_back(P(e,-1));
        }

        sort(time.begin(), time.end());

        int res = 0, MAX = 0;
        for (int i = 0; i < time.size(); i++) {
            res += time[i].second;
            MAX = max(MAX, res);
        }

        cout << MAX << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

vector<int> imos(100000, 0);

bool solve() {
    int n;
    cin >> n;
    if(n == 0) {
        return false;
    }
    imos.assign(100000, 0);
    for(int i = 0; i < n; i++) {
        string s, e;
        cin >> s >> e;
        // print(s.substr(0, 2), s.substr(3, 2), s.substr(6, 2));
        int l = stoi(s.substr(0, 2)) * 3600 + stoi(s.substr(3, 2)) * 60 +
                stoi(s.substr(6, 2));
        int r = stoi(e.substr(0, 2)) * 3600 + stoi(e.substr(3, 2)) * 60 +
                stoi(e.substr(6, 2));
        imos[l]++;
        imos[r]--;
    }
    for(int i = 1; i < 100000; i++) {
        imos[i] += imos[i - 1];
    }
    print(*max_element(ALL(imos)));
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        if(!solve()) {
            break;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<vector<int>, bool> PVIB;

int main() {
	int N;
	while( cin >> N, N ) {
		vector<int>T( 3 );
		priority_queue<PVIB, vector<PVIB>, greater<PVIB>>que;
		for( size_t i = 0; i < N; i++ ) {
			for( int j = 1; j >= 0; j-- ) {
				char c;
				cin >> T[0] >> c >> T[1] >> c >> T[2];
				que.push( make_pair( T, j ) );
			}
		}
		int now = 0, ans = 0;
		while( que.size() ) {
			auto X = que.top(); que.pop();
			if( X.second ) {
				now++;
				ans = max( now, ans );
			} else {
				now--;
			}
		}
		cout << ans << endl;
	}
}