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>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define int long long
#define ll long long
#define inf  1000000007
#define mod 1000000007
#define pa pair<int,int>
#define pal pair<ll,ll>
#define ppa pair<int,pa>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y) {}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(x*a,y*a);}
  Point operator / (double a) {return Point(x/a,y/a);}
  double absv() {return sqrt(norm());}
  double norm() {return x*x+y*y;}
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x: y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};

double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());

}

double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ru[11]={1,2,4,8,16,32,64,128,256,512,1024};

ll frac[100010];
ll inv[100010];

ll saikif(ll a,int n){
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=100000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=100000;i++) inv[i]=saikif(frac[i],mod-2);
}


//----------------kokomade temple------------


signed main(){
char s[8],t[8];
int n;

while(cin>>n){
  if(n==0) break;
pa a[10010];
for(int i=0;i<n;i++){
 scanf("%s %s", s,t);
int a1=0,a2=0;
a1 += (s[0]-'0')*36000+(s[1]-'0')*3600+(s[3]-'0')*600+(s[4]-'0')*60+(s[6]-'0')*10+(s[7]-'0');
 a2 += (t[0]-'0')*36000+(t[1]-'0')*3600+(t[3]-'0')*600+(t[4]-'0')*60+(t[6]-'0')*10+(t[7]-'0');
a[i].first=a1;
a[i].second=a2;
//cout<<a1<<" "<<a2<<endl;
}
int z[100000]={0};
for(int i=0;i<n;i++){
  z[a[i].first]++;
  z[a[i].second]--;
}
for(int i=1;i<90000;i++){
  z[i] += z[i-1];
}

int ma=0;
for(int i=0;i<90000;i++){
  ma=max(ma,z[i]);
}

cout<<ma<<endl;
}

return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;

int tos(int h, int m, int s){
	return h * 3600 + m * 60 + s;
}


int main(){
	int n;
	int h, m, s;
	pii p;
	while(cin>>n && n > 0){
		vector<pii> v;
		for(int i = 0; i < n; i++){
			scanf("%d:%d:%d", &h, &m, &s);
			p.se = tos(h, m, s);
			scanf("%d:%d:%d", &h, &m, &s);
			p.fi = tos(h, m, s);
			v.pb(p);
		}
		sort(all(v));
		vi u;
		u.pb(v[0].fi);
		for(int i = 1; i < v.size(); i++){
			for(int j = 0; j < u.size(); j++){
				if(u[j] <= v[i].se){
					u[j] = v[i].fi;
					break;
				}
				if(j == u.size() - 1) {
					u.pb(v[i].fi);
					break;
				}
			}
			sort(all(u));
		}
		cout<<u.size()<<endl;
	}
}

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

int main(void){

  int n;
  int sum[3000];

  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            int h,m,s;
            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<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> se;
typedef vector<se> tt;
int main(){
  int n;
  cin>> n;
  while(n!=0){
    int i,j,k;
    string str;
    tt t;
    for(i=0;i<n;i++){
      int st=0,et=0;
      cin >> str;
      st+=((str[0]-'0')*10+str[1]-'0')*24*60
	+((str[3]-'0')*10+str[4]-'0')*60+((str[6]-'0')*10+str[7]-'0');
      cin >> str;
      et+=((str[0]-'0')*10+str[1]-'0')*24*60
	+((str[3]-'0')*10+str[4]-'0')*60+((str[6]-'0')*10+str[7]-'0');
      t.push_back(make_pair(st,et));
    }
    sort(t.begin(),t.end());
    int m=0,b;
    for(j=0;j<86401;j++) {
      b=0;
      for(k=0;k<t.size();k++){
	if(t[k].first<=j&&j<t[k].second) b++;
	if(t[k].first>j) break;
      }
      if(m<b) m=b;
    }
    cout << m << endl;
    cin >> n;
  }
  return 0;
}