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++: # define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int a[24 * 60 * 60];

int main()
{
	int n;
	while (cin >> n&&n)
	{
		FOR(i, 24 * 60 * 60)a[i] = 0;
		FOR(i, n)
		{
			int st, en;
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			st = h * 60 * 60 + m * 60 + s;
			scanf("%d:%d:%d", &h, &m, &s);
			en = h * 60 * 60 + m * 60 + s;
			a[st]++;
			a[en]--;
		}
		int ans = 0;
		for (int i = 1; i < 24 * 60 * 60; i++)
		{
			a[i] += a[i - 1];
			ans = max(ans, a[i]);
		}
		cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

ll a[100005];

int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			fill(a, a + 100005, 0);
			int  h, m, s, h1, m1, s1;
			REP(i, n)
			{
				scanf("%d:%d:%d%d:%d:%d", &h, &m, &s, &h1, &m1, &s1);
				a[h * 3600 + m * 60 + s]++;
				a[h1 * 3600 + m1 * 60 + s1]--;
			}
			ll mx = 0;
			REP(i, 100005)
			{
				if (i) {
					a[i] += a[i - 1];
				}
				mx = max<ll>(mx, a[i]);
			}
			cout << mx << endl;
		}
	}
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	while (N != 0) {
		vector<int>A(86401, 0);
		int ans = 0, num = 0;
		char a, b, c, d, e, f, g, h;
		for (int i = 0; i < N; i++) {
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			int H = (a - '0') * 10 + (b - '0'), M = (d - '0') * 10 + (e - '0'), S = (g - '0') * 10 + (h - '0');
			A.at(H * 3600 + M * 60 + S) += 1;
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			H = (a - '0') * 10 + (b - '0'), M = (d - '0') * 10 + (e - '0'), S = (g - '0') * 10 + (h - '0');
			A.at(H * 3600 + M * 60 + S) -= 1;
		}
		for (int i = 0; i < 86401; i++) {
			num += A.at(i);
			ans = max(ans, num);
		}
		cout << ans << endl;
		cin >> N;
	}
}

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

using namespace std;

int time_parse(string time)
{
  int hour = atoi(time.substr(0, 2).c_str());
  int minute = atoi(time.substr(3, 5).c_str());
  int second = atoi(time.substr(6).c_str());
  return hour * 3600 + minute * 60 + second;
}

int main()
{
  int n;
  int table[24 * 3600] = {0};
  while (cin >> n && n)
  {
    table[24 * 3600] = {0};
    string time_in, time_out;
    for (int i = 0; i < n; i++)
    {
      cin >> time_in >> time_out;
      table[time_parse(time_in)] = 1;
      table[time_parse(time_out) - 1] = -1;
    }
    int ans = 0, sum = 0;
    for (int i = 0; i < 24 * 3600; i++)
    {
      sum += table[i];
      ans = max(sum, ans);
    }
    cout << ans << endl;
  }
}

C++: #include<set>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  int mx;
  multiset<pair<int,int> > a;
  multiset<pair<int,int> >::iterator it;
  while(cin>>n&&n){
    a.clear();
    for(i=0;i<n;i++){
      int t,u,v,w,x,y;
      scanf("%d:%d:%d%d:%d:%d",&t,&u,&v,&w,&x,&y);
      a.insert(make_pair(t*3600+u*60+v,1));
      a.insert(make_pair(w*3600+x*60+y,0));
    }
    mx=0;
    i=0;
    for(it=a.begin();it!=a.end();it++){
      if((*it).second){
	i++;
	mx=max(mx,i);
      }else
	i--;
    }
    cout<<mx<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair< int , int > P;
int main(){
  int n;
  vector< P > vc;
  while(scanf("%d",&n) , n){
    vc.resize(2 * n);
    for(int i = 0 ; i < n ; i++ ){
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      vc[2*i] = P( h*3600 + m*60 + s, 1);
      scanf("%d:%d:%d", &h, &m, &s);
      vc[2*i+1] = P( h*3600 + m*60 + s, -1);
    }
    sort(vc.begin(),vc.end());
    int ret = 0, ans = 0;
    for(int i = 0 ; i < 2 * n ; i++ ){
      ret += vc[i].second;
      ans = max( ans, ret);
    }
    printf("%d\n", ans);
  }
}