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;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
  int n;
  int h1, h2, m1, m2, s1, s2;
  for(;; ) {
    scanf("%d", &n);
    if(!n) break;
    vpi train(n);
    REP(i, n){
      scanf("%2d:%2d:%2d", &h1, &m1, &s1);
      scanf("%2d:%2d:%2d", &h2, &m2, &s2);
      train[i].first = h1 * 60 * 60 + m1 * 60 + s1;
      train[i].second = h2 * 60 * 60 + m2 * 60 + s2;
  // LOG("%d %d %d\n", h1,m1,s1);
  // LOG("%d %d %d\n", h2,m2,s2);
    }

    int mcnt = 0;
    REP(i, n - 1){
      int cnt = 0;
      FOR(j, i + 1, n){
        if (train[i].first < train[j].second || train[j].first < train[i].second) cnt++;
      }
      mcnt = max(cnt, mcnt);
    }
    cout << mcnt + 1 << endl;
  }
}

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

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

C++: #include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int toi(string s){
    int t = ((s[0] - '0')*10 + s[1] - '0') * 3600 + ((s[3] - '0') * 10 + s[4] - '0') * 60 + (s[6] - '0')*10 + s[7] - '0';
    return t;
}
int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> sum(24*60*60 + 1, 0);
        for(int i =0; i < n; i++){
            string go, arrive;
            cin >> go >> arrive;
            int gos = toi(go);
            int as = toi(arrive);
            sum[gos]++;
            sum[as]--;
        }
        for(int i = 1; i < 24*60*60 + 1; i++) sum[i] += sum[i - 1];
        int ans = 0;
        for(int i = 0; i < 24*60*60 + 1; i++) ans = max(ans, sum[i]);
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < (int)(n); i++)
using ull = unsigned long long;
using ll = long long;

int str2time(string time_str) {
    int time_int = 0;
    time_int += stoi(time_str.substr(0, 2))*60*60;
    time_int += stoi(time_str.substr(3, 2))*60;
    time_int += stoi(time_str.substr(6, 2));
    return time_int;
}

int main() {
    while (true) {
        int N;
        cin >> N;
        if (N==0) break;

        int time[86401] = {};
        string leave, arrive;
        int leave_time, arrive_time;
        rep(i, N) {
            cin >> leave >> arrive;
            leave_time = str2time(leave);
            arrive_time = str2time(arrive);

            time[leave_time]++;
            if (leave_time!=arrive_time) time[arrive_time]--;
            else time[arrive_time+1]--;
        }

        int num_train[86401] = {}, ans=0;
        num_train[0] = time[0];
        for (int i=1; i<86401; i++) {
            num_train[i] = num_train[i-1] + time[i];
            ans = max(ans, num_train[i]);
        }

        cout << ans << endl;
    }


    return 0;
}

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

#define rep(i,x,y) for(int (i)=(x);i<(y);i++)

typedef struct{
  int hour;
  int minute;
  int second;
}Train;

int main()
{
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }

    string str1;
    string str2;
    vector<int> sh,sm,ss,eh,em,es;
    rep(i,0,n){
      cin>>str1>>str2;
      sh.emplace_back(stoi(str1.substr(0,2)));
      sm.emplace_back(stoi(str1.substr(3,2)));
      ss.emplace_back(stoi(str1.substr(6,2)));
      eh.emplace_back(stoi(str2.substr(0,2)));
      em.emplace_back(stoi(str2.substr(3,2)));
      es.emplace_back(stoi(str2.substr(6,2)));
    }

    vector<Train> trains;
    Train t={0,0,0};
    trains.push_back(t);

    rep(i,0,n){
      bool flag=false;
      int size=trains.size();
      rep(j,0,size){
        if((sh[i]>trains[j].hour)||(sh[i]==trains[j].hour&&sm[i]>trains[j].minute)||(sh[i]==trains[j].hour&&sm[i]==trains[j].minute&&ss[i]>=trains[j].second)){
          trains[j].hour=eh[i];
          trains[j].minute=em[i];
          trains[j].second=es[i];
          flag=true;
          break;
        }
      }
      if(flag==false){
        t.hour=eh[i];
        t.minute=em[i];
        t.second=es[i];
        trains.push_back(t);
      }
    }

    cout<<trains.size()<<endl;
  }

  return 0;
}