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 <string>
#include <cstdlib>
#include <utility>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define vec vector

using namespace std;

int main(void)
{
	while(1) {
		int n;
		cin >> n;
		if (n == 0) break;
		vec<pair<int, int>> time(2 * n);

		rep(i, n) {
			string p, q;
			cin >> p >> q;
			time[2 * i].first = (p[0] - '0') * (int)pow(10, 5) + (p[1] - '0') * (int)pow(10, 4) + (p[3] - '0') * (int)pow(10, 3) + (p[4] - '0') * (int)pow(10, 2) + (p[6] - '0') * (int)pow(10, 1) + p[7] - '0';
			time[2 * i].second = 1;
			time[2 * i + 1].first = (q[0] - '0') * (int)pow(10, 5) + (q[1] - '0') * (int)pow(10, 4) + (q[3] - '0') * (int)pow(10, 3) + (q[4] - '0') * (int)pow(10, 2) + (q[6] - '0') * (int)pow(10, 1) + q[7] - '0';
			time[2 * i + 1].second = - 1;
		}

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

		int train = 0;
		int ans = 0;
		rep(i, 2 * n) {
			train += time[i].second;
			if (train > ans) ans = train;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int MAX = 240000;

int main()
{
    int n;
    while (cin >> n && n != 0)
    {
        vector<int> table(MAX, 0);
        for (int i = 0; i < n; i++)
        {
            string start, end;
            cin >> start >> end;
            start.erase(remove(start.begin(), start.end(), ':'), start.end());
            end.erase(remove(end.begin(), end.end(), ':'), end.end());

            int int_start = stoi(start);
            int int_end = stoi(end);

            table[int_start]++;
            table[int_end]--;
        }

        vector<int> sum(MAX, 0);
        int tmp_ans = 0;
        for (int i = 0; i < MAX; i++)
        {
            sum[i + 1] = sum[i] + table[i];
            tmp_ans = max(tmp_ans, sum[i + 1]);
        }

        cout << tmp_ans << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> p;

int atooi(char s){
  string n="0123456789";
  for(int i=0;i<=10;i++){
    if(s==n[i]){
      return i;
    }
  }
  return 0;
}

int timetime(string s){
  int hh,mm,ss,st,ft,h1,h2,m1,m2,s1,s2;
  h1= atooi(s[0]);
  h2= atooi(s[1]);
  m1= atooi(s[3]);
  m2= atooi(s[4]);
  s1= atooi(s[6]);
  s2= atooi(s[7]);
  hh=h1*10+h2;
  mm=m1*10+m2;
  ss=s1*10+s2;
  st=hh*3600+mm*60+ss;
  return st;
}

int main(){
  while(true){
  int n,st,ft;
  cin>>n;
  if(n==0) return 0;
  int  tm[100000]={};
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    st =timetime(s);
    tm[st]+=1;
   cin>>s;
   ft=timetime(s);
    tm[ft]-=1;
  }

  int val=0,ans=0;
  for(int i=0;i<=89899;i++){
    tm[i]+=val;
    val=tm[i];
    ans=max(ans,tm[i]);
  }
  cout<<ans<<endl;
}
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    while (1) {
        int n;
        cin >> n;
        if (!n) break;
        vector<int> imosu(90000, 0);
        for (int i = 0; i < n; i++) {
            string start, end;
            cin >> start >> end;
            int s = stoi(start.substr(0, 2)) * 3600 + stoi(start.substr(3, 2)) * 60 + stoi(start.substr(6, 2));
            int e = stoi(end.substr(0, 2)) * 3600 + stoi(end.substr(3, 2)) * 60 + stoi(end.substr(6, 2));
            imosu[s] += 1;
            imosu[e] -= 1;
        }
        for (int i = 1; i < imosu.size(); i++) {
            imosu[i] = imosu[i] + imosu[i - 1];
            // cout << imosu[i - 1];
        }
        // cout << endl;
        int ans = 0;
        for (auto i : imosu)
            ans = max(i, ans);
        cout << ans << endl;
    }
}

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("%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 <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

static const int MAX = 24 * 3600 + 60*60 + 60;
int t[MAX];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

		memset(t,0,sizeof(t));
		rep(i,0,n) {
			int h,m,s;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]++;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]--;
		}

		int ans = -1, tmp = 0;
		rep(i,0,MAX) {
			tmp += t[i];
			if(ans < tmp) ans = tmp;
		}
		cout << ans << endl;
	}

	return 0;
}