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<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<fstream>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int di[3] = {3600,60,1};

int getTime(string s){
  rep(i,s.length())if(s[i] == ':')s[i] = ' ';
  stringstream ss;
  ss << s;
  int ret = 0;
  for(int i=0;i<3;i++){
    string pre;
    ss >> pre;
    int tim = (atoi)(pre.c_str());
    ret += tim*di[i];
  }
 
  return ret;
}

int main(){
  int n;

  while(true){
    cin >> n;
    if(n == 0)break;
    string star,endar;
    vector<P> vec;
    rep(i,n){
      cin >> star >> endar;
      int st,ed;
      st = getTime(star);
      ed = getTime(endar);
      vec.pb(P(st,ed));
    }
    sort(all(vec));
    int cnt = 0;
    int mex = 0;
   
    rep(i,n){
      cnt = 1;
      for(int j=i-1;j>=0;j--){
	if(vec[j].S <= vec[i].F)continue;
	cnt++;
      }
      mex = max(cnt,mex);
    }

    cout << mex << endl;

  }
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int g(string s){

  int h = (s[0]-'0')*10+s[1]-'0';
  h *=3600;
  int m = (s[3]-'0')*10+s[4]-'0';
  m *=60;
  int t = (s[6]-'0')*10+s[7]-'0';

  return (h+m+t);
}

void f(int n){
  int c[1000000]={};
  rep(i,n){
    string a,b;
    cin>>a>>b;
    int t = g(a);
    int r = g(b);
    c[t]++;
    c[r]--;
  }
  rep(i,1000000){
    if(i==0) continue;
    c[i]+=c[i-1];
  }
  int ans = 0;
  rep(i,1000000){
    ans = max(ans,c[i]);
 } 


    cout<<ans<<endl;
}


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

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int cnt[100000];
int main(){
	int n; 
	while(1){
		cin >> n; 
		if(n==0)break;
		for(int i=0;i<100000;i++){
			cnt[i]=0;
		}
		for(int i=0;i<n;i++){
			int h,m,s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			int a=h*3600+m*60+s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			int b=h*3600+m*60+s;
			cnt[a]++; cnt[b]--;
		}
		int ans=0;
		for(int i=1;i<99999;i++){
			cnt[i]+=cnt[i-1];
			ans=max(ans,cnt[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

int n;
std::string dep, arr;

int main() {
    while (true) {
        std::cin >> n;
        if (n == 0) {
            return 0;
        }
        std::vector<int> vec(86401, 0);
        for (int i = 0; i < n; i++) {
            std::cin >> dep >> arr;
            int dep_time = std::stoi(dep.substr(0, 2))*3600+std::stoi(dep.substr(3, 2))*60+std::stoi(dep.substr(6,2));
            int arr_time = std::stoi(arr.substr(0, 2))*3600+std::stoi(arr.substr(3, 2))*60+std::stoi(arr.substr(6,2));
            vec[dep_time]++;
            vec[arr_time+1]--;
        }
        std::cout << *std::max_element(vec.begin(), vec.end()) << std::endl;
    }
}

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    while (n > 0) {
        string s, t;
        vector<int> d(24 * 60 * 60, 0);
        rep(i, n) {
            cin >> s >> t;
            int a = stoi(s.substr(0, 2)) * 3600 + stoi(s.substr(3, 2)) * 60 + stoi(s.substr(6, 2));
            d[a]++;
            a = stoi(t.substr(0, 2)) * 3600 + stoi(t.substr(3, 2)) * 60 + stoi(t.substr(6, 2));
            d[a]--;
        }
        int ans = 0, a = 0;
        rep(i, 24 * 60 * 60) {
            a += d[i];
            ans = max(ans, a);
        }
        cout << ans << "\n";
        cin >> n;
    }
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;


const int MAX = 25*3600;

bool solve(){
	
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<int> v(MAX,0);
	for(int k=0;k<n;k++){
		int in[2] = {0};
		for(int i=0;i<2;i++){
			int h,m,s;
			char c[2];
			cin>> h>> c[0]>> m>> c[1]>> s;
			in[i] = 3600 * h + 60 * m + s;
		}
		for(int i=in[0]; i<in[1]; i++) v[i]++;
	}
	
	cout<< *max_element(v.begin(), v.end()) << endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}