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 <queue>
#include <string>
#include <vector>
using namespace std;

struct data{
	int s, t;
};

int main(){
	int n;
	while(cin >> n && n){
		queue<data> qd1;
		priority_queue<int, vector<int>, greater<int> > 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.t);
			}else{
				int d2 = qd2.top();
				if(d2 <= d.s) qd2.pop();
				qd2.push(d.t);
			}
		}
		cout << qd2.size() << endl;
	}
	return 0;
}

C++: #include <iostream>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 10000
using namespace std;
int ans,cou;
int n;
char s[10],g[10];
struct t {
  int h;
  int m;
  int s;
};
t start[MAX],goal[MAX];
int main() {
  while(true){
    cin >> n;
    if(n==0) return 0;
    ans = 0;
    cou = 0;
    rep(i,n){
      cin >> s >> g;
      start[i] = t();
      goal[i] = t();
      start[i].h = (int)(s[0]-'0')*10+(int)(s[1]-'0');
      start[i].m = (int)(s[3]-'0')*10+(int)(s[4]-'0');
      start[i].s = (int)(s[6]-'0')*10+(int)(s[7]-'0');
      goal[i].h = (int)(g[0]-'0')*10+(int)(g[1]-'0');
      goal[i].m = (int)(g[3]-'0')*10+(int)(g[4]-'0');
      goal[i].s = (int)(g[6]-'0')*10+(int)(g[7]-'0');
    }
    rep(i,24) rep(j,60) rep(k,60){
      rep(l,n) if(goal[l].h==i&&goal[l].m==j&&goal[l].s==k) cou--;
      rep(l,n) if(start[l].h==i&&start[l].m==j&&start[l].s==k){
        cou++;
        if(cou>ans) ans = cou;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <array>
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

using namespace std;

int to_second(string time) {
  auto h = stoi(time.substr(0, 2));
  auto m = stoi(time.substr(3, 2));
  auto s = stoi(time.substr(6, 2));
  return h * 60 * 60 + m * 60 + s;
}

int main() {
  int n;
  string str;

  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }

    vector<array<int, 2>> timetable(n);
    for (auto &y : timetable) {
      for (auto &x : y) {
        cin >> str;
        x = to_second(str);
      }
    }

    auto start_f = [](const array<int, 2> &t1, const array<int, 2> &t2) {
      return t1[0] < t2[0];
    };
    sort(timetable.begin(), timetable.end(), start_f);

    multiset<int> trains;  // record arraive-time
    int max_train = 0;
    for (auto x : timetable) {
      while (trains.cbegin() != trains.end() && *trains.cbegin() <= x[0]) {
        trains.erase(trains.cbegin());
      }

      trains.insert(x[1]);

      auto pool_size = trains.size();
      if (max_train < pool_size) {
        max_train = pool_size;
      }
    }

    // cout << max_train << endl;
    cout << max_train << endl;
  }
}

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

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    while(1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        VI time(60 * 60 * 24 + 1);
        for (int i = 0; i < n; i++) {
            int s_h;
            int s_m;
            int s_s;
            int e_h;
            int e_m;
            int e_s;
            scanf("%d:%d:%d %d:%d:%d", &s_h, &s_m, &s_s, &e_h, &e_m, &e_s);
            int start = 60 * 60 * s_h + 60 * s_m + s_s;
            int end = 60 * 60 * e_h + 60 * e_m + e_s;
            for (int j = start; j < end; j++) {
                time[j]++;
            }
        }
        int res = 0;
        for (int i = 0; i < (int)(time.size()); i++) {
            res = std::max(res, time[i]);
        }
        cout << res << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define ADAY 86400
using namespace std;
typedef long long ll;

int main(void){
  ll n;
  while(cin >> n, n){
    vector < pair < ll, ll > > t;
    for(ll i=0; i < n; i++){
      pair<ll, ll> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = (ll)(h * 3600 + m * 60 + s);
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = (ll)(h * 3600 + m * 60 + s);
      t.push_back(tmp);
    }

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

    ll ans = 0, movin = 0, ind = 0;
    queue<ll> q;
    for(ll now=0; now <= ADAY; now++){
      while(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      while(ind < n && now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}