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>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

ll sec(string S){
    ll h = (S[0] - '0') * 10 + S[1] - '0';
    ll m = (S[3] - '0') * 10 + S[4] - '0';
    ll s = (S[6] - '0') * 10 + S[7] - '0';
    return h * 3600 + m * 60 + s;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    while(true){
        cin >> N;
        if(N == 0)break;
        vector<ll> TL(86400);
        string from,to;
        rep(i,N){
            cin >> from >> to;
            TL[sec(from)]++;
            TL[sec(to)]--;
        }
        ll ans = 0;
        rep(i,86399LL){
            TL[i + 1] += TL[i];
        }
        rep(i,86400LL){
            chmax(ans,TL[i]);
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  vector<int> st;
  vector<int> fi;
  int n,t;
  int c,m;
  string T;
  while(1){
    c=0;
    m=0;
    st.erase(st.begin(),st.end());
    fi.erase(fi.begin(),fi.end());
    //
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> T;
      t=(T[0]-'0')*36000+(T[1]-'0')*3600+(T[3]-'0')*600+(T[4]-'0')*60+(T[6]-'0')*10+T[7]-'0';
      st.push_back(t);
      cin >> T;
      t=(T[0]-'0')*36000+(T[1]-'0')*3600+(T[3]-'0')*600+(T[4]-'0')*60+(T[6]-'0')*10+T[7]-'0';
      fi.push_back(t);
    }
    sort(st.begin(),st.end());
    sort(fi.begin(),fi.end());
    int i1=0,i2=0;
    while(1){
      if(st[i1]<fi[i2]){
	i1++;
	c++;
	m=max(m,c);
	if(i1==n)break;
      }
      else{
	i2++;
	c--;
	if(i2==n)break;
      }
    }
    cout << m << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;
int main(){
  while(1){
  	int n;
  	int s[10100];
  	int e[10100];
  	cin >> n;
  	if(n==0) break;
  	rep(i,n*2){
  		string str;
  		cin >> str;
  		
  		//??????????????°????????????
  		int hh = (char(str[0])-'0')*10+char(str[1])-'0';
  		int mm = (char(str[3])-'0')*10+char(str[4])-'0';
  		int ss = (char(str[6])-'0')*10+char(str[7])-'0';
  		// cout << hh << "mm" << mm << "ss"<<ss << endl;
  		int time = hh*3600+mm*60+ss;
  		if(i%2==0) s[i/2] = time;
  		else e[i/2] = time;
  	}
  	sort(s,s+n);
  	sort(e,e+n);
  	int sp = 0;
  	int ep = 0;
  	int ans = 0;
  	int tm = 0;
  	rep(i,n*2){
  		if(sp!=n&&(ep==n||s[sp]<e[ep])){
  			ans++;
  			sp++;
  			// cout << "a";
  		}else{
  			ans--;
  			ep++;
  			// cout << "b";
  		}
  		tm = max(tm,ans);
  		// cout <<endl << "tm:" <<tm << endl;
  	}
  	cout << tm << endl;

  }
  return 0;
}