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<cmath>
#include<algorithm>
using namespace std;

int Time(string t, string h, string m, string s){
  h = t.substr(0, 2);
  m = t.substr(3, 2);
  s = t.substr(6, 2);
  return atoi(h.c_str())*3600 + atoi(m.c_str())*60 + atoi(s.c_str());
}

int main(int argc, char *argv[]){
  int n;
  int table[24*3600] = {0};
  while(cin >> n, n){
    string t;
    for (int i = 0; i < n; i++) {
      cin >> t;
      string h, m, s;
      int st = Time(t, h, m, s);
      cin >> t;
      int e  = Time(t, h, m, s);
      table[st]++;
      table[e]--;
    }
    int a = 0;
    int Max = 0;
    for (int i = 0; i < 24*3600; i++) {
      a += table[i];
      Max = max(Max, a);
    }
    std::cout << Max << std::endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int n; cin >> n, n; )
	{
		VPII events;

		REP( i, 0, n )
		{
			int h1, m1, s1, h2, m2, s2;
			char d;
			cin >> h1 >> d >> m1 >> d >> s1 >> h2 >> d >> m2 >> d >> s2;
			events.PB( MP( h1 * 3600 + m1 * 60 + s1, 1 ) );
			events.PB( MP( h2 * 3600 + m1 * 60 + s2, -1 ) );
		}
		sort( ALL( events ) );

		int res = 0, cur = 0;
		REP( i, 0, events.size() )
		{
			res = max( res, ( cur += events[i].snd ) );
		}
		cout << res << endl;
	}

	return 0;
}

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


using namespace std;

const int INF=1e+8;

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

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


//比較関数
int comp(const void *c1,const void *c2){
	jikan jikan1=*(jikan *)c1;
	jikan jikan2=*(jikan *)c2;
	
	int tmp1=jikan1.start;
	int tmp2=jikan2.start;
	
	return tmp1-tmp2;
}

int main(){
	int n,cnt,ans;
	int h,m,s;
	jikan interval[10000];
	
	
	while(cin>>n,n){
		cnt=1;
		ans=1;
		for(int i=0;i<10000;i++){
			interval[i].start=INF;
			interval[i].end=INF;
			interval[i].labelFlag=false;
		}
		
		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);
		}
		
		qsort(interval,10000,sizeof(jikan),comp);
		
		for(int i=0;i<n;i++){
			cnt=1;
			//if(!interval[i].labelFlag){
				//interval[i].labelFlag=true;
				for(int j=0;j<n;j++){
					if(interval[i].end>interval[j].start){
						cnt++;
						//interval[j].labelFlag=true;
					}
				}
			//}
			ans=max(ans,cnt);
		}
		
		cout<<ans<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        vector<int> cnt(24*60*60+3);
        
        for(int i=0;i<N;i++){
            string S;cin>>S;
            int sum=0;
            sum+=(S[0]-'0')*10*60*60;
            sum+=(S[1]-'0')*60*60;
            sum+=(S[3]-'0')*10*60;
            sum+=(S[4]-'0')*60;
            sum+=(S[6]-'0')*10;
            sum+=(S[7]-'0');
            
            cnt[sum+1]++;
            
            sum=0;
            cin>>S;
            
            sum+=(S[0]-'0')*10*60*60;
            sum+=(S[1]-'0')*60*60;
            sum+=(S[3]-'0')*10*60;
            sum+=(S[4]-'0')*60;
            sum+=(S[6]-'0')*10;
            sum+=(S[7]-'0');
            
            cnt[sum+1]--;
        }
        
        int ans=0;
        
        for(int i=1;i<cnt.size();i++){
            cnt[i]+=cnt[i-1];
            ans=max(ans,cnt[i]);
        }
        
        cout<<ans<<endl;
        
    }
    
}