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<sstream>
#include<string.h>
#include<algorithm>

using namespace std;

int time[86400];

int stoi(string str){
	stringstream ss;
	int num;
	ss << str;
	ss >> num;
	return num;
}

int hmstot(string str){
	return stoi(str.substr(0,2)) * 3600 + stoi(str.substr(2,2)) * 60 + stoi(str.substr(4,2));
}

int main(){
	while(1){
		memset(time, 0,sizeof(time));
		int n;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0;i < n;i++){
			string shms,ghms;
			cin >> shms >> ghms;
			int st,gt;
			st = hmstot(shms);
			gt = hmstot(ghms);
			for(int j = st;j < gt;j++){
				time[j]++;
			}
		}
		
		int ans = 0;
		for(int i = 0;i < 86400;i++){
			ans = max(ans,time[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,ma,sum;
	string s,t;
	vector<P> box;
	while(cin>>n,n){
		ma=0;
		for(int i=0;i<n;i++){
			cin>>s>>t;
			box.push_back(P(((s[0]-'0')*10+s[1]-'0')*3600+((s[3]-'0')*10+s[4]-'0')*60+(s[6]-'0')*10+s[7]-'0',((t[0]-'0')*10+t[1]-'0')*3600+((t[3]-'0')*10+t[4]-'0')*60+(t[6]-'0')*10+t[7]-'0'));
		}
		for(int i=0;i<n;i++){
			sum=1;
			for(int j=0;j<n;j++){
				if(i!=j&&!(box[j].second<box[i].first||box[i].second<box[j].first))
				sum++;
			}
			if(sum>ma)
			ma=sum;
		}
		cout<<ma<<endl;
		box.clear();
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){

  for(;;){

  int n;
  cin>>n;
  if(!n) break;

  pair <string,string> train[n];

  for(int i=0;i<n;i++){

    string s1,s2;
    cin>>s1>>s2;

    train[i]=make_pair(s1,s2);

  }

  sort(train,train+n);

  priority_queue <string, vector <string>,greater <string>> train_q;
  int r=0;

  for(int i=0;i<n;i++){

    if(train_q.empty() || train_q.top()>train[i].first) r++;
    else train_q.pop();

    train_q.push(train[i].second);

  }

  cout<<r<<endl;

  }

  return 0;

}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int t(int h,int m,int s){
	return h*60*60+m*60+s;
}
int main(){
	int n;
	while(cin>>n,n){
		vector<pii> times(n);
		REP(i,n){
			int h1,m1,s1,h2,m2,s2;
			scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
			times[i]=make_pair(t(h1,m1,s1),t(h2,m2,s2));
		}
		sort(ALL(times));
		priority_queue<int,vi,greater<int>> q;
		REP(i,n){
			if(q.empty())
				q.push(times[i].second);
			else
			{
				if(q.top()<=times[i].first){
					q.pop();
					q.push(times[i].second);
				}else{
					q.push(times[i].second);
				}
			}
		}
		cout<<q.size()<<endl;
	}
}

C++: #include "iostream"
#include "random"
#include "ctime"
#include "chrono"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"

using namespace std;


int main() {
	int N;
	cin >> N;
	while (N) {
		vector<pair<string, string>>v(N);
		for (int i = 0; i < N; i++) {
			cin >> v[i].first >> v[i].second;
		}
		map<string, int>m;
		sort(v.begin(), v.end());
		int ans = 0;
		for (auto i : v) {
			if (m.empty()) {
				m[i.second]++;
				ans++;
				continue;
			}
			if ((*m.begin()).first <= i.first) {
				*m.begin()--;
				if ((*m.begin()).second == 0) {
					m.erase(m.begin());
				}
			}
			else {
				m[i.second]++;
				ans++;
			}
		}
		cout << ans << endl;
		cin >> N;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int t[30000];
		int sgn[30000];
		for(int i = 0;i < n;i++){
			int h,m,s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			t[2 * i] = h*60*60+m*60+s;
			sgn[2 * i] = 1;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			t[2 * i + 1] = h*60*60+m*60+s;
			sgn[2 * i + 1] = -1;
		}
		for(int i = 0;i < 2*n;i++){
			for(int j = i+1;j < 2*n;j++){
				if(t[i] > t[j]){
					swap(t[i],t[j]);
					swap(sgn[i],sgn[j]);
				}
			}
		}
		int cnt = 0;
		int ma = 0;
		for(int i = 0;i < 2*n;i++){
			cnt += sgn[i];
			ma = max(cnt,ma);
		}
		cout<<ma<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main(void) {
  int n;
  int hh1, mm1, ss1, hh2, mm2, ss2;
  int a, b;
  int ans;
  int buri[90000];
  while (1) {
	cin >> n;
	if (n == 0) return 0;
	ans = 0;
	fill(buri, buri + 90000, 0);
	for (int i = 0; i < n; i++) {
	  scanf("%d:%d:%d%d:%d:%d", &hh1, &mm1, &ss1, &hh2, &mm2, &ss2);
	  a = 3600 * hh1 + 60 * mm1 + ss1;
	  b = 3600 * hh2 + 60 * mm2 + ss2;
	  for (int j = a; j < b; j++) {
		buri[j]++;
		ans = max(ans, buri[j]);
	  }
	}
	cout << ans << endl;
  }
}