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 int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	//IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(!N)break;
		int imos[123456]={};
		rep(i,0,N){
			int h,m,s;
			scanf("%lld:%lld:%lld",&h,&m,&s);
			imos[h*3600+m*60+s]++;
			scanf("%lld:%lld:%lld",&h,&m,&s);
			imos[h*3600+m*60+s]--;
		}
		int ma = 0;
		rep(i,0,123455)imos[i+1]+=imos[i];
		rep(i,0,123456)chmax(ma,imos[i]);
		ans.push_back(ma);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}

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

int main() {
	int n, data[6], x[864001] = { 0 };
	int max_mini = 0;
	while (cin >> n) {
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			scanf_s("%d:%d:%d %d:%d:%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5]);
			x[data[0] * 3600 + data[1] * 60 + data[2]]++;
			x[data[3] * 3600 + data[4] * 60 + data[5]]--;
			if (max_mini < data[3] * 3600 + data[4] * 60 + data[5])
				max_mini = data[3] * 3600 + data[4] * 60 + data[5];
		}
		int ans = 0, cnt = 0;
		for (int i = 0; i <= max_mini; i++) {
			cnt += x[i];
			ans = max(ans, cnt);
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

// convert hh:mm::ss to sec
int convertSec(const string& str) {
  int h = 10 * (str[0] - '0') + (str[1] - '0');
  int m = 10 * (str[3] - '0') + (str[4] - '0');
  int s = 10 * (str[6] - '0') + (str[7] - '0');
  return 3600 * h + 60 * m + s;
}

int main() {

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

    vector<int> table(23 * 3600 + 59 * 60 + 59, 0);

    for (int i = 0; i < n; i++) {
      string s, e;
      cin >> s >> e;

      table[convertSec(s)]++;
      table[convertSec(e)]--;
    }

    // simulate
    for (int i = 0; i < table.size(); i++) {
      if (i != 0) table[i] += table[i - 1];
    }

    // find max value
    int maxValue = 0;
    for (int i = 0; i < table.size(); i++) {
      if (table[i] > maxValue) maxValue = table[i];
    }

    cout << maxValue << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>

using namespace std;

int main(void)
{
	vector <string> s, t; //s????????????t?????°???
	multimap<int, int> mp;
	vector <pair<int, int>> pr;
	vector <int> ans;
	string temp1, temp2;
	int m, n;
	int temp;
	int i, j, k;
	int count = 0; //???????????¬??°
	int max = 0;

	while (1) {

		cin >> n;
		if (n == 0) {
			break;
		}

		for (i = 0; i < n; i++) {
			cin >> temp1 >> temp2;


			temp = stoi(temp1.substr(0, 2)) * 3600 + stoi(temp1.substr(3, 2)) * 60 + stoi(temp1.substr(6, 2));

			pr.push_back(make_pair(temp, 1));

			temp = stoi(temp2.substr(0, 2)) * 3600 + stoi(temp2.substr(3, 2)) * 60 + stoi(temp2.substr(6, 2));

			pr.push_back(make_pair(temp, 0));


		}
		sort(pr.begin(), pr.end());

		for (i = 0; i < pr.size(); i++) {
			
			if (pr[i].second == 1) {
				count++;
				if (max < count) {
					max = count;
				}

			}
			else if (pr[i].second == 0) {
				count--;
			}

	
			

		}

		pr.clear();

		ans.push_back(max);

	}

	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}



	return (0);
}