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

#define rep(i,x,y) for(int (i)=(x);i<(y);i++)

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

    string str1;
    string str2;
    vector<int> start,end;
    int sh,sm,ss,eh,em,es;
    rep(i,0,n){
      cin>>str1>>str2;
      sh=stoi(str1.substr(0,2));
      sm=stoi(str1.substr(3,2));
      ss=stoi(str1.substr(6,2));
      eh=stoi(str2.substr(0,2));
      em=stoi(str2.substr(3,2));
      es=stoi(str2.substr(6,2));
      start.emplace_back(sh*3600+sm*60+ss);
      end.emplace_back(eh*3600+em*60+es);
    }

    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
        if(start[j]>start[j+1]){
          swap(start[j],start[j+1]);
          swap(end[j],end[j+1]);
        }
      }
    }

    vector<int> trains;
    int t=0;
    trains.push_back(t);

    rep(i,0,n){
      bool flag=false;
      int size=trains.size();
      rep(j,0,size){
        if(trains[j]<=start[i]){
          trains[j]=end[i];
          flag=true;
          break;
        }
      }
      if(flag==false){
        t=end[i];
        trains.push_back(t);
      }
    }

    cout<<trains.size()<<endl;
  }

  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int calc(int a, int b, int c) {
    return 3600*a + 60*b + c;
}

signed main() {
    int n;
    while(cin >> n, n) {
        int rec[100010] = {};
        rep(i,0,n) {
            int a, b, c, d, e, f;
            scanf(" %lld:%lld:%lld", &a, &b, &c);
            scanf(" %lld:%lld:%lld", &d, &e, &f);
            int s = calc(a, b, c), t = calc(d, e, f);
            rec[s]++; rec[t]--;
        }
        rep(i,1,100000) {
            rec[i] += rec[i-1];
        }
        cout << *max_element(rec, rec+100000) << endl;
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int n) {
    vector<int> vec(1e5);
    REP(i, n) {
        int sh, sm, ss, th, tm, ts;
        scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
        int s = sh * 3600 + sm * 60 + ss, t = sh * 3600 + sm * 60 + ss;
        vec[s] += 1;
        vec[t + 1] -= 1;
    }

    REP(i, 1e5 - 1) {
        vec[i + 1] += vec[i];
    }

    int ans = 0;

    REP(i, 1e5) {
        ans = max(ans, vec[i]);
    }

    cout << ans << endl;

    return;
}

int main() {
    int n;
    while (cin >> n && n) {
        solve(n);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int stoi(string a){
	return (a[0]-'0')*10+a[1]-'0';
}
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > que;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		rep(i,n){
			string x,y;
			cin >> x >> y;
			int a=stoi(x.substr(0,2))*3600+stoi(x.substr(3,2))*60+stoi(x.substr(6,2));
			int b=stoi(y.substr(0,2))*3600+stoi(y.substr(3,2))*60+stoi(y.substr(6,2));
			que.push(P(b,0));
			que.push(P(a,1));
		}
		int now=0,ans=0;
		while(!que.empty()){
			P q=que.top();
			que.pop();
			if(q.second==0) now++;
			else{
				if(now>0) now--;
				else ans++;
			}
		}
		cout << ans << endl;
	}
}