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>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
#include<sstream>

  using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)


typedef pair<int,int> pii;

int main()
{
  
  while(true){
    int n;cin>>n;
    if(n==0)break;
    priority_queue<pii> que;
    int ans=0;
    rep(i,n){
      string s,e;cin>>s>>e;
      pii train;
      const char *s_char = s.c_str();
      const char *e_char = e.c_str();
      int hour,minute,second;
      sscanf(s_char, "%d:%d:%d",&hour,&minute,&second);
      train.second=hour*60*60+minute*60+second;
      sscanf(e_char, "%d:%d:%d",&hour,&minute,&second);
      train.first=hour*60*60+minute*60+second;
      

      while(que.size()>0 && train.second>=que.top().first){
        que.pop();
      }
      que.push(train);
      ans=max(ans,(int)que.size());
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N;
    vector<int> ans;
    while(true){
        vector<int> train(60*60*24, 0);
        cin >> N;
        if(N == 0) break;
        rep(i, N){
            string S, T; cin >> S >> T;
            int h, m, s;
            h = (S[0]-'0')*10 + (S[1]-'0');
            m = (S[3]-'0')*10 + (S[4]-'0');
            s = (S[6]-'0')*10 + (S[7]-'0');
            train[h*3600 + m*60 + s]++;

            //cout << h << " " << m << " " << s << endl;

            h = (T[0]-'0')*10 + (T[1]-'0');
            m = (T[3]-'0')*10 + (T[4]-'0');
            s = (T[6]-'0')*10 + (T[7]-'0');
            train[h*3600 + m*60 + s]--;
        }
        int res = 0;
        rep(i, 86399){
            train[i+1] += train[i];
            res = max(res, train[i+1]);
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

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

struct TIME {
	int time;
	int start;
	bool operator<(const TIME &t) const{
		if( time == t.time ){
			return start<t.start;
		}
		return time<t.time;
	}
};

int main() {
	while(true){
		
		vector<TIME> times;
		
		int n;
		cin >> n;
		if(n==0)break;
		
		for(int i=0;i<n;i++){
			int h,m,s;
			char c;
			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s <<endl; 
			TIME t0={h*60*60+m*60+s,1};
			times.push_back(t0);

			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s<<endl; 
			TIME t1={h*60*60+m*60+s,0};
			times.push_back(t1);
		}

		sort( times.begin(),times.end());

		int count=0;
		int ans=0;
		for(TIME &t : times){
//			cout << t.start << " " << t.time << endl;;
			if(t.start==1){
				count++;
				ans=max(count,ans);
			}else{
				count--;
			}
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
#define max_t 24 * 60 * 60

int main(){
    int n;
    while( cin >> n, n ){
        int list[max_t] = {};
        while( n-- ){
            int d_h, d_m, d_s;      // the departure time
            int a_h, a_m, a_s;      // the arrival time
            //cin >> d_h >> ":" >> d_m >> ":" >> d_s;
            //cin >> a_h >> ":" >> a_m >> ":" >> a_s;
            scanf("%d:%d:%d", &d_h, &d_m, &d_s );
            scanf("%d:%d:%d", &a_h, &a_m, &a_s );
            int s, e;
            s = d_h * 60 * 60 + d_m * 60 + d_s;
            e = a_h * 60 * 60 + a_m * 60 + a_s;
            //cout << s << " " << e << endl;
            for( int i = s; i < e; i++ ){
                list[i]++;
            }
        }
        int max = 0;
        for( int i = 0; i < max_t; i++ ){
            if( max < list[i] ) max = list[i];
        }
        cout << max << endl;
    }
}

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

const int H=60*60;
const int M=60;
const int S =1;

int train[24*H+1];
int unit[3]={H,M,S};

int getTime(string s){
  string tmp;
  int res=0;
  for(int i=0;i<3;i++){
    tmp=s.substr(3*i,2);
    int val=atoi(tmp.c_str());
    res+=unit[i]*val;
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    memset(train,0,sizeof(train));
    for(int i=0;i<n;i++){
      string start,arrival;
      int st=0,at=0;
      cin>>start>> arrival;
      st=getTime(start);
      at=getTime(arrival);
      for(int i=st;i<at;i++)train[i]++;
    }
    int ans=0;
    for(int i=0;i<=24*H;i++){
      ans=max(ans,train[i]);
      //cout << train[i] << " ";
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
long long int N[10000000]={};
int main(){

int n,q;
int h1=0,m1=0,s1=0,h2=0,m2=0,s2=0;
while(1){
cin>>n;if(n==0)break;
for(int i=0;i<n;i++)
{scanf("%d:%d:%d",&h1,&m1,&s1);
scanf("%d:%d:%d",&h2,&m2,&s2);
long int L1=h1*10000+m1*100+s1;
long int L2=h2*10000+m2*100+s2;
for(int j=L1;j<L2;j++)
	N[j]++;
}
int max=00;
for(int i=0;i<240000;i++)
{if(N[i]>max)max=N[i];}
cout<<max<<endl;
}
return 0;
}