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>
#define MAX 86400
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n,l,a;
	char s[20];
	vector<int> table;
	while(cin>>n,n){
		int max=0;
		for(int i=0;i<MAX;i++)
		table.push_back(0);
		for(int i=0;i<n;i++){
			cin>>s;
			l=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			cin>>s;
			a=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			for(int j=l+1;j<=a;j++){
			table[j]++;
			if(table[j]>max)
			max=table[j];
			}
		}
		cout<<max<<endl;
		table.clear();
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int g(string s){

  int h = (s[0]-'0')*10+s[1]-'0';
  h *=3600;
  int m = (s[3]-'0')*10+s[4]-'0';
  m *=60;
  int t = (s[6]-'0')*10+s[7]-'0';

  return (h+m+t);
}

void f(int n){
  vector<P> v;

  rep(i,n){
    string a,b;
    cin>>a>>b;
    int t = g(a);
    int r = g(b);
    v.push_back(P(r,t));
  }
  sort(v.begin(),v.end());

  int ans=0;
  int t=0;
  bool e[1000000]={};
  while(t<n){
    ans++;
    int s = 0;
    rep(i,n){
      if(s<=v[i].second&&!e[i]){
        s = v[i].first;
        e[i] = true;
        t++;
      }
    }
  }

    cout<<ans<<endl;
}


int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    f(n);
  }

  return 0;
}

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

bool comp(vector<int> a, vector<int> b){
    return a[0] < b[0];
}

int time(string str){  //入力形式に対して秒を返す

    //hh:mm:ss
    int s = (int)str[7] - '0' + ((int)str[6] - '0')*10;
    int m = (int)str[4] - '0' + ((int)str[3] - '0')*10;
    int h = (int)str[1] - '0' + ((int)str[0] - '0')*10;
    
    return s + 60*m + 3600*h;
}

int main(){

    while(1){

        int n; cin >> n;
        if(!n) break;

        vector<vector<int> > train(2*n, vector<int> (2));
        

        for(int i = 0; i < n; i++){
            string s;
            cin >> s;
            train[i][0] = 2*time(s) + 1;
            train[i][1] = 1;
            cin >> s;
            train[n + i][0] = 2*time(s) - 1;
            train[n + i][1] = -1;
        }

        sort(train.begin(), train.end(), comp);

        /*for(int i = 0; i < 2*n; i++){
            cout << train[i][0] << " " << train[i][1] << endl;
        }*/

        int count = 0;
        int ans = 0;

        for(int i = 0; i < 2*n; i++){
            if(train[i][1] == 1) count++;
            else count--;
            ans = max(ans, count);
        }

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

C++: #include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

int N;

int input() {
  string S;
  cin >> S;
  int h, m, s;
  h = (S[0] - '0') * 10 + (S[1] - '0');
  m = (S[3] - '0') * 10 + (S[4] - '0');
  s = (S[6] - '0') * 10 + (S[7] - '0');
  return h * 3600 + m * 60 + s;
}

int main(void) {
  while(cin >> N, N) {
    pii T[20000];
    REP(i, 0, N) {
      T[i * 2] = pii(input(), 1);
      T[i * 2 + 1] = pii(input(), 0);
    }

    sort(T, T + N * 2);

    int ans = 0, cnt = 0;
    REP(i, 0, N * 2) {
      if(T[i].se == 0) cnt--;
      if(T[i].se == 1) cnt++;
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(void){
  int n;
  while(cin>>n,n){
    vector<pair<int,int> > timetable(n);
    for(int i=0;i<n;++i){
      int sh,sm,ss,eh,em,es;
      scanf("%d:%d:%d",&sh,&sm,&ss);
      scanf("%d:%d:%d",&eh,&em,&es);
      timetable[i]=make_pair(sh*3600+sm*60+ss,eh*3600+em*60+es);
    }
    int ans=0;
    for(int i=0,sti,eti;i<n;++i){
    	int cnt=1;
      sti=timetable[i].first;
      eti=timetable[i].second;
      for(int j=0,stj,etj;j<n;++j){
        if(i==j)continue;
        stj=timetable[j].first;
        etj=timetable[j].second;
        if((sti<=stj&&stj<=eti)||(sti<=etj&&etj<=eti)||(stj<=sti&&eti<=etj)||(sti<=stj&&etj<=eti))++cnt;
      }
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll ttol(string time) {
  ll res=0;
  res+=(int(time[0]-'0')*10+int(time[1]-'0'))*60*60;
  res+=(int(time[3]-'0')*10+int(time[4]-'0'))*60;
  res+=(int(time[6]-'0')*10+int(time[7]-'0'));
  return res;
}

int main() {
  while(1) {
    ll n;
    cin >> n;
    if(n==0) {
      break;
    }
    priority_queue<ll,vector<ll>,greater<ll>> s;
    priority_queue<ll,vector<ll>,greater<ll>> e;
    for(ll i=0;i<n;i++) {
      string temps,tempe;
      cin >> temps >> tempe;
      s.push(ttol(temps));
      e.push(ttol(tempe));
    }
    ll ready=0;
    ll ans=0;
    for(ll i=0;i<24*60*60;i++) {
      while(e.size()&&e.top()==i) {
        ready++;
        e.pop();
      }
      while(s.size()&&s.top()==i) {
        if(ready>0) {
          ready--;
        }
        else {
          ans++;
        }
        s.pop();
      }
    }
    cout << ans << endl;
  }
}