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 <vector>
#include <stdio.h>

#define TIME 24 * 60 * 60

using namespace std;

int main(){
	int n;
	
	while(1){
		cin >> n;
		if(n == 0)
			break;
		
		int h_dep, m_dep, s_dep, h_arr, m_arr, s_arr;
		vector <int> dep(n), arr(n);
		for(int i = 0; i < n; i++){
			scanf("%d:%d:%d %d:%d:%d", &h_dep, &m_dep, &s_dep, &h_arr, &m_arr, &s_arr);
			dep[i] = s_dep + m_dep * 60 + h_dep * 60 * 60;
			arr[i] = s_arr + m_arr * 60 + h_arr * 60 * 60;
		}
		vector <int> train(TIME, 0);
		for(int i = 0; i < n; i++){
			train[dep[i]]++;
			train[arr[i]]--;
		}
		int max = 0;
		for(int i = 1; i < TIME; i++){
			train[i] += train[i - 1];
			if(train[i] > max)
				max = train[i];
		}
		
		cout << max << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <memory.h>
int y[24*3600];
int main(void){
	int n,h,m,s,i,max;
	while(scanf("%d",&n),n){
		max=0;
		memset(y,0,sizeof(y));
		for(i=0;i<2*n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			if(!(i%2))y[h*3600+m*60+s]++;
			else y[h*3600+m*60+s]--;
		}
		for(i=0;i<24*3600;i++){
			if(i>0)y[i]+=y[i-1];
			if(y[i]>max)max=y[i];
		}
		printf("%d\n",max);
	}
	return 0;
}

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

using namespace std;

constexpr int MAX = 60 * 60 * 24 + 100;
int L[MAX];

int main()
{
	int n;
	while (cin >> n, n)
	{
		int fh, fm, fs, th, tm, ts;
		int f, t;
		for (int i = 0; i < n; ++i)
		{
			scanf("%d:%d:%d %d:%d:%d", &fh, &fm, &fs, &th, &tm, &ts);
			f = 60 * 60 * fh + 60 * fm + fs;
			t = 60 * 60 * th + 60 * tm + ts;
			//cout << f << t << endl;
			L[f]++;
			L[t]--;
		}
		for (int i = 1; i < MAX; ++i)
		{
			L[i] += L[i - 1];
		}
		int ans = 0;
		for (int i = 0; i < MAX; ++i)
		{
			ans = max(ans, L[i]);
			L[i] = 0;
		}
		cout << ans << endl;
	}
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    while(cin >> n, n){
        vector< P > train(n);
        rep(i, n){
            int h, m, s;
            scanf("%d:%d:%d", &h, &m, &s);
            train[i].first = h * 10000 + m * 100 + s;
            scanf("%d:%d:%d", &h, &m, &s);
            train[i].second = h * 10000 + m * 100 + s;
        }
        SORT(train);
        vector<bool> done(n);
        int ans = 0;
        rep(i, n){
            if(!done[i]){
                ++ans;
                done[i] = true;
                int tmp = train[i].second;
                REP(j, i + 1, n){
                    if(tmp <= train[j].first && !done[j]){
                        done[j] = true;
                        tmp = train[j].second;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
   
  char ch;
  int ta[200000];
  int n,a,b,c,time,mx,cnt;
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n*2;i++){
      cin>>a>>ch>>b>>ch>>c;
      time=a*100000+b*1000+c*10;
      //cout<<time<<endl;
      if(i%2==0)time+=1;
      ta[i]=time;
    }
    sort(ta,ta+n*2);
    mx=cnt=0;
    for(int i=0;i<n*2;i++){
      if(ta[i]%10){
    cnt++;
      }else{
    cnt--;
      }
      if(mx<cnt)mx=cnt;
    }
    cout<<mx<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
#define MAX 10000
struct Train{
	int st;
	int ed;
	void SetSt(int h, int m, int s){
		st = h * 3600 + m * 60 + s;
	}
	void SetEd(int h, int m, int s){
		ed = h * 3600 + m * 60 + s;
	}
	bool operator<(const Train &t)const{
		return ed < t.ed;
	}
};
int main(){
	while(true){
		unsigned int ans = 0;
		int n;
		priority_queue< Train > pq;
		scanf("%d", &n);

		if( n == 0 ) break;

		for(int i = 0; i < n; ++i){
			int sh,sm,ss;
			int eh,em,es;
			Train t;
			
			scanf("%02d:%02d:%02d %02d:%02d:%02d",
				&sh,&sm,&ss,
				&eh,&em,&es);
			t.SetSt( sh, sm, ss );
			t.SetEd( eh, em, es );
			
			if( pq.size() == 0 )
				pq.push( t );
			else{
				Train tt = pq.top();
				if( tt.ed <= t.st )
					pq.pop();
				else
					pq.push( t );
			}
			ans = max(ans, pq.size());
		}
		printf("%d\n", ans);
	}
	return 0;
}