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 <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX 86400

int main(){
  int n, t[MAX+1];
  while(cin >> n, n){
    memset(t, 0, sizeof(t));
    int H1, H2, M1, M2, S1, S2;
    for(int i = 0 ; i < n ; i++){
      scanf("%d:%d:%d %d:%d:%d", &H1, &M1, &S1, &H2, &M2, &S2);
      t[H1*3600+M1*60+S1]++, t[H2*3600+M2*60+S2]--;
    }
    int ans = 0;
    
    for(int i = 1 ; i <= MAX ; i++){
      t[i] += t[i-1];
      ans = max(ans, t[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<cstdio>

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int table[86400];

int convert2sec(int hh, int mm, int ss){
    return 3600*hh + 60*mm + ss;
}

int main(){
    int n;
    while(cin >> n && n != 0){
        REP(i,n){
            int hd, md, sd, ha, ma, sa;
            scanf("%d:%d:%d %d:%d:%d", &hd, &md, &sd, &ha, &ma, &sa);
            int dep_sec = convert2sec(hd,md,sd);
            int arr_sec = convert2sec(ha,ma,sa);
            table[dep_sec]++;
            table[arr_sec]--;
        }
        REP(i,86400){
            if(i>0) table[i] += table[i-1];
        }
        int m = 0;
        REP(i,86400){
            if(table[i] > m) m = table[i];
        }
        cout << m << endl;
    }
    return 0;
}

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

int ss(int a, int b, int c)
{
  return a * 3600 + b * 60 + c;
}

int N;
int main()
{
loop:
  int a, b, c, d, e, f;
  vector<pair<int, int>> v;

  scanf("%d", &N);
  if(!N)
    return 0;
  for(int i = 0; i < N; i++)
  {
    scanf("%d:%d:%d %d:%d:%d", &a, &b, &c, &d, &e, &f);
    v.push_back(make_pair(ss(a, b, c), ss(d, e, f)));
  }

  int ans = 0, x = 0;
  priority_queue<int, vector<int>, greater<int>> q;
  q.push(1000000000);
  sort(v.begin(), v.end());
  for(int i = 0; i < v.size(); i++)
  {
    while(v[i].first >= q.top())
    {
      q.pop();
      x++;
    }
    if(!x)
      ans++;
    q.push(v[i].second);
  }
  printf("%d\n", ans);
  goto loop;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int imos[24*60*60];

int time2num(string t)
{
	int h, m, s;
	h = (t[0] - '0') * 10 + t[1] - '0';
	m = (t[3] - '0') * 10 + t[4] - '0';
	s = (t[6] - '0') * 10 + t[7] - '0';
	m += h * 60;
	s += m * 60;
	return s;
}

int main()
{
	int N;
	cin >> N;
	while (N) {
		rep(i, N) {
			string s1, s2;
			cin >> s1 >> s2;
			int l = time2num(s1);
			int r = time2num(s2);
			imos[l]++;
			imos[r]--;
		}
		int ma = imos[0];
		reps(i, 1, 24*60*60) {
			imos[i] += imos[i-1];
			ma = max(ma, imos[i]);
		}
		rep(i, 24*60*60) {
			imos[i] = 0;
		}
		cout << ma << endl;
		cin >> N;
	}
}

C++: #include <stdio.h>
#include <iostream>
using namespace std;

int main() {
  int n;
  int h1, m1, s1;
  int h2, m2, s2;

  while(cin >> n, n!=0){
    int res	= 0;
    signed int time[24*3600+60*60+60] = {0};
    for(int i = 0; i < n; i++) {
      scanf("%d:%d:%d", &h1, &m1, &s1);
      scanf("%d:%d:%d", &h2, &m2, &s2);
      time[h1*3600+m1*60+s1]++;
      time[h2*3600+m2*60+s2]--;
    }

    for(int i = 0; i < 24*3600+60*60+60; i++) {
      time[i+1]+=time[i];
      if(res < time[i+1])
        res = time[i+1];
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
 
using namespace std;

int main(void){

  int n;
  int sum[3000];
  int h,m,s;

  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            
            scanf("%02d:%02d:%02d",&h,&m,&s);
            sum[h*60*60+m*60+s]++;
            scanf("%02d:%02d:%02d",&h,&m,&s);
            sum[h*60*60+m*60+s]--;
        }
        int res=sum[0];
        for(int i=0;i<=24*60*60;i++){
            sum[i+1]+=sum[i];
            res=max(res,sum[i+1]);
        }
        printf("%d\n",res);
    }
    return 0;
}