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 rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007

using namespace std;

int n;
int solve(){
  vector<int>t(86401);
  rep(i, n){
    int h1,m1,s1,h2,m2,s2;
    scanf("%2d:%2d:%2d %2d:%2d:%2d",&h1,&m1,&s1,&h2,&m2,&s2);
    int l = h1*3600+m1*60+s1;
    int r = h2*3600+m2*60+s2;
    t[l]++;
    t[r]--;
  }
  rep(i, 86400)t[i+1]+=t[i];
  int result = 0;
  rep(i, 86400)result = max(result, t[i]);

  return result;
}

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

  return 0;
}

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


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


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

    for(int i = 0; i < n; i++){
      cin >> str;
      int s = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      table[s]++;
      cin >> str;
      int e = stoi(str.substr(0,2))*60*60 + stoi(str.substr(3,2))*60
	+ stoi(str.substr(6,2));
      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 <bits/stdc++.h>
#define ADAY 86400
using namespace std;

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int 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 <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;

int main() {
	int n, data[6];
	int max_mini = 0;
	
	while (cin >> n) {
		if (n == 0)break;
		int x[86401] = { 0 };
		for (int i = 0; i < n; i++) {
			scanf("%d:%d:%d %d:%d:%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5]);
			x[data[0] * 3600 + data[1] * 60 + data[2]]++;
			x[data[3] * 3600 + data[4] * 60 + data[5]]--;
			if (max_mini < data[3] * 3600 + data[4] * 60 + data[5])
				max_mini = data[3] * 3600 + data[4] * 60 + data[5];
		}
		int ans = 0, cnt = 0;
		for (int i = 0; i <= max_mini; i++) {
			cnt += x[i];
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
	
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
#include <map>
#include <cstdlib>
using namespace std;
int N;
int t[86400];
int main() {
   while(cin >> N, N){
       int t[86400+1]={0};
       for(int i=0; i<N; ++i){
           int h, m, s;
           int start, end;
            scanf("%d:%d:%d", &h, &m, &s);
            start = h*3600+m*60+s;
            scanf("%d:%d:%d", &h, &m, &s);
            end = h*3600 + m*60 + s;
            for(int i=start; i<end; ++i) t[i]++;
           
       }
       int ans = 0;
       for(int i=0; i<86400+1; ++i) ans = max(ans, t[i]);
       cout << ans << endl;
   }
   return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;


int main()
{
	pai a[10010];
	int n;
	while(1)
	{
		cin >> n;
		int h, m, s;
		if(n==0) break;
		rep(i, n)
		{
			char dummy;
			cin >> h >> dummy >> m >> dummy >> s;
			a[i].first=h*3600+m*60+s;
			cin >> h >> dummy >> m >> dummy >> s;
			a[i].second=h*3600+m*60+s;
		}
		sort(a, a+n);
		int b[10010]={};
		rep(i, n)
		{
			for(int j=i+1; j<=n; j++)
			{
				if(a[j].first>=a[i].second && b[j]==0)
				{
					b[j]=b[i]+1;
					break;
				}
			}
		}
		int ans=0;
		rep(i, n) if(b[i]==0) ans++;
		cout << ans << endl;
	}
	return 0;
}

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

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int now=0; now <= ADAY; now++){
      if(ind > n) break;
      while(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      while(now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}