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++: // 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) {
    int c = 0;
    vector<int> v;
    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 (v.size() && v.front() <= l) {
        v.erase(v.begin());
      } else {
        c++;
      }
      v.insert(lower_bound(all(v), r), r);
    }
    cout << c << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 10000;
int Change(string);
int main(){
  int n,cnt,check[N],ok,flag,Max,sh[N],sm[N],ss[N],eh[N],em[N],es[N],i,j;
  int comh,comm,coms;
  string start[N],end[N],sub;
  while(1){
    cin >> n;
    cnt=0;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> start[i] >> end[i];
      check[i]=-1;
      sub=start[i].substr(0,2);
      sh[i]=Change(sub);
      sub=start[i].substr(3,2);
      sm[i]=Change(sub);
      sub=start[i].substr(6,2);
      ss[i]=Change(sub);
      sub=end[i].substr(0,2);
      eh[i]=Change(sub);
      sub=end[i].substr(3,2);
      em[i]=Change(sub);
      sub=end[i].substr(6,2);
      es[i]=Change(sub);
    }
    for(i=0;i<n;i++){
      if(check[i]==-1){
	check[i]=i;
	comh=eh[i];
	comm=em[i];
	coms=es[i];
	for(j=i+1;j<n;j++){
	  if(check[j]==-1){
	    ok=0;
	    if(comh==sh[j]){
	      if(comm==sm[j]){
		if(coms<=ss[j]) ok=1;
	      }
	      else if(comm<sm[j]) ok=1;
	    }
	    else if(comh<sh[j]) ok=1;
	    if(ok==1){
	      check[j]=i;
	      comh=eh[j];
	      comm=em[j];
	      coms=es[j];
	    }
	  }
	}
      }
    }
    Max=0;
    for(i=0;i<n;i++){
      Max=max(Max,check[i]);
    }
    cout << Max+1 << endl;
  }
  return 0;
}
int Change(string sub){
  int ret=0,x=1,i;
  for(i=0;i<2;i++){
    ret=ret*x+(sub[i]-'0');
    x=10;
  }
  return ret;
}

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

C++: #include <bits/stdc++.h>
#define M 1e7
using namespace std;
int main(){
	int n,i,j,b[6];
	while(cin>>n,n){
		j=n;
		int a[10000],ans=0,c=0;
		while(--n){
			scanf("%d:%d:%d %d:%d:%d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
			a[n*2-1]=b[0]*3600+b[1]*60+b[2]+M;
			a[n*2-2]=b[3]*3600+b[4]*60+b[5];
		}
		sort(a,a+j*2);
		for(i=0;i<j*2;j++){
			if(a[i]>1e7)c++;
			else c--;
			ans=max(ans,c);
		}
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int dabu(int a, int b,int a1,int b1){
    if (a1>=b)return 0;
    if (b1<=a)return 0;
    return 1;
}

int main(){
    int n;
    while (cin >> n, n){
        int jikoku[10000][2]={};
        int ans=1;
        int ans1 = 1;
        int si,shu;
        for (int i = 0; i < n; i++){
            int  si1, si2, si3, shu1, shu2, shu3;
            scanf("%d:%d:%d %d:%d:%d", &si1, &si2, &si3, &shu1, &shu2, &shu3);
            si = 3600 * si1 + 60 * si2 + si3;
            shu = 3600 * shu1 + 60 * shu2 + shu3;
            jikoku[i][0]=si;
            jikoku[i][1]=shu;
        }
        for(int i=0;i<n;i++){
            ans = 1;
            for (int j=0; j < n; j++){
                if(i==j)continue;
                ans += dabu(jikoku[j][0], jikoku[j][1], jikoku[i][0], jikoku[i][1]);
            }
            ans1 = max(ans, ans1);
        }
        cout << ans1 << endl;
    }
}