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 <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

struct E {
    int time, c;
    E(int time, int c) : time(time), c(c) {}
    bool operator<(const E& e) const {
        if (time == e.time) {
            return c < e.c;
        }
        return time < e.time;
    }
};

int N;
vector<E> es;
bool input() {
    es.clear();
    scanf("%d\n", &N);
    if (N == 0) return false;
    for (int i = 0; i < N; i++) {
        int h, m, s;
        scanf("%d:%d:%d", &h, &m, &s);
        int from = h * 3600 + m * 60 + s;
        es.push_back(E(from, +1));
        scanf(" %d:%d:%d\n", &h, &m, &s);
        int to = h * 3600 + m * 60 + s;
        es.push_back(E(to, -1));
    }
    return true;
}

void solve() {
    sort(es.begin(), es.end());
    int ans = 0;
    int pool = 0;
    for (int i = 0; i < es.size(); i++) {
        const E& e = es[i];
        if (e.c == 1) {
            if (pool > 0) pool--;
            else ans++;
        } else {
            pool++;
        }
    }
    printf("%d\n", ans);
}

int main() {
    while (input()) solve();
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int v[20000];
int b[10000], e[10000];
int p[20000];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(p, 0, sizeof(p));
		
		for (int i = 0; i < n; i++){
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			b[i] = h * 60 * 60 + m * 60 + s;
			scanf("%d:%d:%d", &h, &m, &s);
			e[i] = h * 60 * 60 + m * 60 + s;
			
			v[i * 2] = b[i];
			v[i * 2 + 1] = e[i];
		}
		
		sort(v, v + 2 * n);
		
		for (int i = 0; i < n; i++){
			b[i] = lower_bound(v, v + 2 * n, b[i]) - v;
			e[i] = lower_bound(v, v + 2 * n, e[i]) - v;
			p[b[i]] += 1;
			p[e[i]] -= 1;
		}
		
		int num = 0;
		int res = 0;
		
		for (int i = 0; i < 2 * n; i++){
			num += p[i];
			res = max(res, num);
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;++i)
typedef long long int ll;

int hour(string s){
    return stoi(s.substr(0,2));
}
int minute(string s){
    return stoi(s.substr(3,2));
}
int sec(string s){
    return stoi(s.substr(6,2));
}
int hms(string s){
    int ss=hour(s);
    int tt=minute(s);
    int uu=sec(s);
    return ss*3600+tt*60+uu;
}

int main(){

    while(1){
        int n;
        cin >> n;
        if(n==0)break;
        vector<pair<int,int>> se(n);
        rep(i,n){
            string s,t;
            cin >> s >> t;
            se[i].first=hms(s);
            se[i].second=hms(t);
        }
        vector<int> ti(86400,0);
        for(int i=0;i<n;i++){
            ti[se[i].first]++;
            ti[se[i].second]--;            
        }
        int ma=ti[0];
        for(int i=0;i<86400-1;i++){
            ti[i+1]+=ti[i];
            ma=max(ma,ti[i+1]);
        }
        cout << ma << endl;
    }

    return 0;
}

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

using namespace std;

struct DATA{
  int time;
  int log;
};

int GetTime(const string);
int AtoiString(const string);
bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, count, _count;
  string s, t;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> s >> t;
      _data.time = GetTime(s);
      _data.log = 1;
      data.push_back(_data);
      _data.time = GetTime(t);
      _data.log = -1;
      data.push_back(_data);
    }

    sort(data.begin(), data.end(), Compare);

    for(i=0, count=0, _count=0; i<data.size(); ++i){
      _count += data[i].log;
      if(count < _count) count = _count;
    }
    cout << count << endl;
    data.clear();
  }
  return 0;
}

int GetTime(const string str){
  string s, t, u;
  copy(str.begin(), str.begin()+2, back_inserter(s));
  copy(str.begin()+3, str.begin()+5, back_inserter(t));
  copy(str.begin()+6, str.end(), back_inserter(u));
  return AtoiString(s) * 3600 + AtoiString(t) * 60 + AtoiString(u);
}

int AtoiString(const string s){
  int i, x, d;
  for(i=s.size()-1, x=0, d=1; i>=0; --i, d*=10)
    x += ((s[i] - 48) * d);
  return x;
}

bool Compare(const DATA& x, const DATA& y){
  if(x.time == y.time)
    return x.log < y.log; 
  else
    return x.time < y.time;
}

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

using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  vector<int> ary(24*60*60,0);
  int n;
  while(cin>>n,n){
    char b[9],e[9];
    while(n--){
      cin>>b>>e;
      int h,m,s;
      sscanf(b,"%d:%d:%d",&h,&m,&s);
      int start = ((h * 60) + m) * 60 + s; 
      sscanf(e,"%d:%d:%d",&h,&m,&s);
      int finish = ((h * 60) + m) * 60 + s; 
      for(int i = start ; i < finish ; i ++)ary[i]++;
    }
    int ret = -1;
    for(int i = 0 ; i < ary.size() ; i ++)ret = max(ret,ary[i]);
    cout<<ret<<endl;
  }
}