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;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int n;
VI ss, gs;

bool check(int s, int g, VI& gts) {
	rep (i, gts.size()) {
		if (s >= gts[i]) {
			gts[i] = g;
			return true;
		}
	}
	return false;
}

int main(void) {
	while (1) {
		ss.clear();
		gs.clear();
		cin >> n;
		if (n == 0) break;
		rep (i, n) {
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			int stime = h * 60 * 60;
			stime += m * 60;
			stime += s;
			scanf("%d:%d:%d", &h, &m, &s);
			int gtime = h * 60 * 60;
			gtime += m * 60;
			gtime += s;
			ss.PB(stime);
			gs.PB(gtime);
		}
		VI gts;
		int ans = 0;
		rep (i, n) {
			if (!check(ss[i], gs[i], gts)) {
				ans++;
				gts.PB(gs[i]);
			}
			sort(ALL(gts));
			reverse(ALL(gts));
		}
		cout << ans << endl;
	}
    return 0;
}

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

int main(){
  int n,h,m,s,time[2],cnt;
  char q;
  pair<int,int> ti[10000];
  while(1){
    cin>>n;
    if(n==0) break;
    cnt=1;
    for(int i=0;i<n;i++){
      cin>>h>>q>>m>>q>>s;
      time[0]=h*3600+m*60+s;
      cin>>h>>q>>m>>q>>s;
      time[1]=h*3600+m*60+s;
      ti[i]=make_pair(time[0],time[1]);
    }
    sort(ti,ti+n);
    for(int i=1;i<n;i++)
      if(ti[i-1].second>=ti[i].second)cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
string a[10001],b[10001];
int n;

int s2n(string str){
  int num=0;
  int c = 0;
  
  for(int j=0;j<str.size();j++) {
    if(j == 2) {
      c += num*60*60;
      num = 0;
      continue;
    }
    if(j == 5) {
      c += num*60;
      num = 0;
      continue;
    }
    num *= 10;
    num += str[j]-'0';
    
  }
  c += num;
  return c;
  
}
int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    int time[86401]={};
    int c ,d;
    for(int i=0;i<n;i++) {
      cin >> a[i] >> b[i];
      c = s2n(a[i]);
      d = s2n(b[i]);
      //  cout << c << " "<<d <<endl;
      time[c]++;
      time[d]--;
    }
    int ans=-1;
    for(int i=1;i<=86400;i++){
      time[i] += time[i-1];
      if(time[i] > ans) ans = time[i];
    }
    cout << ans <<endl;
  }
  return 0;
}

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

using namespace std;

struct E {
    int time, c;
    E(int t, int c) : time(t), c(c) {}
    bool operator<(const E& e) const {
        return time < e.time;
    }
};

int N;
vector<E> es;
bool input() {
    es.clear();
    scanf("%d\n", &N);
    for (int i = 0; i < N; i++) {
        int h, m, s;
        scanf("%d:%d:%d", &h, &m, &s);
        int from = h * 3600 + m * 60 + s;
        es.push_back(E(from, +1));
        scanf(" %d:%d:%d\n", &h, &m, &s);
        int to = h * 3600 + m * 60 + s;
        es.push_back(E(to, -1));
    }
    return true;
}

void solve() {
    sort(es.begin(), es.end());
    int ans = 0;
    int pool = 0;
    for (int i = 0; i < N; i++) {
        const E& e = es[i];
        if (e.c == 1) {
            if (pool > 0) pool--;
            else ans++;
        } else {
            pool++;
        }
    }
    printf("%d\n", ans);
}

int main() {
    while (input()) solve();
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        vector<int> sum(200000,0);
        for(int i=0; i<N; i++){
            string S;
            cin >> S;
            int h,w,s;
            h = (S[0]-'0')*10+S[1]-'0';
            w = (S[3]-'0')*10+S[4]-'0';
            s = (S[6]-'0')*10+S[7]-'0';
            s += h*60*60+w*60;
            int s2;
            cin >> S;            
            h = (S[0]-'0')*10+S[1]-'0';
            w = (S[3]-'0')*10+S[4]-'0';
            s2 = (S[6]-'0')*10+S[7]-'0';
            s2 += h*60*60+w*60;
            sum[s]++;
            sum[s2]--;
        }
        int mx = 0;
        for(int i=0; i<100000; i++){
            sum[i+1] += sum[i];
            chmax(mx,sum[i+1]);
        }
        cout << mx << enld;
        cin >> N;
    }
    return 0;
}