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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(scanf("%d",&n), n) {
    vector<pair<int,int> > v;
    REP(i,n) {
      REP(k,2) {
        int h,m,s;
        scanf("%d:%d:%d ", &h,&m,&s);
        v.push_back(make_pair(h*3600+m*60+s, 1-k));
      }
    }
    sort(ALL(v));
    int res = 0;
    int cnt = 0;
    REP(i,v.size()) {
      int t = v[i].first;
      int k = v[i].second;

      if (k) {
        cnt++;
      } else
        cnt--;
      res = max(res, cnt);
    }
    cout << res << endl;
  }
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}


signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;

    vector<int> ans;
    while(n != 0){
        vector<int> train_time(86400, 0);
        for(int i=0; i<n; i++){
            int h, m, s;
            char a, b;
            cin >> h >> a >> m >> b >> s;
            int t = h * 3600 + m * 60 + s;
            train_time[t]++;

            cin >> h >> a >> m >> b >> s;
            t = h * 3600 + m * 60 + s;
            train_time[t]--;
        }

        for(int i=0; i<86400-1; i++){
            train_time[i+1] += train_time[i];
        }
        sort(train_time.begin(), train_time.end());
        reverse(train_time.begin(), train_time.end());
        ans.push_back(train_time[0]);

        cin >> n;
    }

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main(){
    int n;
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        
        vector< pair<int, int> > train;
        train.push_back(make_pair(0, 0));

        vector< pair<int, int> > time;
        int hs, ms, ss, he, me, se;
        char tmp;
        for(int i=0; i<n; i++){
            cin >> hs >> tmp >> ms >> tmp >> ss;
            cin >> he >> tmp >> me >> tmp >> se;
            time.push_back(make_pair(hs*3600 + ms*60 + ss, he*3600 + me*60 + se));
        }
        sort(time.begin(), time.end());

        int ans = 1;
        for(int i=0; i<n; i++){
            int sz = train.size();
            for(int j=0; j<sz; j++){
                if(train[j].second <= time[i].first){
                    train[j].second = time[i].second;
                    break;
                }
                if(j == sz-1){
                    train.push_back(make_pair(time[i].first, time[i].second));
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    while(cin >> n, n){
        array<int, 100000> v{};
        for (int i = 0; i < n; ++i) {
            int h1, m1, s1, h2, m2, s2;
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            int x = h1*3600+m1*60+s1, y = h2*3600+m2*60+s2;
            v[x]++; v[y]--;
        }
        for (int i = 1; i < 100000; ++i) {
            v[i] += v[i-1];
        }
        cout << *max_element(v.begin(),v.end()) << "\n";
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef  pair<int,int>P;
int main(){
  int n;
  vector<P>ve;
  while(cin >> n,n){
    ve.clear();
    int t,s;
    for(int i = 0 ; i < n ; i++ ){
      int a,b,c;
      char ch;
      cin >> a >> ch >> b >> ch >> c;
      s = a*3600 + b*60 + c;
      ve.push_back(P(s,1));
      cin >> a >> ch >> b >> ch >> c;
      t = a*3600 + b*60 + c;
      ve.push_back(P(t,-1));
    }

    sort(ve.begin(),ve.end());

    int ans = 0,sum = 0;
    for(int i = 0 ; i < ve.size() ; i++ ){
      sum += ve[i].second;
      ans = max(ans,sum);
    }
    cout << ans << endl;
  }
  return 0;
}