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<vector>
#include<string>
#include<algorithm>
using namespace std;
int in(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)s[i] -= '0';
    int h = s[0]*10 + s[1];
    int m = s[3]*10 + s[4];
    int ret = s[6]*10 + s[7];
    ret += m * 60 + h * 60*60;
    return ret;
}
int main(){
    int n;
    while(cin >> n, n){
        vector<int> imos(24*60*60);
        while(n--){
            imos[in()]++;
            imos[in()-1]--;
        }
        for(int i = 1; i < 24*60*60; i++)imos[i] += imos[i-1];
        int ans = 0;
        for(int i = 0; i < 24*60*60; i++)ans = max(ans, imos[i]);
        cout << ans << endl;
    }
}

C++: #include<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;

int n;
struct jikoku{
    int hh,hm,hs,ah,am,as;
};
bool operator<(const jikoku j1,const jikoku j2){
    if(j1.ah<j2.ah)return 1;
    if(j1.ah==j2.ah&&j1.am<j2.am)return 1;
    if(j1.ah==j2.ah&&j1.am==j2.am&&j1.as<j2.as)return 1;
    return 0;
}
bool ok(const jikoku j1,const jikoku j2){
    if(j1.ah<j2.hh)return 1;
    if(j1.ah==j2.hh&&j1.am<j2.hm)return 1;
    if(j1.ah==j2.hh&&j1.am==j2.hm&&j1.as<=j2.hs)return 1;
    return 0;
}
vector<jikoku>vec;

int main(){
    while(cin>>n,n){
        vec.clear();
        for(int i=0;i<n;i++){
            jikoku j;
            char c;
            cin>>j.hh>>c>>j.hm>>c>>j.hs>>j.ah>>c>>j.am>>c>>j.as;
            vec.push_back(j);
        }
        sort(vec.begin(),vec.end());
        set<jikoku>se;
        se.insert(vec[0]);
        for(int i=1;i<n;i++){
            if(ok(*se.begin() , vec[i])){
                se.erase(se.begin());
            }
            se.insert(vec[i]);
        }
        cout<<se.size()<<endl;
    }
}

C++: // Last Change: 05/23/2019 19:15:46.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll n;
  const ll dayTime = 60 * 60 * 24 + 5;

  while (cin >> n and n > 0) {
    vector<ll> time(dayTime, 0);
    string ipt;
    int h, m, s;
    for (ll i = 0; i < n; ++i) {
      cin >> ipt;
      h = stoi(ipt.substr(0, 2));
      m = stoi(ipt.substr(3, 2));
      s = stoi(ipt.substr(6, 2));
      ++time[h * 60 * 60 + m * 60 + s];
      cin >> ipt;
      h = stoi(ipt.substr(0, 2));
      m = stoi(ipt.substr(3, 2));
      s = stoi(ipt.substr(6, 2));
      --time[h * 60 * 60 + m * 60 + s];
    }

    ll tmp = 0, ans = 0;
    for (ll i = 0; i < dayTime; ++i) {
      tmp += time[i];
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }

  //NS::LoopUntilZeroInpput();
}

C++: //#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
#include<sstream>

  using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)


typedef pair<int,int> pii;

int main()
{
  
  while(true){
    int n;cin>>n;
    if(n==0)break;
    priority_queue<pii> que;
    int ans=0;
    rep(i,n){
      string s,e;cin>>s>>e;
      pii train;
      const char *s_char = s.c_str();
      const char *e_char = e.c_str();
      int hour,minute,second;
      sscanf(s_char, "%d:%d:%d",&hour,&minute,&second);
      train.second=hour*60*60+minute*60+second;

      sscanf(e_char, "%d:%d:%d",&hour,&minute,&second);
      train.first=hour*60*60+minute*60+second;

      while(que.size()>0 && train.second>=que.top().first){
        que.pop();
      }
      que.push(train);
      ans=max(ans,(int)que.size());
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

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

  int n;
  int sum[3000];

int main(void){



  while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++){
            int h,m,s;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]++;
            scanf("%2d:%2d:%2d",&h,&m,&s);
            sum[h*60*60+m*60+s]--;
        }
        int res=sum[0];
        for(int i=0;i<=24*60*60;i++){
            sum[i+1]+=sum[i];
            res=max(res,sum[i+1]);
        }
        printf("%d\n",res);
    }
    return 0;
}