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 fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int t[100010];

int main(){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(t,0,sizeof(t));
		rep(i,n){
			int h,m,s;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]++;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]--;
		}
		int res=t[0];
		rep(i,100000){
			t[i+1]+=t[i];
			maxch(res,t[i+1]);
		}
		printf("%d\n", res);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main(){
	while(1){
		int n;
		cin >> n;
		if(!n)break;

		vector<pair<int, int> > v;

		rep(i, n){
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			v.push_back(MP(h*60*60+m*60+s, +1));
			scanf("%d:%d:%d", &h, &m, &s);
			v.push_back(MP(h*60*60+m*60+s, -1));
		}

		int need = 0;
		sort(all(v));

		int train = 0;
		rep(i, 2*n){
			train += v[i].second;
			need = max(need, train);
		}

		cout << need << endl;
	}

	return 0;
}

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


#define M  24*60*60
int table[M];


int main(){
  int n;
  string str;
  while(cin >> n, n){
    for(int i = 0; i < M; i++){
      table[i] = 0;
    }
    for(int i = 0; i < n; i++){
      cin >> str;
      int s = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[s]++;
      cin >> str;
      int e = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[e]--;
    }
    for(int i = 1; i < M; i++){
      table[i] += table[i-1];
    }
    int max = 0;
    for(int i = 0; i < M; i++){
      if(max < table[i]) max = table[i];
    }
    cout << max << endl;
  }


}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX_N 100000
int x[MAX_N];

int main() {
	int n, a, b, c, d, e, maxn = 0;;
	while (true) {
		for (int i = 0; i < MAX_N; i++) {
			x[i] = 0;
		}
		cin >> n; maxn = 0;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d", &a, &b, &c);
			d = a * 3600 + b * 60 + c;
			scanf("%02d:%02d:%02d", &a, &b, &c);
			e = a * 3600 + b * 60 + c;
			x[d]++; x[e]--;
		}
		for (int i = 1; i < 99999; i++) {
			x[i] += x[i - 1];
			maxn = max(maxn, x[i]);
		}
		cout << maxn << endl;
	}
}

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

using namespace std;

int time2sec(string s) {
    int hour = stoi(s.substr(0,2), nullptr, 10);
    int minute = stoi(s.substr(3,2), nullptr, 10);
    int sec = stoi(s.substr(6,2), nullptr, 10);

    return hour * 3600 + minute * 60 + sec;
}

int main() {
    int table[24*3600+1];

    int n;
    while (cin >> n, n) {
        fill_n((int *)table, 24*3600+1, 0);
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            string s, e;
            cin >> s >> e;

            int ss = time2sec(s);
            int es = time2sec(e);

            for (int t = ss; t < es; t++) {
                table[t]++;
                if (max < table[t]) {
                    max = table[t];
                }
            }
        }
        cout << max << endl;
    }

    return 0;
}

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

struct Range {
    int begin,end;
    Range(int begin,int end) : begin(begin), end(end) {;}
};

bool operator<(const Range &r,const Range &s) {
    return (r.end != s.end) ? r.end < s.end : r.begin < s.begin;
}

inline int ss(char c) { return c-'0'; }

int stoi(string s) {
    int h = 0;
    h += ss(s[0])*10 + ss(s[1]);
    h *= 60;
    h += ss(s[3])*10 + ss(s[4]);
    h *= 60;
    h += ss(s[6])*10 + ss(s[7]);
    return h;
}

int main() {
    int n;
    string s,t;
    while(cin>>n, n) {
        vector<Range> rv;
        for(int i=0; i<n; ++i) {
            cin>>s>>t;
            rv.push_back(Range(stoi(s), stoi(t)));
        }

        sort(rv.begin(), rv.end());
        int ans = 0;
        for(int i=0; i<rv.size(); ++i) {
            int tt = rv[i].begin,overap = 0,to = 0;
            for(int j=0; j<rv.size(); ++j) {
                if(rv[j].begin > tt) break;
                if(rv[j].begin <= tt && rv[j].end > tt) overap++;
            }

            tt = rv[i].end;
            for(int j=0; j<rv.size(); ++j) {
                if(rv[j].begin > tt) break;
                if(rv[j].begin < tt && rv[j].end >= tt) to++;
            }
            overap = max(overap, to);
            ans = max(ans, overap);
        }
        cout<<ans<<endl;
    }
}