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<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	while(cin>>n,n){
		vector<int>in(25*60*60);
		rep(i,n){
			int a,b,c;char d;
			cin>>a>>d>>b>>d>>c;
			in[a*60*60+b*60+c]++;
			cin>>a>>d>>b>>d>>c;
			in[a*60*60+b*60+c]--;
		}
		int ma=0;
		int co=0;
		rep(i,25*60*60){
			co+=in[i];
			ma=max(ma,co);
		}
		cout<<ma<<endl;
	}
}

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

const int TIME = 60 * 60 * 30 + 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<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0) return 0;

        vector<int> imos(90000,0);
        rep(i,n){
            string s,t;
            cin>>s>>t;

            int t1=0;
            t1+=60*60*10*(s[0]-'0')+60*60*(s[1]-'0');
            t1+=60*10*(s[3]-'0')+60*(s[4]-'0');
            t1+=10*(s[6]-'0')+(s[7]-'0');
            t1++;
            int t2=0;
            t2+=60*60*10*(t[0]-'0')+60*60*(t[1]-'0');
            t2+=60*10*(t[3]-'0')+60*(t[4]-'0');
            t2+=10*(t[6]-'0')+(t[7]-'0');
            t2++;

            imos[t1]++;
            imos[t2]--;
        }
        rep(i,90000){
            if(i) imos[i]+=imos[i-1];
        }

        int ans=0;
        rep(i,90000) ans=max(ans,imos[i]);

        cout<<ans<<endl;
    }
}

C++: #include<iostream>
#define MAX 86400
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n,l,a;
	char s[20];
	vector<int> table;
	while(cin>>n,n){
		int max=0;
		for(int i=0;i<MAX;i++)
		table.push_back(0);
		for(int i=0;i<n;i++){
			cin>>s;
			l=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			cin>>s;
			a=atoi(s)*3600+atoi(&s[2])*60+atoi(&s[6]);
			for(int j=l;j<a;j++){
			table[j]++;
			if(table[j]>max)
			max=table[j];
			}
		}
		cout<<max<<endl;
		table.clear();
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll conv(string s){
    ll ret=0;
    ll hh=atoi(s.substr(0,2).c_str());
    ll mm=atoi(s.substr(3,2).c_str());
    ll ss=atoi(s.substr(6,2).c_str());
    return 3600*hh+60*mm+ss;
}
void solve(){
    while(1){
        ll n;cin>>n;
        if(!n)return;
        vl cnt(86400);
        rep(i,n){
            string s,t;cin>>s>>t;
            ll ss=conv(s),tt=conv(t);
            cnt[ss]++;
            cnt[tt]--;
        }
        rep(i,86400)cnt[i+1]+=cnt[i];
        ll ans=0;
        rep(i,86400)chmax(ans,cnt[i]);
        cout<<ans<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    int *hatsu = new int[n];
    int *tyaku = new int[n];
    for (int i = 0; i < n; i++) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      hatsu[i] = (h * 60 + m ) * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tyaku[i] = (h * 60 + m ) * 60 + s;
    }

    int count = n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (hatsu[i] >= tyaku[j]) {
          count--;
          break;
        }
      }
    }

    cout << count << endl;
  }
  return 0;
}