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>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);

    while(true){
        ll n; cin >> n;
        if(n == 0){
            break;
        }
        vector<ll> imos(240000);
        rep(i, n){
            string start, end; cin >> start >> end;
            ll num = 100000;
            ll start_num = 0, end_num = 0;
            rep(j, 8){
                if(j % 3 == 2){
                    j++;
                }
                start_num += (ll)(start[j] - 48) * num;
                end_num += (ll)(end[j] - 48) * num;
                num /= 10;
            }
            imos[start_num]++;
            imos[end_num]--;
        }
        
        ll ans = 0;
        rep(i, 240000){
            if(i > 0){
                imos[i] += imos[i-1];
            }
        }
        rep(i, 240000){
            if(imos[i] > ans){
                ans = imos[i];
            }
        }

        cout << ans << endl;

    }
    

}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

int cnt[86400];

int main() {
    int n;
    while( scanf("%d", &n), n ) {
        memset( cnt, 0, sizeof(cnt) );
        rep(i,n) {
            int sh, sm, ss, eh, em, es;
            scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &eh, &em, &es);
            int st = sh*3600+sm*60+ss;
            int et = eh*3600+em*60+es;
            for(int t=st; t<et; t++) {
                cnt[t]++;
            }
        }
        int maxi = 0;
        rep(i, 86400) {
            if( maxi < cnt[i] )
                maxi = cnt[i];
        }
        cout << maxi << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
const ll key = 998244353;
int main() {
	int n;
	while (cin >> n, n) {
		string s, t; int tim[100000] = {};
		for (int i = 0; i < n; i++) {
			cin >> s >> t;
			int sta = 0; int las = 0;
			sta += 36000 * (s[0] - '0');
			sta += 3600 * (s[1] - '0');
			sta += 600 * (s[3] - '0');
			sta += 60 * (s[4] - '0');
			sta += 10 * (s[6] - '0');
			sta += s[7] - '0';
			las += 36000 * (t[0] - '0');
			las += 3600 * (t[1] - '0');
			las += 600 * (t[3] - '0');
			las += 60 * (t[4] - '0');
			las += 10 * (t[6] - '0');
			las += t[7] - '0';
			tim[sta+1]++;
			tim[las+1]--;
		}
		for (int i = 1; i < 100000; i++) {
			tim[i] += tim[i - 1];
		}
		int ma = 0;
		for (int i = 0; i < 100000; i++) {
			ma = max(ma, tim[i]);
		}
		cout << ma << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

int toTimeSecond(const string& s) {
    int ret = atoi(s.substr(0, 2).c_str()) * 3600;
    ret += atoi(s.substr(3, 2).c_str()) * 60;
    ret += atoi(s.substr(6, 2).c_str());
    return ret;
}

void Main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        vector<int> imos(86410 * 2, 0);
        for (int i = 0; i < n; ++i) {
            string depS, arrS;
            cin >> depS >> arrS;
            int dep = 2 * toTimeSecond(depS);
            int arr = 2 * toTimeSecond(arrS);
            imos[dep] += 1;
            imos[arr - 1] -= 1;
        }
        for (int i = 1; i < imos.size(); ++i) {
            imos[i] += imos[i - 1];
        }
        int ans = *max_element(imos.begin(), imos.end());
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}