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 <algorithm>
#include <vector>
using namespace std;
typedef  pair<int,int>P;
int main(){
  int n;
  vector<P>ve;
  while(cin >> n,n){
    ve.clear();
    int t,s;
    for(int i = 0 ; i < n ; i++ ){
      int a,b,c;
      char ch;
      cin >> a >> ch >> b >> ch >> c;
      s = a*3600 + b*60 + c;
      cin >> a >> ch >> b >> ch >> c;
      t = a*3600 + b*60 + c;
      ve.push_back(P(t,s));
    }

    sort(ve.begin(),ve.end());

    int ans = 1,p = 0;
    for(int i = 0 ; i < n-1 ; i++ ){
      if(ve[i].first > ve[i+1].second ){ans++;}
      if(ve[p].first <= ve[i].second && ans > 1 ){ans--;p++;}
    }
    cout << ans << endl;
  }
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int t(int h,int m,int s){
	return h*60*60+m*60+s;
}
int main(){
	int n;
	while(cin>>n,n){
		vector<pii> times(n);
		REP(i,n){
			int h1,m1,s1,h2,m2,s2;
			scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
			times[i]=make_pair(t(h1,m1,s1),t(h2,m2,s2));
		}
		sort(ALL(times));
		queue<pii> q;
		REP(i,n){
			if(q.empty())
				q.push(times[i]);
			else
			{
				if(q.front().second<=times[i].first){
					q.pop();
					q.push(times[i]);
				}else{
					q.push(times[i]);
				}
			}
		}
		cout<<q.size()<<endl;
	}
}

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

typedef pair<int,int> pii;

vector<pii>train;
const int H=60*60;
const int M=60;
const int S=1;
int unit[3]={H,M,S};

int getTime(string s){
  string tmp;
  int res=0;
  for(int i=0;i<3;i++){
    tmp=s.substr(3*i,2);
    int val=unit[i]*atoi(tmp.c_str());
    res+=val;
  }
  return res;
}

void makeEvent(string start,string arrival){
  int st=getTime(start);
  int at=getTime(arrival);
  train.push_back(make_pair(st,1));
  train.push_back(make_pair(at,0));
}

int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
    string start,arrival;
    cin>>start>>arrival;
    makeEvent(start,arrival);
    }
    int ans=0,tmp=0;
    sort(train.begin(), train.end());
    for(pii i:train){
      if(i.second==1){
	tmp++;
      }else{
	tmp--;
      }
      ans=max(tmp,ans);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    int *hatsu = new int[n];
    int *tyaku = new int[n];
    for (int i = 0; i < n; i++) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      hatsu[i] = (h * 60 + m ) * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tyaku[i] = (h * 60 + m ) * 60 + s;
    }

    vector<int> train;
    bool avail = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < train.size(); j++) {
        if (train[j] <= hatsu[i]) {
          avail = true;
          train[j] = tyaku[i];
          break;
        }
      }
      if (avail) {
        avail = false;
        continue;
      }
      train.push_back(tyaku[i]);
    }

    cout << train.size() << endl;
    train.clear();
  }
  return 0;
}

C++: //   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  while(true) {
    int n,ans=0;
    cin >> n;
    if(n==0) {
      return 0;
    }
    string s,g;
    int t[86500]={};
    for(int i=0; i<n; i++) {
      int x,y;
      cin >> s >> g;
      x=(stoi(s.substr(0,2)))*3600+(stoi(s.substr(3,2)))*60+stoi(s.substr(6,2));
      y=(stoi(g.substr(0,2)))*3600+(stoi(g.substr(3,2)))*60+stoi(g.substr(6,2));
      x++,y++;
      t[x]++,t[y]--;
    }
    for(int i=1; i<=86450; i++) {
      t[i]+=t[i-1];
      ans=max(ans,t[i]);
    }
    cout << ans << endl;
  }
}