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;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e12)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n;
    while(cin >> n){
        if(n==0) break;
        int h1, m1, s1, h2, m2, s2;
        int maxv=0, minv=3600*24;
        vector<int> v(60*60*24, 0);
        rep(i, n){
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            // printf("%d:%d:%d %d:%d:%d\n", h1, m1, s1, h2, m2, s2);
            int st = h1*3600 + m1*60 + s1;
            int ed = h2*3600 + m2*60 + s2;
            chmin(minv, st); chmax(maxv, ed);
            v[st] += 1;
            v[ed] += -1;
        }
        int ans = 0;
        rep(i, 86400) v[i+1] += v[i];
        FOR(i, minv, maxv+1) chmax(ans, v[i]);
        pr(ans);
    }
    return 0;}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int a[86401];

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

int main(){
    int N;
    while(std::cin >> N, N){
        std::fill(a, a+86401, 0);
        REP(i, N){
            int h1, m1, s1, h2, m2, s2;
            scanf("%2d%*c%2d%*c%2d %2d%*c%2d%*c%2d", &h1, &m1, &s1, &h2, &m2, &s2);

            int t1 = toSeconds(h1, m1, s1),
                t2 = toSeconds(h2, m2, s2);

            a[t1]++;
            a[t2]--;
        }

        int res = a[0];
        FOR(i, 1, 86401){
            a[i] += a[i-1];
            res = std::max(res, a[i]);
        }

        std::cout << res << std::endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<int> imos(24 * 60 * 60 + 1);
    while (n--) {
      int h, m, s;
      char $;
      cin >> h >> $ >> m >> $ >> s;
      imos[h * 60 * 60 + m * 60 + s] += 1;
      cin >> h >> $ >> m >> $ >> s;
      imos[h * 60 * 60 + m * 60 + s] -= 1;
    }
    int res = 0;
    for (int t = 0; t < 24 * 60 * 60; ++t) {
      imos[t + 1] += imos[t];
      res = max(res, imos[t]);
    }
    cout << res << '\n';
  }
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
int r[86401], n, h1, m1, s1, h2, m2, s2;
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break;
		for (int i = 0; i <= 86400; i++) r[i] = 0;
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d %02d:%02d:%02d", &h1, &m1, &s1, &h2, &m2, &s2);
			r[h1 * 3600 + m1 * 60 + s1]++;
			r[h2 * 3600 + m2 * 60 + s2]--;
		}
		int ret = 0, sum = 0;
		for (int i = 0; i <= 86400; i++) {
			sum += r[i];
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		priority_queue<int,vector<int>,greater<int> > q;
		int leave,arrive;
		for(int i = 0; i < n; ++i)
		{
			int h,m,s; 
			scanf(" %d:%d:%d",&h,&m,&s);
			leave=h*3600+m*60+s;
			
			scanf(" %d:%d:%d",&h,&m,&s);
			arrive=h*3600+m*60+s;
			if(q.empty()||leave<q.top())
			{
				q.push(arrive);
			}
			else 
			{
				q.pop();
				q.push(arrive);
			}
		}	
		cout<<q.size()<<endl;
	}
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 10000
#define TOSEC(h,m,s) ((h)*3600+(m)*60+(s))
struct Train{
	int st;
	int ed;
	bool operator<(const Train &t)const{
		return ed < t.ed;
	}
};
bool CompTrainForSort(const Train &a, const Train &b){
	return a.st < b.st;
}
int main(){
	while(true){
		Train vt[MAX];
		unsigned int ans = 0;
		int n;
		priority_queue< Train > pq;
		scanf("%d", &n);

		if( n == 0 ) break;

		for(int i = 0; i < n; ++i){
			int sh,sm,ss;
			int eh,em,es;
			Train t;
			
			scanf("%02d:%02d:%02d %02d:%02d:%02d",
				&sh,&sm,&ss,
				&eh,&em,&es);
			t.st = TOSEC(sh,sm,ss);
			t.ed = TOSEC(eh,em,es);

			vt[i] = t;
		}

		sort( vt, vt + n, CompTrainForSort );
		
		for(int i = 0; i < n; ++i){
			if( pq.size() == 0 )
				pq.push( vt[i] );
			else{
				Train tt = pq.top();
				if( tt.ed <= vt[i].st )
					pq.pop();
				else
					pq.push( vt[i] );
			}
			ans = max(ans, pq.size());
		}

		printf("%d\n", ans);
	}
	return 0;
}