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;
int k[10000][2], n, T[3] = { 3600,60,1 }, MAX, s;
string S;
int main() {
	while (true) {
		MAX = 0;
		memset(k, 0, sizeof(k));
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			for (int h = 0; h < 2; h++) {
				cin >> S;
				for (int j = 0; j < 3; j++) {
					k[i][h] += T[j] * stoi(S.substr(3 * j, 2));
				}
			}
		}
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				s = 0;
				for (int l = j; l < n; l++) {
					if ((k[l][i] - k[j][i]) < 3600) {
						s++;
					}
					else {
						goto E;
					}
				}
			E:; MAX = max(s, MAX);
			}
		}
		cout << MAX << endl;
	}
}

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

int main(){
	while(1){
		int n;
		scanf(" %d", &n);
		if(n==0) break;

		//??????t????????????????????????????????°??£????????????
		int runningTrain[3600*24]={0};

		for(int i=0; i<n; ++i){
			int ah, am, as; //arrival
			int lh, lm, ls; //leave;

			scanf(" %d:%d:%d %d:%d:%d", &lh, &lm, &ls, &ah, &am, &as);

			int arrival = ah*3600+am*60+as;
			int leave = lh*3600+lm*60+ls;
			runningTrain[leave]++;
			runningTrain[arrival]--;
		}

		int ans=runningTrain[0];
		for(int i=0; i<3600*24-1; ++i){
			runningTrain[i+1] += runningTrain[i];
			ans = max(ans, runningTrain[i+1]);
		}

		printf("%d\n", ans);
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
//#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
#include <stdio.h>
//小数制度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#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++)

int st[10001];
int en[10001];
vector < pair <int , int > > v;
int main(){
 int n;
  while(cin >> n,n){
  	int h,m,s;
  	v.clear();
  	REP(i,n){
	  	scanf("%d:%d:%d",&h,&m,&s);
  		v.push_back(make_pair(h*3600+m*60+s,1));
	  	scanf("%d:%d:%d",&h,&m,&s);
  		v.push_back(make_pair(h*3600+m*60+s,-1));
  	}
  	sort(All(v));
  	//for(int i = 0 ; i < v.size();++i) cout << v[i].first << ":" << v[i].second << endl;
  	//event処理
  	int res , ans ;

    res = ans = 0;
    for(int i = 0 ; i < v.size();++i){
      res += v[i].second;
      ans = max(ans,res);
    }
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include <iostream>

#define MIDNIGHT 24*3600+1

using namespace std;

int read_time() {
    int h, m, s;
    cin >> h;
    cin.ignore(1);
    cin >> m;
    cin.ignore(1);
    cin >> s;
    cin.ignore(1);
    return 3600*h+60*m+s;
}

int main() {
    int n, time;
    int table[MIDNIGHT];
    while (true) {
        int count = 0;
        int max_count = 0;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<MIDNIGHT; i++) {
            table[i] = 0;
        }
        for (int i=0; i<n; i++) {
            time = read_time();
            table[time] += 1;
            time = read_time();
            table[time] -= 1;
        }
        for (int i=0; i<MIDNIGHT; i++) {
            count += table[i];
            max_count = max(count, max_count);
        }
        cout << max_count << endl;
    }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n;
int add[24*60*60+10];

void solve() {
    rep(i,24*60*60+5) add[i]=0;
    
    rep(i,n) {
        int s1,s2,s3;
        int t1,t2,t3;
        scanf("%d:%d:%d",&s1,&s2,&s3);
        scanf("%d:%d:%d",&t1,&t2,&t3);

        add[s1*24*60+s2*60+s3] += 1;
        add[t1*24*60+t2*60+t3] += -1;
    }
    rep(i,24*60*60+5) {
        add[i+1]+=add[i];
    }

    int ans=0;
    rep(i,24*60*60+5) {
        ans=max(ans,add[i]);
    }
    cout<<ans<<endl;

    

}

int main() {
    while(cin>>n) {
        if(!n) return 0;
        solve();
    }

    return 0;
}

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

int main(void){
  int n;
  while(cin >> n, n){
    vector < pair < int, int > > t;
    for(int i=0; i < n; i++){
      pair<int, int> tmp;
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.first = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tmp.second = h * 3600 + m * 60 + s;
      t.push_back(tmp);
    }

    int ans = 0, movin = 0, ind = 0;
    queue<int> q;
    for(int now=0; now <= ADAY; now++){
      if(!q.empty() && now == q.front()){
        movin--;
        q.pop();
      }
      if(now == t[ind].first){
        q.push(t[ind].second);
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(void){
  int n;
  while(cin>>n,n){
    vector<pair<int,int> > timetable(n);
    for(int i=0;i<n;++i){
      int sh,sm,ss,eh,em,es;
      scanf("%d:%d:%d",&sh,&sm,&ss);
      scanf("%d:%d:%d",&eh,&em,&es);
      timetable[i]=make_pair(sh*3600+sm*60+ss,eh*3600+em*60+es);
    }
    int ans=0;
    for(int i=0,sti,eti;i<n;++i){
    	int cnt=1;
      sti=timetable[i].first;
      eti=timetable[i].second;
      for(int j=0,stj,etj;j<n;++j){
        if(i==j)continue;
        stj=timetable[j].first;
        etj=timetable[j].second;
        if((sti<=stj&&stj<=eti)||(sti<=etj&&etj<=eti))++cnt;
      }
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}