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 <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
//#define int long long
using namespace std;
const int MOD = 1e9 + 7;
// const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int convert(string s) {
  int sum = 0;
  string t, u, v;
  t = s.substr(0, 2);
  u = s.substr(3, 2);
  v = s.substr(6, 2);
  sum += ((t[0] - '0') * 10 + (t[1] - '0')) * 3600;
  // cout << sum << ' ';
  sum += ((u[0] - '0') * 10 + u[1] - '0') * 60;
  // cout << sum << ' ';
  sum += (v[0] - '0') * 10 + v[1] - '0';
  // cout << sum << endl;
  return sum;
}

int main() {
  int n;
  while (cin >> n, n) {
    int times[1000006] = {};
    rep(i, n) {
      string s, e;
      cin >> s >> e;
      int start = convert(s);
      int end = convert(e);
      // cout << start << ' ' << end << endl;
      times[start] += 1;
      times[end] += -1;
    }
    rep(i, 1000000) times[i + 1] += times[i];
    int ans = 0;
    rep(i, 1000000) cmax(ans, times[i]);
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
	while(1){
		int n;
		int arrival[10000], leave[10000];

		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			int ah, am, as; //arrival
			int lh, lm, ls; //leave;

			scanf(" %d:%d:%d %d:%d:%d", &lh, &lm, &ls, &ah, &am, &as);

			arrival[i] = ah*3600+am*60+as;
			leave[i] = lh*3600+lm*60+ls;
		}

		//test print
		//for(int i=0; i<n; ++i) printf("%d::le %d, ar %d\n", i, leave[i], arrival[i]);

		int ans=1;
		int nowa=0, nowl=0;
		while(nowl<n){
			while(nowl<n && leave[nowl]<arrival[nowa]) nowl++;
			//printf("nowl=%d , nowa=%d\n", nowl, nowa);
			ans = max(ans, nowl-nowa);
			nowa=nowl;
		}

		printf("%d\n", ans);
	}
}

C++: #include<iostream>
#include<vector>
#include<utility>
#include<cstdio>
using namespace std;
typedef struct Time{
  int h;
  int m;
  int s;
}Time;
typedef pair<int,int> pii;
int main(){
  int n;
  Time s[10000],e[10000];
  vector<pii>::iterator ite;
  vector<pii> train; 
  while(cin>>n,n){
    train.clear();
    int ans=0,sum=0,i = 0;
    for(i = 0;i < n;i++){
      scanf("%d:%d:%d %d:%d:%d",&s[i].h,&s[i].m,&s[i].s,&e[i].h,&e[i].m,&e[i].s);
      train.push_back(pii(s[i].h*3600 + s[i].m*60 + s[i].s,1)); 
      train.push_back(pii(e[i].h*3600 + e[i].m*60 + e[i].s,0));
    }
    sort(train.begin(),train.end());
    ite = train.begin();
    while(ite != train.end()){
      if(ite->second == 1){
	sum++;
	ans=max(ans,sum);
      }else{
	sum--;
      }
      ite++;
    }
    cout<<ans<<endl;
  }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL


typedef struct{
	int s,g;
}Time;

void swap_Time(Time *x, Time *y) {
	Time tmp = *x;
	*x = *y;
	*y = tmp;
}

void sort_by_s(Time a[], int n) {
	for (int i = 0; i < n - 1; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j - 1].s > a[j].s)swap_Time(&a[j - 1], &a[j]);
		}
	}
}


int main() {
	int   hhs, mms, sss, hhg, mmg, ssg, cnt = 1;
	Time yamanote[10000];
	bool f[10000];
	for (int n; cin >> n&&n;) {
		for (int i = 0; i < n; i++) {
			char c;
			cin >> hhs >> c >> mms >> c >> sss >> hhg >> c >> mmg >> c >> ssg;

			yamanote[i].s = 3600 * hhs + 60 * mms + sss;
			yamanote[i].g = 3600 * hhg + 60 * mmg + ssg;
			f[i]=0;
		}

		sort_by_s(yamanote, n);

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i;) {
	
				if (f[j] == 1) { j++; continue; }
				if (yamanote[i].s >= yamanote[j].g) {
					f[j] = 1;
					break;
				}
				j++;
				if (j == i)cnt++;
			}
			
		}
		
		cout << cnt << endl;
		cnt = 1;

	}
	return 0;
}

C++: #include <iostream>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int used[86401];
		memset(used, 0, sizeof(used));
		for(int i = 0; i < n; ++i)
		{
			string start, end;
			cin >> start >> end;
			int s = (start[0] - '0') * 10 * 3600 + (start[1] - '0') * 3600 + (start[3] - '0') * 10 * 60 + (start[4] - '0') * 60 + (start[6] - '0') * 10 + (start[7] - '0');
			int t = (end[0] - '0') * 10 * 3600 + (end[1] - '0') * 3600 + (end[3] - '0') * 10 * 60 + (end[4] - '0') * 60 + (end[6] - '0') * 10 + (end[7] - '0');
			for(int j = s; j < t; ++j)
			{
				++used[j];
			}
		}
		int max_val = 0;
		for(int i = 0; i < 86401; ++i)
		{
			max_val = max(max_val, used[i]);
		}
		cout << max_val << endl;
	}
}

int main()
{
	solve();
	return(0);
}