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>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n;
int add[24*60*60+10];

void solve() {
    rep(i,24*60*60+5) add[i]=0;
    
    rep(i,n) {
        int s1,s2,s3;
        int t1,t2,t3;
        scanf("%d:%d:%d",&s1,&s2,&s3);
        scanf("%d:%d:%d",&t1,&t2,&t3);

        add[s1*24*60+s2*60+s3] = 1;
        add[t1*24*60+t2*60+t3-1] = -1;
    }
    rep(i,24*60*60+5) {
        add[i+1]+=add[i];
    }

    int ans=0;
    rep(i,24*60*60+5) {
        ans=max(ans,add[i]);
    }
    cout<<ans<<endl;

    

}

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

    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int a[3600*24+5];

int n;
string s;
int tr(int i){
  return s[i] - '0';
}

void solve(){
  fill(a,a+3600*24+5,0);
  rep(i,0,n){
    int l,r;
    cin >> s;
    l = (tr(0)*10+tr(1))*3600 + (tr(3)*10+tr(4))*60 + tr(6)*10+tr(7);
    cin >> s;
    r = (tr(0)*10+tr(1))*3600 + (tr(3)*10+tr(4))*60 + tr(6)*10+tr(7);
    a[l]++;
    a[r]--;
    //cout << l << " " << r << endl;
  }
  int u = a[0];
  rep(i,1,3600*24){
    a[i] += a[i-1];
    u = max(u,a[i]);
  }
  cout << u << endl;
}


int main(){
  for(;;){
    cin >> n;
    if(n==0)break;
    solve();
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using Pair = pair<int, int>;

enum { END, START };

int time(string str) {
    int h = stoi(str.substr(0, 2));
    int m = stoi(str.substr(3, 2));
    int s = stoi(str.substr(6, 2));
    return 3600 * h + 60 * m + s;
}

void solve(int N) {
    priority_queue<Pair, vector<Pair>, greater<Pair>> que;
    for(int i = 0; i < N; ++i) {
        string s, e;
        cin >> s >> e;
        que.emplace(time(s), START);
        que.emplace(time(e), END);
    }
    int now = 0, ans = 0;
    while(!que.empty()) {
        auto t = que.top(); que.pop();
        if(t.second == START) now++;
        else now--;
        ans = max(ans, now);
    }
    cout << ans << '\n';
}

int main() {
    int N;
    while(cin >> N) {
        if(!N) break;
        solve(N);
    }
    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;

/* global variables */

int n;
pii tbl[MAX_N];

/* subroutines */

int hms2s(string hms) {
  int h = (hms[0] - '0') * 10 + hms[1] - '0';
  int m = (hms[3] - '0') * 10 + hms[4] - '0';
  int s = (hms[6] - '0') * 10 + hms[7] - '0';
  return h * 3600 + m * 60 + s;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      string shms, ghms;
      cin >> shms >> ghms;
      tbl[i].first = hms2s(shms);
      tbl[i].second = hms2s(ghms);
    }
    sort(tbl, tbl + n);
    
    priority_queue<int,vi,greater<int> > q;
    int wt = 0;

    for (int i = 0; i < n; i++) {
      int st = tbl[i].first;
      int gt = tbl[i].second;

      while (! q.empty() && q.top() <= st)
	q.pop(), wt++;

      if (wt > 0) wt--;
      q.push(gt);
    }

    cout << wt + q.size() << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int a[24 * 60 * 60+10];
int main() {
	long long a1, m1, a2, m2, a3, m3;
	int n;
	while (cin >> n&&n != 0) {
		int h1, m1, s1, h2, m2, s2;
		fill(a, a + 60 * 24 * 60+10, 0);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			bool k = false;
			for (int i = h1 * 3600 + m1 * 60 + s1; i<h2 * 3600 + m2 * 60 + s2; i++) {
				a[i]--;
				if (a[i] < 0) {
					sum++;
					for (int i = 0; i < 24 * 60 * 60; i++) a[i]++;
				}
			}
			a[h2 * 3600 + m2 * 60 + s2]++;
		}
		cout << sum << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

bool 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;
	vector<vector<int>>jikoku(10000,vector<int>(2));
	while (cin >> n, n){
		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;
	}
}