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 <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool isin(const T& x, const T& l, const T& r){ return l <= x and x < r; }
inline ostream& fcout(int n = 10){ return cout << fixed << setprecision(n); }
inline ostream& rcout(int n = 2){ return cout << right << setw(n); }
constexpr int64_t INF = numeric_limits<int64_t>::max();
constexpr int32_t INF32 = numeric_limits<int32_t>::max();
constexpr int64_t MOD = 1000000007LL;
constexpr double PI = 3.14159265358979323846264338327950288;
constexpr double EPS = 1e-10;


int32_t main(){
    int n;
    while(cin >> n, n){
        vector<int> s(24*3600+10);
        rep(i, 0, n){
            string t1, t2;
            stringstream ss;
            cin >> t1 >> t2;
            replace(ALL(t1), ':', ' ');
            replace(ALL(t2), ':', ' ');
            ss << t1;
            int a, b, c;
            ss >> a >> b >> c;
            s[a*3600+b*60+c]++;
            ss.clear();
            ss << t2;
            ss >> a >> b >> c;
            s[a*3600+b*60+c]--;
        }
        int ans = 1;
        rep(i, 0, 24*3600){
            s[i+1] += s[i];
            chmax(ans, s[i]);
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int t[90000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {
		int n;
		cin >> n;
		if(!n) break;

		rep(i,0,90000) t[i] = 0;
		rep(i,0,n) {
			int sH,sM,sS,eH,eM,eS;
			scanf("%d:%d:%d %d:%d:%d", &sH, &sM, &sS, &eH, &eM, &eS);
			t[sH*3600 + sM*60 + sS]++;
			t[eH*3600 + eM*60 + eS]--;
		}

		int ans = -1, tmp = 0;
		rep(i,0,90000) {
			tmp += t[i];
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int toInt(char c)
{
	//cout << c << endl;
	return (int)(c - '0');
}
int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		vector<pair<int, int> > input;
		for (int i = 0; i < n; i++)
		{
			char line[15];
			pair<int, int> newRange;
			cin >> line;
			int hour = toInt(line[0]) * 10 + toInt(line[1]);
			int minute = toInt(line[3]) * 10 + toInt(line[4]);
			int second = toInt(line[6]) * 10 + toInt(line[7]);
			newRange.first = hour * 60 * 60 + minute * 60 + second;
			char line2[15];
			cin >> line2;
			hour = toInt(line2[0]) * 10 + toInt(line2[1]);
			minute = toInt(line2[3]) * 10 + toInt(line2[4]);
			second = toInt(line2[6]) * 10 + toInt(line2[7]);
			newRange.second = hour * 60 * 60 + minute * 60 + second;
			input.push_back(newRange);
		}

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

		vector<pair<int, int> > out[10000 + 1];
		int vectorIndex = -1;
		for (int i = 0; i < n; i++)
		{
			bool flag = false;
			for (int j = 0; j < vectorIndex; j++)
			{
				bool f = false;
				for (int k = 0; k < out[j].size(); k++)
				{
					if (input.at(i).first >= out[j].at(k).first && input.at(i).first < out[j].at(k).second ||
						input.at(i).second > out[j].at(k).first && input.at(i).second <= out[j].at(k).second)
					{
						f = true;
						break;
					}
				}

				if (!f)
				{
					out[j].push_back(input.at(i));
					flag = true;
					break;
				}
			}

			if (!flag)
			{
				out[++vectorIndex].push_back(input.at(i));
			}
		}
		cout << vectorIndex << endl;
	}
	return 0;
}