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 unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int imos[111111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    memset(imos,0,sizeof(imos));
    rep(i,n){
      string s,t;
      cin>>s>>t;
      int start=stoi(s.substr(0,2))*60*60+stoi(s.substr(3,2))*60+stoi(s.substr(6,2));
      int end=stoi(t.substr(0,2))*60*60+stoi(t.substr(3,2))*60+stoi(t.substr(6,2));
      imos[start]+=1;
      imos[end]-=1;
      //dbg(start); dbg(end);
    }
    rep(i,100000)imos[i+1]+=imos[i];
    cout<<*max_element(imos,imos+100000)<<endl;
  }
	return 0;
}

C++: #include <bits/stdc++.h>
#define ADAY 86400
using namespace std;

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int now=0; now <= ADAY; now++){
      if(ind > n) break;
      while(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      if(now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
int dat[20000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<2*a;i++){
			int j,h,b;
			scanf("%d:%d:%d",&j,&h,&b);
			dat[i]=j*7200+h*120+b*2+(i+1)%2;
		}
		std::sort(dat,dat+2*a);
		int ret=0;
		int c=0;
		for(int i=0;i<2*a;i++){
			if(dat[i]&1)c++;
			else c--;
			ret=max(ret,c);
		}
		printf("%d\n",ret);
	}
}

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_s("%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 <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

ll calc(string s){
    ll res = 0;
    ll num = (s[0] - '0')*10+(s[1] - '0');
    res += num *3600;
    num = (s[3] - '0')*10+(s[4] - '0');
    res += num *60;
    num = (s[6] - '0')*10+(s[7] - '0');
    res += num;
    return res;
}

int main(){
    while(cin >> n && n){
        vector<ll> sum(24*3600+1,0);
        rep(i,n){
            string s,t;
            cin >> s >> t;
            sum[calc(s)]++;
            sum[calc(t)]--;
        }
        rep(i,sum.size()-1)sum[i+1] += sum[i];
        ll ans = 0;
        rep(i,sum.size())ans = max(ans,sum[i]);
        cout << ans << endl;
    }
}

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

const int H=60*60;
const int M=60;
const int S =1;
int train[24*H+1];
int unit[3]={H,M,S};

int getTime(string s){
  string tmp;
  int res=0;
  for(int i=0;i<8;i+=3){
    tmp=s.substr(i,2);
    int val=atoi(tmp.c_str());
    res+=unit[i]*val;
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    memset(train,0,sizeof(train));
    for(int i=0;i<n;i++){
      string start,arrival;
      int st=0,at=0;
      cin>>start>> arrival;
      st=getTime(start);
      at=getTime(arrival);
      for(int i=st;i<at;i++)train[i]++;
    }
    int ans=0;
    for(int i=0;i<=24*H;i++){
      ans=max(ans,train[i]);
      //cout << train[i] << " ";
    }
    cout << ans << endl;
  }
  return 0;
}