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

import heapq

n = int(input())
h = list(map(int, input().split()))

for i in range(1, n):
  h_minus = list(map(lambda x: x*(-1), h[:i]))
  heapq.heapify(h_minus)
  if h[i] < (h_minus[0])*(-1)-1:
    print("No")
    exit(0)
print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
   
h_max = h[0]
for i in range(1, n):
  if h[i-1] > h_max:
    h_max = h[i-1]
  if h[i] < h_max -1:
    print("No")
    exit(0)
print("Yes")
### BUGGY CODE ###

import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, T = rl()
A = rl()
B = np.array(A)
answer = 1
profit = 0
for i in range(N):
    p = B[i:].max() - A[i]
    if p > profit:
        profit = p
        answer = 1
    elif p == profit:
        answer += 1

print(answer)

# 40


### FIXED CODE ###

import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, T = rl()
A = rl()
answer = 1
profit = 0
min = A[0]
for i in range(1, N):
    if A[i] < min:
        min = A[i]
        continue
    x = A[i] - min
    if x > profit:
        answer = 1
        profit = x
    elif x == profit:
        answer += 1

print(answer)
# 40
### BUGGY CODE ###

import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            for j in range(len(se[kkk])):
                if se[kkk][j] <= i-n:
                    return True
            else:
                se[kkk].append(i)
        else:
            bs.insort(data,kkk)
            se[kkk] = [i]
    return False








n = onem()

s = list(input())
l = 0
r = n//2
while True:
    mid = -(-(l+r)//2)
    ans = search(s,mid)
    if l == mid:
        break
    if ans:
        l = mid
    else:
        r = mid-1
print(l)









### FIXED CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            if se[kkk] <= i-n:
                    return True
        else:
            bs.insort(data,kkk)
            se[kkk] = i
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



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

import sys
sys.setrecursionlimit(200001)

N, M = [int(n) for n in input().split()]
S = input()

ans = []

def rest(l, ans):
    s = M
    while s > 0:
        if s >= l:
            ans.append(l)
            return ans
        if S[l-s] == "1":
            if s == 1:
                return -1
            s -= 1
            continue
        l -= s
        if rest(l, ans) == -1:
            s -= 1
        else:
            ans.append(s)
            return ans
    return -1

ans = rest(N, [])

if ans == -1:
    print(-1)
else:
    print(" ".join([str(n) for n in ans]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(200001)

N, M = [int(n) for n in input().split()]
S = input()

p1 = False
x1 = 0
m1 = N
c1 = 0
for n in S:
    if n == "1":
        if p1:
            c1 += 1
        else:
            c1 = 1
            p1 = True
    else:
        p1 = False
        if c1 > 0:
            if c1 > x1:
                x1 = c1
            if c1 < m1:
                m1 = c1
           
def rest(l, ans):
    s = M
    while s > 0:
        if s >= l:
            ans.append(l)
            return ans
        if S[l-s] == "1":
            if s == 1:
                return -1
            s -= 1
            continue
        l -= s
        if rest(l, ans) == -1:
            s -= 1
        else:
            ans.append(s)
            return ans
    return -1

if x1 > M - 1:
    ans = -1
else:
    ans = rest(N, [])

if ans == -1:
    print(-1)
else:
    print(" ".join([str(n) for n in ans]))
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

kami = []
for i in range(N):
    if A[i] not in kami:
        kami.append(A[i])
    else:
        kami.remove(A[i])

print(len(kami))

### FIXED CODE ###

N = int(input())

kami = set([])
for i in range(N):
    A = int(input())
    if A not in kami:
        kami.add(A)
    else:
        kami.remove(A)

print(len(kami))
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
now=0
l=[1]
ll=[]
for i in range(n*2):
    now=a[now]
    if now not in l:
        l.append(now)
    elif now in l and now not in ll:
        ll.append(now)
    else:
        break
    now-=1

b=len(l)
c=len(ll)
num=b-c
if k>num:
    k=(k-num)%c
    print(ll[k])
else:
    k=k%b
    print(l[k])


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[1]
di={}
di[1]=1
for i in a:
    b=a[l[-1]-1]
    if b in di:
        x=b
        break
    l.append(b)
    di[b]=1
t1=0
for j in l:
    if j==x:
        break
    else:
        t1+=1
t2=len(l)-t1
if k<=t1:
    print(l[k])
else:
    num=(k-t1)%t2
    print(l[t1+num])
### BUGGY CODE ###

def solve():
    H, N = map(int, input().split())
    
    INF = 10 ** 9
    dp = [INF for _ in range(10 ** 7)]
    dp[0] = 0

    for _ in range(N): 
        a, b = list(map(int, input().split()))
        for i in range(H+1):
            if dp[i] == INF: continue
            dp[i+a] = min(dp[i+a], dp[i] + b)
            
    return min(dp[H:])

print(solve())

### FIXED CODE ###

import numpy as np

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

A = []
B = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A = np.array(A)
B = np.array(B)

dp = np.full((H+1), np.inf)
dp[0] = 0

def solve():
    for i in range(1, H + 1):
        dp[i] = np.amin(dp[np.maximum(i - A , 0)] + B)
    return int(dp[H])

print(solve())
### BUGGY CODE ###

import math
import bisect
n, ticket = map(int, input().split())
L = list(map(int, input().split()))


if len(L) == 1:
    print(math.floor(L[0] / (2**ticket)))
else:
    L.sort()
    for _ in range(ticket):
        top = L.pop()
        top /= 2
        bisect.insort_left(L,top)
    print(sum(map(math.floor, L)))

### FIXED CODE ###

import math
import heapq
n, ticket = map(int, input().split())
L = list(map(int, input().split()))
h = []
for num in L:
    heapq.heappush(h, -num)
for _ in range(ticket):
    top = heapq.heappop(h)
    top /= 2
    heapq.heappush(h, top)
print(sum(map(lambda x: math.floor(-x), h)))
### BUGGY CODE ###

X=int(input())
res=[]
for b in range(1,1000):
  for p in range(2,1000):
    if b**p<=X :
      res.append(b**p)
print(res[-1])

### FIXED CODE ###

X=int(input())
res=0
for b in range(1,1000):
  for p in range(2,1000):
    if b**p<=X :
      res=max(res,b**p)
    else:
      break
print(res)
### BUGGY CODE ###

def binary_search(list,target):

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = int((left + right)/2)
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return result
	else:
		return result


if __name__=="__main__":
    n=int(input())
    s=list(input())
    rlist=[]
    glist=[]
    blist=[]
    ans=0
    if len(s)<=3:
        print(0)
        exit()
    for i in range(n):
        if s[i]=="R":
            rlist.append(i)
        elif s[i]=="G":
            glist.append(i)
        else:
            blist.append(i)
    rlist=tuple(rlist)
    blist=tuple(blist)
    glist=tuple(glist)
    if len(rlist)==0 or len(glist)==0 or len(blist)==0:
        print(0)
        exit()
    ans+=len(rlist)*len(glist)*len(blist)
    for i in glist:
        for j in blist:
            if i>j :
                if binary_search(rlist,2*i-j)!=-1:
                    ans-=1
                if binary_search(rlist,2*j-i)!=-1:
                    ans-=1
                if (i+j)/2 in rlist:
                    ans-=1
            else:
                if binary_search(rlist,2*i-j)!=-1:
                    ans-=1
                if binary_search(rlist,2*j-i)!=-1:
                    ans-=1
                if (i+j)/2 in rlist:
                    ans-=1

    print(ans)

### FIXED CODE ###

def binary_search(list,target):

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = int((left + right)/2)
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return result
	else:
		return result


if __name__=="__main__":
    n=int(input())
    s=list(input())
    rlist=[]
    glist=[]
    blist=[]
    ans=0
    if len(s)<=3:
        print(0)
        exit()
    for i in range(n):
        if s[i]=="R":
            rlist.append(i)
        elif s[i]=="G":
            glist.append(i)
        else:
            blist.append(i)
    if len(rlist)==0 or len(glist)==0 or len(blist)==0:
        print(0)
        exit()
    ans+=len(rlist)*len(glist)*len(blist)
    for i in range(n-2):
        for j in range(i+1,n-1):
            k=2*j-i
            if s[i]==s[j]:
                continue
            elif k>len(s)-1:
                continue
            else:
                if s[k]!=s[i] and s[k]!=s[j]:
                    ans-=1

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

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans += (a[i]%mod)*(a[j]%mod)
    ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
mod = 10**9+7
f = lambda x: int(x)%mod
a = list(map(f,input().split()))
kei = sum(a[1:])%mod
ans = 0
for i in range(n-1):
  ans += a[i]*(kei)
  ans %= mod
  kei -= a[i+1]
print(ans)
### BUGGY CODE ###

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

for i in range(m):
  b, c = map(int, input().split())
  x = [c]*b
  a = a+x
  a = sorted(a, reverse=True)
  a = a[:n]
  
print(sum(a))

### FIXED CODE ###

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

l = []
for i in range(m):
  l.append(list(map(int, input().split())))
  
l = sorted(l, reverse=True, key=lambda x: x[1])

b = []
for _ in range(n):
  b.append(l[0][1])
  l[0][0] -= 1
  if l[0][0] == 0:
    l.pop(0)
  if l == []:
    break

for i in range(len(b)):
  if a[i] < b[i]:
    a[i] = b[i]
  else:
    break
    
print(sum(a))
### BUGGY CODE ###

#input
N, P = map(int, input().split())
S = input()

# process
sl = [] # S[i:N]のリスト
for i in range(N):
    sl.append(int(S[i:N]))
sl.append(0)

ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if (sl[i]-sl[j])//10**(N-j)%P == 0:
            ans += 1

# output
print(ans)

### FIXED CODE ###

#input
N, P = map(int, input().split())
S = input()

# process
ans = 0
if P == 2 or P == 5:
    # 1桁目がPで割り切れる数をカウント
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1

else:
    cnt = [0]*P # S[i:N]%Pの結果をカウント
    num = 0
    tenPow = 1
    for i in reversed(range(N)):
        num = (num + int(S[i])*tenPow)%P
        tenPow = tenPow*10%P
        cnt[num] += 1

    ans += cnt[0]
    for c in cnt:
        ans += c*(c-1)//2 # c=0,1のときは0加算

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


from fractions import gcd

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

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        print(0)
        exit()

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:

            print(0)
            exit()
        else: num = format(a[i], 'b')[::-1].find('1')



g = b[0]

for i in range(1,n):

    g = (g*b[i]) // gcd(b[i],g)

if g > m: 
    print(0)
    exit()
    
ans = 1
g1 = g
while 1:
    g += 2*g1
    if g > m:
        break
    else:
        ans += 1

print(ans)

### FIXED CODE ###

from fractions import gcd
n, m = map(int, input().split())

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        ans = 0
        break

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:
            ans = 0
            break
        else:
            num = format(a[i], 'b')[::-1].find('1')


if ans != 0:
    g = b[0]
    for i in range(1,n):

        g = (g*b[i]) // gcd(b[i],g)

    if g > m: ans = 0
    else:
        ans = (1 + (m-g)//(2*g))

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

#abc167c
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

root = [1]
for i in range(10**100):
    next_num = a[root[-1]]
    root.append(next_num)

if k < n+1:
    print(root[k])
    exit()

loop_end = n 
loop_start = n-1
while(root[loop_start]!=root[loop_end]):
    loop_start -= 1
period = loop_end - loop_start
k%=period
while k < n:
    k += period
print(root[k])





### FIXED CODE ###

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
root = [1]
for i in range(2*n+1000):
    next_num = a[root[-1]]
    root.append(next_num)

if k < n+1:
    print(root[k])

else: 
    loop_end = n 
    loop_start = n-1
    while(root[loop_start]!=root[loop_end]):
        loop_start -= 1
    period = loop_end - loop_start
    k %= period
    while k < n:
        k += period
    print(root[k])
### BUGGY CODE ###

n, a, b = map(int, input().split())
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  y = 1
  p = mod - 2
  base = x
  while p != 0:
    if p % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    p //= 2
  return y
def doubling(N, M):
  y = 1
  base = N
  while M != 0:
    if M % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    M //= 2
  return y
S = [inved(i+1) for i in range(b)]
A = doubling(2, n)
A = (A - 1) % mod
proda, prodb = 1, 1
for i in range(b):
  proda *= ((n - i) * S[i]) % mod
  proda %= mod
  if i == a - 1:
    A -= proda
    A %= mod
print((A - proda) % mod)

### FIXED CODE ###

n, a, b = map(int, input().split())
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  a = extgcd(x, mod)
  return a % mod
def doubling(N, M):
  y = 1
  base = N
  while M != 0:
    if M % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    M //= 2
  return y
S = [inved(i+1) for i in range(b)]
A = doubling(2, n)
A = (A - 1) % mod
proda, prodb = 1, 1
for i in range(a):
  proda *= ((n - i) * S[i]) % mod
  proda %= mod
for i in range(b):
  prodb *= ((n - i) * S[i]) % mod
  prodb %= mod
print((A - proda - prodb) % mod)
### BUGGY CODE ###

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

res = 0
for i in range(N):
    res += A[i] - (i+1)
b = res // N

ans = 99999999
for bj in range(b-100, b+100):
    res = 0
    for i in range(N):
        res += abs(A[i] - (b+(i+1)))
    ans = min(ans, res)
print(ans)

### FIXED CODE ###

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

A_sorted = sorted([A[i] - (i+1) for i in range(N)])

if len(A) != 1:
    b = A_sorted[int((len(A)-1)/2)]
    b2 = A_sorted[int((len(A)-1)/2 + 1)]
    sad_1 = sum([abs(A_sorted[i] - b) for i in range(N)])
    sad_2 = sum([abs(A_sorted[i] - b2) for i in range(N)])
    print(min(sad_1, sad_2))
else:
    print('0')
### BUGGY CODE ###

import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)
#T = [1,17,13,14,13]
T = [12] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    #print(last)
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()
#print(Vmax)
Q = []
for i in range(2000):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(2000):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  #print(Vmax)
#print(T)
for t in T:
  print(t)

### FIXED CODE ###

import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)
T = [1] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    #print(last)
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()
Q = []
for i in range(10):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(10):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  #print(Vmax)
#print(T)
for t in T:
  print(t)
### BUGGY CODE ###

from itertools import combinations
n = int(input())-3
s = list(input())
ans = list(combinations(s,3))
#print(ans)
answer = []
for i in ans:
    if i not in answer:
        answer.append(i)
print(len(answer))

### FIXED CODE ###

n = input()
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k),b+1)
            if c == -1:
                continue
            ans += 1
print(ans)
### BUGGY CODE ###

lngN, lngC = map(int, input().split())

##  lstD[x][y]
##  1 オリジン の C × C グリッド として扱うために、[False] * lngC を第一行と第一列に追加
##  x -> y に塗り替えたときの違和感
##  x, y: 0 ... lngC - 1
lstD = []
lstD.append([False] * lngC)
for i in range(lngC):
    lstD.append([False] + list(map(int, input().split())))
##  lstC[i][j]
##  1 オリジン の N × N グリッド として扱うために、[False] * lngN を第一行と第一列に追加
##  マス(i, j)の初期色
##  1 から C までの値を取る
lstC = []
lstC.append([False] * lngN)
for i in range(lngN):
    lstC.append([False] + list(map(int, input().split())))
##  lstDSum[r][c]
##  剰余 r のグループを 色 c で塗るときの違和感の和
##　[c]を 1 オリジン として扱うために、[False] * lngC を第一行に追加
##  r: 0, 1, 2
##  c: 1 ... lngC
lstDSum = [False] * 3
for r in range(3):
    lstDSum[r] = [False] * (lngC + 1)
    for c in range(1, lngC + 1):
        lstDSum[r][c] = 0##違和感の初期値

for i in range(1, lngN + 1):
    for j in range(1, lngN + 1):
        for c in range(1, lngC + 1):
            r = (i + j) % 3##　剰余
            oriC = lstC[i][j]##初期色
            lstDSum[r][c] += lstD[oriC][c]

ans = float('inf')
for i in range(1, lngC + 1):
    for j in range(1, lngC + 1):
        if (i != j):
            for k in range(1, lngC + 1):
                if (i != k) and (j != k):
                    ans = min(ans, lstDSum[0][i] + lstDSum[1][j] + lstDSum[2][k])
print(ans)

##グリッドのマス(i, j)とすると,
##(i + j) % 3 の値によって, マスは 3 グループに分かれる (0, 1, 2)

##各グループの色分けの仕方は, itertools.permutations(c, 3) 通り
##内訳は次の通り
    ##(0)色 1 から C までの C 通りに色分け
    ##(1)色 1 から C までの (C - 1) 通りに色分け ((0) 分を除外)
    ##(2)色 1 から C までの (C - 2) 通りに色分け ((0, 1) 分を除外)

##各グループについて
##色 1 から C までの C 通りに色分けしたときの違和感の和を配列化
##lstDSum[グループ番号][色]
    ##グループ番号: 0, 1, 2
    ##色: 1 から C まで

##for 文で, 各グループを塗る色を全探索
##(グループ番号, 色) = (0, i), (1, j), (2, k)とするときの違和感の和
##lstDSum[0][i] + lstDSum[1][j] + lstDSum[2][k]
##これの最小値を取ればよい


### FIXED CODE ###

n, c = map(int, input().split())
arrD = list(list(map(int, input().split())) for i in range(c))
arrC = list(list(map(int, input().split())) for i in range(n))

##剰余r=0,1,2で、
    ##色の出現数を確認する -> いずれかの色に統一する
        ##どの色に統一するか全パターンを実施して、違和感を算出
##和を取る

arrCCnt = []
for r in range(3):
    d = dict()
    for i in range(1, c + 1):
        d[i] = 0
    arrCCnt += [d]

ret = 1000 * 500 * 500
for r in range(3):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if (i + j) % 3 == r:
                arrCCnt[r][arrC[i - 1][j - 1]] += 1##色の出現数を確認

##print(arrCCnt)
for c0 in range(1, c + 1):
    for c1 in range(1, c + 1):
        for c2 in range(1, c + 1):
            if c0 != c1 and c1 != c2 and c2 != c0:
                buf = 0
                ##print(c0,c1,c2)
                for i0 in range(1, c + 1):
                    ##print(i0)
                    buf += arrD[i0 - 1][c0 - 1] * arrCCnt[0][i0]##数
                for i1 in range(1, c + 1):
                    buf += arrD[i1 - 1][c1 - 1] * arrCCnt[1][i1]##数
                for i2 in range(1, c + 1):
                    buf += arrD[i2 - 1][c2 - 1] * arrCCnt[2][i2]##数
                ret = min(ret, buf)
print(ret)
### BUGGY CODE ###

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
sys.setrecursionlimit(10**6)
N=int(input())
A=[0]+list(map(int,input().split()))

E=[[] for i in range(N+1)]
for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[0]*(N+1)
USE[1]=1
ANS=[0]*(N+1)

import bisect
def dfs(x,DP):
    #print(x,DP)
    DP=list(DP)
    pos=bisect.bisect_left(DP,A[x])
    #print(pos)
    if pos<len(DP):
        DP[pos]=A[x]
    else:
        DP.append(A[x])
    #print(DP)

    ANS[x]=len(DP)

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            dfs(to,tuple(DP))

dfs(1,tuple())

print(*ANS[1:])

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
sys.setrecursionlimit(10**6)

N=int(input())
A=[0]+list(map(int,input().split()))

E=[[] for i in range(N+1)]
for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[0]*(N+1)
USE[1]=1
ANS=[0]*(N+1)
DP=[]

def dfs(x):
    pos=bisect.bisect_left(DP,A[x])
    
    if pos<len(DP):
        changepos=pos
        old=DP[pos]
        
        DP[pos]=A[x]
    else:
        changepos=pos
        old=-1
        
        DP.append(A[x])

    ANS[x]=len(DP)

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            dfs(to)

    if old==-1:
        DP.pop()
    else:
        DP[changepos]=old

dfs(1)

print(*ANS[1:])
### BUGGY CODE ###

A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  for i in range(B):
    x = i+1
    Y = int(A*x//B) - A*(x//B)
    if Y>Ymax:
      Ymax = Y
  print(Ymax)

### FIXED CODE ###

A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)