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>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    int a[100000];
    memset(a,0,sizeof(a));
    P p[n];
    rep(i,n) {
      int h,m,s;
      scanf("%d%*c%d%*c%d",&h,&m,&s);
      p[i].F=h*60*60+m*60+s;
      scanf("%d%*c%d%*c%d",&h,&m,&s);
      p[i].S=h*60*60+m*60+s;
    }
    sort(p,p+n);
    int j=0,ans=0;
    rep(i,90000) {
      while(p[j].F==i && j<n) {
	if(a[i]) {
	  a[i]--;
	}// else ans++;
	a[p[j].S]++;
	j++;
      }
      a[i+1]+=a[i];
    }
    pr(a[89000]);
  }
  return 0;
}

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

int main() {
    while (true)
    {
        int n; cin >> n;
        if(n == 0) break;
        vector<int> train(86410, 0);
        for (int i = 0; i < n; i++)
        {
            string ss, se; cin >> ss >> se;
            int sh = (ss[0] - '0') * 10 + ss[1] - '0';
            int sm = (ss[3] - '0') * 10 + ss[4] - '0';
            int ssec = (ss[6] - '0') * 10 + ss[7] - '0';
            int eh = (se[0] - '0') * 10 + se[1] - '0';
            int em = (se[3] - '0') * 10 + se[4] - '0';
            int esec = (se[6] - '0') * 10 + se[7] - '0';
            train[sh * 3600 + sm * 60 + ssec]++;
            train[eh * 3600 + em * 60 + esec]--;
        }
        for (int i = 0; i < 86400; i++)
        {
            if(i > 0) train[i] += train[i - 1];
        }
        int ans = 0;
        for (int i = 0; i < 86400; i++)
        {
            if(ans < train[i]) ans = train[i];
        }
        cout << ans << endl;
    }

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#define N 10000
using namespace std;
int Change(string);
int Change_sup(string);
struct data{
  int s,g;
  bool operator<(const data & right)const{
    if(g>right.g) return g<right.g;
    return s<right.s;
  }
};
int main(){
  int n,flag[N],com,cnt,i,j;
  string ins,ing;
  struct data d[N];
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> ins >> ing;
      d[i].s=Change(ins);
      d[i].g=Change(ing);
      flag[i]=0;
    }
    sort(d,d+n);
    cnt=0;
    for(i=0;i<n;i++){
      if(flag[i]==0){
	flag[i]=1;
	cnt++;
	com=d[i].g;
	for(j=i+1;j<n;j++){
	  if(com<=d[j].s){
	    flag[j]=1;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
int Change(string str){
  int r;
  string a,b,c;
  a=str.substr(0,2);
  b=str.substr(3,2);
  c=str.substr(6,2);
  r=Change_sup(a+b+c);
  return r;
}
int Change_sup(string str){
  int len=str.size(),x=1,ret=0,i=0;
  while(len){
    ret=ret*x+(str[i]-'0');
    x=10;
    i++;
    len--;
  }
  return ret;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL


typedef struct {
	int s;
	int g;
	bool f;
}time;
void swap_time(time *x, time *y) {
	time tmp = *x;
	*x = *y;
	*y = tmp;
}
void sort_by_s(time a[], int n) {
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j > i; j--) {
			if (a[j - 1].s > a[j].s)
				swap_time(&a[j], &a[j - 1]);
		}
	}
}
int main() {
	int n, hhs, mms, sss, hhg, mmg, ssg, cnt = 1;
	time yamanote[10000];
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			char c;
			cin >> hhs >> c >> mms >> c >> sss >> hhg >> c >> mmg >> c >> ssg;
			yamanote[i].s = 3600 * hhs + 60 * mms + sss;
			yamanote[i].g = 3600 * hhg + 60 * mmg + ssg;
		}
		sort_by_s(yamanote,n);
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i;j++) {
				if (yamanote[j].f == 1) { break; }
				if (yamanote[i].s >= yamanote[j].g) {
					yamanote[j].f = 1;
					break;
				}
				if (j == i)cnt++;
			}
		}
		cout << cnt << endl;
		cnt = 1;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int imoss[60*60*24+100]={0};
        for(int i=0;i<n;i++){
            int t,m,s;
            scanf("%d:%d:%d",&t,&m,&s);
            imoss[t*3600+m*60+s]++;
            scanf("%d:%d:%d",&t,&m,&s);
            imoss[t*3600+m*60+s+1]--;
        }
        int ma=0;
        for(int i=0;i<=24*60*60;i++)ma=max(ma,imoss[i]);
        printf("%d\n",ma);
    }
    return 0;
}