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 <vector>
#include <stack>

using std::cin;
using std::cout;
using std::endl;

bool is_early(std::vector<int> v1, std::vector<int> v2) {
	if (v1.size() != v2.size()) {
		return false;
	}
	for (int i = 0; i < v1.size(); i++) {
		if (v1[i] < v2[i]) {
			return true;
		}
		if (v1[i] > v2[i]) {
			return false;
		}
	}
	return false;
}

int main(void) {
	int n;
	cin >> n;

	int temp;
	char c;
	while ( n != 0 ) {
		std::vector< std::vector<int> > start(n+1, std::vector<int>(3)); 
		std::vector< std::vector<int> > stop(n+1, std::vector<int>(3)); 
		int l = 0;
		for (int i = 0; i < (n*3*2); i++) {
			if ( i%6 < 3 ) {
				cin >> start[l][i%3];
			}
			else {
				cin >> stop[l][i%3];
				if ( i%6 == 5 ) {
					l++;
				}
			}
			if ( i%3 != 2 ) {
				cin >> c;
			}
		}

		for (int i = 0; i < 3; i++) {
			start[n][i] = 100;
			stop[n][i] = 100;
		}

		std::stack<int> train;
		int count_t = 1;
		int r1 = 1;
		int r2 = 0;
		for (int i = 0; i < ((n*2)-1); i++) {
			if (is_early(start[r1],stop[r2])) {
					if (train.empty()) {
						count_t++;
					}
					else {
						train.pop();
					}
					r1++;
			}
			else {
				train.push(count_t);
				r2++;
			}
		}

		cout << count_t << endl;
		cin >> n;
	}

	return 0;
}

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

struct TIME {
	int time;
	int start;
	bool operator<(const TIME &t){
		if( time == t.time ){
			return start<t.start;
		}
		return time<t.time;
	}
};

int main() {
	while(true){
		
		vector<TIME> times;
		
		int n;
		cin >> n;
		if(n==0)break;
		
		for(int i=0;i<n;i++){
			int h,m,s;
			char c;
			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s <<endl; 
			TIME t0={h*60*60+m*60+s,1};
			times.push_back(t0);

			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s<<endl; 
			TIME t1={h*60*60+m*60+s,0};
			times.push_back(t1);
		}

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

		int count=0;
		int ans=0;
		for(TIME &t : times){
//			cout << t.start << " " << t.time << endl;;
			if(t.start==1){
				count++;
				ans=max(count,ans);
			}else{
				count--;
			}
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int day = 60*60*24;

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    
    while (1) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vi a(day+1);
        rep(i, n) {
            int h1, m1, s1, h2, m2, s2;
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            int s = h1*60*60 + m1*60 + s1;
            int e = h2*60*60 + m2*60 + s2;
            a[s]++;
            a[e]--;
        }
        rep(i, day) a[i+1] += a[i];
        cout << *max_element(a.begin(), a.end()) << endl; 
    }
}

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

const int H=60*60;
const int M=60;
const int S =1;
int train[24*H+1];

int getTime(string s){
  string tmp;
  int res=0;
  for(int i=0;i<8;i+=3){
    tmp=s.substr(i,2);
    int val=atoi(tmp.c_str());
    if(i==0){
      res+=H*val;
    }else if(i==1){
      res+=M*val;
    }else{
      res+=val;
    }
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    memset(train,0,sizeof(train));
    for(int i=0;i<n;i++){
      string start,arrival;
      int st=0,at=0;
      cin>>start>> arrival;
      st=getTime(start);
      at=getTime(arrival);
      for(int i=st;i<at;i++)train[i]++;
    }
    int ans=0;
    for(int i=0;i<=24*H;i++){
      ans=max(ans,train[i]);
      //cout << train[i] << " ";
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

class Time{
public:
  string _st;
  string _end;
};

int main(){

  int n;
  int ans=1;
  string st,end;
  vector<string> sub;
  vector<Time> time;
  bool flag=true;


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

    time.resize(n);

    for(int i=0; i<time.size(); ++i){
      cin >> st >> end;
      time[i]._st=st;
      time[i]._end=end;
    }

    for(int i=0; i<time.size()-1; ++i){
      if(time[i]._end > time[i+1]._st){
	flag = true;
	if(sub.size()!=0){
	  for(int k=0; k<sub.size(); ++k){
	    if(sub[k]<time[i+1]._st){
	      sub[k]="99999999";
	      flag=false;
	    }
	  }
	  sub.emplace_back(time[i+1]._st);
	  if(flag) ++ans;
	}else
	  {
	    ++ans;
	    if(sub.size()==0){
	      sub.emplace_back(time[i]._end);
	      sub.emplace_back(time[i+1]._st);
	    }else{
	      sub.emplace_back(time[i+1]._st);
	    }
	    
	    
	    
	    //cout << "///    "<< i << time[i]._end << "  "<< time[i+1]._st <<endl;
	  }
      }
    }
    
    cout << ans << endl;

    ans=1;
    time.clear();
  }

  
  return 0;
}