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<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ma=0;
    int time_table[30][65][65];
    for(int i=0;i<n;i++){
      int a,b,c;
      scanf("%d:%d:%d",&a,&b,&c);
      time_table[a][b][c]++;
      scanf("%d:%d:%d",&a,&b,&c);
      time_table[a][b][c]--;
    }
    int cnt=0;
    for(int i=0;i<=24;i++){
      for(int j=0;j<=60;j++){
	for(int k=0;k<=60;k++){
	  cnt+=time_table[i][j][k];
	  ma=max(ma,cnt);
	}
      }
    }
    cout<<ma<<endl;
  }
  return 0;
}

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

int main()
{
	while (true)
	{
		int n;cin >> n;
		if (n==0) break;
		vector<int> time(86500,0);
		string start,stop;
		for (int i=0;i<n;i++)
		{
			cin >> start >> stop;
			int time1=((start[0]-'0')*10+(start[1]-'0'))*3600+((start[3]-'0')*10+(start[4]-'0'))*60+((start[6]-'0')*10+start[7]-'0');
			int time2=((stop[0]-'0')*10+(stop[1]-'0'))*3600+((stop[3]-'0')*10+(stop[4]-'0'))*60+((stop[6]-'0')*10+stop[7]-'0');
			time[time1]++;
			time[time2]--;
		}
		for (int i=0;i<86499;i++)
		{
			time[i+1]+=time[i];
		}
		int ans=0;
		for (int i=0;i<86500;i++) ans=max(ans,time[i]);
		cout << ans << endl;
	}
	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 = -1;
    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 <iostream>
#include <vector>

#define TIME 24 * 60 * 60

using namespace std;

int main(){
	int n;
	
	while(1){
		cin >> n;
		if(n == 0)
			break;
		
		int h_dep, m_dep, s_dep, h_arr, m_arr, s_arr;
		vector <int> dep(n), arr(n);
		for(int i = 0; i < n; i++){
			scanf("%d:%d:%d %d:%d:%d", &h_dep, &m_dep, &s_dep, &h_arr, &m_arr, &s_arr);
			dep[i] = s_dep + m_dep * 60 + h_dep * 60 * 60;
			arr[i] = s_arr + m_arr * 60 + h_arr * 60 * 60;
		}
		vector <int> train(TIME, 0);
		for(int i = 0; i < n; i++){
			train[dep[i]]++;
			train[arr[i]]--;
		}
		int max = 0;
		for(int i = 1; i < TIME; i++){
			train[i] += train[i - 1];
			if(train[i] > max)
				max = train[i];
		}
		
		cout << max << endl;
	}
	
	return 0;
}

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

using namespace std;

struct DATA{
  int time;
  int log;
};

int GetTime(const string);
int AtoiString(const string);
bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, count, _count;
  string s, t;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> s >> t;
      _data.time = GetTime(s);
      _data.log = 1;
      data.push_back(_data);
      _data.time = GetTime(t);
      _data.log = -1;
      data.push_back(_data);
    }

    sort(data.begin(), data.end(), Compare);

    for(i=0, count=0, _count=0; i<data.size(); ++i){
      _count += data[i].log;
      if(count < _count) count = _count;
    }
    cout << count << endl;
    data.clear();
  }
  return 0;
}

int GetTime(const string str){
  string s, t, u;
  copy(str.begin(), str.begin()+2, back_inserter(s));
  copy(str.begin()+3, str.begin()+5, back_inserter(t));
  copy(str.begin()+6, str.end(), back_inserter(u));
  return AtoiString(s) * 3600 + AtoiString(t) * 60 + AtoiString(u);
}

int AtoiString(const string s){
  int i, x, d;
  for(i=s.size()-1, x=0, d=1; i>=0; --i, d*=10)
    x += ((s[i] - 48) * d);
  return x;
}

bool Compare(const DATA& x, const DATA& y){
  return x.time < y.time;
}