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>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

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

    int n;
    while(cin>>n&&n){
        int ti[24*60*60*2]={};
        for(int i=0;i<n;i++){
            int t=0;
            string s;
            cin>>s;
            t+=(s[0]-'0')*10*60*60;
            t+=(s[1]-'0')*60*60;
            t+=(s[3]-'0')*10*60;
            t+=(s[4]-'0')*60;
            t+=(s[6]-'0')*10;
            t+=(s[7]-'0');
            ti[t]++;
            t=0;
            cin>>s;
            t+=(s[0]-'0')*10*60*60;
            t+=(s[1]-'0')*60*60;
            t+=(s[3]-'0')*10*60;
            t+=(s[4]-'0')*60;
            t+=(s[6]-'0')*10;
            t+=(s[7]-'0');
            ti[t]--;
        }
        int ans=ti[0];
        for(int i=1;i<=24*60*60;i++){
            ti[i]+=ti[i-1];
            ans=max(ans,ti[i]);
        }
        cout<<ans<<endl;
    }
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<int> ans;

void solve(int N, int M) {
    int r; cin >> r;
    vector<vector<int>> imos(M+1, vector<int>(1261));
    for (int i = 0; i < r; i++) {
        int t, n, m, s; cin >> t >> n >> m >> s;
        if (s) imos[m][t]++;
        else imos[m][t]--; 
    }
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j < 1261; j++) {
            imos[i][j] += imos[i][j-1];
        }
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int s, e, m; cin >> s >> e >> m;
        int cnt = 0;
        for (int j = s; j < e; j++) {
            if (imos[m][j]) cnt++;
        }
        ans.push_back(cnt);
    }
}

int solve(int N) {
    vector<int> imos(60*60*24+1);
    for (int i = 0; i < N; i++) {    
        string h, m, s;
        getline(cin, h, ':');
        getline(cin, m, ':');
        getline(cin, s, ' ');
        int H = stoi(h);
        int M = stoi(m);
        int S = stoi(s);
        imos[H*60*60+M*60+S]++;
        getline(cin, h, ':');
        getline(cin, m, ':');
        getline(cin, s);
        H = stoi(h);
        M = stoi(m);
        S = stoi(s);
        imos[H*60*60+M*60+S]--;
    }
    int ret = 0;
    for (int i = 1; i < imos.size(); i++) {
        imos[i] += imos[i-1];
        ret = max(imos[i], ret);
    }
    return ret;
}

int main(void) {
    int N;
    vector<int> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}

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

int main() {
	int n, data[6];
	int max_mini = 0;
	
	while (cin >> n) {
		if (n == 0)break;
		int x[86401] = { 0 };
		for (int i = 0; i < n; i++) {
			scanf("%d:%d:%d %d:%d:%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5]);
			x[data[0] * 3600 + data[1] * 60 + data[2]]++;
			x[data[3] * 3600 + data[4] * 60 + data[5]]--;
			if (max_mini < data[3] * 3600 + data[4] * 60 + data[5])
				max_mini = data[3] * 3600 + data[4] * 60 + data[5];
		}
		int ans = 0, cnt = 0;
		for (int i = 0; i <= max_mini; i++) {
			cnt += x[i];
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
	
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int MAX = 1000005;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		vector<int> s(MAX);
		rep(i, n) {
			int h1, m1, s1;
			int h2, m2, s2;
			scanf("%d:%d:%d", &h1, &m1, &s1);
			scanf("%d:%d:%d", &h2, &m2, &s2);
			int t1 = h1 * 60 * 60 + m1 * 60 + s1;
			int t2 = h2 * 60 * 60 + m2 * 60 + s2;
			s[t1]++;
			s[t2]--;
		}
		rep(i, MAX) s[i + 1] += s[i];
		int mx = 0;
		rep(i, MAX) mx = max(mx, s[i]);
		cout << mx << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(v) v.begin(), v.end()
using i64 = int64_t;
using P = pair<i64,i64>;


int main(){
    int N;
    while(cin >> N, N != 0){
        string S;
        vector<int> timeTable(24*60*60, 0);

        rep(i,N){
            rep(k,2){
                cin >> S;
                int h = stoi(S.substr(0,2));
                int m = stoi(S.substr(3,2));
                int s = stoi(S.substr(6,2));

                s += m*60 + h*60*60;

                int stamp = (k == 0 ? 1 : -1);
                timeTable[s] += stamp;
            }
        }
        for(int i = 1; i < 24*60*60; i++){
            timeTable[i] += timeTable[i-1];
        }

        cout << *max_element(all(timeTable)) << endl;
    }
}