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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int t(int h,int m,int s){
	return h*60*60+m*60+s;
}
int main(){
	int n;
	while(cin>>n,n){
		vector<pii> times(n);
		REP(i,n){
			int h1,m1,s1,h2,m2,s2;
			scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
			times[i]=make_pair(t(h1,m1,s1),t(h2,m2,s2));
		}
		sort(ALL(times));
		priority_queue<int,vi,greater<int> > q;
		REP(i,n){
			if(q.empty())
				q.push(times[i].second);
			else
			{
				if(q.top()<=times[i].first){
					q.pop();
					q.push(times[i].second);
				}else{
					q.push(times[i].second);
				}
			}
		}
		cout<<q.size()<<endl;
	}
}

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

const int time_max = 86410;

int imos[time_max];

int time_split(char Tens_Place,char One_Place){
    int return_num;
    string s = {Tens_Place, One_Place};
    stringstream ss;
    ss << s;
    ss >> return_num;
    return return_num;
}

int main() {

    while(1) {

        int n;

        cin >> n;

        if(n==0){
            break;
        }

        for(int i=0; i<time_max; i++){
            imos[i] = 0;
        }

        for (int i = 0; i < n; i++) {
            string start, goal;
            cin >> start >> goal;
            int h, m, s;
            h = time_split(start[0], start[1]);
            m = time_split(start[3], start[4]);
            s = time_split(start[6], start[7]);
            imos[h * 60 * 60 + m * 60 + s]++;
            h = time_split(goal[0], goal[1]);
            m = time_split(goal[3], goal[4]);
            s = time_split(goal[6], goal[7]);
            imos[h * 60 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < time_max; i++) {
            imos[i] += imos[i - 1];
        }

        int ans = 0;

        for (int i = 0; i < time_max; i++) {
            ans = max(ans, imos[i]);
        }

        cout << ans << endl;

    }

    return 0;
}

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

struct E {
    int t;
    char type;
    E(int t, char type) : t(t), type(type) {}
    bool operator<(const E& o) const {
        return (t == o.t ? type < type : t < o.t);
    }
};

int main() {
    int n;
    while (scanf("%d", &n), n != 0) {
        vector<E> es;
        for (int i = 0; i < n; i++) {
            int h, m, s;
            int _h, _m, _s;
            scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &_h, &_m, &_s);
            es.push_back(E(h*3600+m*60+s, 'o'));
            es.push_back(E(_h*3600+_m*60+_s, 'i'));
        }
        sort(es.begin(), es.end());
        int cnt = 0;
        int total = 0;
        for (int i = 0; i < es.size(); i++) {
            if (es[i].type == 'o') {
                cnt++;
                total = max(total, cnt);
            } else {
                cnt--;
            }
        }
        cout << total << endl;
    }
    return 0;
}

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

////////////////////////////////

int main()
{
    const int day = 24 * 60 * 60;
    vector<int> imos;
    int n;
    while(cin >> n,n){
        imos.assign(day + 1, 0);
        for(int i=0;i<n;i++){
            string s,t;
            cin >> s >> t;
            int ts = stoi(s.substr(0,2)) * 60 * 60 + stoi(s.substr(3,2)) * 60 + stoi(s.substr(6,2));
            int tt = stoi(t.substr(0,2)) * 60 * 60 + stoi(t.substr(3,2)) * 60 + stoi(t.substr(6,2));
            // cerr << s << " " << t << " " << ts << " " << tt << endl;
            imos[ts]++;imos[tt]--;
        }
        for(int i=0;i<day;i++){
            imos[i+1] += imos[i];
        }
        int res = 1;
        for(int i=0;i<day+1;i++){
            res = max(res,imos[i]);
        }
        // cerr << imos[10800] << endl;
        cout << res << endl;
    }

}