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 <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[1];
		}
		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;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int calc_time(string s){
    int t[3];
    for(int i = 0; i <= 6; i += 3)
      t[i / 3] = (s[i] - '0') * 10 + (s[i + 1] - '0');
    return t[0] * 3600 + t[1] * 60 + t[2];
}
typedef pair<int, bool> pib;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while(cin >> N && N){
        vector<pib> t;
        rep(i, N){
            string a, b; cin >> a >> b;
            t.push_back(pib(calc_time(a), true));
            t.push_back(pib(calc_time(b), false));
        }
        sort(t.begin(), t.end());
        int res = 0, running = 0;
        for(const pib& k : t){
            if(k.second) running++; else running--;
            res = max(res, running);
        }
        cout << res << endl;
    }
    return 0;
}

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

struct data{
	int s, t;
};

int main(){
	int n;
	while(cin >> n && n){
		queue<data> qd1, qd2;
		for(int i = 0; i < n; i++){
			string s1, s2;
			cin >> s1 >> s2;
			data d;
			d.s = (s1[0]-'0')*36000 + (s1[1]-'0')*3600 + (s1[3]-'0')*600 + 
				(s1[4]-'0')*60 + (s1[6]-'0')*10 + (s1[7]-'0');
			d.t = (s2[0]-'0')*36000 + (s2[1]-'0')*3600 + (s2[3]-'0')*600 + 
				(s2[4]-'0')*60 + (s2[6]-'0')*10 + (s2[7]-'0');
			qd1.push(d);
		}
		while(!qd1.empty()){
			data d = qd1.front();
			qd1.pop();
			if(qd2.empty()){
				qd2.push(d);
			}else{
				data d2 = qd2.front();
				if(d2.t <= d.s) qd2.pop();
				qd2.push(d);
			}
		}
		cout << qd2.size() << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int bh[n],bm[n],bs[n],eh[n],em[n],es[n];
		for(int i=0;i<n;i++)
		scanf("%d:%d:%d %d:%d:%d",&bh[i],&bm[i],&bs[i],&eh[i],&em[i],&es[i]);
		int count=0,m=1;
		for(int i=0;i<n;i++){
			for(int j=1;i+j<n;j++){
				if(((eh[i]==bh[i+j])&&(em[i]==bm[i+j])&&(es[i]>bs[i+j]))||((eh[i]==bh[i+j])&&(em[i]>bm[i+j]))||eh[i]>bh[i+j]){
					count++;
				}
				else{
				i=j;
				break;
				}
			}
			m=max(m,count);
		}
		cout << m << endl;
	}
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	while(cin>>n,n){
		vector<pii> dia;
		dia.clear();
		for(int i = 0;i < n;i++){
			string str;
			int h,m,s;
			cin>>str;
			h = ((str[0]-'0')*10+(str[1]-'0'))*60*60;
			m =((str[3]-'0')*10 +(str[4]-'0'))*60;
			s =(str[6]-'0')*10+(str[7]-'0');
			int dep = h+m+s;
			dia.push_back(pii(dep,1));
			cin>>str;
			h = ((str[0]-'0')*10+(str[1]-'0'))*60*60;
			m =((str[3]-'0')*10 +(str[4]-'0'))*60;
			s =(str[6]-'0')*10+(str[7]-'0');
			int arr = h+m+s;
			dia.push_back(pii(arr,-1));
		}
		sort(dia.begin(),dia.end());
		int ans = 0;
		int cnt = 0;
		for(int i = 0;i <dia.size();i++){
			cnt +=dia[i].second;
			ans =max(ans,cnt);
		}
		cout <<ans<<endl;
	}
	return 0;
}