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 <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int calc(string s) {
  int res = 0;
  res += 60 * 60 * ((s[0] - '0') * 10 + (s[1] - '0'));
  res += 60 * ((s[3] - '0') * 10 + (s[4] - '0'));
  res += (s[6] - '0') * 10 + (s[7] - '0');
  return res;
}

bool solve() {
  int n; cin >> n;
  if(n == 0) return false;

  vector<P> v;
  REP(i, n) {
    string l, r; cin >> l >> r;
    v.push_back({calc(l), calc(r)});
  }

  vector<int> imos(60 * 60 * 60+1, 0);
  REP(i, n) {
    imos[v[i].first]++;
    imos[v[i].second]--;
  }
  REP(i, SZ(imos)-1) {
    imos[i+1] += imos[i];
  }

  int ans = 0;
  REP(i, SZ(imos)-1) {
    chmax(ans, imos[i]);
  }
  cout << ans << endl;

  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while(1) {
    if(!solve()) break;
  }

}

C++: #include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,ma,sum;
	string s,t;
	vector<P> box;
	while(cin>>n,n){
		ma=0;
		for(int i=0;i<n;i++){
			cin>>s>>t;
			box.push_back(P(((s[0]-'0')*10+s[1]-'0')*3600+((s[3]-'0')*10+s[4]-'0')*60+(s[6]-'0')*10+s[7]-'0',((t[0]-'0')*10+t[1]-'0')*3600+((t[3]-'0')*10+t[4]-'0')*60+(t[6]-'0')*10+t[7]-'0'));
		}
		for(int i=0;i<n;i++){
			sum=1;
			for(int j=0;j<n;j++){
				if(i!=j&&!(box[j].second<box[i].first||box[i].second<=box[j].first))
				sum++;
			}
			if(sum>ma)
			ma=sum;
		}
		cout<<ma<<endl;
		box.clear();
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

void slove(int n){
	vector<int> v(86400);
	rep(i, 86400) v[i] = 0;//?????????
	rep(i, n){
		string s, e;
		cin >> s >> e;
		//?§???°?????????
		int start = 36000 * (s[0] - '0') + 3600 * (s[1] - '0') 
					+ 600 * (s[3] - '0') + 60 * (s[4] - '0')
					+ 10 * (s[6] - '0') + 1 * (s[7] - '0');
		int end = 36000 * (e[0] - '0') + 3600 * (e[1] - '0') 
					+ 600 * (e[3] - '0') + 60 * (e[4] - '0')
					+ 10 * (e[6] - '0') + 1 * (e[7] - '0');
		//printf("%d %d\n", start, end);
		for (int j = start; j < end ; ++j) v[j]++;//???????????????
	}
	int ans;

	/*
	rep(i, 86400){
		ans = max(ans, v[i]);
	}
	*/
	sort(all(v));
	reverse(all(v));
	printf("%d\n", v[0]);
	return;
}
int main(void){
	rep(i, 100000000){
		int n; scanf("%d", &n);
		if(n == 0) break;
		slove(n);
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
long long int N[10000000]={};
int main(){

int n,q;
int h1=0,m1=0,s1=0,h2=0,m2=0,s2=0;
while(1){
cin>>n;if(n==0)break;
for(int i=0;i<n;i++)
{scanf("%d:%d:%d",&h1,&m1,&s1);
scanf("%d:%d:%d",&h2,&m2,&s2);
long int L1=h1*10000+m1*100+s1;
long int L2=h2*10000+m2*100+s2;
for(int j=L1;j<L2;j++)
	N[j]++;
}
int max=00;
for(int i=0;i<240000;i++)
{if(N[i]>max)max=N[i];}
cout<<max<<endl;
}
return 0;
}

C++: 
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int N;
P G[20000];
int solve(){
  int res = 0;
  int c = 0;
  for (int i = 0; i < 2*N; i++){
    if (G[i].second){
      c++;
      res = max(c, res);
    }
    else{
      c--;
    }
  }
  return res;
}
int main(){
  while (1){
    cin >> N;
    if (N == 0) break;
    for (int i = 0; i < N; i++){
      for (int j = 0; j < 2; j++){
	char str[10];
	cin >> str;
	int a = (str[0]-'0')*10 + str[1]-'0';
	int b = (str[3]-'0')*10 + str[4]-'0';
	int c = (str[6]-'0')*10 + str[7]-'0';
	G[i*2+j] = P(a*60*60 + b*60 + c, 1-j);
      }
    }
    sort(G, G+2*N);
    cout << solve() << endl;
  }
}