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 lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int a[100000];
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    lp(i,100000){
      a[i]=0;
    }
    lp(i,n){
      int start=0;
      int memo=0;
      char x,y,z;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*3600;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*60;
      memo=0;
      cin>>x>>y;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo;
      a[start]++;
      start=0;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*3600;
      memo=0;
      cin>>x>>y>>z;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo*60;
      memo=0;
      cin>>x>>y;
      memo+=(x-'0')*10;
      memo+=y-'0';
      start+=memo;
      a[start]--;
    }
    int maxs=0;
    for(int i=1;i<90000;i++){
      a[i]+=a[i-1];
      maxs=max(maxs,a[i]);
    }
    cout<<maxs<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int sec()
{
	int h, m, s;
	scanf("%d:%d:%d", &h, &m, &s);
	m += h * 60;
	return s + m * 60;
}
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		vector<pint> t;
		while (n--)
		{
			t.push_back(pint(sec(), 1));
			t.push_back(pint(sec(), -1));
		}
		t.push_back(pint(1 << 25, 0));
		sort(all(t));

		int res = 0;
		int s = 0, p = -1;
		foreach (it, t)
		{
			if (it->first != p)
				max_swap(res, s);
			s += it->second;
			p = it->first;
		}

		printf("%d\n", res);
	}
}

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

int i, n;
int h, m, s;
int osaki[90000];
int ans;
int main (){
        while(cin >> n && n > 0){
                ans = 0;
                for (i = 0; i <= 90000; i++) osaki[i] = 0;
                for (i = 0; i < n; i++){
                        scanf("%02d:%02d:%02d", &h, &m, &s);
                        osaki[3600 * h + 60 * m + s]++;
                        scanf("%02d:%02d:%02d", &h, &m, &s);
                        osaki[3600 * h + 60 * m + s]--;
                }
                ans = osaki[0];
                for (i = 0; i < 24 * 3600; i++){
                        osaki[i + 1] += osaki[i];
                        ans = max(ans, osaki[i + 1]);
                }
                cout << ans << endl;
        }
        return 0;
}

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

void read(int& s0, int& s1)
{
  char d;
  int h0, m0, h1, m1;
  cin >> h0 >> d >> m0 >> d >> s0;
  cin >> h1 >> d >> m1 >> d >> s1;
  s0 += 3600*h0 + 60*m0;
  s1 += 3600*h1 + 60*m1;
}

int main()
{
  int n;
  while (cin >> n && n != 0) {
    vector<pair<int,int> > entries(n);
    for (int i = 0; i < n; i++) {
      read(entries[i].first, entries[i].second);
    }
    sort(entries.begin(), entries.end());

    priority_queue<int, vector<int>, greater<int> > q;
    q.push(entries.front().second);
    for (int i = 1; i < n; i++) {
      if (q.top() > entries[i].first) {
        q.push(entries[i].second);
      } else {
        q.pop();
        q.push(entries[i].second);
      }
    }
    cout << q.size() << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	int n;
	while(cin >> n, n){
		map<ll, int> mp;
		rep(i, n){
			ll h, m, s;
			scanf("%ld:%ld:%ld", &h, &m, &s);
			mp[h*10000+m*100+s]++;
			scanf("%ld:%ld:%ld", &h, &m, &s);
			mp[h*10000+m*100+s]--;
		}
		
		int cnt = 0;
		int ans = 0;
		for(auto it : mp){
			cnt += it.second;
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}

	return 0;
}