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

a,b,n = map(int,input().split())
c =0
for i in range(n+1):
    p =i % b 
    P = a*p//b
    if P > c:
        c = P
print(c)

### FIXED CODE ###

a,b,n = map(int,input().split())
c = 0
if n >=b:
    i = b-1
else:
    i =n
ans = int(a*i/b)-a*int(i/b)
print(ans)
### BUGGY CODE ###

import heapq


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


class Graph:
    def __init__(self):
        self.edge = {}
        self.cost = {}
        self.vertex = set()
        return

    def addEdgeCost(self, i, j, c, directed=False):
        self.vertex.add(i)
        self.vertex.add(j)

        if i not in self.edge:
            self.edge[i] = []
        self.edge[i].append(j)
        self.cost[(i, j)] = c

        if directed is False:
            return

        if j not in self.edge:
            self.edge[j] = []
        self.edge[j].append(i)
        self.cost[(j, i)] = c
        return


def dijkstra(g: Graph, s=None) -> dict:
    def solve(v_start):
        ret_cost = {v: float("inf") for v in g.vertex}
        ret_cost[v_start] = 0
        heap = [(0, v_start)]

        while heap:
            _, v_from = heapq.heappop(heap)
            for v_to in g.edge.get(v_from, []):
                nc = ret_cost[v_from] + g.cost[(v_from, v_to)]
                if ret_cost[v_to] > nc:
                    ret_cost[v_to] = nc
                    heapq.heappush(heap, (nc, v_to))
        return ret_cost

    if s is None:
        V = g.vertex
    else:
        V = [s]

    ret = {}
    for v in V:
        ret[v] = solve(v)
    return ret


N, X, Y = inpl()

G = Graph()
for i in range(N - 1):
    G.addEdgeCost(i, i + 1, 1, directed=True)
G.addEdgeCost(X - 1, Y - 1, 1, directed=True)

ans_dict = {}
for g in dijkstra(G).values():
    for v in g.values():
        ans_dict[v] = ans_dict.get(v, 0) + 1

for i in range(1, N):
    print(ans_dict.get(i, 0) // 2)


### FIXED CODE ###

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


N, X, Y = inpl()
X -= 1
Y -= 1
ans = {i: 0 for i in range(N)}
for i in range(N):
    for j in range(i + 1, N):
        c = min(j - i, abs(i - X) + 1 + abs(j - Y), abs(i - Y) + 1 + abs(j - X))
        ans[c] += 1

for i in range(1, N):
    print(ans[i])
### BUGGY CODE ###

import collections
n = int(raw_input())
mem = {1: 1}
primes = [True] * (n + 1)
posprimes = []
for d in range(2, n +1):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1

def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * (f(q))
			return mem[k]



s = 0
for k in range(1,n+1): s += k * f(k)
print s 




#2 4 6 8 10 12 14 16 18
#    6      12       18

### FIXED CODE ###



"""
ai             aj
bi             bj


1              2
2              1

1  how many pairs 
2
"""



import collections
n = int(raw_input())
mem = [0] * (n + 1)
mem[1] = 1
primes = [True] * (n + 1)
posprimes = []
d= 2
while( d <= n):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1
	d+=1
def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * mem[q]
			return mem[k]



s = 0
k = 1
while (k<= n):
	s += k * f(k)
	k += 1
print s




#2 4 6 8 10 12 14 16 18
#    6      12       18
### BUGGY CODE ###

# 正解ではない

from queue import PriorityQueue


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for i in range(H)]
    q = PriorityQueue()
    q.put((0, (Ch - 1, Cw - 1)))

    answer = resolve(q, S, (Dh - 1, Dw - 1), H, W)
    print(answer)


def resolve(q, S, D, H, W):
    while not q.empty():
        worp_count, (x, y) = q.get()
        if S[x][y] == '/':
            continue
        S[x][y] = '/'

        if (x, y) == D:
            return worp_count

        for i, j in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]:
            if 0 <= i < H and 0 <= j < W and S[i][j] == '.':
                q.put((worp_count, (i, j)))

        for i, j in [(a, b) for a in range(-2, 3) for b in range(-2, 3)]:
            if 0 <= x + i < H and 0 <= y + j < W and S[x + i][y + j] == '.':
                q.put((worp_count + 1, (x + i, y + j)))

    return -1


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    d = [[-1 for _ in range(W)] for _ in range(H)]

    q = deque([])
    q.appendleft((0, Ch - 1, Cw - 1))

    while len(q):
        worp_count, x, y = q.popleft()

        if d[x][y] != -1:
            continue
        d[x][y] = worp_count

        for i, j in ((a, b) for a in range(-2, 3) for b in range(-2, 3)):
            nx = x + i
            ny = y + j
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                if i == 0 and j == 0:
                    continue
                elif abs(i) + abs(j) == 1:
                    q.appendleft((worp_count, nx, ny))
                else:
                    q.append((worp_count + 1, nx, ny))

    print(d[Dh - 1][Dw - 1])


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

a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
while True:
    for i in range(a):
        #print(a, i)
        x = i + 2
        if a%x == 0:
            if b%x == 0:
                c.append(x)
                a = a//x
                b = b//x
                #print(c)
                break
    if i > a**0.5:
        break
s = 1
for j in c:
    s = s * j
print(s)



### FIXED CODE ###

a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
if b%a == 0:
    print(a)
else:
    while True:
        for i in range(a):
            x = i + 2
            if a%x == 0:
                if b%x == 0:
                    c.append(x)
                    a = a//x
                    b = b//x
                    break
                elif b%(a//x) == 0:
                    c.append(a//x)
                    a = x
                    b = b//(a//x)
                    break
            if x > a**0.5:
                break
        if x > a**0.5:
            break
    s = 1
    for j in c:
        s = s * j
    print(s)
### BUGGY CODE ###

n = input()
l1 = []

for i in range(n):
	t = input()
	l1.append(t)

l2 = sorted(l1)

s = []

for i in range(n):
	if i % 2 == 1:
		s.append(l1[i])

count = 0

for i in range(n):
	if i % 2 == 1:
		if l2[i] not in s:
			count += 1

print count


### FIXED CODE ###

n = input()
l1 = []

for i in range(n):
	t = input()
	l1.append(t)

l2 = sorted(l1)

s1, s2 = set([]), set([])

for i in range(n):
	if i % 2 == 1:
		s1.add(l1[i])
		s2.add(l2[i])

print len(s1) - len(s1.intersection(s2))
### BUGGY CODE ###

n = int(input())
lis = [input() for _ in range(n)]
s = set(lis)
a = []
for i in s:
    a.append([lis.count(i), i])
slis = sorted(a, key=lambda i : i[1])
M = max(slis, key=lambda i : i[0])
func = lambda i:i[1] if i[0] == M else None
anslis = [i[1] for i in slis if i[0]==M[0]]
for i in anslis:
    print(i)

### FIXED CODE ###

n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('\n'.join(sorted(anslis)))
### BUGGY CODE ###

import numpy as np
N = int(input())
An = list(map(int, input().split()))
ans = 0
ng = set()
a_An = np.array(An)
for i, a in enumerate(An):
    temp = a_An / a
    temp[i] = 0.1
    check = np.where(temp % 1 == 0)
    check = np.delete(check, np.where(check == i))
    # check = check[check != i]
    if len(check) > 0:
        ng = ng | set(check)
print(N-len(ng))


### FIXED CODE ###

N = int(input())
An = list(map(int, input().split()))
An.sort()
max_n = max(An)
dp = [0] * (max_n + 1)
for i in range(N):
    if dp[An[i]] != 0:
        dp[An[i]] = 2
        continue
    for j in range(1, max_n//An[i] + 1):
        dp[An[i]*j] += 1
ans = 0
for a in An:
    if dp[a] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))

for i in range(m):
  a.sort(reverse=True)
  a[0]=int((a[0]/2)//1)
  
print(sum(a))


### FIXED CODE ###

import heapq as hq
n,m=map(int,input().split())
a=[-int(x) for x in input().split()]
hq.heapify(a)
for i in range(m):
    x=hq.heappop(a)
    x=-x//2
    hq.heappush(a,-x)
 
print(sum(a)*-1)
### BUGGY CODE ###

N = int(input())
X = list(map(int, input().split()))

for n in range(N):
	x = X.copy()
	x.pop(n)
	#print(sorted(x))
	print(sorted(x)[(N - 1) // 2])


### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))

c = N // 2
x = sorted(X)
for v in X:
	if v < x[c]:
		print(x[c])
	else:
		print(x[c - 1])
### BUGGY CODE ###

import fractions

n = int(input())

t = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans = i
            ans = fractions.gcd(ans, j)
            ans = fractions.gcd(ans, k)
            t += ans

print(t)

### FIXED CODE ###

from math import gcd

def main():
    n = int(input())

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

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

s = input("")
Q = int(input())
for i in range(Q):
    t = input()
    if len(t) == 1:
        s = s[::-1]
    elif t[2] == "1":
        s = t[4] + s
    else:
        s = s + t[4]

print(s)

### FIXED CODE ###

s = input("")
Q = int(input())
c = 0
before = []
after = []
for i in range(Q):
    t = input()
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c%2 == 0:
            before.append(t[4])
        else:
            after.append(t[4])
    else:
        if c%2 == 0:
            after.append(t[4])
        else:
            before.append(t[4])

if c%2 == 0:
    print("".join(before[::-1]),end="")
    print(s,end="")
    print("".join(after),end="")
else:
    print("".join(after[::-1]),end="")
    print(s[::-1],end="")
    print("".join(before),end="")
### BUGGY CODE ###

N,M = map(int,input().split())    
    
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 

uf = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)

root = uf.roots()
print( max(len(uf.members(r)) for r in root) )

### FIXED CODE ###

N,M = map(int,input().split())    
       
AB = [None]*M
for i in range(M):
    a,b = map(int,input().split())
    if a>b:
        a,b=b,a
    AB[i] = (a-1,b-1)

AB=set(AB)

tree=[[] for _ in range(N)]
for a,b in AB:
    tree[a].append(b)
    tree[b].append(a) #aがbの親、とかが保証されてれば不要。

from collections import deque

groups=[]
been=[0]*N
for i in range(N):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

print(max( len(g) for g in groups))
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import Counter

def main():
  s = input().strip()
  remains = dict(Counter([int(s[-i:]) % 2019 for i in range(1, len(s)+1)]).items())

  cnt = 0
  for k, v in remains.items():
    cnt += (v * (v - 1)) // 2
    if k == 0:
      cnt += v
  print(cnt)
  
if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = input().strip()
  x = remain = 0
  remains = [0] * 2019
  k = 1
  for d in map(int, list(s[::-1])):
    x = d * k + remain
    remain = x % 2019
    k = (10 * k) % 2019
    remains[remain] += 1

  print(sum([(remain * (remain - 1)) // 2 for remain in remains]) + remains[0])
  
if __name__=='__main__':
  main()
### BUGGY CODE ###

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m + 1) for _ in range(n + 1)]
sum = [[0] * (m + 1) for _ in range(n + 1)]
MOD = 10 ** 9 + 7

ans = 0
for i in range(n):
  for j in range(m):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = (sum[i][j] + 1) % MOD
    else:
      dp[i + 1][j + 1] = 0
    sum[i + 1][j + 1] = (sum[i][j + 1] + sum[i + 1][j] 
                       - sum[i][j] + dp[i + 1][j + 1]) % MOD
    ans += dp[i + 1][j + 1]
    ans %= MOD
print((ans + 1) % MOD)


### FIXED CODE ###

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m + 1) for _ in range(n + 1)]
sum = [[0] * (m + 1) for _ in range(n + 1)]
MOD = 10 ** 9 + 7

ans = 0
for i in range(n):
  for j in range(m):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = (sum[i][j] + 1) % MOD
    else:
      dp[i + 1][j + 1] = 0
    sum[i + 1][j + 1] = (sum[i][j + 1] + sum[i + 1][j] 
                       - sum[i][j] + dp[i + 1][j + 1]) % MOD
    ans += dp[i + 1][j + 1]
    ans %= MOD
print((ans + 1) % MOD)
### BUGGY CODE ###

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = sum([abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)])

    for i in range(N):
        spam = Ai[:]
        del spam[i]
        spam = [0] + spam + [0]

        if foo[i] < foo[i + 1] < foo[i + 2] or foo[i + 2] < foo[i + 1] < foo[i]:
            print(bar)
        else:
            ham = [abs(spam[i] - spam[i + 1]) for i in range(len(spam) - 1)]
            print(sum(ham))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = [abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)]
    sumbar = sum(bar)

    spam = [0] + Ai + [0]
    for i in range(N):
        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(sumbar)
        else:
            ans = sumbar - (bar[i] + bar[i + 1]) + abs(spam[i] - spam[i + 2])
            print(ans)


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

import math
A,B=map(int,input().split())
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

def cf(a,b):
  cf=[]
  for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
      if isPrime(i):
        cf.append(i)
  return cf
print(len(cf(A,B)))

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
s=set()
x=gcd(A,B)
y=2
while y*y<=x:
  while x%y==0:
    s.add(y)
    x//=y
  y+=1
if x>1:
  s.add(x)
print(len(s)+1)
### BUGGY CODE ###

from sys import stdin

def main():
    n, m, k = [int(x) for x in stdin.readline().rstrip().split()]

    pileda = 0
    a = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        pileda += x
        a.append(pileda)
    
    piledb = 0
    b = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        piledb += x
        b.append(piledb)

    ans = 0
    for ai, time_a in enumerate(a):
        if time_a > k:
            break
        for bi, time_b in enumerate(b):
            if time_b > k:
                break
            if time_a + time_b <= k and ai + bi > ans:
                ans = ai + bi
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin

def main():
    n, m, k = [int(x) for x in stdin.readline().rstrip().split()]

    pileda = 0
    a = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        pileda += x
        a.append(pileda)
    
    piledb = 0
    b = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        piledb += x
        b.append(piledb)

    ans = 0
    bi = m
    for ai, at in enumerate(a):
        if at > k:
            break

        while at + b[bi] > k:
            bi -= 1
        
        ans = max(ans, ai+bi)
    
    print(ans)
            

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

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()
     
    def clear(self):
        self.tree = [0] * (self.size + 1)

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = (n * (n - 1) // 2) // 2 + 1
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]
bit = BIT(n+10)

def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit.clear()
  ans = 0
  for x in b:
    ans += bit.bitsum(x+1)
    bit.bitadd(x, 1)
  return ans >= m

t = [max(a) + 1, min(a) - 1]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])
  

### FIXED CODE ###

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = n * (n + 1) // 4
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a + [0]))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]


def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit = BIT(max(b) + 2)
  ans = 0
  for x in b:
    ans += bit.bitsum(x + 1)
    bit.bitadd(x, 1)
  return ans >= m

t = [len(_a), 0]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])
### BUGGY CODE ###

# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m = map(int,input().split())
ps = [input().split() for i in range(m)]

# 問題数分配列を作成 -> 正解判定用の関数
tmp=[0]*m
ac = 0
wa = 0

tmp_wa = 0

for i in range(m):
    if ps[i][1] == "AC":
        # 正解したことのある問題か確認
        if ps[i][0] not in tmp:
            ac += 1          
            wa = tmp_wa
            # tmp_wa = 0
            tmp[i] = ps[i][0]


    else:
        if ps[i][0] not in tmp:
            tmp_wa += 1


print(ac,wa)


# ACのカウントを数える
# ACが出るまでにでたWAをカウントする

# すでに正解済みの問題であれば、ACはカウントアップしない。

# すでに正解済みの問題であれば、ACはカウントアップしない。

# おそらく辞書を使う




### FIXED CODE ###

N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
### BUGGY CODE ###

n, q = [int(i) for i in input().split()]
s = input()
for _ in range(q):
    l, r = [int(i) for i in input().split()]
    print(
        len([i for i in [a + b for a, b in zip(s[l-1: r-1], s[l: r+1])] if i == 'AC']))

### FIXED CODE ###

import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


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

H, W, M = (int(i) for i in input().split())

hw = set()
hh = [0] * H
ww = [0] * W

for i in range(M):
    ht , wt = (int(i) for i in input().split())
    hw.add((ht-1) * W + wt - 1)
    hh[ht-1] += 1
    ww[wt-1] += 1

hhh = max(hh)
ih = [i for i, x in enumerate(hh) if x == hhh]

www = max(ww)
iw = [i for i, x in enumerate(ww) if x == www]

minus = 1
for iih in ih:
    for iiw in iw:
        if iih * W + iiw not in hw:
            minus = 0


print(hhh + www - minus)




### FIXED CODE ###

H, W, M = (int(i) for i in input().split())

hw = set()
hh = [0] * H
ww = [0] * W

for i in range(M):
    ht , wt = (int(i) for i in input().split())
    hw.add((ht-1) * W + wt - 1)
    hh[ht-1] += 1
    ww[wt-1] += 1

hhh = max(hh)
ih = [i for i, x in enumerate(hh) if x == hhh]

www = max(ww)
iw = [i for i, x in enumerate(ww) if x == www]

minus = 1
for iih in ih:
    for iiw in iw:
        if iih * W + iiw not in hw:
            minus = 0
            break

print(hhh + www - minus)