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<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 <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int n, hh, mm, ss;
	char ch;
	while (cin >> n, n) {
		vector<int> go, come;
		go.reserve(n); come.reserve(n);
		for (int i = 0; i < n; i++) {
			cin >> hh >> ch >> mm >> ch >> ss;
			go.push_back(hh * 1440 + mm * 60 + ss);
			cin >> hh >> ch >> mm >> ch >> ss;
			come.push_back(hh * 1440 + mm * 60 + ss);
		}
		sort(go.begin(), go.end());
		sort(come.begin(), come.end());
		int res = 0, tmp = 0, g = 0, c = 0;
		while (g != n || c != n) {
			if (g == n) {
				c++;
				tmp--;
			}
			else if (c == n) {
				g++;
				tmp++;
			}
			else {
				if (go[g] < come[c]) {
					g++;
					tmp++;
				}
				else {
					c++;
					tmp--;
				}
			}
			if (tmp > res)
				res = tmp;
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <list>

using namespace std;

typedef pair<int,int> P;
enum{IN,OUT};

int tosec(int h,int m,int s){
     int t=0;
     t+=s;
     t+=m*60;
     t+=h*60*60;
     return t;
}

int main(){
     int N;
     while(cin>>N,N){
	  list<P> hyou;
	  for(int i=0;i<N;i++){
	       int h1,h2,m1,m2,s1,s2;
	       scanf(" %d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
	       int temp1,temp2;
	       temp1=tosec(h1,m1,s1);temp2=tosec(h2,m2,s2);
	       //cout<<h2<<m2<<s2<<endl;
	       hyou.push_back(P(temp1,OUT));
	       hyou.push_back(P(temp2,IN));
	  }
	  hyou.sort();
	  int current=0,max_line=0;
	  list<P>::iterator itr=hyou.begin();
	  while(itr!=hyou.end()){
	       //cout<<itr->first<<" "<<itr->second<<endl;
	       switch(itr->second){
	       case OUT:
		    current++;
		    max_line=max(current,max_line);
		    break;
	       case IN:
		    current--;
		    break;
	       }
	       itr++;
	  }
	  cout<<max_line<<endl;
     }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct train{
  string s,t;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  ll n;
  while(cin >> n && n){
    vector<train> ans;
    cin >> s >> t;
    ans.push_back({s,t});
    rep(i,n-1){
      cin >> s >> t;
      bool f = false;
      rep(i,ans.size()){
        if(ans[i].t <= s){
          ans[i] = {s,t};
          f = true;
          break;
        }
      }
      if(!f) ans.push_back({s,t});
    }
    cout << ans.size() << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int day=86400;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<int> v(day,0);
		for(int i=0; i<n; i++){
			for(int s=0; s<2; s++){
				string tmp;
				cin >> tmp;
				int sec=0;
				for(int j=0,r=3600; j<9; j+=3,r/=60){
					tmp[j+2] = 0;
					sec += atoi(&tmp[j])*r;
				}
				v[sec] += -2*s+1;
			}
		}
		
		int ans=0;
		for(int i=1; i<day; i++){
			v[i] += v[i-1];
			ans = max(ans, v[i]);
		}
		cout << ans << endl;
	}
	return 0;
}