Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    S = [c for c in S]

    ans = 0
    N = len(S)
    i = 0
    while i < N - 2:
        if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
            S[i] = 'B'
            S[i+1] = 'C'
            S[i+2] = 'A'
            ans += 1
            i = max(0, i - 4)
        else:
            i += 1
    return ans


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    S = S.replace('BC', 'D')
    S = S.replace('B', ' ')
    S = S.replace('C', ' ')

    ans = 0
    for s in S.split():
        a = 0
        for c in s:
            if c == 'A':
                a += 1
            else:
                ans += a
    return ans

def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
s=list(input())
s1=[]
s2=[]
for i in s:
    if i=='W':
        s1.append(0)
    else:
        s1.append(1)
#print(s1)
for i in range(n):
    tmp1=i-sum(s1[0:i])
    tmp2=abs(0-sum(s1[i+1:n]))
    #print("tmp1:{} tmp2:{}".format(tmp1,tmp2))
    s2.append(tmp1+tmp2)
print(min(s2))


### FIXED CODE ###

n=int(input())
s=list(input())
p=s.count('E')
ans=p
for i in s:
    if i=="E":
        p-=1
    else:
        p+=1
    ans=min(p,ans)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3


def main() -> None:
    N, K = rmi()
    A = rmi()
    route = []
    current = 1
    for n in range(N):
        if not current in route:
            route.append(current)
            current = A[current - 1]
        else:
            route.append(current)
            break
    dup = [town for town in set(route) if route.count(town) > 1][0]
    dup_index = route.index(dup)
    roop_range = len(route) - dup_index - 1
    if K < len(route):
        w(route[K])
    else:
        w(route[dup_index:][(K - dup_index) % roop_range])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def main() -> None:
    N, K = rmi()
    A = rmi()
    route = []
    visited = [False] * N
    current = 1
    for n in range(N):
        route.append(current)
        if not visited[current - 1]:
            visited[current - 1] = True
            current = A[current - 1]
        else:
            break
    dup = route[-1]
    dup_index = route.index(dup)
    roop_range = len(route) - dup_index - 1
    if K < dup_index:
        w(route[K])
    else:
        w(route[dup_index:][(K - dup_index) % roop_range])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()
### BUGGY CODE ###


import bisect

N = int(input())
L = sorted(list(map(int, input().split(" "))))



cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        if l2 < l1 / 2:
            break
        if l2 < l1 / 2:
            break
        rest2 = rest[i2+1:]
        cnt += bisect.bisect_left(rest2, l2+l1) - bisect.bisect_left(rest2, l2-l1)

print(cnt)

### FIXED CODE ###

from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)
### BUGGY CODE ###

from collections import deque

def getInts():
    return [ int(x) for x in input().split() ]

[N] = getInts()
As = getInts()

maxV = max(As)
minV = min(As)

count = 0
for i in range(N):
    r1, r2 = max(0, i+1-As[i]-minV), min(i+1+As[i]+maxV, N-1)
    for j in range(r1, r2+1):
        if As[j]+As[i] == abs((j+1)-(i+1)):
            count += 1
print(count)


### FIXED CODE ###

def getInts():
    return [ int(x) for x in input().split() ]

[N] = getInts()
As = getInts()
A = {}
for i in range(1, N+1):
    A[i] = As[i-1]

L = {}
R = {}
for i in range(1, N+1):
    if i - A[i] not in L:
        L[i-A[i]] = 1
    else:
        L[i-A[i]] += 1
    if i + A[i] not in R:
        R[i+A[i]] = 1
    else:
        R[i+A[i]] += 1
count = 0
for k in R.keys():
    if k in L:
        count += R[k]*L[k]
print(count)
### BUGGY CODE ###

i = int(input())
list = []
while i > 0:
    list.append(i%10)
    i //= 10
list.reverse()

SUM = sum(list)

if SUM % 9 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())

if n % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    FF = []
    for i in range(n):
        if A[A[i] - 1] == i + 1 and A[i] not in FF:
            res += 1
            FF.append(A[A[i] - 1])
            FF.append(i + 1)
    
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for i in range(n):
        if A[A[i] - 1] == i + 1:
            res += 1

    print(res // 2)


if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = [0] * q
c = [0] * q
for i in range(q):
    b[i],c[i] = map(int,input().split())

for i in range(q):
    ans = 0
    for j in range(n):
        if a[j] == b[i]:
            a[j] = c[i]
        ans += a[j]
    print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))
ac = collections.Counter(a)
q = int(input())
b = [0] * q
c = [0] * q
for i in range(q):
    b[i],c[i] = map(int,input().split())
sum = sum(a)
for j in range(q):
    div = 0
    if ac[b[j]] != 0:
        div = c[j] * ac[b[j]] - b[j] * ac[b[j]]
        ac[c[j]] += ac[b[j]]
        ac[b[j]] = 0
    sum += div
    print(sum)
### BUGGY CODE ###

import math
def dis(x1,y1,r1,x2,y2,r2):
    if math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)>r1+r2:
        return  math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)-r1-r2
    else:
        return 0
import heapq

def dijkstra(s,g,c,n):
    d=[float('inf')]*n
    d[s]=0
    pq=[]
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        if d[u]<t:
            continue
        for v in g[u]:
            if d[u]+c[u][v]<d[v]:
                d[v]=d[u]+c[u][v]
                heapq.heappush(pq,[d[v],v])
    return d

xs,ys,xt,yt=map(int,raw_input().split())
n=int(raw_input())
c=[[xs,ys,0]]+[map(int,raw_input().split()) for _ in xrange(n)]+[[xt,yt,0]]
g=[[] for _ in xrange(n+2)]
dist=[[float("inf")]*(n+2) for _ in xrange(n+2)]
for i in xrange(n+2):
    for j in xrange(n+2):
        if i==j:continue
        g[i].append(j)
        dist[i][j]=min(dist[i][j],dis(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2]))
ans=dijkstra(0,g,dist,n+2)
print(ans[n+1])


### FIXED CODE ###

import math
import heapq
def dijkstra(s,m,n):
    visited=[0]*n
    d=[float("inf")]*n
    d[s]=0
    while True:
        mincost=float("inf")
        for i in xrange(n):
            if visited[i]!=2 and d[i]<mincost:
                mincost=d[i]
                u=i
        if mincost==float("inf"):
            break
        visited[u]=2
        for v in xrange(n):
            if visited[v]!=2:
                if d[u]+m[u][v]<d[v]:
                    d[v]=d[u]+m[u][v]
                    visited[v]=1
    return d

def main():
    xs,ys,xt,yt=map(int,raw_input().split())
    n=int(raw_input())
    c=[[xs,ys,0]]+[map(int,raw_input().split()) for _ in xrange(n)]+[[xt,yt,0]]
    dist=[[float("inf")]*(n+2) for _ in xrange(n+2)]
    for i in xrange(n+2):
        for j in xrange(n+2):
            if i==j:continue
            dist[i][j]=min(dist[i][j],dist[j][i],max(math.sqrt(abs(c[i][0]-c[j][0])**2+abs(c[i][1]-c[j][1])**2)-c[i][2]-c[j][2],0))
            dist[j][i]=dist[i][j]
    ans=dijkstra(0,dist,n+2)
    print(ans[n+1])
main()
### BUGGY CODE ###

n=input()
ans=0
chk=""
for i in n:
    if chk=="" or chk[-1]==i:
        chk+=i
    else:
        chk=chk[:-1]
        ans+=2

print(ans)


### FIXED CODE ###

n=input()
ans=0
chk=""
for i in n:
    if chk=="" or chk[-1]==i:
        chk+=i
    else:
        chk=chk[:-1]
        ans+=2

print(ans)
### BUGGY CODE ###

h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [[1e18] * (h + 1) for _ in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h + 1):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][min(j + a[i], h)] = min(dp[i + 1][min(j + a[i], h)], dp[i + 1][j] + b[i])

print(dp[n][h])

### FIXED CODE ###

h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [[1e18] * (h + 1) for _ in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h + 1):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][min(j + a[i], h)] = min(dp[i + 1][min(j + a[i], h)], dp[i + 1][j] + b[i])

print(dp[n][h])
### BUGGY CODE ###

import math
N = int(input())
for i in range(1,N+1):
    count=0
    for x in range(1,int(math.sqrt(i))):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if x*x+y*y+z*z+x*y+y*z+z*x==i:
                    if x==y and y==z:
                        count+=1
                    elif (x==y and x!=z) or (y==z and y!=x):
                        count+=3
                    else:
                        count+=6
    print(count)

### FIXED CODE ###

a=[0]*int(input())
r=range(1,99)
for x in r:
    for y in r:
        for z in r:
            n=x*(x+y+z)+y*(y+z)+z*z-1
            if n<len(a):
                a[n]+=1
print(*a)
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    A = [0] + [int(x) for x in input().split()]

    way = []
    now = 1
    for _ in range(K):
        if now in way:
            loop_start = way.index(now)
            K -= len(way[:loop_start])
            loop = way[loop_start:]
            K %= len(loop)
            now = loop[K]
            break
        way.append(now)
        now = A[now]
    print(now)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    A = [int(x) - 1 for x in input().split()]

    way = []
    seen = [False for _ in [0] * (2 * 10 ** 5 + 1)]
    now = 0
    for _ in range(K):
        if seen[now]:
            loop_start = way.index(now)
            loop = way[loop_start:]
            K -= len(way[:loop_start])
            now = loop[K % len(loop)]
            break
        way.append(now)
        seen[now] = True
        now = A[now]
    print(now + 1)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from itertools import product

N = int(input())
XYP = [tuple(map(int, input().split())) for _ in range(N)]
X = [x for x, _, _ in XYP]
Y = [y for _, y, _ in XYP]
INF = 10**18

def calcCost(AP, A):
    ret = [[INF] * N for _ in range(1 << N)]
    for state in range(1 << N):
        useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
        for i, (a, p) in enumerate(AP):
            cost = abs(a)
            for z in useA:
                cost = min(cost, abs(a - z))
            ret[state][i] = cost * p
    return ret

costX = calcCost([(x, p) for x, _, p in XYP], X)
costY = calcCost([(y, p) for _, y, p in XYP], Y)

def makeState(state, sign):
    ret = 0
    for s in state:
        ret <<= 1
        if s == sign:
            ret |= 1
    return ret

ans = [INF] * (N + 1)
for state in product((0, 1, 2), repeat=N):
    cx = costX[makeState(state, 1)]
    cy = costY[makeState(state, 2)]

    cost = sum(min(x, y) for x, y in zip(cx, cy))

    M = N - state.count(0)
    if ans[M] > cost:
        ans[M] = cost

print(*ans, sep='\n')


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

flag = 0
for t in T:
    try:
        D.remove(t)
    except ValueError:
        flag = 1
        print("NO")
        break
if flag == 0:
    print("YES")

### FIXED CODE ###

import collections

N = int(input())
D = list(map(int, input().split()))
D_set = set(D)
M = int(input())
T = list(map(int, input().split()))

D_count = collections.Counter(D)
T_count = collections.Counter(T)
flag = 0
for key, value in T_count.items():
    if key not in D_set:
        flag = 1
        print("NO")
        break
    else:
        if D_count[key] < value:
            flag = 1
            print("NO")
            break


# flag = 0
# for t in T:
#     try:
#         D.remove(t)
#     except ValueError:
#         flag = 1
#         print("NO")
#         break
if flag == 0:
    print("YES")
### BUGGY CODE ###

import queue
n = int(input())

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  u, v = map(int, input().split())
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0):
            q.put([b, a[1] + 1])
            v[b] = 1

l = a[1]
if l%3 == 2:
    print("Second")
else:
    print("First")



### FIXED CODE ###

import queue
n = int(input())

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
    l = n
else:
	l = a[1] + 2

if l%3 == 2:
    print("Second")
else:
    print("First")
### BUGGY CODE ###

import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1))
for b,c in BC:
    tmp = bisect.bisect_left(A,c)
    if b <= tmp:
        A = A[b:]
        for i in range(b):
            bisect.insort_left(A,c)
    else:
        A = A[tmp:]
        for i in range(tmp):
            bisect.insort_left(A,c)
print(sum(A))

### FIXED CODE ###

import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
            cnt += 1
            if cnt == tmp:
                break
        else:
            break
    else:
        continue
    break

print(sum(A))
### BUGGY CODE ###

s = input()
n = len(s)
dp = [1] + [0]*2019
now = 0
i = 1

for c in reversed(s):
    now += i*int(c)
    i *= 10
    dp[now%2019] += 1

ans = sum([i*(i-1)/2 for i in dp])
print(int(ans))


### FIXED CODE ###

s = input()
n = len(s)
dp = [1] + [0]*2019
now = 0
i = 1

for c in reversed(s):
    now = (now+i*int(c))%2019
    dp[now] += 1
    i *= 10
    i %= 2019

ans = sum([i*(i-1)/2 for i in dp])
print(int(ans))
### BUGGY CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
b=[0]*(10**5+2)
if a[0]==a[-1]:
  print(n)
else:
  for i in range(10**5 + 2):
    b[i]=a.count(i)
  for i in range(10**5 -1):
    ans=max(ans,sum(b[i:i+3]))
  print(ans)

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)
### BUGGY CODE ###

from collections import deque
s=input()
q=int(input())
sd=deque()
for i in range(len(s)):
    sd.append(s[i])
    
for i in range(q):
    que=list(map(str,input().split()))
    if int(que[0])==1:
        sd.reverse()
    else:
        if int(que[1])==1:
            sd.appendleft(str(que[2]))
        else:
            sd.append(str(que[2]))

ans=''.join(sd)
print(ans)

### FIXED CODE ###

from collections import deque
s=input()
q=int(input())
sd=deque()
for i in range(len(s)):
    sd.append(s[i])
count=0
for i in range(q):
    que=list(map(str,input().split()))
    if int(que[0])==1:
        count+=1
    else:
        if int(que[1])==1:
            if count%2==0:
                sd.appendleft(str(que[2]))
            else:
                sd.append(str(que[2]))
        else:
            if count%2==0:
                sd.append(str(que[2]))
            else:
                sd.appendleft(str(que[2]))
if count%2!=0:
    sd.reverse()

ans=''.join(sd)
print(ans)
### BUGGY CODE ###

h, w, n = map(int, input().split())
blacks = [[0 for _ in range(w - 2)] for _ in range (h - 2)]
for _ in range(n):
    a, b = map(int, input().split())
    for p in range(a - 3, a):
        for q in range(b - 3, b):
            blacks[p][q] += 1
count = [0 for _ in range(10)]
for k in range(h - 2):
    for l in range(w -2):
        count[blacks[k][l]] += 1
for i in range(10):
    print(count[i])


### FIXED CODE ###

from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)