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 ADAY 86400
using namespace std;

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int now=0; now <= ADAY; now++){
      if(ind >= n) break;
      while(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      while(now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
        if(ind >= n) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define MAX 1000

int to_int(char c) {
    return 9 - (int)('9' - c);
}

int to_num(string s) {
    int t = 0;
    //cout << "{" << s[0] << "," << to_int(s[0]) << "}" << endl;
    t += (to_int(s[0]) * 10 + to_int(s[1])) * 100 * 100;
    t += (to_int(s[3]) * 10 + to_int(s[4])) * 100;
    t += (to_int(s[6]) * 10 + to_int(s[7]));
    return t;
}

int enable_train_index(int list[], int now_list_max, int t1) {
    sort(list, list+now_list_max);
    for(int i=now_list_max-1; i>=0; i--) {
        if (list[i] == -1) { continue; }
        if (list[i] <= t1) { return i; }
    }
    return -1;
}

int main(void) {
    int n;
    string s;
    while (cin >> n, n) {
        int list[MAX];
        int now_list_max = 0;
        int train_num = 0;
        for(int i=0; i<n; i++) {
            list[i] = -1;
        }
        for(int i=0; i<n; i++) {
            cin >> s;
            int t1 = to_num(s);
            cin >> s;
            int t2 = to_num(s);
            int index = enable_train_index(list, now_list_max, t1);
            //cout << "[" << t1 << "," << t2 << "]" << endl;
            if (index != -1) {
                list[index] = -1;
            } else {
                train_num++;
            }
            list[now_list_max] = t2;
            now_list_max++;
        }
        cout << train_num;
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 10000;
int Change(string);
int main(){
  int n,cnt,check[N],ok,flag,Max,sh[N],sm[N],ss[N],eh[N],em[N],es[N],i,j;
  string start[N],end[N],sub;
  while(1){
    cin >> n;
    cnt=0;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> start[i] >> end[i];
      check[i]=-1;
      sub=start[i].substr(0,2);
      sh[i]=Change(sub);
      sub=start[i].substr(3,2);
      sm[i]=Change(sub);
      sub=start[i].substr(6,2);
      ss[i]=Change(sub);
      sub=end[i].substr(0,2);
      eh[i]=Change(sub);
      sub=end[i].substr(3,2);
      em[i]=Change(sub);
      sub=end[i].substr(6,2);
      es[i]=Change(sub);
    }
    for(i=0;i<n;i++){
      if(check[i]==-1){
	check[i]=i;
	for(j=i+1;j<n;j++){
	  if(check[j]==-1){
	    ok=0;
	    if(eh[i]==sh[j]){
	      if(em[i]==sm[j]){
		if(es[i]<=ss[j]) ok=1;
	      }
	      else if(em[i]<sm[j]) ok=1;
	    }
	    else if(eh[i]<sh[j]) ok=1;
	    if(ok==1){
	      check[j]=i;
	    }
	  }
	}
      }
    }
    Max=0;
    for(i=0;i<n;i++){
      Max=max(Max,check[i]);
    }
    cout << Max+1 << endl;
  }
  return 0;
}
int Change(string sub){
  int ret=0,x=1,i;
  for(i=0;i<2;i++){
    ret=ret*x+(sub[i]-'0');
    x=10;
  }
  return ret;
}

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

const int TIME = 60 * 60 * 24 + 60;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n && n){
	int data[TIME];
		fill(data, data + TIME, 0);
		
		int a, b, c;
		for(int i = 0; i < n; ++i){
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] ++;
			
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] --;
		}
	
		int ans = 0;
		for(int i = 0; i < TIME; ++i){
			if(i != 0)
				data[i] += data[i - 1];
			ans = max(ans, data[i]);
		}
		
		cout << ans << endl;
	}
	return 0;
}

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

template <class T, class U>
T lexical_cast(const U& from) {
    stringstream ss;
    ss << from;
    T to;
    ss >> to;
    return to;
}

int time2int(const string& str) {
    int h = lexical_cast<int>(str.substr(0,2));
    int m = lexical_cast<int>(str.substr(3,2));
    int s = lexical_cast<int>(str.substr(6,2));
    return h * 60 * 60 + m * 60 + s;
}

int main() {
    for(int N; cin >> N, N; ) {
        vector<int> v(60*60*24, 0);
        for(int i = 0; i < N; i++) {
            string s, e; cin >> s >> e;
            int ss = time2int(s);
            int ee = time2int(e);
            for(int j = ss; j < ee; j++) {
                v[j]++;
            }
        }
        cout << *max_element(v.begin(), v.end()) << endl;
    }
}