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;
int main()
{
	int n,i;
	int h,m,s,s1,ti[100001];
	char a,b;
	
	while(1){
	
		cin>>n;
		if(n==0) break;
		
		for(i=0;i<86400;i++) ti[i]=0;
		
		for(i=0;i<n*2;i++){
			cin>>h>>a>>m>>b>>s;
			if(i%2==0) ti[h*3600+m*60+s]++;
			else ti[h*3600+m*60+s]--;
		}
		
		for (i=0;i<86400;i++) {
			if (0<i) ti[i]+=ti[i-1];
		}
		
		int M = -1;
		for (i=0;i<86400;i++) {
			M=max(ti[i],M);
		}
		
		cout<<M<<endl;
	}	
	return 0;
}

C++: #include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
int a[90000];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  int n;
  while(cin>>n,n){
    for(int i=0;i<90000;i++)a[i]=0;
    for(int i=0;i<n;i++){
      string s,t;cin>>s>>t;
      int start=stoi(s.substr(0,2))*60*60;
      start+=stoi(s.substr(3,2))*60;
      start+=stoi(s.substr(6,2));
      int end=stoi(t.substr(0,2))*60*60;
      end+=stoi(t.substr(3,2))*60;
      end+=stoi(t.substr(6,2));
      a[start]++;
      a[end]--;
      //cerr<<"start="<<start<<" end="<<end<<endl;
    }
    for(int i=1;i<90000;i++)a[i]=a[i-1]+a[i];
    int ans=0;
    for(int i=0;i<90000;i++)ans=max(ans,a[i]);
    cout<<ans<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int n) {
    vector<int> vec(1e5);
    REP(i, n) {
        int sh, sm, ss, th, tm, ts;
        scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
        int s = sh * 3600 + sm * 60 + ss, t = th * 3600 + tm * 60 + ts;
        vec[s] += 1;
        vec[t] -= 1;
    }

    REP(i, 1e5 - 1) {
        vec[i + 1] += vec[i];
    }

    int ans = 0;

    REP(i, 1e5) {
        ans = max(ans, vec[i]);
    }

    cout << ans << endl;

    return;
}

int main() {
    int n;
    while (cin >> n && n) {
        solve(n);
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int a[24 * 60 * 60+10];
int main() {
	long long a1, m1, a2, m2, a3, m3;
	int n;
	while (cin >> n&&n != 0) {
		int h1, m1, s1, h2, m2, s2;
		fill(a, a + 60 * 24 * 60+10, 0);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			scanf_s("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			bool k = false;
			for (int i = h1 * 3600 + m1 * 60 + s1; i<h2 * 3600 + m2 * 60 + s2; i++) {
				a[i]--;
				if (a[i] < 0) {
					sum++;
					for (int i = 0; i < 24 * 60 * 60+10; i++) a[i]++;
				}
			}
		}
		cout << sum << endl;
	}
}

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

using namespace std;
using ll = long long;
vector<pair<int,int>> jiko;
vector<int> imo;
bool solve(){
    int n;
    cin>>n;
    if(n==0)return false;

    jiko.clear();

    for(int i = 0;i < n;++i) {
        int h,m,s;
        scanf("%d:%d:%d",&h,&m,&s);
        int l=h*3600+m*60+s;

        scanf("%d:%d:%d",&h,&m,&s);
        int r=h*3600+m*60+s;

        jiko.emplace_back(l,r);
    }

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

    imo.assign(3600*24+1,0);
    for(int i = 0;i < n;++i) {
        imo[jiko[i].first]++;
        imo[jiko[i].second]--;
    }
    int ans=imo[0];
    for(int i = 0;i < 3600*24;++i) {
        imo[i+1]+=imo[i];
        ans=max(ans,imo[i+1]);
    }

    cout<<ans<<endl;


    return true;
}

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