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 <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	while(cin>>n,n)
	{
		vector<pair<int,int>> v;
		REP(i,n)
		{
			int a,b,c,t;
			scanf("%d:%d:%d",&a,&b,&c);
			t = 3600*a+60*b+c;
			v.push_back(make_pair(t,1));
			scanf("%d:%d:%d",&a,&b,&c);
			t = 3600*a+60*b+c;
			v.push_back(make_pair(t,-1));
		}
		sort(v.begin(),v.end());
		int cnt = 0;int train = 0;
		REP(i,2*n)
		{
		if(train==0&&v[i].second == 1)
		{
		cnt++;
		}
		else train-=v[i].second;
		}
		cout<<cnt<<endl;
	}
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int h, m, s;
		char c;
		priority_queue< P, vector<P>, greater<P> > pq;
		int start, end;
		for (int i = 0; i < n; i++) {
			cin >> h >> c >> m >> c >> s;
			start = h*3600+m*60+s;
			cin >> h >> c >> m >> c >> s;
			end = h*3600+m*60+s;
			P p = P(end, start);
			pq.push(p);
		}
		vector<int> data[2];
		while (!pq.empty()) {
			P pp = pq.top();
			pq.pop();
			data[0].push_back(pp.first);
			data[1].push_back(pp.second);
		}
		int MAX = 0;
		int counter = 0;
		for (int i = 0; i < n; i++) {
			counter = 0;
			for (int j = i; j < n; j++) {
				if (data[0][i] > data[1][j]) {
					counter++;
				}
			}
			MAX = max(MAX, counter);
		}
		cout << MAX << endl;
	}
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

struct data_t {
	int hh;
	int mm;
	int ss;

	bool operator<(const data_t& right) const {
		if ( hh ==  right.hh ) {
			if ( mm == right.mm ) {
				return ( ss == right.ss ) || ( ss < right.ss );
			}
			else {
				return ( mm < right.mm );
			}
		}
		else {
			return ( hh < right.hh );
		}
	}
};

bool is_early(data_t d1, data_t d2) {
	if (d1.hh == d2.hh) {
		if (d1.mm == d2.mm) {
			return (d1.ss < d2.ss);
		}
		else {
			return (d1.mm < d2.mm);
		}
	}
	else {
		return (d1.hh < d2.hh);
	}
}

int main(void) {
	int n;
	cin >> n;

	char c;
	while ( n != 0 ) {
		std::vector<data_t> start(n+1); 
		std::vector<data_t> stop(n+1); 
		for (int i = 0; i < n; i++) {
			cin >> start[i].hh;
			cin >> c;
			cin >> start[i].mm;
			cin >> c;
			cin >> start[i].ss;

			cin >> stop[i].hh;
			cin >> c;
			cin >> stop[i].mm;
			cin >> c;
			cin >> stop[i].ss;
		}

		start[n].hh = 100;
		start[n].mm = 100;
		start[n].ss = 100;
		stop[n].hh = 100;
		stop[n].mm = 100;
		stop[n].ss = 100;
		std::sort(start.begin(), start.end());
		std::sort(stop.begin(), stop.end());

		std::stack<bool> train;
		int count_t = 0;
		int r1 = 0;
		int r2 = 0;
		for (int i = 0; i < (n*2); i++) {
			if (is_early(start[r1],stop[r2])) {
				if (train.empty()) {
					count_t++;
				}
				else {
					train.pop();
				}
				r1++;
			}
			else {
				train.push(true);
				r2++;
			}
		}

		cout << count_t << endl;
		cin >> n;
	}

	return 0;
}

C++: #include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <stdlib.h>
#include <algorithm>

#define L 1
#define A 0

using namespace std;

int main(void)
{
	int n;
	string s,a;
	int i1;
	int max;
	int count;
	


	while(1){

		vector<int> v;

		cin >> n;
		if (n == 0) break;


		vector< pair<string,int> > t;


		for(i1=0;i1<n;i1++){
			cin >> s;
			cin >> a;

			t.push_back(make_pair(s,L));
			t.push_back(make_pair(a,A));

		}

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

		
		v.push_back(t[0].second);
		max=v.size();
		vector<int>::iterator it;

//	for(i1=0;i1<2*n;i1++) cout<<t[i1].second<<endl;


		for(i1=1;i1<2*n;i1++){
//			it = find(v.begin(),v.end(),t[i1].second);

			if(t[i1].second == L) {
				v.push_back(L);
			}
			else {
				v.pop_back();
			}

			if(max < v.size()) max = v.size();
		}

		cout << max << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
int tosc(int h, int m,int s){
  return h*3600 + m * 60 + s;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P> v;
    REP(i,n){
      int h,m,s;
      scanf("%d:%d:%d",&h,&m,&s);
      int m1 = tosc(h,m,s);
      scanf("%d:%d:%d",&h,&m,&s);
      int m2 = tosc(h,m,s);
      v.push_back(make_pair(m1,m2));
    }
    sort(v.begin(),v.end());
    int ans = 0;
    priority_queue<int, vector<int>, greater<int> > que;
    REP(i,n){
      if(que.empty() || que.top() > v[i].first){
        ans++;
      }else{
        que.pop();
      }
      que.push(v[i].second);
    }
    cout<<ans<<endl;
  }
  return 0;
}