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


#define M  24*60*60
int table[M];


int main(){
  int n;
  int h,m,sec;
  string str;
  while(cin >> n, n){

    for(int i = 0; i < n; i++){
      cin >> str;
      scanf("%d:%d:%d", &h,&m,&sec);
      int s = h*60*60 + m*60 + sec;
      table[s]++;
      scanf("%d:%d:%d", &h,&m,&s);
      int e = h*60*60 + m*60 + s;
      table[e]--;
    }
    for(int i = 1; i < M; i++){
      table[i] += table[i-1];
    }
    int max = 0;
    for(int i = 0; i < M; i++){
      if(max < table[i]) max = table[i];
    }
    cout << max << endl;
  }
}

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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
int imos[86401];
int main() {
    while (cin >> n, n) {
        memset(imos, 0, sizeof(imos));
        int h1, m1, s1;
        int h2, m2, s2;
        rep(i, n) {
            scanf("%d:%d:%d", &h1, &m1, &s1);
            scanf("%d:%d:%d", &h2, &m2, &s2);
            imos[h1 * 3600 + m1 * 60 + s1]++;
            imos[h2 * 3600 + m2 * 60 + s2]--;
        }
        rep(i, 86401) if (i) imos[i] += imos[i - 1];
        cout << *max_element(imos, imos + 86401) << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;

int main(void){

  int n;
  int sum[2000];

  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            int h,m,s;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]++;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]--;
        }
        int res=sum[0];
        for(int i=0;i<=24*60*60;i++){
            sum[i+1]+=sum[i];
            res=max(res,sum[i+1]);
        }
        printf("%d\n",res);
    }
    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    priority_queue<int, vector<int>, greater<int>> q;
    while (n--) {
      int h, m, d;
      char gomi;
      cin >> h >> gomi >> m >> gomi >> d;
      int l = h * 60 * 60 + m * 60 + d;
      cin >> h >> gomi >> m >> gomi >> d;
      int r = h * 60 * 60 + m * 60 + d;
      if (q.size() && q.top() <= l) {
        q.pop();
      }
      q.push(r);
    }
    cout << q.size() << endl;
  }
}

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 ;
  int Sh,Sm,Ss;
  int Eh,Em,Es;
  int max = -1;
  long int Sindex,Eindex;
  vector<int> time(240001);


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

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

      rep(i,n){

        scanf("%d:%d:%d %d:%d:%d",&Sh,&Sm,&Ss,&Eh,&Em,&Es);

        Sindex = Sh*10000 + Sm*100 + Ss;
        Eindex = Eh*10000 + Em*100 + Es;

        time[Sindex]++;
        time[Eindex]--;

      }

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	string s1,s2;
	int cnt;
	int max;

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

		vector<pair<string,int> > v;

		for(int i1=0;i1<n;i1++){
			cin>>s1>>s2;
			v.push_back(make_pair(s1,1));
			v.push_back(make_pair(s2,0));
		}

		cnt=0;
		max=0;
		sort(v.begin(), v.end());
		for(int i1=0; i1<v.size();i1++){
			if(v[i1].second==1) cnt++;
			else if(v[i1].second==0) cnt--;

			if(max<cnt) max=cnt;
		}

		cout<<max<<endl;
	}
	return 0;
}