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>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

void solve(int n) {
    map<string, int> mp;
    rep(i, n) {
        string s, t;
        cin >> s >> t;
        mp[s]++;
        mp[t]--;
    }
    auto itr = mp.begin();
    int mx = itr->second;
    for (; next(itr) != mp.end(); itr++) {
        next(itr)->second += itr->second;
        mx = max(mx, next(itr)->second);
    }
    cout << mx << endl;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        solve(n);
    }

}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    while(cin >> n) {
        if(n == 0) return 0;

        ll MAX = 24 * 3600 + 60 * 60 + 60 + 1;

        vll s(MAX, 0);

        rep(i, n) {
            int hs, ms, ss, he, me, se;
            scanf("%d:%d:%d", &hs, &ms, &ss);
            ll start = 3600 * hs + 60 * ms+ ss;
            scanf("%d:%d:%d", &he, &me, &se);
            ll end = 3600 * he + 60 * me + se;

            s[start]++;
            s[end]--;
        }

        rep(i, MAX) if(i > 0) s[i] += s[i-1];
        ll ans = 0;
        rep(i, MAX) chmax(ans, s[i]);
        cout << ans << endl;
    }

}

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

int search(int t[], int s[], int a[], int b[], int n) {
  int memo;
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    if (n > 0) {
      if (a[i] < b[i - 1]) s[i] = s[i - 1] + 1;
      else s[i] = 0;
    }
    for (int j = i; j < n; j++) {
      if (a[j] >= b[i])	break;
      t[i]++;
    }
    t[i] += s[i];
  }
  int max = t[0];
  for (int i = 1; i < n; i++)
    if (t[i] > max) max = t[i];

  return max;
}

void sort(int a[], int b[], int n) {
  for (int i = 0; i < n; i++)
    for (int j = i; j > 0; j--)
      if (a[j - 1] > a[j]) {
	swap(a[j - 1], a[j]);
	swap(b[j - 1], b[j]);
      }
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    string a[n], b[n];
    int s[n], t[n];
    for (int i = 0; i < n; i++)
      cin >> a[i] >> b[i];

    for (int i = 0; i < n; i++) {
      s[i] = a[i][0] * 36000 + a[i][1] * 3600 + a[i][3] * 600 + a[i][4] * 60
	+ a[i][6] * 10 + a[i][7];
      t[i] = b[i][0] * 36000 + b[i][1] * 3600 + b[i][3] * 600 + b[i][4] * 60
	+ b[i][6] * 10 + b[i][7];
    }

    sort(s, t, n);
    
    int car[n];
    int need[n];
    for (int i = 0; i < n; i++) {
      car[i] = 0;
      need[i] = 0;
    }
    int ans = search(car, need, s, t, n);
    cout << ans << endl;
  }
}

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

#define MAX 24*60*60

int main(){

  int train[MAX];
  int N;

  while(1){

    cin >> N;
    if(N == 0) break;
    int ans = 0;
    for(int i = 0 ; i < MAX ; i++){
      train[i] = 0;
    }    

    int h1,m1,s1,h2,m2,s2;
    char tmp;

    for(int i = 0; i < N ; i++){
    
      cin  >> h1 >> tmp >> m1 >> tmp >> s1 >> h2 >> tmp >> m2 >> tmp >> s2;
      //  cout << h1 << " " << m1 << " " << s1 << " " << h2 << " " << m2 << " " << s2 << endl;
      // cout   << train[3*60*60 +1] << " " << train[3*60*60] << endl;


      //列車を増やすとき

      bool OK = true;
      for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	if(train[i] == 0){
	  OK = false;
	  break;
	}
      }  
      
      if(OK == false){
	ans++;
	for(int i = 0 ; i < s1 + 60*m1 + 60*60*h1 ;i++){
	  train[i]++;
	} 
	for(int i = s2 + 60*m2 + 60*60*h2 ; i < MAX ;i++){
	  train[i]++;
	} 
      } 
      //足りているとき
      else{
	for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	  if(train[i] != 0) train[i]--;
	} 
      }
      //   cout << train[0] <<" "<< train[MAX-1] << endl;
    }
    cout << ans << endl;
  }  
  return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 86401 //60*60*24
ll field[MAX_N];

void init(){
	rep(i,MAX_N){
		field[i] = 0;
	}
}

int stringToIntTime(string str){
	int hour,minutes,second;
	hour = stoi(str.substr(0,2));	//hh:mm:ss
	minutes = stoi(str.substr(3,2));
	second = stoi(str.substr(6,2));
	return 60*60*hour + 60*minutes + second;
}

int main()
{
	int n;
	cin>>n;
	while( n!=0){
		init();
		for(int i = 0; i < n; i++){
			string start,end;
			cin>>start>>end;
			field[stringToIntTime(start)]++;
			field[stringToIntTime(end)]--;
		}
		ll ans = 0;
		for(int i = 0; i < MAX_N-1; i++){
			field[i+1] += field[i];
			ans = max(ans,field[i+1]);
		}
		cout<<ans<<endl;
		cin>>n;
	}
	
	return 0;
}