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<queue>
using namespace std;
typedef pair<int,int> p;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		priority_queue<p,vector<p>,greater<p> > q;
		int leave,arrive;
		for(int i = 0; i < n; ++i)
		{
			int h,m,s; 
			scanf(" %d:%d:%d",&h,&m,&s);
			leave=h*3600+m*60+s;
			
			scanf(" %d:%d:%d",&h,&m,&s);
			arrive=h*3600+m*60+s;
			
			q.push(p(leave,1));	
			q.push(p(arrive,-1));	
			
		}	
		int ans=0,tmp=0;
		while(!q.empty()) 
		{
			p t=q.top(); q.pop();
			if(t.second==-1) tmp--;
			else 
			{
				tmp++;
				ans=max(ans,tmp);
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

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;
		for (int i = 0; i < n; i++){
			int si, shu;
			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;
			if (i){
				ans = 1;
				for (int j=0; j < i; j++){
					ans += dabu(jikoku[j][0], jikoku[j][1], si, shu);
				}
			}
			ans1 = max(ans, ans1);
		}
		cout << ans1 << endl;
	}
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

int main(){
    int n;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        int par[100000];
        fill(par, par + 100000, 0);
        for(int _ = 0; _ < n; _++){
            int h, m, s;
            scanf("%d:%d:%d", &h, &m, &s);
            par[1440 * h + 60 * m + s] += 1;
            scanf("%d:%d:%d", &h, &m, &s);
            par[1440 * h + 60 * m + s] -= 1;
        }
        int acc = 0, ans = 0;
        for(int i = 0; i < 100000; i++){
            acc += par[i];
            ans = max(ans, acc);
        }
        printf("%d\n", ans);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main()
{
  while(1){
    int n;
    scanf("%d", &n);
    if(n == 0) break;
    int ans = 1;
    int t = 1;
    vector<int> time;
    REP(i,n){
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      int ts = h*3600 + m*60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      int te = h*3600 + m*60 + s;
      if(!time.empty())
        REP(j,(int)time.size())
          if(time[j] <= ts){
            t++;
            time.erase(time.begin()+j);
          }
      if(t > 0){
        t--;
        time.push_back(te);
      }else{
        ans++;
        time.push_back(te);
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<tuple<ll,ll,ll,ll>> v(2*n);
        for(ll i=0; i<n; i++) {
            string s;

            cin >> s;
            s[2] = s[5] = '\0';
            ll x, y, z;
            tie(x, y, z) = make_tuple(atoll(s.c_str()), atoll(s.c_str()+3), atoll(s.c_str()+6));
            v[2*i+0] = make_tuple(x,y,z,1);

            cin >> s;
            s[2] = s[5] = '\0';
            tie(x, y, z) = make_tuple(atoll(s.c_str()), atoll(s.c_str()+3), atoll(s.c_str()+6));
            v[2*i+1] = make_tuple(x,y,z,-1);
        }

        sort(v.begin(), v.end());

        ll res = 0, s = 0;
        for(auto &t: v) {
            ll x, y, z, w;
            tie(x, y, z, w) = t;
            s += w;
            res = max(res, s);
        }
        cout << res << endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  while (true) {
    int N = nextInt();
    if (N == 0) break;
    int ans = 0;
    int h, m, s;
    int arr[100000] = {0};
    REP(i, N) {
      scanf("%d:%d:%d", &h, &m, &s);
      arr[h * 60 * 60 + m * 60 + s] ++;
      scanf("%d:%d:%d", &h, &m, &s);
      arr[h * 60 * 60 + m * 60 + s] --;
    }

    REP(i, 100000 - 1) {
      arr[i + 1] += arr[i];
      if (ans < arr[i + 1]) {
        ans = arr[i + 1];
      }
    }

    PRINT(ans);
  }
  return 0;
}
// END   //////////////////////////////////////////////////////////////