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)
}

Python: #!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

def conv(l):
    #l.reverse()
    ret = 0
    for e in l:
        ret = ret*60+e
    return ret

while True:
    N = int(sys.stdin.readline())
    if N == 0:
        exit()
    a = tuple(tuple(sys.stdin.readline().split()) for _ in range(N)) # multi line with single param
    a = [[conv(list(map(int,s.split(":")))), conv(list(map(int,e.split(":"))))] for s,e in a]

    N = 24*60*60
    imos = [0]*(N+1)

    for s,e in a:
        imos[s] += 1
        if e < N+1 : imos[e] -= 1

    cur = 0
    ret = 0
    for i in range(N):
        cur = cur + imos[i]
        ret = max(ret,cur)
    print(ret)

Python: while True:
    n = int(input())
    if n == 0:
        break
    l = [0]*(3600*24 + 1)
    for i in range(n):
        s, t = input().split()
        stime = int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8])
        etime = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6:8])
        # print(stime, etime)
        l[stime]+=1
        l[etime]-=1
    for i in range(len(l)-1):
        l[i+1] = l[i] + l[i+1]
    # print(l[0:3700])
    ans = max(l[1:])
    print(ans)

Python: def sec(m):
  hour = int(m[0:2])
  minute = int(m[3:5])
  second = int(m[6:8])
  s= 60 * 60 * hour + 60 * minute + second
  return s
  
p = 0
while p == 0:
  N = int(input())
  if N == 0:
    p = 1
    quit()
  time = [0] * (86500)
  for i in range(N):
    a, b = map(str, input().split())
    time[sec(a)] += 1
    time[sec(b)] -= 1
  ans = 1
  now = 0
  for i in range(len(time)):
    now += time[i]
    ans = max(ans, now)
  print(ans)

Python: from itertools import accumulate


def get_sec(s):
    return sum(t * c for t, c in zip(map(int, s.split(':')), (3600, 60, 1)))

while True:
    n = int(input())
    if n == 0:
        break
    cnt = [0] * 86400
    for _ in range(n):
        dep, arr = map(get_sec, input().split())
        cnt[dep] += 1
        cnt[arr] -= 1
    print(max(accumulate(cnt)))

Python: m=24*60*60
while True:
	n=int(input())
	if n==0:break
#	dp=[0]*(m+1)
#	for _ in range(n):
#		a,d=input().split()
#		a,b,c=map(int,a.split(':'));
#		d,e,f=map(int,d.split(':'));
#		dp[a*3600+b*60+c]+=1
#		dp[d*3600+e*60+f]-=1
#	for i in range(m):
#		dp[i+1]+=dp[i]
#	print(max(dp))

Python: import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    
    def hhmmss_to_s(t):
        hh = int(t[0:2])
        mm = int(t[3:5])
        ss = int(t[6:8])
        return hh*3600+mm*60+ss

    while True:
        n = I()
        if n==0:
            break
        else:
            cnt = [0]*(24*3600+1)
            for _ in range(n):
                leave, arrive = map(hhmmss_to_s, input().split())
                cnt[leave] += 1
                cnt[arrive] -= 1
            for i in range(24*3600):
                cnt[i+1] += cnt[i]

            print(max(cnt))


if __name__ == '__main__':
    resolve()

Python: from itertools import accumulate
import operator
while True:
    L = [0] * 86401
    num = int(input())
    if num == 0:
        break

    for _ in range(num):
        s, t = input().split()
        hh, mm, ss = [int(x) for x in s.split(":")]
        s  = 3600 * hh + 60 * mm + ss
        hh, mm, ss = [int(x) for x in t.split(":")]
        t = 3600 * hh + 60 * mm + ss
        L[s] +=1
        L[t] -=1

    S = accumulate(L, operator.add)
    print(max(S))

Python: import sys


def culc(time):
    h=int(time[:2])
    m=int(time[3:5])
    s=int(time[6:8])

    return 3600*h+60*m+s


R=60*60*24
while True:
    n=int(input())
    if n==0:
        sys.exit()
    
    L=[0]*(R+1)
    for i in range(n):
        leave,arrive=map(str,input().split())
        leave=culc(leave)
        arrive=culc(arrive)
        L[leave]+=1
        L[arrive]-=1
    
    for i in range(1,R):
        L[i]+=L[i-1]
    
    ans=0
    for i in range(R):
        ans=max(ans,L[i])
    print(ans)

Python: def second(s):
    return int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8])
while(1):
    n = int(input())
    if not n:
        break
    a = [0] * 86500
    b = [0] * 86500
    for i in range(n):
        l, r = map(second, input().split())
        a[l+1] += 1
        b[r] += 1

    ans = a[0]
    cur = a[0]

    for i in range(86499):
        cur += a[i+1]-b[i]
        ans = max(ans, cur)

    print(ans)

Python: # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013


from itertools import accumulate
import sys
input = sys.stdin.readline


while True:
    N = int(input())
    if N == 0:
        break

    imos = [0]*86401

    def trams_sec(x):
        return int(x[:2]) * 3600 + int(x[3:5]) * 60 + int(x[6:])


    for _ in range(N):
        a, b = input().split()
        imos[trams_sec(a)] += 1
        imos[trams_sec(b)] -= 1

    res = list(accumulate([0] + imos))

    print(max(res))