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 <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

void solve(int n){
  int h,m,s;
  int imos[86405];
  rep(i,86405)imos[i]=0;
  cin>>n;
  rep(i,n){
    scanf("%d:%d:%d",&h,&m,&s);
    imos[h*3600+m*60+s]++;
    scanf("%d:%d:%d",&h,&m,&s);
    imos[h*3600+m*60+s+1]--;
  }
  REP(i,1,86405)imos[i]+=imos[i-1];
  int ans=0;
  rep(i,86405){
    ans=max(ans,imos[i]);
  }
  cout<<ans<<endl;
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    solve(n);
  }
  return 0;
}

C++: #include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

char in[20];
int n;
pi t[20000];

int main()
{
	while(scanf("%d",&n),n)
	{
		rep(i,n)rep(j,2)
		{
			int h,m,s; scanf("%d:%d:%d",&h,&m,&s);
			t[i*2+j]=mp(h*3600+m*60+s,1-j);
		}
		sort(t,t+2*n);
		
		int ans=0,c=0;
		rep(i,2*n)
		{
			if(t[i].second)c++; else c--;
			ans=max(ans,c);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int imos[90000];

int time_split(char Tens_Place,char One_Place){
    int return_num;
    string s = {Tens_Place, One_Place};
    stringstream ss;
    ss << s;
    ss >> return_num;
    return return_num;
}

int main() {

    while(1) {

        int n;

        cin >> n;

        if(n==0){
            break;
        }

        for(int i=0; i<90000; i++){
            imos[i] = 0;
        }

        for (int i = 0; i < n; i++) {
            string start, goal;
            cin >> start >> goal;
            int h, m, s;
            h = time_split(start[0], start[1]);
            m = time_split(start[3], start[4]);
            s = time_split(start[6], start[7]);
            imos[h * 24 * 60 + m * 60 + s]++;
            h = time_split(goal[0], goal[1]);
            m = time_split(goal[3], goal[4]);
            s = time_split(goal[6], goal[7]);
            imos[h * 24 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < 90000; i++) {
            imos[i] += imos[i - 1];
        }

        int ans = 0;

        for (int i = 0; i < 90000; i++) {
            ans = max(ans, imos[i]);
        }

        cout << ans << endl;

    }

    return 0;
}

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

int n;
int cnt[86401];

int toSec(string s) {
	int h = (s[0] - '0') * 10 + (s[1] - '0');
	int m = (s[3] - '0') * 10 + (s[4] - '0');
	int sec = (s[6] - '0') * 10 + (s[7] - '0');
	return h * 3600 + m * 60 + sec;
}

int main() {
	while (cin >> n) {
		if (!n) return 0;
		
		int i;
		for (i = 0; i < 86400; i++) cnt[i] = 0;
		for (i = 0; i < n; i++) {
			string s, t;
			cin >> s >> t;
			cnt[toSec(s)]++;
			cnt[toSec(t)]--;
		}
		for (i = 1; i < 86400; i++) cnt[i] += cnt[i - 1];
		int ans = 0;
		for (i = 0; i < 86400; i++) ans = max(ans, cnt[i]);
		cout << ans << endl;
	}
	return 0;
}