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 <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = (int)1e4 + 4;
int s[MAX_N], t[MAX_N];

string omit_colon (string s ){
	int n = s.length();
	rep (i, n ){
		if (s[i] == ':' ) s[i] = ' ';
	} // end rep

	return s;
}

int time2s (string s ){
	int h, m, sec;
	stringstream ss (s );
	ss >> h >> m >> sec;

	return (h*60*60 + m*60 + sec );
}

int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	while (cin >> N, N ){
		memset (s, 0, sizeof (s ) );
		memset (t, 0, sizeof (t ) );
		rep (i, N ){
			string ss = "", tt = ""; cin >> ss >> tt;
			ss = omit_colon (ss );
			tt = omit_colon (tt );
 			s[i] = time2s (ss );
			t[i] = time2s (tt );
		} // end rep

		queue<int> que;
		que.push (t[0] );
		int res = que.size();
		for (int i = 1; i < N; i++ ){
			while (!que.empty() && que.front() <= s[i]   ){
				que.pop();
			} // end while

			if (que.empty() || que.front() > s[i] ){
				que.push (t[i] );
				res = max (res, (int)que.size() );
			} // end if
//			cerr << "que_size: " << (int)que.size() << endl;
		} // end for
		cout << res << endl;

	} // end while
		
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main()
{
	int n;
	while (cin >> n) {
		if (n == 0)return 0;
		P a[105000];

		string s1, s2;
		for (int i = 0; i < n; i++) {
			cin >> s1 >> s2;
			int hour1 = (int)(s1[0] - '0') * 10 + (int)(s1[1] - '0');
			int min1= (int)(s1[3] - '0') * 10 + (int)(s1[4] - '0');
			int sec1 = (int)(s1[6] - '0') * 10 + (int)(s1[7] - '0');
			int hour2 = (int)(s2[0] - '0') * 10 + (int)(s2[1] - '0');
			int min2 = (int)(s2[3] - '0') * 10 + (int)(s2[4] - '0');
			int sec2 = (int)(s2[6] - '0') * 10 + (int)(s2[7] - '0');
			a[i].first = 3600 * hour1 + 60 * min1 + sec1;
			a[i].second = 3600 * hour2 + 60 * min2 + sec2;
		}
		sort(a, a + n);
		/*
		for (int i = 0; i < n; i++) {
			cout << a[i].first <<" "<< a[i].second << endl;
		}
		*/

		priority_queue<int,vector<int>,greater<int> >que;
		que.push(a[0].second);
		int cnt = 1;
		for (int i = 1; i < n; i++) {
			
			if (que.empty()) {
				cnt++;
				que.push(a[i].second);
			}
			else {
				int k = que.top();
				if (a[i].first >= k) {
					que.pop();
					que.push(a[i].second);
					continue;
				}
				else {
					cnt++;
					que.push(a[i].second);
				}
			}
		}
		cout << cnt << endl;

	}

	return 0;
}

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

using namespace std;
int N;
string In[10000], Out[10000];
int main() {
  while (cin >> N && N > 0) {
    for (int i=0; i<N; ++i) {
      cin >> Out[i] >> In[i];
      sort(In, In+N);
      sort(Out, Out+N);
      //    for (int i=0; i<N; ++i)
      //      cout << Out[i] << ' ' << In[i] << endl;
    }

    int p=0, taiki=0, train=0;
    for (int i=0; i<N; ++i) {
      while (p<N && In[p] <=Out[i]) {
	taiki++;
	p = p+1;
      }
      if (taiki > 0) taiki = taiki - 1;
      else train = train + 1;
    }
    cout << train << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
  int n, ans;
  string s, t;
  map<string, int> D, A;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      cin >> s >> t;
      ++D[s];
      ++A[t];
    }
    ans = 0;
    for (map<string, int>::iterator itr = D.begin(); itr != D.end(); ++itr) ans = max(ans, itr->second);
    for (map<string, int>::iterator itr = A.begin(); itr != A.end(); ++itr) ans = max(ans, itr->second);
    cout << ans << endl;
  }
  return 0;
}

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

const int H=60*60;
const int M=60;
const int S =1;
int train[24*H+1];

int main(){
  int n;
  while(cin>>n,n){
    memset(train,0,sizeof(train));
    for(int i=0;i<n;i++){
      string start,arrival;
      int st=0,at=0;
      cin>>start>> arrival;
      string tmp;
      for(int i=0;i<8;i+=3){
	tmp=start.substr(i,2);
	if(i==0){
	  st+=H*atoi(tmp.c_str());
	}else if(i==1){
	  st+=M*atoi(tmp.c_str());
	}else{
	  st+=S*atoi(tmp.c_str());
	}
	  tmp=arrival.substr(i,2);
	if(i==0){
	  at+=H*atoi(tmp.c_str());
	}else if(i==1){
	  at+=M*atoi(tmp.c_str());
	}else{
	  at+=S*atoi(tmp.c_str());
	}
      }
      for(int j=st;j<at;j++)train[j]++;
    }
    int ans=0;
    for(int i=0;i<=60*60*24;i++){
      ans=max(ans,train[i]);
      //cout << train[i] << " ";
    }
    cout << ans << endl;
  }
  return 0;
}