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++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N;
	while(cin >> N && N)
	{
		vector< pair<int,int> > train( N, {0,0} );
	
		int hh,mm,ss;
		rep(nth,N)
		{
			scanf("%d:%d:%d",&hh,&mm,&ss);
			train[nth].first = (hh*10000) + (mm*100) + (ss);

			scanf("%d:%d:%d",&hh,&mm,&ss);
			train[nth].second = (hh*10000) + (mm*100) + (ss);
		}

		vector<int> route(240000,0);
		rep(i,train.size()){
			REP(j,train[i].first, train[i].second){
				route[j] += 1;
			}
		}

		cout << *max_element(ALL(route)) << endl;

}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
int h, m, s;
int t, u;

int main()
{
  while(cin >> n, n){
    priority_queue<pii> que;
    rep(i, n){
      scanf("%d:%d:%d", &h, &m, &s);  t = 3600 * h + 60 * m + s;
      scanf("%d:%d:%d", &h, &m, &s);  u = 3600 * h + 60 * m + s;
      que.push(mp(-t, -1));
      que.push(mp(-u, 1));
    }

    int res = 0;
    int cnt = 0;
    while(!que.empty()){
      pii p = que.top();  que.pop();
      cnt += p.second;
      minup(res, cnt);
    }

    cout << -res << endl;
  }

  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;


struct st{
	bool flag;
	int b;
	int e;
	
	st(int b, int e) : b(b), e(e), flag(true) {}
	
	bool operator< (const st &a)const{
		return (*this).e < a.e;
	}
};

bool check(vector<st> &a){
	for(int i=0;i<a.size();i++){
		if(a[i].flag == true) return true;
	}
	return false;
}

bool solve(){
	
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<st> vst;
	for(int k=0;k<n;k++){
		int in[2] = {0};
		for(int i=0;i<2;i++){
			int h,m,s;
			char c[2];
			cin>> h>> c[0]>> m>> c[1]>> s;
			in[i] = 3600 * h + 60 * m + s;
		}
		st a(in[0], in[1]);
		vst.push_back(a);
	}
	sort(vst.begin(), vst.end());
	//for(int k=0;k<n;k++) cout<< vst[k].b<< " "<< vst[k].e<< endl;
	
	int ans = 1;
	int t = 0;
	while(check(vst)){
		int f = false;
		for(int i=0;i<vst.size();i++){
			if(vst[i].flag == true && t <= vst[i].b){
				vst[i].flag = false;
				t = vst[i].e;
				f = true;
				break;
			}
		}
		if(!f){
			t = 0;
			ans++;
		}
	}
	
	cout<< ans<< endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

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

#define MAX 24*60*60+1

int main(){

  int train[MAX];
  int N;

  while(1){

    cin >> N;
    if(N == 0) break;
    int ans = 0;
    for(int i = 0 ; i < MAX ; i++){
      train[i] = 0;
    }    

    int h1,m1,s1,h2,m2,s2;
    char tmp;

    for(int i = 0; i < N ; i++){
    
      cin  >> h1 >> tmp >> m1 >> tmp >> s1 >> h2 >> tmp >> m2 >> tmp >> s2;
      //  cout << h1 << " " << m1 << " " << s1 << " " << h2 << " " << m2 << " " << s2 << endl;
      //    cout << "train[2:59:59] train[3:00:00] = " << train[3*60*60 -1] << " " << train[3*60*60] << endl;


      //列車を増やすとき
      if(train[s1 + 60*m1 + 60*60*h1] <= 0){
	ans++;
	for(int i = 0 ; i < s1 + 60*m1 + 60*60*h1 ;i++){
	  train[i]++;
	} 
	for(int i = s2 + 60*m2 + 60*60*h2 ; i < MAX ;i++){
	  train[i]++;
	} 
      } 
      //足りているとき
      else{
	for(int i =  s1+60*m1+60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	  if(train[i] != 0) train[i]--;
	} 
      }
      //   cout << train[0] <<" "<< train[MAX-1] << endl;
    }
    cout << ans << endl;
  }  
  return 0;
}