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 rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int change(int h,int m,int s){
	return h*3600+m*60+s;
}

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		int sh,sm,ss,th,tm,ts,ans=0;
		vi d(86410);
		rep(i,0,n){
			scanf("%d:%d:%d %d:%d:%d",&sh,&sm,&ss,&th,&tm,&ts);
			d[change(sh,sm,ss)]++; d[change(th,tm,ts)]--;
		}
		rer(i,1,86400){
			d[i]+=d[i-1]; ans=max(ans,d[i]);
		}
		o(ans);
	}
}

C++: #include<iostream>
using namespace std;
typedef struct range Range;
struct range
{
	int start;
	int end;
};
int cti(char c)
{
	return c - '0';
}
int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		Range timeRange[10000 + 1];
		int ans = n;
		char time[10];
		for (int i = 0; i < n; i++)
		{
			Range range;
			cin >> time;
			int hour = (cti(time[0]) * 10) + (cti(time[1]));
			int minute = cti(time[3]) * 10 + cti(time[4]);
			int second = cti(time[6] * 10) + cti(time[7]);
			range.start = hour * 60 * 60 + minute * 60 + second;
			cin >> time;
			hour = (cti(time[0]) * 10) + (cti(time[1]));
			minute = cti(time[3]) * 10 + cti(time[4]);
			second = cti(time[6] * 10) + cti(time[7]);
			range.end = hour * 60 * 60 + minute * 60 + second;
			timeRange[i] = range;
		}

		for (int i = 0; i < n - 1; i++)
		{
			bool flag = false;
			for (int j = i + 1; j < n; j++)
			{
				if ((timeRange[i].start >= timeRange[j].start && timeRange[i].start < timeRange[j].end) || (timeRange[i].end > timeRange[j].start && timeRange[i].end < timeRange[j].end))
				{
					flag = true;
				}
			}

			if (!flag)ans--;
		}

		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int n, i, j, f[86400], time[3] = {3600,60,1}, h, m, s, c1, c2, max;
	while(1){
		scanf("%d%*c",&n);
		if(!n)
			break;
		memset(f,0,sizeof(f));
		for(i = 0;i < n;i++){
			scanf("%d%*c%d%*c%d",&h,&m,&s);
			c1 = h * time[0] + m * time[1] + s * time[2];
			scanf("%d%*c%d%*c%d",&h,&m,&s);
			c2 = h * time[0] + m * time[1] + s * time[2];
			for(j = c1;j < c2;j++) f[j]++;
		}
		max = -1;
		for(i = 0;i < 86400;i++)
			if(max < f[i]) max = f[i];
		printf("%d\n",max);
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int n) {
    vector<int> vec(1e5);
    REP(i, n) {
        int sh, sm, ss, th, tm, ts;
        scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
        int s = sh * 3600 + sm * 60 + ss, t = th * 3600 + tm * 60 + ts;
        vec[s] += 1;
        vec[t + 1] -= 1;
    }

    REP(i, 1e5 - 1) {
        vec[i + 1] += vec[i];
    }

    int ans = 0;

    REP(i, 1e5) {
        ans = max(ans, vec[i]);
    }

    cout << ans << endl;

    return;
}

int main() {
    int n;
    while (cin >> n && n) {
        solve(n);
    }
    return 0;
}

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

short ss[90061];
short ee[90061];
int ans[10000];
int c = 0;

int ch2int(char c){
    return (int)c - (int)'0';
}

int st2int(string s){
    return (ch2int(s[0]) * 10 + ch2int(s[1])) * 3600 + (ch2int(s[3]) * 10 + ch2int(s[4])) * 60 + ch2int(s[6]) * 10 + ch2int(s[7]);
}

int main()
{
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        c++;
        int maxi = 0;
        vector<string> s(n, ""), e(n, "");
        for (int j = 0; j <= 90060; j++)
        {
            ss[j] = 0;
            ee[j] = 0;
        }
        for (int i = 0; i < n; i++)
        {
            cin >> s[i] >> e[i];
            ss[st2int(s[i])] = ss[st2int(s[i])] + 1;
            ee[st2int(e[i])] = ee[st2int(e[i])] + 1;
        }
        int count = 0;
        for (int j = 0; j <= 90060; j++)
        {
            count = count + ss[j];
            count = count - ee[j];
            if (maxi < count)
            {
                maxi = count;
            }
        }
        ans[c - 1] = maxi;
    }

    for(int k = 0; k < c; k++) cout << ans[k] << endl;

    return 0;
}