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<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3 - 1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };

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


int main() {
	int n;
	while (cin >> n, n) {
		vector<pii> times(2*n);
		string buf;
		REP(i,n)
			REP(j, 2) {
			cin >> buf;
			times[2 * i + j].first = stoi(buf.substr(0, 2)) * 60 * 60 + stoi(buf.substr(3, 2)) * 60 + stoi(buf.substr(6, 2));
			times[2 * i + j].second = j;
		}
		sort(ALL(times),
			[](pii lef, pii rig) {
			return lef.first < rig.first ||
				lef.first == rig.first && lef.second>rig.second;
		});
		int count = 0;
		int stopping = 0;
		REP(i, 2 * n) {
			if (times[i].second)
				stopping++;
			else if (stopping > 0)
				stopping--;
			else
				count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

struct TIME {
	int time;
	int start;
	bool operator<(const TIME &t){
		if( time == t.time ){
			return start<t.start;
		}
		return time<t.time;
	}
};

int main() {
	while(true){
		
		vector<TIME> times;
		
		int n;
		cin >> n;
		if(n==0)break;
		
		for(int i=0;i<n;i++){
			int h,m,s;
			char c;
			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s <<endl; 
			TIME t0={h*60*60+m*60+s,1};
			times.push_back(t0);

			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s<<endl; 
			TIME t1={h*60*60+m*60+s,0};
			times.push_back(t1);
		}

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

		int count=0;
		int ans=0;
		for(TIME &t : times){
//			cout << t.start << " " << t.time << endl;;
			if(t.start==1){
				count++;
				ans=max(count,ans);
			}else{
				count--;
			}
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  while(true) {
    int n;
    cin >> n;
    int sum[86402] = {0};
    if(n == 0) break;
    rep(i, n) {
      string a, b;
      cin >> a >> b;
      int ah, am, as, bh, bm, bs;
      ah = atoi(a.substr(0,2).c_str());
      am = atoi(a.substr(3,2).c_str());
      as = atoi(a.substr(6,2).c_str());
      bh = atoi(b.substr(0,2).c_str());
      bm = atoi(b.substr(3,2).c_str());
      bs = atoi(b.substr(6,2).c_str());
      int at, bt;
      at = 60 * 60 * ah + 60 * am + as;
      bt = 60 * 60 * bh + 60 * bm + bs;
      // cout << at << " " << bt << endl;
      sum[at]++;sum[bt]--;
    }
    int ans;
    ans = sum[0];
    rep(i, 86400) {
      sum[i+1] += sum[i];
      ans = max(ans, sum[i+1]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

const int TIME = 60 * 60 * 24 + 60;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n && n){
	int data[TIME];
		fill(data, data + TIME, 0);
		
		for(int i = 0; i < n; ++i){
			int a, b, c;
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] ++;
			
			int d, e, f;
			scanf("%d:%d:%d", &d, &e, &f);
			data[d * 60 * 60 + e * 60 + f] --;
		}
	
		int ans = 0;
		for(int i = 0; i < TIME; ++i){
			if(i != 0)
				data[i] += data[i - 1];
			ans = max(ans, data[i]);
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int time_parse(string time) {
  int hour = atoi(time.substr(0, 2).c_str());
  int minute = atoi(time.substr(3, 5).c_str());
  int second = atoi(time.substr(6).c_str());
  return hour * 3600 + minute * 60 + second;
}

int main() {
  int n;
  int table[24 * 3600] = {0};
  while (cin >> n && n) {
    table[24 * 3600] = {0};
    string time_in, time_out;
    for (int i = 0; i < n; i++) {
      cin >> time_in >> time_out;
      table[time_parse(time_in)]++;
      table[time_parse(time_out)]--;
    }
    int ans = 0, sum = 0;
    for (int i = 0; i < 24 * 3600; i++) {
      sum += table[i];
      ans = max(sum, ans);
    }
    cout << ans << endl;
  }
}

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

int Hen(char s,char t){
  return ((s-'0')*10+(t-'0'));
}
int main()
{
  string s,f;
  int n,a,b,max,T[86401]={};
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      a=(Hen(s[0],s[1])*3600+Hen(s[3],s[4])*60+Hen(s[6],s[7]));
      b=(Hen(f[0],f[1])*3600+Hen(f[3],f[4])*60+Hen(f[6],f[7]));
      for(int j=a;j<=b;j++)T[j]++;
    }
    max=0;
    for(int i=0;i<86401;i++){
      if(max<T[i])max=T[i];
      T[i]=0;
    }
    cout<<max<<endl;
  }
  return 0;
}