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>
#define PB push_back
#define MP make_pair
#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(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int rec(int h,int m,int s){
      return h*3600+m*60+s;
}
int cnt[60*60*24+1];
int main(){
      int n;
      while(cin>>n&&n){
            memset(cnt,0,sizeof(cnt));
            int h1,m1,s1,h2,m2,s2;
            REP(i,n){
                  scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
                  cnt[rec(h1,m1,s1)]++;
                  cnt[rec(h2,m2,s2)]--;
            }
            int ans=0;
            REP(i,60*60*24+1){
                  if(i==0)continue;
                  cnt[i]+=cnt[i-1];
                  ans=max(cnt[i],ans);
            }
            cout<<ans<<endl;
      }
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<pair<string,int> > train;
    // begin+1 end-1;
    REP(i,n){
      string b,e;
      cin >> b >> e;
      train.push_back(make_pair(b,1));
      train.push_back(make_pair(e,-1));
    }
    SORT(train);
    int tmp=0,answer=0;
    REP(i,train.size()){
      tmp+=train[i].second;
      answer=max(answer,tmp);
    }
    cout << answer << endl;
  }
}

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


typedef struct{
	int start,end;
	bool labelFlag;
}jikan;

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

int main(){
	int n,cnt,ans;
	int h,m,s;
	jikan interval[10000];
	
	for(int i=0;i<10000;i++){
		interval[i].start=0;
		interval[i].end=0;
		interval[i].labelFlag=false;
	}
	while(cin>>n,n){
		cnt=1;
		ans=1;
		for(int i=0;i<10000;i++){
			interval[i].start=0;
			interval[i].end=0;
		}
		
		for(int i=0;i<n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].start=jikanShori(h,m,s);
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].end=jikanShori(h,m,s);
		}
		
		//sort(interval,interval+n,LessStart);
		
		for(int i=0;i<n;i++){
			cnt=1;
			if(!interval[i].labelFlag){
				interval[i].labelFlag=true;
				for(int j=i+1;j<n;j++){
					if(interval[i].end>interval[j].start && 
									!interval[j].labelFlag){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
			ans=max(ans,cnt);
		}
		
		cout<<ans<<endl;
	}
}

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

using namespace std;

bool dabu(int a, int b,int a1,int b1){
	if (a1>=b)return 0;
	if (b1<=a)return 0;
	return 1;
}

int main(){
	int n;
	vector<vector<int>>jikoku(10000,vector<int>(2));
	while (cin >> n, n){
		int ans=1;
		int ans1 = 1;
        int si,shu;
		for (int i = 0; i < n; i++){
			int  si1, si2, si3, shu1, shu2, shu3;
			scanf("%d:%d:%d %d:%d:%d", &si1, &si2, &si3, &shu1, &shu2, &shu3);
			si = 3600 * si1 + 60 * si2 + si3;
			shu = 3600 * shu1 + 60 * shu2 + shu3;
			jikoku[i][0]=si;
			jikoku[i][1]=shu;
        }
        for(int i=0;i<n;i++){
			ans = 1;
			for (int j=0; j < n; j++){
                if(i==j)continue;
				ans += dabu(jikoku[j][0], jikoku[j][1], jikoku[i][0], jikoku[i][1]);
			}
			ans1 = max(ans, ans1);
		}
		cout << ans1 << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

const int T = 24 * 60 * 60;

int main(){
  istringstream ss;
  while(1){
    int n;
    cin >> n;
    if (n == 0) break;
    vector<int> sum(T+1, 0);
    rep(i, n){
      vector<string> s(2);
      cin >> s[0] >> s[1];
      rep(k, 2){
        int t = 0;
        rep(j, 3){
          ss = istringstream(s[k].substr(j*3, 2));
          int num; ss >> num;
          t += num * pow(60, 2-j);
        }
        if (k == 0) sum[t]++;
        else sum[t]--;
      }
    }
    
    int ans = sum[0];
    rep(i, T){
      sum[i+1] += sum[i];
      ans = max(ans, sum[i+1]);
    }
    cout << ans << endl;
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int MAX = 24 * 60 * 60 + 2;

int get_timestamp(string t)
{
  int h = stoi(t.substr(0, 2));
  int m = stoi(t.substr(3, 2));
  int s = stoi(t.substr(6, 2));
  return h * 60 * 60 + m * 60 + s;
}

int main()
{
  while (1)
  {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<int> t(MAX, 0);
    rep(i, n)
    {
      string s, e;
      cin >> s >> e;
      t.at(get_timestamp(s))++;
      t.at(get_timestamp(e))--;
    }
    rep(i, MAX - 1)
    {
      t.at(i + 1) += t.at(i);
    }
    int ans = 0;
    rep(i, MAX - 1)
    {
      ans = max(ans, t.at(i));
    }
    cout << ans << endl;
  }
}