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 <cstdio>
#include <vector>
#include <map>
using namespace std;

typedef pair< int, int > iP;

int main() {

    int n;

    while(cin >> n, n) {
        vector< iP > v;
        vector< int > t(24 * 3600, 0);
        for(int i = 0; i < n; i++) {
            int h, m, s, hh, mm, ss;
            scanf("%2d:%2d:%2d %2d:%2d:%2d", &h, &m, &s, &hh, &mm, &ss);
            v.push_back(iP(h * 3600 + m * 60 + s, hh * 3600 + mm * 60 + ss));
            t[v[v.size() - 1].first]++, t[v[v.size() - 1].second]--;
        }

        for(int i = 1; i < 24 * 3600; i++) {
            t[i] += t[i - 1];
        }
        cout << *max_element(t.begin(), t.end()) << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

int sum[86401];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		memset(sum, 0, sizeof(sum));
		int h, m, s, h1, m1, s1;
		rep(i, n) {
			scanf("%d:%d:%d%d:%d:%d", &h, &m, &s, &h1, &m1, &s1);
			sum[h * 3600 + m * 60 + s]++; sum[h1 * 3600 + m1 * 60 + s1]--;
		}
		int Max = 0;
		rep(i, 86401) {
			if (i)sum[i] += sum[i - 1];
			Max = max(Max, sum[i]);
		}
		printf("%d\n", Max);
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int nowtrain[864000];
int main(){
	int n;
	string a;
	int bef,aft;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<86400;i++)
		nowtrain[i]=0;
	for(int i=0;i<n;i++){
		cin>>a;
		bef=3600*((a[0]-'0')*10+a[1]-'0');
		bef+=60*((a[3]-'0')*10+a[4]-'0');
		bef+=a[6]*10+a[7];
		cin>>a;
		aft=3600*((a[0]-'0')*10+a[1]-'0');
		aft+=60*((a[3]-'0')*10+a[4]-'0');
		aft+=a[6]*10+a[7];
		for(int j=bef;j<aft;j++)
			nowtrain[j]++;
	}
	int best=0;
	for(int i=0;i<86400;i++)
		best=max(best,nowtrain[i]);
	cout<<best<<endl;
	}
	return 0;
}

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

struct data{
	int s, t;
};

bool comp(data d1, data d2){
	return d1.s < d2.s;
}

int main(){
	int n;
	while(cin >> n && n){
		vector<data> qd1;
		priority_queue<int, vector<int>, greater<int> > qd2;
		for(int i = 0; i < n; i++){
			string s1, s2;
			cin >> s1 >> s2;
			data d;
			d.s = (s1[0]-'0')*36000 + (s1[1]-'0')*3600 + (s1[3]-'0')*600 + 
				(s1[4]-'0')*60 + (s1[6]-'0')*10 + (s1[7]-'0');
			d.t = (s2[0]-'0')*36000 + (s2[1]-'0')*3600 + (s2[3]-'0')*600 + 
				(s2[4]-'0')*60 + (s2[6]-'0')*10 + (s2[7]-'0');
			qd1.push_back(d);
		}
		sort(qd1.begin(), qd1.end(), comp);
		vector<data>::iterator iter = qd1.begin();
		while(iter != qd1.end()){
			data d = *iter;
			iter++;
			if(qd2.empty()){
				qd2.push(d.t);
			}else{
				int d2 = qd2.top();
				if(d2 <= d.s) qd2.pop();
				qd2.push(d.t);
			}
		}
		cout << qd2.size() << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

void slove(int n){
	vector<int> v(86400);
	rep(i, 86400) v[i] = 0;//?????????
	rep(i, n){
		string s, e;
		cin >> s >> e;
		//?§???°?????????
		int start = 36000 * (s[0] - '0') + 3600 * (s[1] - '0') 
					+ 600 * (s[3] - '0') + 60 * (s[4] - '0')
					+ 10 * (s[6] - '0') + 1 * (s[7] - '0');
		int end = 36000 * (e[0] - '0') + 3600 * (e[1] - '0') 
					+ 600 * (e[3] - '0') + 60 * (e[4] - '0')
					+ 10 * (e[6] - '0') + 1 * (e[7] - '0');
		//printf("%d %d\n", start, end);
		for (int j = start; j < end ; ++j) v[j]++;//???????????????
	}
	int ans;

	rep(i, 86400){
		ans = max(ans, v[i]);
	}
	//sort(all(v));
	//reverse(all(v));
	printf("%d\n", ans);
	return;
}
int main(void){
	rep(i, 100000000){
		int n; scanf("%d", &n);
		if(n == 0) break;
		slove(n);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>

using namespace std;
#define MP make_pair
typedef pair<int,int> PII;

int main(){
  int N;

  while(cin >> N, N){
	vector<PII> tm(N);
	for(int i=0;i<N;++i){
	  int h1, m1, s1, h2, m2, s2;
	  scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
	  tm[i].first = s1+m1*60+h1*60*60;
	  tm[i].second = s2+m2*60+h2*60*60;
	}
	sort(tm.begin(), tm.end());

	int ans = 0;
	for(int i=0;i<N;++i){
	  int sum = 1;
	  for(int j=i+1;j<N;++j){
		if(tm[i].first <= tm[j].first && tm[j].first < tm[i].second)
		  ++sum;
		else
		  break;
	  }
	  ans = max(ans, sum);
	}
	cout << ans << endl;
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin>> n;
  while(n!=0){
    int i,j,k;
    string str;
    int mp[86401]={};
    for(i=0;i<n;i++){
      int st=0,et=0;
      cin >> str;
      st=((str[0]-'0')*10+str[1]-'0')*60*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')*60*60
	+((str[3]-'0')*10+str[4]-'0')*60+((str[6]-'0')*10+str[7]-'0');
      for(j=st;j<et;j++) mp[j]++;
    }
    int m=0,b;
    for(i=0;i<86401;i++) if(m<mp[i]) m=mp[i];
    cout << m << endl;
    cin >> n;
  }
  return 0;
}