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++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int, int> P;

int main(){
    int n;
    while (cin >> n && n){
        vector<P> v(n * 2);
        rep(i, n){
            int a, b, c, d, e, f;
            scanf("%d:%d:%d %d:%d:%d", &a, &b, &c, &d, &e, &f);
            int arive = a * 3600 + b * 60 + c;
            int leave = d * 3600 + e * 60 + f;
            v[i] = P(arive, 1);
            v[i + n] = P(leave, -1);
        }
        sort(all(v));

        int ans = 0;
        int cur = 0;
        rep(i, v.size()){
            cur += v[i].second;
            ans = max(ans, cur);
        }
        cout << ans << endl;
    }
}

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

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) {
    if (!item.empty()) {
      elems.push_back(item);
    }
  }
  return elems;
}

int to_seconds(vector<string> t) {
  int h = atoi(t[0].c_str()) * 3600;
  int m = atoi(t[1].c_str()) * 60;
  int s = atoi(t[2].c_str());
  return h + m + s;
}

const int MAX_M = 24 * 60 * 60;
int sum[MAX_M];

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    rep(i, MAX_M) sum[i] = 0;
    rep(i, n) {
      string a, b;
      cin >> a >> b;
      int dep = to_seconds(split(a, ':'));
      int arr = to_seconds(split(b, ':'));
      sum[dep]++;
      if (arr < MAX_M) sum[arr]--;
    }
    rep(i, MAX_M - 1) sum[i + 1] += sum[i];
    int ans = 0;
    rep(i, MAX_M) ans = max(ans, sum[i]);
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int toInt(char c)
{
	//cout << c << endl;
	return (int)(c - '0');
}
int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		vector<pair<int, int> > input;
		for (int i = 0; i < n; i++)
		{
			char line[15];
			pair<int, int> newRange;
			cin >> line;
			int hour = toInt(line[0]) * 10 + toInt(line[1]);
			int minute = toInt(line[3]) * 10 + toInt(line[4]);
			int second = toInt(line[6]) * 10 + toInt(line[7]);
			newRange.first = hour * 60 * 60 + minute * 60 + second;
			char line2[15];
			cin >> line2;
			hour = toInt(line2[0]) * 10 + toInt(line2[1]);
			minute = toInt(line2[3]) * 10 + toInt(line2[4]);
			second = toInt(line2[6]) * 10 + toInt(line2[7]);
			newRange.second = hour * 60 * 60 + minute * 60 + second;
			input.push_back(newRange);
		}

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

		vector<pair<int, int> > out[10000 + 1];
		int vectorIndex = 0;
		for (int i = 0; i < n; i++)
		{
			bool flag = false;
			for (int j = 0; j < vectorIndex; j++)
			{
				bool f = false;
				for (int k = 0; k < out[j].size(); k++)
				{
					if (input.at(i).first >= out[j].at(k).first && input.at(i).first < out[j].at(k).second ||
						input.at(i).second > out[j].at(k).first && input.at(i).second <= out[j].at(k).second)
					{
						f = true;
						break;
					}
				}

				if (!f)
				{
					out[j].push_back(input.at(i));
					flag = true;
					break;
				}
			}

			if (!flag)
			{
				out[vectorIndex++].push_back(input.at(i));
			}
		}
		cout << vectorIndex << endl;
	}
	return 0;
}

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

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

using namespace std;

int main()
{

  int n ;

  while(cin >> n && n!=0)
    {

      int max = -1;
      int h,m,s;
      int start,end;
      vector<int> time(240001);

      fill(time.begin(),time.end(),0);

      rep(i,n){

        scanf("%d:%d:%d",&h,&m,&s);
        start = h*10000 + m*100 + s;
        scanf("%d:%d:%d",&h,&m,&s);
        end = h*10000 + m*100 + s;

        time[start]++;
        time[end]--;

      }

      rep(i,time.size())
        if(i > 0)
          time[i] += time[i-1];

      rep(i,time.size())
        if(max < time[i])
          max = time[i];

      cout << max << endl;

    }

  return 0;

}

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

typedef long long ll;

ll f(string s){
    string s1,s2,s3;
    s1 = s.substr(0,2);
    s2 = s.substr(3,2);
    s3 = s.substr(6,2);

    int h = stoi(s1)*3600;
    int m = stoi(s2)*60;
    int ss = stoi(s3)*1;

    return h+m+ss;
}

void solve(int n){
    vector<int> v(60*60*60+3600+60+10,0);
    for(ll i=0;i<n;i++){
        string s1,s2;
        cin >> s1 >> s2;
        ll s=f(s1);
        ll t=f(s2);
        v[s]++;
        v[t]--;
    }
    for(int i=1;i<=60*60*60+60*60+60+1;i++){
        v[i] = v[i] + v[i-1];
    }
    int ans = -1;
    for(int i=0;i<=60*60*60+60*60+60+1;i++){
        ans = max(ans,v[i]);
        if(v[i] == 6)  cout << i << endl;
    }
    cout << ans << endl;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}