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<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    pii v[10000];
    string s;
    rep(i,n){
      int a,b;
      cin>>s;
      a=(s[0]-'0')*10+(s[1]-'0');
      a*=60;
      a+=(s[3]-'0')*10+(s[4]-'0');
      a*=60;
      a+=(s[6]-'0')*10+(s[7]-'0');
      cin>>s;
      b=(s[0]-'0')*10+(s[1]-'0');
      b*=60;
      b+=(s[3]-'0')*10+(s[4]-'0');
      b*=60;
      b+=(s[6]-'0')*10+(s[7]-'0');
      v[i].first=a;
      v[i].second=b; 
   }
    sort(v,v+n);
    priority_queue<int> q;
    q.push(-v[0].second);
    loop(i,1,n){
      if(q.top()>=-v[i].first)q.pop();
      q.push(v[i].second);
    }
    cout<<q.size()<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	char d;
	while(cin>>n) {
		if(n == 0){
			break;
		}
		vector<P> t(n);
		int h[2],m[2],s[2];
		for(int i= 0;i < n;i++){
			cin >> h[0]>> d >> m[0] >> d >> s[0] >> h[1] >> d >>m[1]>> d >>s[1];
			t[i].first= h[0]*3600+m[0]*60+s[0];
			t[i].second= h[1]*3600+m[1]*60+s[0];
		}
		for (int i =n-1; i> 0; i--) {
			for (int j =0; j < i; j++){
				if (t[j].first > t[j+1].first) {
					swap(t[j], t[j+1]);
				} else if (t[j].first == t[j+1].first){
					if (t[j].second > t[j+1].second) {
						swap(t[j], t[j+1]);
					}
				}
			}
		}
		queue<P> t1;
		priority_queue<int, vector<int>, greater<int>> t2;
		for (int i=0; i< n; i++) {
			t1.push(t[i]);
		}
		int train =0;
		P p = t1.front();
		t1.pop();
		t2.push(p.second);
		train++;
		for (int i= 1; i < n; i++){
			p = t1.front();
			t1.pop();
			if (!t2.empty() && t2.top() <= p.first) {
				t2.pop();
			} else {
				train++;
			}
			t2.push(p.second);
		}
		cout<<train << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){
    int table[100000] = {0};
    for(int i = 0; i < n; i++){
      int sh, sm, ss, th, tm, ts;
      scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
      table[sh*3600+sm*60+ss]++;
      table[th*3600+tm*60+ts]--;
    }
    for(int i = 1; i < 100000; i++) table[i] += table[i-1];
    cout << *max_element(table, table + 100000) << endl;
  }
  return 0;
}

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

#define IN 1;
#define OUT -1;

struct data{string time;int io;};
//bool operator<(data a,data b){return a.time<b.time?1:a.io<b.io;}
bool operator<(data a,data b){return a.time!=b.time?a.time<b.time:a.io<b.io;}

int main()
{
  int n,i,cnt,max;
  vector<data> v;
  while(cin>>n,n){
    v.resize(2*n);
    for(i=0;i<2*n;i+=2){
      cin>>v[i].time>>v[i+1].time;
      v[i].io=IN;
      v[i+1].io=OUT;
    }
    sort(v.begin(),v.end());
    for(cnt=max=i=0;i<2*n;i++){
      cnt+=v[i].io;
      if(max<cnt)max=cnt;
    }
    cout<<max<<endl;
  }
}

C++: #include <iostream>
#include <string>
#define M  24*60*60
int table[M];

using namespace std;

int main(){
  int n;
  string str;
  while(cin >> n, n){
    for(int i = 0; i < M; i++){
      table[i] = 0;
    }
    for(int i = 0; i < n; i++){
      cin >> str;
      int s = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[s]++;
      cin >> str;
      int e = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[e]--;
    }
    for(int i = 1; i < M; i++){
      table[i] += table[i-1];
    }
    int max = 0;
    for(int i = 0; i < M; i++){
      if(max < table[i]) max = table[i];
    }
    cout << max << endl;
  }


}

C++: #include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/* respect for nanikaka-senpai */

struct Note {
  const static int ARRV = 0;
  const static int DEPT = 1;
  int time;
  int type;
};

bool operator < (const Note& s, const Note& t ) {
  if( s.time == t.time ) {
    return s.type < t.type;
  }
  return s.time < t.time;
}

int conv ( string t ) {
  return (
    ( ( t[ 0 ] - '0' ) * 10 + t[ 1 ] - '0' ) * 3600 +
    ( ( t[ 3 ] - '0' ) * 10 + t[ 4 ] - '0' ) * 60   +
    ( ( t[ 6 ] - '0' ) * 10 + t[ 7 ] - '0' )
  );
}

int main() {
  while( 1 ) {
    int n;
    cin >> n;
    if( !n ) { return EXIT_SUCCESS; }
    
    vector<Note> v;   
    for( int i = 0; i < n; i++ ) {
      string dept, arrv;
      cin >> dept >> arrv;
      
      Note nd, na;
      nd.time = conv( dept );
      nd.type = Note::DEPT;
      na.time = conv( arrv );
      na.type = Note::ARRV;
      v.push_back( nd );
      v.push_back( na );
    }
    sort( v.begin(), v.end() );
    int len = v.size();
    int trN = 0;
    int trMax = 0;
    for( int i = 0; i < len; i++ ) {
      if( v[ i ].type == Note::DEPT ) {
        trN++;
        trMax = max( trN, trMax );
      } else {
        trN--;
      }
    }
    
    cout << trMax << endl;
  }
}