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>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int tosec(string S){
  int h = stoi(S.substr(0, 2));
  int m = stoi(S.substr(3, 2));
  int s = stoi(S.substr(6, 2));
  return h * 3600 + m * 60 + s;
}

int main(){
while(true){
  int n;
  cin >> n;
  if(n == 0) break;
  map<int, int> ma;
  vector<P> imos(0);
  for(int i = 0; i < n; i++){
    string s1, s2;
    cin >> s1 >> s2;
    int start = tosec(s1), goal = tosec(s2);

    if(!ma.count(start)){
      ma[start] = imos.size();
      imos.push_back(P(start, 1));
    }
    else imos.at(ma.at(start)).second++;

    if(!ma.count(goal)){
      ma[goal] = imos.size();
      imos.push_back(P(goal, -1));
    }
    else imos.at(ma.at(goal)).second--;
  }

  sort(ALL(imos));
  
  int ans = 0;
  for(int i = 1; i < imos.size(); i++){
    imos.at(i).second += imos.at(i-1).second;
    chmax(ans, imos.at(i).second);
  }
  cout << ans << endl;
}
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
#define max_t 24 * 60 * 60

int main(){
    int list[max_t] = {};
    int n;
    while( cin >> n, n ){
        while( n-- ){
            int d_h, d_m, d_s;      // the departure time
            int a_h, a_m, a_s;      // the arrival time
            //cin >> d_h >> ":" >> d_m >> ":" >> d_s;
            //cin >> a_h >> ":" >> a_m >> ":" >> a_s;
            scanf("%d:%d:%d", &d_h, &d_m, &d_s );
            scanf("%d:%d:%d", &a_h, &a_m, &a_s );
            int s, e;
            s = d_h * 60 * 60 + d_m * 60 + d_s;
            e = a_h * 60 * 60 + a_m * 60 + a_s;
            //cout << s << " " << e << endl;
            for( int i = s + 1; i < e; i++ ){
                list[i]++;
            }
        }
        int max = 0;
        for( int i = 0; i < max_t; i++ ){
            if( max < list[i] ) max = list[i];
        }
        cout << max << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

int exchange(string s){
  int res=0;
  res = (s[0]-48)*36000+(s[1]-48)*3600+(s[3]-48)*600+(s[4]-48)*60+
        (s[6]-48)*10+(s[7]-48);
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(cin >> n,n){
    int time[900000]={0};
    for(int i=0;i<n;i++){
      string s1,s2;cin >>s1>>s2;
      int start=exchange(s1),end=exchange(s2);
      time[start]++;time[end]--;
    }
    for(int i=1;i<900000;i++) time[i]+=time[i-1];
    int res=-1;
    for(int i=0;i<900000;i++) res=max(res,time[i]);
    cout << res << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int h, m, s, hh, mm, ss;
        int d[24 * 3600 + 100] = {};
        rep(i, 0, n){
            scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &hh, &mm, &ss);
            int st = h * 3600 + m * 60 + s;
            int ed = hh * 3600 + mm * 60 + ss;
            d[st]++; d[ed]--;
        }
        int MAX = 0;
        rep(i, 1, 24 * 3600 + 10){
            d[i] += d[i - 1];
            MAX = max(MAX, d[i]);
        }
        cout << MAX << endl;
    }
}

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

int main(void){

  int n;
  int sum[3000];
  int h,m,s;

  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]++;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]--;
        }
        int res=sum[0];
        for(int i=0;i<=24*60*60;i++){
            sum[i+1]+=sum[i];
            res=max(res,sum[i+1]);
        }
        printf("%d\n",res);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int n,h1,h2,m1,m2,s1,s2;
	int time[60*60*24];
	int start, end, max=0;

	while(true){
		scanf("%d\n",&n);
		if(n==0){return 0;}
		max=0;
		for(int i=0; i<60*60*24; i++){ time[i]=0;}
		for(int i=0; i<n; i++){
			scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			start=3600*h1+60*m1+s1; end=3600*h2+60*m2+s2;
			for(int j=start; j<end; j++){ time[j]++;}
		}
		for(int i=0; i<60*60*24; i++){
			if(max<time[i]){ max=time[i];}
		}
		cout << max << endl;
	}
}