CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
d = sorted(list(map(int, input().split())) + [0])

bit, cnt = [0] * 24, 1
for num in d:
    bit[((num - 12) * cnt + 12) % 24] += 1
    cnt *= -1

if any(i > 1 for i in bit):
    print((0))
    exit()
ans = [i for i, li in enumerate(bit * 2) if li == 1]
s = min(ans[i] - ans[i - 1] for i in range(1, len(ans)))
print(s)


# Optimized solution
n = int(eval(input()))
d = sorted(list(map(int, input().split())) + [0])

ans, cnt = [], 1
for num in d:
    ans.append(((num - 12) * cnt + 12) % 24)
    cnt *= -1

ans = sorted(ans + [i + 24 for i in ans])
s = min(ans[i] - ans[i - 1] for i in range(1, len(ans)))
print(s)
# Original solution
n=int(eval(input()))
d=list(map(int,input().split()))
if n>=24:
    print((0))
    exit()
if n==23:
    print((1))
op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


# Optimized solution
n=int(eval(input()))
d=list(map(int,input().split()))
if n>=24:
    print((0))
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print((0))
                exit()
            f=1
    print((1))
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)
# Original solution
import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


INF = 10**9

def solve() -> int:
    N = read_int()
    D = read_ints()
    if N>23:
        return 0
    max_distance = -INF
    for mask in range(1<<N):
        distances = [0]
        min_distance = INF
        temp = mask
        for i in range(N):
            if temp&1 == 0:
                d = D[i]
            else:
                d = 24-D[i]
            current = min(min(abs(d0-d), 24-abs(d0-d)) for d0 in distances)
            distances.append(d)
            if current < min_distance:
                min_distance = current
            temp >>= 1
        if min_distance > max_distance:
            max_distance = min_distance
    return max_distance
        


if __name__ == '__main__':
    print((solve()))


# Optimized solution
import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


INF = 10**9

def solve() -> int:
    N = read_int()
    D = read_ints()
    if N>23:
        return 0
    D.sort(key=lambda d:min(d, 24-d))
    right = True
    assignment = [False]*24
    assignment[0] = True
    for d in D:
        if right:
            if assignment[d]:
                return 0
            assignment[d] = True
        else:
            if assignment[(24-d)%24]:
                return 0
            assignment[(24-d)%24] = True
        right = not right

    count = 0
    counts = []
    for i in range(1, len(assignment)+1):
        i %= 24
        if not assignment[i]:
            count += 1
        else:
            counts.append(count)
            count = 0
    return min(counts)+1
        


if __name__ == '__main__':
    print((solve()))
# Original solution
def main():
    N = int(input())
    D = [int(i) for i in input().split()]
    ans = 0
    cnt = [0]*24
    from collections import Counter
    c = Counter(D)
    cnt[0] = 1
    s = [0]*13
    for k, v in c.items():
        if v >= 3 or k == 0:
            ans = 0
            return print(ans)
        elif v >= 2:
            cnt[k] += 1
            cnt[24 - k] += 1
        elif k == 12:
            cnt[12] += v
        else:
            s[k] += 1
    if any(c >= 2 for c in cnt):
        return print(0)
    for bit in range(1 << 11):
        cur = cnt[:]
        for i in range(11):
            if s[i+1]:
                if bit & (1 << i):
                    cur[24 - (i+1)] += 1
                else:
                    cur[i+1] += 1
        if any(c >= 2 for c in cnt):
            continue
        pre = 0
        mi = 24
        for i, ne in enumerate(cur[1:] + [1], start=1):
            if ne:
                if i - pre < mi:
                    mi = i - pre
                pre = i
        if mi != 24:
            ans = max(ans, mi)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    _ = int(input())
    D = [int(i) for i in input().split()]
    ans = 0
    cnt = [0]*24
    from collections import Counter
    c = Counter(D)
    cnt[0] = 1
    s = [0]*13
    for k, v in c.items():
        if v >= 3:
            ans = 0
            return print(ans)
        elif k == 0 or k == 12:
            cnt[k] += v
        elif v >= 2:
            cnt[k] += 1
            cnt[24 - k] += 1
        else:
            s[k] += 1
    if any(c >= 2 for c in cnt):
        return print(0)
    for bit in range(1 << 11):
        cur = cnt[:]
        for i in range(11):
            if s[i+1]:
                if bit & (1 << i):
                    cur[24 - (i+1)] += 1
                else:
                    cur[i+1] += 1
        pre = 0
        mi = 24
        for i, ne in enumerate(cur[1:] + [1], start=1):
            if ne:
                if i - pre < mi:
                    mi = i - pre
                pre = i
        ans = max(ans, mi)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
from itertools import product
import random

def solve(n,dl):
    # n = int(input())
    # dl = list(map(int, input().split()))

    if 0 in dl:
        return 0

    doubles = []
    dl1 = []
    dl2 = []
    for i in range(1,13):
        i_cnt = dl.count(i)
        if i_cnt > 2:
            return 0
        elif i_cnt == 2:
            dl2.append(24-i)
            dl2.append(i)
        elif i_cnt == 1:
            dl1.append(i)        

    ans = 0
    ite = list(product(list(range(2)),repeat=len(dl1)))
    for pattern in ite:
        dl24 = [0,24]
        for i, v in enumerate(pattern):
            if v == 1:
                dl24.append(24-dl1[i])
            else:
                dl24.append(dl1[i])
        dl24 = dl24 + dl2
        dl24.sort()
        diff_min = 24
        # print(dl24)
        if len(dl24) == 1:
            ans = max(ans, min(dl24[0], 24-dl24[0]))
        else:
            for a,b in zip(dl24[:-1],dl24[1:]):
                diff = b-a
                if diff != 24:
                    diff_min = min(diff_min,diff)
            ans = max(diff_min,ans)
    return ans


def solve2(n,dl):
    ite = list(product(list(range(2)),repeat=len(dl)))
    ans = 0
    for pattern in ite:
        dl_new = [0]
        for i, v in enumerate(pattern):
            if v == 1:
                dl_new.append(24-dl[i])
            else:
                dl_new.append(dl[i])
        dl_new.sort()
        diff_min = 24
        for a,b in zip(dl_new[:-1], dl_new[1:]):
            diff = b-a
            diff_min = min(diff_min, diff)
        ans = max(ans,diff_min)
    return ans


if __name__ == "__main__":
    n = int(eval(input()))
    dl = list(map(int, input().split()))
    ans = solve(n,dl)
    print(ans)
    # for _ in range(10):
    #     n = random.randint(1,10)
    #     dl = [random.randint(1,12) for _ in range(n)]
    #     ans1 = solve(n, dl[:])
        # ans2 = solve2(n,dl[:])
        # if ans1 != ans2:
        #     print(n)
        #     print(dl)
        #     print(ans1)
        #     print(ans2)
        #     print('----')

# Optimized solution
n = int(eval(input()))
dl = list(map(int, input().split()))

if 0 in dl:
    print((0))
    exit()

dl.sort()
dl1 = [0,24]
dl2 = [0,24]
for i, d in enumerate(dl):
    if i%2 == 0:
        dl1.append(d)
        dl2.append(24-d)
    else:
        dl1.append(24-d)
        dl2.append(d)

dl1.sort()
dl2.sort()

min_1 = 24
for a,b in zip(dl1[1:],dl1[:-1]):
    diff = a-b
    min_1 = min(min_1,diff)

min_2 = 24
for a,b in zip(dl2[1:],dl2[:-1]):
    diff = a-b
    min_2 = min(min_2,diff)

ans = max(min_1,min_2)
print(ans)
# Original solution
N = int(eval(input()))
D = [int(d) for d in input().split()]

D.append(0)
D.sort()
ans = 0
time1 = []
time2 = []
for i in range(N+1):
    if D.count(D[i]) == 2:
        if D[i] == 0:
            ans = -1
            break
        time2.append(D[i])
        time2.append(24-D[i])
    if D.count(D[i]) + D.count(24-D[i]) > 2:
        ans = -1
        break
    if D.count(D[i]) == 1:
        time1.append(D[i])

time2 = set(time2)    
if ans == 0:
    for i in range(2**len(time1)):
        temp = []
        for j in range(len(time1)):
            if i & 1<<j:
                temp.append(24-time1[j])
            else:
                temp.append(time1[j])
        temp += list(time2)
        temp.sort()
        cnt = 24-temp[-1]
        if temp[-1] == 0:
            cnt = 0
        for k in range(len(temp)-1):
            cnt = min(cnt, temp[k+1]-temp[k])
        ans = max(ans, cnt)
else:
    ans = 0

print(ans)

# Optimized solution
N = int(eval(input()))
D = [int(d) for d in input().split()]

D.append(0)
D.sort()
for i in range(1, N+1):
    if i%2 == 0:
        D[i] = 24-D[i]
D.sort()
ans = min(D[-1], 24-D[-1])
for i in range(N):
    ans = min(ans, D[i+1]-D[i])
print(ans)
# Original solution
from collections import Counter 
import itertools

N = int(eval(input()))
D = list(map(int, input().split()))
M = Counter(D)
if max(M.values()) > 2:
    print((0))
elif 0 in D:
    print((0))
else:
    D = [[x, 24-x] for x in D]
    generator = list(itertools.product([0, 1], repeat=N))
    D_gen = [[D[i][g[i]] for i in range(N)] for g in generator]
    ans = 0
    for d in D_gen:
        if len(set(d)) < N:
            pass
        else:
            tmp = [0] + sorted(d) + [24]
            s = 13
            for i in range(N+1):
                s = min(s, tmp[i+1]-tmp[i])
            ans = max(ans, s)
    print(ans)


# Optimized solution
from collections import Counter 
import itertools

N = int(eval(input()))
D = list(map(int, input().split()))
D.append(12)
M = Counter(D)
if max(M.values()) > 2:
    print((0))
elif 0 in D:
    print((0))
elif N > 11:
    print((1))
else:
    D.remove(12)
    D = [[x, 24-x] for x in D]
    generator = list(itertools.product([0, 1], repeat=N))
    D_gen = [[D[i][g[i]] for i in range(N)] for g in generator]
    ans = 0
    for d in D_gen:
        if len(set(d)) < N:
            pass
        else:
            tmp = [0] + sorted(d) + [24]
            s = 13
            for i in range(N+1):
                s = min(s, tmp[i+1]-tmp[i])
            ans = max(ans, s)
    print(ans)
# Original solution
n,*d=list(map(int,open(0).read().split()));s=sorted
l=[0]+s([x if i%2 else 24-x for i,x in enumerate(s(d))])+[24]
print((min(j-i for i,j in zip(l,l[1:]))))

# Optimized solution
_,d=open(0);s=sorted;l=[0]+s([x if i%2else 24-x for i,x in enumerate(s(list(map(int,d.split()))))])+[24];print((min(j-i for i,j in zip(l,l[1:]))))
# Original solution
_,d=open(0);s=sorted;l=[0]+s([x if i%2else 24-x for i,x in enumerate(s(list(map(int,d.split()))))])+[24];print((min(j-i for i,j in zip(l,l[1:]))))

# Optimized solution
_,d=open(0);s=sorted;l=s([(24-x,x)[i%2]for i,x in enumerate(s(list(map(int,d.split()))))]);print((min(j-i for i,j in zip([0]+l,l+[24]))))
# Original solution
n,t=open(0)
n=int(n)+1
d=[t if i%2else(24-t)%24for i,t in enumerate([0]+sorted(map(int,t.split())))]
print((min(abs(d[i]-d[j])for i in range(n)for j in range(i+1,n))))

# Optimized solution
_,d=open(0);s=sorted;l=s((24-x,x)[i%2]for i,x in enumerate(s(list(map(int,d.split())))));print((min(j-i for i,j in zip([0]+l,l+[24]))))
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
h = [0]*13
for i in d:
    h[i] += 1

ans = 0
def rec(now, state):
    global ans
    if now == 13:
        state.sort()
        m = float("Inf")
        for i in range(len(state)):
            m = min(m, min(abs(state[i-1]-state[i]), 24-abs(state[i-1]-state[i])))
        ans = max(ans, m)
    elif now == 0:
        if h[now]:
            return
        rec(now+1, state)
    elif now == 12:
        if h[now]==0:
            rec(now+1, state)
        elif h[now]==1:
            state.append(now)
            rec(now+1, state)
    else:
        if h[now]==0:
            rec(now+1, state)
        elif h[now]==1:
            s = state[:]
            s.append(now)
            rec(now+1,s)
            s = state[:]
            s.append(24-now)
            rec(now+1, s)
        elif h[now]==2:
            state.append(now)
            state.append(24-now)
            rec(now+1, state)
rec(0, [0])
print(ans)

# Optimized solution
n = int(eval(input()))
a = [0]*13
for i in map(int, input().split()):
    a[i] += 1

ans = 0
if any(i>2 for i in a) or a[0] or a[12]>1:
    pass
else:
    s = [[0]]
    for i in range(1, 13):
        nxt = []
        if a[i] == 0:
            nxt = s
        elif a[i] == 1:
            for si in s:
                nxt.append(si+[i])
                nxt.append(si+[24-i])
        else:
            for si in s:
                nxt.append(si+[i, 24-i])
        s = nxt
    for si in s:
        si.sort()
        tmp = float("Inf")
        for i in range(len(si)):
            k = abs(si[i]-si[i-1])
            k = min(k, 24-k)
            tmp = min(tmp, k)
        ans = max(ans, tmp)
print(ans)
# Original solution
def ans_is_zero():
    print((0))
    exit(0)

def solve():
    n=int(eval(input()))
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0

    N = 1 << n
    for i in range(N):#left or right
        t=1

        for j in range(n):
            if (i>>j)&1: t |= (1 << d[j])
            else: t |= (1 << (24 - d[j]))

        if bin(t).count("1") < n + 1:#重複あり
            continue

        ret = 100
        prev = 0
        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()


# Optimized solution
def ans_is_zero():
    print((0))
    exit(0)

def solve():
    n=int(eval(input()))
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0

    N = 1 << n
    for i in range(N):#left or right
        t=1
        ret = 100
        for j in range(n):
            if (i>>j)&1: num = d[j]
            else: num = 24 - d[j]

            if (t >> num)&1:
                ret = -1
                break
            t |= (1 << num)
        
        if ret == -1:
            continue

        if bin(t).count("1") < n + 1:#重複あり
            continue

        prev = 0
        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()
# Original solution
import random

def ans_is_zero():
    print((0))
    exit(0)

def solve():
    n=int(eval(input()))
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0
    random.shuffle(d)
    
    N = 1 << n
    for i in range(N):#left or right
        t=1
        ret = 100
        for j in range(n):
            if (i>>j)&1: num = d[j]
            else: num = 24 - d[j]

            if (t >> num)&1:
                ret = -1
                break
            t |= (1 << num)

        if ret == -1:
            continue

        if bin(t).count("1") < n + 1:#重複あり
            continue

        prev = 0
        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()


# Optimized solution

def ans_is_zero():
    print((0))
    exit(0)

def solve():
    n=int(eval(input()))
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0
    d.sort()

    N = 1 << n
    for i in range(N):#left or right
        t=1
        ret = 100

        for j in range(n):
            if (i>>j)&1: num = d[j]
            else: num = 24 - d[j]

            if (t >> num)&1:
                ret = -1
                break
            t |= (1 << num)

        if ret == -1: continue
        prev = 0

        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()
# Original solution
N = int(eval(input()))
D = [0] + list(map(int, input().split()))
Diffs = [[[0, 0] for i in range(N+1)] for j in range(N+1)]

# ある都市間の時差の取りうる値は2種類のみ
# 先ずはそれを全列挙
candidates = []
for i in range(N+1):
  for j in range(i+1, N+1):
    di, dj = D[i], D[j]
    diff1, diff2 = abs(di-dj), min(24-di-dj, di+dj)
    candidates.extend([[i, j, diff1, 0], [i, j, diff2, 1]])
    Diffs[i][j] = [diff1, diff2]

# 上で全列挙した時差に関して、その時差が全体の最小値となり得るかどうかを確認していく
# 最小値となり得るかどうかを確認したい時差の値をdiffとすると、
# 任意の2都市間の時差がdiff以上となる必要があり、そのような時間の設定方法があるかどうかを確認する
# 矛盾するかどうかは都市を2色で塗り分ける要領で確認できる
ans = 0
for idx1, idx2, diff, c in candidates:
  conditions = [-1] * (N+1)
  if c == 0:
    conditions[idx1] = conditions[idx2] = 0
  else:
    conditions[idx1] = 0; conditions[idx2] = 1
  res = True
  for i in range(N+1):
    for j in range(i+1, N+1):
      if idx1 == i and idx2 == j:
        continue
      diff1, diff2 = Diffs[i][j]
      if diff1 < diff and diff2 < diff:
        res = False
        break
      elif diff1 < diff:
        c1, c2 = conditions[i], conditions[j]
        if c1 < 0 and c2 < 0:
          conditions[i] = 0; conditions[j] = 1
        elif c1 < 0:
          conditions[i] = 1 - c2
        elif c2 < 0:
          conditions[j] = 1 - c1
        else:
          if c1 == c2:
            res = False
            break
      elif diff2 < diff:
        c1, c2 = conditions[i], conditions[j]
        if c1 < 0 and c2 < 0:
          conditions[i] = conditions[j] = 0
        elif c1 < 0:
          conditions[i] = c2
        elif c2 < 0:
          conditions[j] = c1
        else:
          if c1 != c2:
            res = False
            break
    else:
      continue
    break
  if res:
    ans = max(ans, diff)

print(ans)

# Optimized solution
# 想定解法

N = int(eval(input()))
D = list(map(int, input().split()))
num_time = [0] * 13
num_time[0] = 2
num_time[12] = 1

fixed = [0]
unfixed = []
for d in D:
  num_time[d] += 1
  if d == 12:
    fixed.append(12)
  if num_time[d] >= 3:
    print((0))
    quit()

for t in range(1, 12):
  if num_time[t] == 2:
    fixed.extend([t, 24 - t])
  elif num_time[t] == 1:
    unfixed.append(t)

ans = 0
n = len(unfixed)
for i in range(2**n):
  t = fixed.copy() + [24]
  # bitが0のものはt, 1のものは24-tとして設定する
  for j in range(n):
    if i >> j & 1:
      t.append(unfixed[j])
    else:
      t.append(24 - unfixed[j])
  t.sort()
  s = 24
  m = len(t)
  for k in range(m-1):
    _s = t[k+1] - t[k]
    s = min(s, _s)
  ans = max(ans, s)

print(ans)
# Original solution
n, c, k = list(map(int, input().split()))
t = []
for i in range(n):
  t.append(int(eval(input())))
t.sort()
result = 1
count = 0

for i in range(n):
  if (t[count] - t[0]) > k or c == count:
    result += 1
    t = t[count:]
    count = 1
  else:
    count += 1
print(result)

# Optimized solution
n, c, k = list(map(int, input().split()))
t = [int(eval(input())) for i in range(n)]
t.sort()

result = 1
count = 0
f = 0

for i in range(n):
  if (t[i] - t[f]) > k or c == count:
    result += 1
    count = 1
    f = i
  else:
    count += 1
print(result)
# Original solution
def ii():return int(eval(input()))
def iim():return list(map(int,input().split()))
def iil():return list(map(int,input().split()))

n,c,k = iim()
time = []
for _ in range(n):
    time.append(ii())

time.sort()

bus = 0
fst = time[0]
ans = 0
for item in time:
    if bus <= c-1 and item <= k+fst:
        bus += 1
    elif bus > c-1:
        bus = 1
        ans += 1
        fst = item
    elif item-fst > k:
        bus = 1
        ans += 1
        fst = item
    

print((ans if bus == 0 else ans+1))

# Optimized solution
def ii():return int(eval(input()))
def iim():return list(map(int,input().split()))
def iil():return list(map(int,input().split()))

n,c,k = iim()
time = []
for _ in range(n):
    time.append(ii())

time.sort()

bus = 0
fst = time[0]
ans = 0
for item in time:
    if bus <= c-1 and item <= k+fst:
        bus += 1
    else:
        bus = 1
        ans += 1
        fst = item

print((ans if bus == 0 else ans+1))
# Original solution
import math

N, C, K = list(map(int, input().split()))
t_dic = {}
for j in range(N):
    t_num = int(eval(input()))
    num = t_dic.get(t_num, 0)
    t_dic[t_num] = num + 1

t_list = sorted(t_dic.keys())
removed_man_dic = {}
total_car = 0
for i, t in enumerate(t_list):
    limit = t + K
    limit_num = t_dic[t] - removed_man_dic.get(t, 0)
    if limit_num == 0:
        continue
    car_num = int(math.ceil(limit_num / C))
    total_car += car_num
    passenger = C * car_num
    remaining_seat = passenger - limit_num
    removed_man_dic = {}
    for j in t_list[i+1:]:
        if j >= limit:
            break
        num = t_dic.get(j, 0)
        if num <= remaining_seat:
            remaining_seat -= num
            removed_man_dic[j] = num
        else:
            removed_man_dic[j] = remaining_seat
            break

print(total_car)


# Optimized solution
N, C, K = list(map(int, input().split()))
t_sorted = [int(eval(input())) for _ in range(N)]
t_sorted.sort()

car = 0
passenger = 0
target_t, limit = 0, 0
for i, t in enumerate(t_sorted):
    if target_t == 0:
        target_t = t
        limit = t + K
    passenger += 1
    if passenger == C:
        car += 1
        passenger = 0
        target_t = 0
        continue
    if i != N - 1:
        if t_sorted[i + 1] > limit:
            car += 1
            passenger = 0
            target_t = 0
            continue
if passenger > 0:
    car += 1

print(car)
# Original solution
N, C, K = list(map(int, input().split()))
T = []
for i in range(N):
    T.append(int(eval(input())))
sorted_T = sorted(T)
bus_count = 1
pas_count = 0
bus_start = sorted_T[0]
for t in sorted_T:
    if pas_count == C or t - bus_start > K:
        bus_count += 1
        pas_count = 0
        bus_start = t
    pas_count += 1
print(bus_count)

# Optimized solution
N, C, K = list(map(int, input().split()))
flag = True
pass_num = 0
count = 1
for t in sorted([int(eval(input())) for _ in range(N)]):
    if flag:
        first_pass_time = t
        flag = False
    if t - first_pass_time > K or pass_num == C:
        first_pass_time = t
        pass_num = 0
        count += 1
    pass_num += 1
print(count)
# Original solution
import bisect

N, C, K = list(map(int, input().split()))
T = sorted([int(eval(input())) for i in range(N)])

i = 0
ans = 0

while T:
    ans += 1
    check = T[0] + K
    people = bisect.bisect_right(T, check)
    if people > C:
        del T[:C]
    else:
        del T[:people]

print(ans)

# Optimized solution
import bisect
N, C, K =list(map(int, input().split()))
T = sorted([int(eval(input())) for i in range(N)])

ans = 0
front = 0
while front < N:
    standard = T[front] + K
    front = min(bisect.bisect_right(T, standard), front+C)
    ans += 1
print(ans)