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<stdio.h>
#include<algorithm>
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int m[86400]={};
		for(int i=0;i<n;i++){
			int bh,bm,bs,eh,em,es;
			scanf("%d:%d:%d %d:%d:%d",&bh,&bm,&bs,&eh,&em,&es);
			m[(bh*60*60)+(bm*60)+bs]+=1;
			m[(eh*60*60)+(em*60)+es]+=-1;
		}
		int count=0,ans=0;
		for(int i=0;i<86400;i++){
			count+=m[i];
			ans=max(ans,count);
		}
		cout << ans << endl;
	}
}

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

const int CountStop=245959;

int main() {
  while (1) {
    int n; cin>>n;
    if (n==0) break;
    vector<int> x(CountStop+1, 0);
    rep(i, n) {
      string S,G; cin>>S>>G;
      int start=0;
      start+=(int)(S[0]-'0')*100000;
      start+=(int)(S[1]-'0')*10000;
      start+=(int)(S[3]-'0')*1000;
      start+=(int)(S[4]-'0')*100;
      start+=(int)(S[6]-'0')*10;
      start+=(int)(S[7]-'0')*1;
      x[start]++;
      int goal=0;
      goal+=(int)(G[0]-'0')*100000;
      goal+=(int)(G[1]-'0')*10000;
      goal+=(int)(G[3]-'0')*1000;
      goal+=(int)(G[4]-'0')*100;
      goal+=(int)(G[6]-'0')*10;
      goal+=(int)(G[7]-'0')*1;
      x[goal]--;
    }
    rep(i, CountStop) x[i+1]+=x[i];
    int res=0;
    rep(i, CountStop+1) res=max(res, x[i]);
    cout<<res<<endl;
  }
}

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

int main (){
  int n;
  vector< pair<int,int> > tm;
  while(cin>>n && n){
    tm.clear();
    char ch1,ch2;
    int h,m,s;
    for(int i=0;i<n;i++){
      cin>>h>>ch1>>m>>ch2>>s;
      tm.push_back(make_pair(h*3600+m*60+s,1));
      cin>>h>>ch1>>m>>ch2>>s;
      tm.push_back(make_pair(h*3600+m*60+s,-1));
    }
    sort(tm.begin(),tm.end());
    int ans=0;
    int co=0;
    for(int i=0;i<(int)tm.size();i++){
      co+=tm[i].second;
      ans = max(co,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
	int n, data[6], x[864001] = { 0 };
	int max_mini = 0;
	while (cin >> n) {
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			scanf("%d:%d:%d %d:%d:%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5]);
			x[data[0] * 3600 + data[1] * 60 + data[2]]++;
			x[data[3] * 3600 + data[4] * 60 + data[5]]--;
			if (max_mini < data[3] * 3600 + data[4] * 60 + data[5])
				max_mini = data[3] * 3600 + data[4] * 60 + data[5];
		}
		int ans = 0, cnt = 0;
		for (int i = 0; i <= max_mini; i++) {
			cnt += x[i];
			ans = max(ans, cnt);
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#define INF 1 << 28
using namespace std;

typedef pair<int,int> P;

int main ()
{
    int n;
    while (cin >> n, n) {
        string str1, str2;
        vector<P> time;
        while (n--) {
            cin >> str1 >> str2;
            for (int i = 0; i < str1.size(); i++) {
                if (str1[i] == ' ') {
                    str1[i] = str2[i] = ' ';
                }
            }

            stringstream ss1, ss2;
            ss1 << str1;
            ss2 << str2;

            int t1, t2, t3;
            ss1 >> t1 >> t2 >> t3;
            int s = t1 * 60 * 60 + t2 * 60 + t3;
            ss2 >> t1 >> t2 >> t3;
            int e = t1 * 60 * 60 + t2 * 60 + t3;

            time.push_back(P(s,e));
        }

        time.push_back(P(INF,INF));
        vector<int> st, et;
        for (int i = 0; i < time.size(); i++) {
            st.push_back(time[i].first);
            et.push_back(time[i].second);
        }

        int k = 0, l = 0;
        int tmp = 0, MAX = 0;
        while (st[k] != INF || et[l] != INF) {
            if (st[k] < et[l]) {
                tmp++;
                k++;
            } else if (k > 0 && (st[k - 1] + 60 * 60) <= et[l]) {
                tmp--;
                l++;
            } else {
                l++;
                MAX = MAX < tmp + 1 ? tmp + 1 : MAX;
            }
            MAX = MAX < tmp ? tmp : MAX;
        }

        cout << MAX << endl;
    }

    return 0;
}

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

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

int main(){
	int n;
	while( scanf("%d", &n ), n ){
		int H[60*60*24+1] = {0};
		
		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 );
			int t1 = to_sec( h1 , m1 , s1 );
			int t2 = to_sec( h2 , m2 , s2 );
			for(int t = t1 ; t < t2 ; t++ ){
				H[t]++;
			}
		}
		int ans = 0;
		for(int t=0 ; t < 60*60*24+1 ; t++ ){
			ans = max( ans , H[t] );
		}
		cout <<  ans << endl;
	}
}