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>
using namespace std;

typedef long long ll;

ll f(string s){
    string s1,s2,s3;
    s1 = s.substr(0,2);
    s2 = s.substr(3,2);
    s3 = s.substr(6,2);

    int hh = stoi(s1)*3600;
    int mm = stoi(s2)*60;
    int ss = stoi(s3)*1;

    return hh+mm+ss;
}

const int mx=23*3600+59*60+59;

void solve(int n){
    vector<int> v(mx+10,0);
    for(ll i=0;i<n;i++){
        string s1,s2;
        cin >> s1 >> s2;
        ll s=f(s1);
        ll t=f(s2);
        v[s]++;
        v[t]--;
    }
    for(int i=1;i<mx+10;i++){
        v[i] = v[i] + v[i-1];
    }
    int ans = -1;
    for(int i=0;i<mx+10;i++){
        ans = max(ans,v[i]);
        if(v[i] == 6)  cout << i << endl;
    }
    cout << ans << endl;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        map<string,int> mp;
        REP(i, n) {
            string s, t; cin >> s >> t;
            ++mp[s], --mp[t];
        }

        int ans = 0, cnt = 0;
        for (auto &tp : mp) {
            cnt += tp.second;
            chmax(ans, cnt);
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> P;


int times[10010][2];
int train[10010];

int main(){
		int n;
		while(true){
				vector<pair<int,int> > times;
				cin >> n;
				if(n == 0)break;
				for(int i = 0;i < n;i++){
						int a1,a2,a3,b1,b2,b3;
						scanf("%d:%d:%d %d:%d:%d",&a1,&a2,&a3,&b1,&b2,&b3);
						int a = a3 + a2*100 + a1*10000,b = b3 + b2*100 + b1*10000;
						times.push_back(P(b,a));
				}
				sort(times.begin(),times.end());
				vector<int> train;
				train.push_back(0);
				for(int i = 0;i < n;i++){
						int ban=-1,mintime = 1000000;
						for(int j = 0;j < train.size();j++){
								int diff = times[i].second - train[j];
								if(diff >= 0 && diff < mintime){
										mintime = diff;
										ban = j;
								}
						}
						if(ban == -1){
								train.push_back(times[i].first);
						}else{
								train[ban] = times[i].first;
						}
				}
				cout << train.size() << endl;
		}
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
const int MAX = 100100;

int calctime(string s) {
    int hh, mm, ss;
    hh = (s.at(0)-'0') * 10 + (s.at(1)-'0');
    mm = (s.at(3)-'0') * 10 + (s.at(4)-'0');
    ss = (s.at(6)-'0') * 10 + (s.at(7)-'0');
    return hh*3600 + mm*60 + ss;
}

int main() {
    while(1) {
        cin >> n;
        if(n == 0) break;
        vector<int> timer(MAX, 0);
        for(int i = 0; i < n; ++i) {
            string fins, sins;
            cin >> fins >> sins;
            int ftime = calctime(fins); int stime = calctime(sins);
            timer.at(ftime)++;
            timer.at(stime)--;
        }

        for(int i = 0; i < 100000; ++i) timer.at(i+1) += timer.at(i);
        int ans = 0;
        for(int i = 0; i < 100000; ++i) chmax(ans, timer.at(i));
        cout << ans << endl;
    }
}