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 <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);
    }

    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;
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int n, i, j, flag[86400], time[3] = {3600,60,1}, sum1, sum2, max;
	char str[9], c;
	while(1){
		scanf("%d%*c",&n);
		if(!n)
			break;
		memset(flag,0,sizeof(flag));
		for(i = 0;i < n;i++){
			j = 0;
			while((c = getchar()) != ' ')
				str[j++] = c;
			str[j] = '\0';
			sum1 = 0;
			for(j = 0;j < strlen(str);j+=3)
				sum1 += time[j / 3] * ((str[j] - '0') * 10 + str[j + 1] - '0');
			j = 0;
			while((c = getchar()) != '\n')
				str[j++] = c;
			str[j] = '\0';
			sum2 = 0;
			for(j = 0;j < strlen(str);j+=3)
				sum2 += time[j / 3] * ((str[j] - '0') * 10 + str[j + 1] - '0');
			for(j = sum1;j < sum2;j++)
				flag[j]++;
		}
		max = -1;
		for(i = 0;i < 86400;i++){
			if(max < flag[i])
				max = flag[i];
		}
		printf("%d\n",max);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int parseTime(string s)
{
    //hh:mm:ss
    int res = 0;
    res += (s[0] - '0') * 10 * 3600;
    res += (s[1] - '0') * 3600;
    res += (s[3] - '0') * 600;
    res += (s[4] - '0') * 60;
    res += (s[6] - '0') * 10;
    res += s[7] - '0';

    return res;
}

const int TMAX = 24 * 60 * 60;
int c[TMAX + 1];

int main()
{
    int n;
    while (cin >> n, n)
    {
        memset(c, 0, sizeof(c));
        rep(i, n)
        {
            string s;
            cin >> s;
            int t = parseTime(s);
            c[t]++;
            cin >> s;
            t = parseTime(s);
            c[t]--;
        }

        int ans = 0;
        int now = 0;
        rep(i, TMAX + 1)
        {
            now = now + c[i];
            ans = max(ans, now);
        }
        cout << ans << endl;
    }

    return 0;
}

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

const int time_max = 86410;

int imos[time_max];

int time_split(char Tens_Place,char One_Place){
    int return_num;
    string s = {Tens_Place, One_Place};
    stringstream ss;
    ss << s;
    ss >> return_num;
    return return_num;
}

int main() {

    while(1) {

        int n;

        cin >> n;

        if(n==0){
            break;
        }

        for(int i=0; i<time_max; i++){
            imos[i] = 0;
        }

        for (int i = 0; i < n; i++) {
            string start, goal;
            cin >> start >> goal;
            int h, m, s;
            h = time_split(start[0], start[1]);
            m = time_split(start[3], start[4]);
            s = time_split(start[6], start[7]);
            imos[h * 60 * 60 + m * 60 + s]++;
            h = time_split(goal[0], goal[1]);
            m = time_split(goal[3], goal[4]);
            s = time_split(goal[6], goal[7]);
            imos[h * 60 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < time_max; i++) {
            imos[i] += imos[i - 1];
        }

        int ans = 0;

        for (int i = 0; i < time_max; i++) {
            ans = max(ans, imos[i]);
        }

        cout << ans << endl;

    }

    return 0;
}

C++: #ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include<map>
using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
int main() {
	int N;
	while (cin >> N, N) {
		vector<string> s;
		REP(i,N){
			string t;
			cin >> t;
			s.push_back(t + "1");
			cin >> t;
			s.push_back(t + "0");
		}
		sort(ALL(s));
		int lb = 0;
		int ub = N;
		auto f = [&](int cnt) {
			for (auto &it : s) {
				if (it.back() == '1')cnt--; else cnt++;
				if (cnt < 0)return false;
			}
			return true;

		};
		while (ub - lb > 1) {
			const int mid = (lb + ub) / 2;
			if (f(mid))ub = mid;
			else lb = mid;
		}
		cout << ub << endl;
	}

}