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<vector>
#include<string>
#include<algorithm>

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

using namespace std;

int main()
{

  int n ;
  int Sh,Sm,Ss;
  int Eh,Em,Es;
  int max = -1;
  int Sindex,Eindex;
  vector<int> time(240001);


  while(cin >> n && n!=0)
    {

      fill(time.begin(),time.end(),0);

      rep(i,n){

        scanf("%d:%d:%d %d:%d:%d",&Sh,&Sm,&Ss,&Eh,&Em,&Es);

        Sindex = Sh*10000 + Sm*100 + Ss;
        Eindex = Eh*10000 + Em*100 + Es;

        time[Sindex]++;
        time[Eindex]--;

      }

      rep(i,time.size())
        if(i > 0)
          time[i] += time[i-1];

      rep(i,time.size())
        if(max < time[i])
          max = time[i];

      cout << max << endl;

    }

  return 0;

}

C++: #include<iostream>
#include<cstdlib>
using namespace std;

int Hen(char s,char t){
  return ((s-'0')*10+(t-'0'));
}
int main()
{
  string s,f;
  int n,a,b,max,T[86401]={};
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      a=(Hen(s[0],s[1])*3600+Hen(s[3],s[4])*60+Hen(s[6],s[7]));
      b=(Hen(f[0],f[1])*3600+Hen(f[3],f[4])*60+Hen(f[6],f[7]));
      for(int j=a;j<b;j++)T[j]++;
    }
    max=0;
    for(int i=0;i<86401;i++)if(max<T[i])max=T[i];
    cout<<max<<endl;
  }
  return 0;
}

C++: // AOJ 2013
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef pair<int,int> P;

const int NMAX = 10008;

int n;
vector<P> diagram;
bool used[NMAX];

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

P read_schedule() {
  int h, m, s, H, M, S;
  scanf("%d:%d:%d %d:%d:%d",  &h,&m,&s, &H,&M,&S);

  int t = second(h,m,s), T = second(H,M,S);
  return make_pair(t, T);
}

int solve() {
  int trains = 0;
  while (true) {
    int _i = 0;
    while (_i < n and used[_i]) { _i++; }
    if (_i == n) break;
    used[_i] = true;
    trains++;
    int last = diagram[_i].second;
    for (int i = _i; i < n; i++) {
      if (used[i] or diagram[i].first < last) {
        continue;
      } else {
        used[i] = true;
        last = diagram[i].second;
      }
    }
  }
  return trains;
}

void init() {
  diagram.clear();
  REP(i, n) {
    used[i] = false;
  }
}

int main() {
  while (cin >> n and n) {
    init();
    REP(i, n) {
      diagram.push_back(read_schedule());
    }
    cout << solve() << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int,int> P;

int main(){
    int n;
    
    while(cin >> n,n){
        vector<P> v;
        int sh,sm,ss,th,tm,ts,Max=0,Min = 100000,totals,totalt;
        for(int i = 0 ; i < n ; i++){
            scanf("%d:%d:%d" ,&sh , &sm , &ss);
            totals = sh*3600+sm*60+ss;
            Min = min(Min,totals);
            v.push_back(P(totals,1));
            scanf("%d:%d:%d" ,&th , &tm , &ts);
            totalt = th*3600+tm*60+ts;
            v.push_back(P(totalt,-1));
            Max = max(Max,totalt);
        }
        sort(v.begin(),v.end());
        
        int ans = 0,tmp = 0;
        for(int i = Min ; i <= Max ; i++){
            if(v[i].first){
                tmp += v[i].second;
                ans = max(ans,tmp);
            }
        }
        cout << ans+1 << endl;
    }
    
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while(cin>>n,n) {
    priority_queue<PP, vector<PP>, greater<PP> > Q;
    int ans = 0;
    FOR(i,0,n) {
      int h1, m1, s1;
      int h2, m2, s2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
      if(Q.empty()) {
        ans++;
        Q.push(PP(h2, P(m2, s2)));
      } else {
        PP pp = Q.top();
        int h = pp.first;
        int m = pp.second.first;
        int s = pp.second.second;
        if(h1 == h) {
          if(m1 == m) {
            // ?????????
            if(s1 >= s) {
              Q.pop();
              Q.push(PP(h2, P(m2, s2)));
            } else {
              ans++;
              Q.push(PP(h2, P(m2, s2)));
            }
          } else {
            // ?????????
            if(m1 >= m) {
              Q.pop();
              Q.push(PP(h2, P(m2, s2)));
            } else {
              ans++;
              Q.push(PP(h2, P(m2, s2)));
            }
          }
        } else {
          if(h1 >= h) {
            Q.pop();
            Q.push(PP(h2, P(m2, s2)));
          } else {
            ans++;
            Q.push(PP(h2, P(m2, s2)));
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}