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<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int n;
int S[10001],E[10001];
int main(){
  while(scanf("%d",&n),n){
    for(int i=0;i<n;i++){
      int s1,h1,m1,s2,h2,m2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
      S[i]=h1*3600+m1*60+s1;
      E[i]=h2*3600+m2*60+s2;
    }
    int res=0;
    for(int i=0;i<n;i++){
      int sum=0;
      for(int j=0;j<n;j++){
	if(S[i] <= S[j] && S[j] < E[i]) sum++;
	else if(S[i] < E[j] && E[j] <= E[i]) sum++;
	else if(S[j] <= S[i] && E[i] <= E[j]) sum++;
      }
      res = max(res,sum);
    }
    printf("%d\n",res);
  }
}

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

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

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

    ll ans = 0, movin = 0, ind = 0;
    vector<ll> q;
    for(ll now=0; now <= ADAY; now++){
      while(!q.empty() && now == q[0]){
        movin--;
        q.erase(q.begin());
      }
      while(ind < n && now == t[ind].first){
        q.push_back(t[ind].second);
        sort(q.begin(), q.end());
        movin++;
        ind++;
        ans = max(ans, movin);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  int dp[SIZE] = {};
  vector<pair<int,int> > vec;
  
  scanf("%d",&n);

  if(n == 0) return false;


  for(int i=0;i<n;i++){
    int sh,sm,ss,eh,em,es;
    int s,e;

    scanf("%d:%d:%d %d:%d:%d",&sh,&sm,&ss,&eh,&em,&es);

    s = sh*3600 + sm*60 + ss;
    e = eh*3600 + em*60 + es;

    dp[s]++;
    dp[e]--;
    
  }

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

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

  return true;
}


int main(){

  while(solve());
  
  return 0;
}

C++: #include<cstdio>

#include<ctime>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	freopen("zoj2013.in","r",stdin);
#endif
	try{
		while(1)
		inp();
	}
	catch(... ){
#ifdef XS
		printf("%s","exception");
#endif
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 1e5;
int tim[N];
void inp(){
	MS(tim);
	int n;scanf("%d",&n);
	if(!n)exit(0);
	time_t raw = time(0);
	tm * be = gmtime(&raw);
	tm * en = new tm;
	memcpy(en, be, sizeof(tm));
	be->tm_hour = be->tm_min = be->tm_sec = 0;
	for(int i = 0;i<n;i++){
		for(int c = 1 ;c>=-1;c-=2){
			scanf("%d:%d:%d", &en->tm_hour,&en->tm_min,&en->tm_sec);
			U d = (U)difftime(mktime(en),mktime(be));
			tim[d] += c;
		}
	}
	int ans = -1;
	for(int i = 1;i<N;i++){
		tim[i]+=tim[i-1];
		if(tim[i]>ans)
			ans = tim[i];
	}
	printf("%d\n",ans);
}
//zoj2013.cc by xsthunder at Tue Jul 25 21:35:55 2017

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<24*60*60;i++){
			sum=0;
			for(int j=0;j<n;j++){
				if(box[j].first<=i&&box[j].second>i)
				sum++;
			}
			if(sum>ma)
			ma=sum;
		}
		cout<<ma<<endl;
		box.clear();
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int n;
  while( cin >> n, n ) {
    int cnt[100000] = {0};
    
    while( n-- ) {
      int st, en;
      int h, m, s;
      
      scanf("%lld:%lld:%lld", &h, &m, &s);
      st = h*3600 + m*60 + s;
      
      scanf("%lld:%lld:%lld", &h, &m, &s);
      en = h*3600 + m*60 + s;

      for(int i=st; i<en; i++) cnt[i]++;
    }

    int ma = 0;
    for(int i=0; i<100000; i++) ma = max( ma, cnt[i] );

    cout << ma << endl;
    
  }
  
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
long long int N[10000000]={};
int main(){

int n,q;
int h1=0,m1=0,s1=0,h2=0,m2=0,s2=0;
while(1){
cin>>n;if(n==0)break;
for(int i=0;i<n;i++)
{scanf("%d:%d:%d",&h1,&m1,&s1);
scanf("%d:%d:%d",&h2,&m2,&s2);
long int L1=h1*3600+m1*60+s1;
long int L2=h2*3600+m2*60+s2;
for(int j=L1;j<L2;j++)
	N[j]++;
}
int max=0;
for(int i=0;i<=10800;i++)
{if(N[i]>max)max=N[i];}
cout<<max<<endl;
}
return 0;
}