Harryxun/stf_run huggingface dataset:
"""
https://atcoder.jp/contests/abc136/tasks/abc136_c
"""

import numpy as np


def calc(N: int, values: np.ndarray) -> bool:
    # 要素が1つなら確定でOK
    if len(values) == 1:
        return True

    # 2つ以上下がっている部分があるとNG
    gradient = np.diff(values)
    if np.min(gradient) <= -2:
        return False

    # 要素が2つでならこの時点でOK確定
    if len(values) == 2:
        return True

    # 1つ下がってから、上がる前に、1つ下がるとNG
    gradient_without_zero = gradient[gradient != 0]
    gradient_without_last = gradient_without_zero[:-1]
    gradient_without_first = gradient_without_zero[1:]
    if np.min(gradient_without_first + gradient_without_last) <= -2:
        return False
    return True


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    values = load_input_as_int_array()
    result = calc(N, values)
    print("Yes" if result else "No")


main()


### FIXED CODE ###

"""
https://atcoder.jp/contests/abc136/tasks/abc136_c
"""

import numpy as np


def calc(N: int, values: np.ndarray) -> bool:
    # 要素が1つなら確定でOK
    if len(values) == 1:
        return True

    # 2つ以上下がっている部分があるとNG
    gradient = np.diff(values)
    if np.min(gradient) <= -2:
        return False

    # 要素が2つでならこの時点でOK確定
    if len(values) == 2:
        return True

    # 1つ下がってから、上がる前に、1つ下がるとNG
    gradient_without_zero = gradient[gradient != 0]
    if len(gradient_without_zero) == 0:
        return True
    gradient_without_last = gradient_without_zero[:-1]
    gradient_without_first = gradient_without_zero[1:]
    if np.min(gradient_without_first + gradient_without_last) <= -2:
        return False
    return True


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    values = load_input_as_int_array()
    result = calc(N, values)
    print("Yes" if result else "No")


main()
N = int(input())
t0, x0, y0 = 0, 0, 0
flag=True
for i in range(N):
    t1,x1,y1 = [int(j) for j in input().split()]
    dt = t1 - t0
    dist = abs(x0-x1) + abs(y0-y1)

    if dist > dt:
        print('No')
        flag=False

    elif (dist%2==0 and dt%2==0) or  (dist%2==1 and dt%2==1):
        t0, x0, y0 = t1, x1, y1

    else:
        print('No')
        flag=False

if flag:
    print('Yes')

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2. == 0:
    print('Even')
else:
    print('Odd')
a,b,c = map(int,input())
for i in range(b):
  if(a*i%b==c):
    print("YES")
    exit()
    
print("NO")


### FIXED CODE ###

a,b,c = map(int,input().rstrip().split())
ans = False
for i in range(b):
  if(a*i%b==c and not(ans)):
    print("YES")
    ans = True
    
if(not(ans)):
  print("NO")
# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
c = list(range(1, a + 1))
d = []
for i, j in zip(b, c):
    d.append(i-j)

d.sort()
e = d[a // 2]
f = 0
for i in range(5):
    f += abs(d[i] - e)
print(f)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
c = list(range(1, a + 1))

d = []
for i, j in zip(b, c):
    d.append(i-j)
d.sort()
e = d[a // 2]
f = 0
for i in range(a):
    f += abs(d[i]-e)

print(f)
n, k = map(int, input().split())
A = list(map(int, input().split()))

Town = []
#まだ訪れていない町は-1
rec = [-1] * (n+1)
idx = 1
#周期までループをまわす
while (rec[idx] == -1):
    rec[idx] = len(Town)
    Town.append(idx)
    idx = A[idx-1]

#周期前
Exce = Town.index(idx)
#周期内
Cycl = len(Town) - Exce

if Cycl >= k:
    print(Town[k])
else:
    k -= Exce
    k %= Cycl
    print(Town[Exce+k])

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))

Town = []
#まだ訪れていない町は-1
rec = [-1] * (n+1)
idx = 1
#周期までループをまわす
while (rec[idx] == -1):
    rec[idx] = len(Town)
    Town.append(idx)
    idx = A[idx-1]

#周期前
Exce = rec[idx]
#周期内
Cycl = len(Town) - Exce

if Exce > k:
    print(Town[k])
else:
    Warp = (k - Exce) % Cycl
    print(Town[Exce+Warp])
N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * array{N}
i = 0
before = 0
for i in array:
    j = 2*i
    if i == before:
        array[i] == False
    while j < array[N]:
        array[j] == False
        j += i
    before = i
for i in array:
    if array[i] == True:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * (10**6 + 1)
i = 0
before = 0
for i in array:
    if a[i] == True:
        j = 2*i
        if i == before:
            a[i] = False
        while j <= array[N-1]:
            a[j] = False
            j += i
        before = i
for i in array:
    if a[i] == True:
        ans += 1
print(ans)
N, K = list(map(int, input().split(" ")))

d = dict()

for i in range(N):
    a, b = list(map(int, input().split(" ")))
    if a in d:
        d[a] = d[a] + b
    else:
        d[a] = b
    
ans_sum = 0

for key in sorted(d.keys()):
    ans_sum += d[key]
    if (ans_sum) >= K:
        print(k)
        break

### FIXED CODE ###

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

nums = {}

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    
    if a in nums:
        nums[a] += b
    else :
        nums[a] = b
        
acc = 0
for key in sorted(nums.keys()):
    acc += nums[key]
    if acc >= K:
        print(key)
        break
N=int(raw_input())
max=(-1)*(10**9)
x1=input()
min=x1

for i in range(n-1):
  x=int(raw_input())

  if max < x-min:
    max=x-min
  if min>x:
    min=x
print max

### FIXED CODE ###

N=int(raw_input())
max=(-1)*(10**9)
x1=input()
min=x1

for i in range(N-1):
  x=int(raw_input())

  if max < x-min:
    max=x-min
  if min>x:
    min=x
print max
a,b,c,d=map(int,input().split())
e=c-a
f=d-b
g=c-f
h=d+e
i=g-e
j=h-f
print(g h i j)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
e=c-a
f=d-b
g=c-f
h=d+e
i=g-e
j=h-f
print(g)
print(h)
print(i)
print(j)
rangeNum = int(input())
n = list(map(int, input().split()))

ans = True
for ni in range(rangeNum+1):
    if n[ni] % 2 == 0:
        if n[ni] % 3 == 0:
            break
        elif n[ni] % 5 == 0:
            break
        else:
            ans = False
    else:
        ans = False
if ans==True:
    print("APPROVED")
else:
    print("DENIED")

### FIXED CODE ###

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

for ni in range(rangeNum):
    if n[ni]%2 == 0:
        if n[ni]%3 == 0:
            continue
        elif n[ni]%5 == 0:
            continue
        else:
            print("DENIED")
            exit()
    else:
        continue
print("APPROVED")
n, m = list(map(int, input().split()))
city_list = [[] for i in range(n)]

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list[pm-1].append(ym)

for i in range(n):
    city_list_copied[i].sort()
    for j in range(len(city_list[i])):
        cindex = sum(x <= city_list[i][j] for x in city_list[i])
        print("{:0=6}{:0=6}".format(i+1, cindex))


### FIXED CODE ###

n, m = list(map(int, input().split()))
city_list = []

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list.append([i,pm,ym])

city_count = {}
city = {}

for i,p,y in sorted(city_list, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 1
    else:
        city_count[p] += 1
    city[i,p] = city_count[p]

for i,p,y in city_list:
    print("{:0=6}{:0=6}".format(p, city[i,p]))
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a


def cul(n,a):
    l=len(a)
    b=[a[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
import math
p=10
N=int(input())
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()
        
M=a[0]
for i in range(1,p):
    M=gcd(M,a[i])

ans=0
for i in range( math.ceil((M+1)**0.5) ):
    if M%i==0:
        
        for j in range(p,N):
            if a[i]%i!=0: break
            elif i==N-1 and i>ans: ans=i
        x=M//i
        for j in range(p,N):
            if a[i]%x!=0: break
            elif i==N-1 and x>ans: ans=i

r=a[N-1]
for i in range(N-1,p-1,-1):
    r=gcd(r,a[i])
if r>ans:
    for i in range(p):
        s=gcd(cul(i,a[:p]),r)
        if s>ans: ans=s

print(ans)


### FIXED CODE ###

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a

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

l=[0]*N
l[0]=a[0]

for i in range(1,N):
    l[i]=egcd(l[i-1],a[i])

r=[0]*N
r[N-1]=a[N-1]
for i in range(N-2,-1,-1):
    r[i]=egcd(r[i+1],a[i])

ans=0
for i in range(N):
    if i==0: tmp=r[1]
    elif i==N-1: tmp=l[N-2]
    else: tmp=egcd(l[i-1],r[i+1])
    ans=max(tmp,ans)

print(ans)
print(1-int(input())

### FIXED CODE ###

n=int(input())
print(1-n)
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit(1)
print('No')


### FIXED CODE ###

N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit()
print('No')
N, M = map(int, input().split())    
                                    
x = []                              
for i in range(M):                  
    l,r = map(int, input().split()) 
    x.append([l, r])                
                                    
                                    
cand = list(range(1, N+1))          
                                    
for i, p in enumerate(x):           
    l,r = p                         
    if cand[0] < l:                 
        del cand[:(l - cand[0])]    
    if cand[-1] > r:                
        del cand[(r-cand[0]+1):]    
                                    
print(len(cand))                    


### FIXED CODE ###

N, M = map(int, input().split())        
                                        
x = []                                  
for i in range(M):                      
    l,r = map(int, input().split())     
    x.append([l, r])                    
                                        
                                        
cand = list(range(1, N+1))              
                                        
for i, p in enumerate(x):               
    l,r = p                             
    if (r < cand[0]) or (l > cand[-1]): 
        del cand[0:]                    
        break                           
                                        
    if cand[0] < l:                     
        del cand[:(l - cand[0])]        
    if cand[-1] > r:                    
        del cand[(r-cand[0]+1):]        
                                        
print(len(cand))
s=input()
if(s[0]==s[1]==s[2])print("Yes")
else print("No")

### FIXED CODE ###

s=input()
if s[0]==s[1] and s[1]==s[2] :print("No")
else: print("Yes")
s=input()
t=input()
ans=0
ti=0
si=0
f=0
for ti in range(len(t)):
  while t[ti]!=s[si]:
    ans+=1
    si+=1
    si=si%len(s)
    f+=1
    if f>len(s)+2:
      print("-1")
      exit()
  si+=1
  ti+=1
  ans+=1
  f=0
print(ans)

### FIXED CODE ###

from collections import defaultdict
import bisect

d=defaultdict(list)

s=input()
t=input()

ns=len(s)
nt=len(t)

for i in range(ns):
  d[s[i]].append(i)

for k,v in d.items():
  d[k].append(ns)
#print(d)

ans=0
cnt=-1

for i in range(nt):
  tt=d[t[i]]
#  print(t[i],tt,ans,cnt)
  if tt==[]:
    print(-1)
    exit(0)
  else:
    a=bisect.bisect_right(tt,cnt)
#    print("ind",a)
    if tt[a]==ns:
      ans+=ns+tt[0]-cnt
      cnt=tt[0]
    else:
      ans+=tt[a]-cnt
      cnt=tt[a]
      
print(ans)
N=int(input)
quotient=N//1000
for i in range(quotient+1):
    N=N-1000
    if N<=0:
        break
print(abs(N))

### FIXED CODE ###

N=int(input())
quotient=N//1000
for i in range(quotient+1):
    N=N-1000
    if N<=0:
        break
print(abs(N))
def main():
    n,x=map(int,input().split())
    a,b=n-x,x
    if(a<b):
       a,b=b,a
    path_length = calc_path(a,b,n)
    print(path_length)

def  calc_path(a1,b1,c1):
    q , mod=divmod(a1,b1)
    count=0
    if mod==0:
         c2=c1+b1*(q+1)
         return c2
    else:
        count=count+1
        c2=c1+b1*(q+1)
        a2=a1-b1*q
        b2=b1
        if(a2<b2):
           a2,b2=b2,a2
        return calc_path(a2,b2,c2)
if __name__=='__main__':
  main()


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=sum(l[0::2])
print(ans)
import sys

S = input()

s = []
for i in S:
    s.append(int(i))
count = 0

if (len(s) < 4 ):
    print(0)
    sys.exit()

for i in range(len(s)):
    j = i
    target = s[i]
    for k in range(len(s)-i):
        j += 1
        if(j >= len(s)):
            break
        target = target*10
        target += s[j]
        if ( target%2019 == 0):
            count += 1
print(count)


### FIXED CODE ###

s, w = map(int, input().split())

if (s > w):
    print("safe")
else:
    print("unsafe")
def main():
    from sys import stdin
    #input = stdin.readline
    import numpy as np
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    ab_d = {(a, b) for a, b in ab}

    ans = [set() for _ in range(9)]
    for a, b in ab:
        temp = np.full((5, 5), None, dtype=np.int64)
        for i in range(max(0, 3-a), min(5, h-a+3)):
            for j in range(max(0, 3-b), min(5, w-b+3)):
                if (a+i-2, b+j-2) in ab_d:
                    temp[i, j] = 1
                else:
                    temp[i, j] = 0
        # print(temp)
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None), dtype=np.int64):
            if np.all(temp[:, 1] == np.full((1, 5), None), dtype=np.int64):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None), dtype=np.int64):
            if np.all(temp[:, 3] == np.full((1, 5), None), dtype=np.int64):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None), dtype=np.int64):
            if np.all(temp[1, :] == np.full(5, None), dtype=np.int64):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None), dtype=np.int64):
            if np.all(temp[3, :] == np.full(5, None), dtype=np.int64):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        # print(new_temp)
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()


### FIXED CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
import sys 
sys.setrecursionlimit(10**6)
def dp(n,cache,height):
  if n<0:
    return float('inf')
  elif n==0:
    return 0
  elif n==1:
    return abs(height[1]-height[0])
  elif n in cache :
    return cache[n]
  else:
    cache[n]= min(dp(n-1,cahche,height)+abs(height[n]-height[n-1]),dp(n-2,cahche,height)+abs(height[n]-height[n-2]))
	return cache[n]

### FIXED CODE ###

import sys 
sys.setrecursionlimit(10**6)
def dp(n,cache,height):
  if n<0:
    return float('inf')
  elif n==0:
    return 0
  elif n==1:
    return abs(height[1]-height[0])
  elif n in cache :
    return cache[n]
  else:
    cache[n]= min(dp(n-1,cache,height)+abs(height[n]-height[n-1]),dp(n-2,cache,height)+abs(height[n]-height[n-2]))
    return cache[n]
n=int(input())
h=list(map(int,input().split()))
print(dp(n-1,dict(),h))
S = str(input())
ans = {}
ans.add(S[0])
ans.add(S[1])
ans.add(S[2])
if len(ans) == 3:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = str(input())
if not(S[0] == S[1]) and not(S[1] == S[2]) and not(S[0] == S[2]):
    print("Yes")
else:
    print("No")
s,t = map(input().split())
print(t+s)


### FIXED CODE ###

s,t = input().split()
print(t+s)
n = int(input())
b = list(map(int, input().split()))

#print(n)
#print(b)

score = b[0]+b[n-2]
#print(b[0],b[n-2])

for i in range(0,n-1):
	score = score + min(b[i],b[i+1])
#	print(min(b[i],b[i+1]))
print(score)

### FIXED CODE ###

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

#print(n)
#print(b)

score = b[0]+b[n-2]
#print(b[0],b[n-2])

for i in range(0,n-2):
	score = score + min(b[i],b[i+1])
#	print(min(b[i],b[i+1]))
print(score)
a, b = map(int, input().split()
if a == b:
  print("Draw")
elif a == 1 or a > b >= 2:
    print("Alice")
elif b == 1 or b > a >= 2:
    print("Bob")

### FIXED CODE ###

a, b = map(int, input().split())
if a == 1:
  a = 14
if b == 1:
  b = 14
if a > b:
  print("Alice")
elif a < b:
  print("Bob")
else:
  print("Draw")
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N)))+2)):
    tmp=i**N
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

### FIXED CODE ###

import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
N = int(input())

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

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

Tlist =[]

for n in range(N):
	Tlist.append(T - H[n]*0.006)


t = Tlist[0]
m = None

for n in range(N):
	if abs(t-A) > abs(Tlist[n]-A):
		t = Tlist[n]
		m = n

M = m + 1
print(M)



### FIXED CODE ###

N = int(input())

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

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

Tlist =[]

for n in range(N):
	Tlist.append(T - H[n]*0.006)

t = Tlist[0]
m = 0

for n in range(N):
	if abs(t-A) > abs(Tlist[n]-A):
		t = Tlist[n]
		m = n

M = m + 1
print(M)
import math
a,b=map(int,input())
print(math.ceil((a+b)/2))

### FIXED CODE ###

print((sum(map(int,input().split()))+1)//2)
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append((b-1,c))
    G[b-1].append((a-1,c))
q,k=map(int,input().split())
k=k-1
stack=[k]
dis=[-1]*n
dis[k]=0
while len(stack)!=[]:
    now=stack.pop()
    d=dis[now]
    for i in G[now]:
        if dis[i[0]]==-1:
            dis[i[0]]=d+i[1]
            stack.append(i[0])
for i in range(q):
    x,y=map(int,input().split())
    x=x-1
    y=y-1
    print(dis[x]+dis[y])



### FIXED CODE ###

n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append((b-1,c))
    G[b-1].append((a-1,c))
q,k=map(int,input().split())
k=k-1
stack=[k]
dis=[-1]*n
dis[k]=0
while len(stack)>0:
    now=stack.pop()
    d=dis[now]
    for i in G[now]:
        if dis[i[0]]==-1:
            dis[i[0]]=d+i[1]
            stack.append(i[0])
for i in range(q):
    x,y=map(int,input().split())
    x=x-1
    y=y-1
    print(dis[x]+dis[y])
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
start = 0
end = max(A)
while abs(start - end) > 1:
    ans = abs(end + start) // 2
    cnt = 0
    for i in range(N):
        cnt += math.floor(A[i]/ans - 0.001)
        if cnt > K: #ダメだったら
            start = ans
            break
    else: #オッケーだったら
        end = ans
        continue

cnt = 0
for i in range(N):
    cnt += math.floor(A[i] / ans - 0.001)

if cnt > K:  # ダメだったら
       print(ans + 1)
else:  # オッケーだったら
    print(ans)


### FIXED CODE ###

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
start = 0
end = max(A)
ans = abs(end + start) // 2 + 1
while abs(start - end) > 1:
    ans = abs(end + start) // 2
    cnt = 0
    for i in range(N):
        cnt += math.floor(A[i]/ans - 0.0000000001)
        if cnt > K: #ダメだったら
            start = ans
            break
    else: #オッケーだったら
        end = ans
        continue

cnt = 0
for i in range(N):
    cnt += math.floor((A[i] / ans) - 0.000000000001)

if cnt > K:  # ダメだったら
    print(ans + 1)
else:  # オッケーだったら
    print(ans)
# -*- config: utg-8 -*-

n = int(input())
s = [input() for i in range(n)]

sort_list = []

for i in s:
	str_sort_list = sorted(i)
	new_str = ''.join(str_sort_list)
	sort_list.append(new_str)

count = 0
for i in sort_list:
  hoge = sort_list.pop(0)
  chohuku_count = sort_list.count(hoge)
  sort_list.remove(hoge)
  
  sum = 0
  for i in range(chohuku_count+1):
    sum += i
  count += sum
  

print(count)

### FIXED CODE ###

import collections
N = (int(input()))

ans = 0
counter_list = []

for _ in range(N):
    s = input()
    counter_list.append("".join(sorted(s)))

ans = 0
wordcount = {}
for word in counter_list:
    if word in wordcount:
        wordcount[word] += 1
        ans += (wordcount[word])
    else:
        wordcount[word] = 0

print(ans)
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))


### FIXED CODE ###

n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))
S = input()

for i in range(3):
	if S[i] == "7":
		print("Yes")
		exit(1)

print("No")

### FIXED CODE ###

S = input()

ans = 0
for i in range(3):
	if S[i] == "7":
		print("Yes")
		ans = 1
		break

if ans == 0:
	print("No")
print(int(input())+int(input())//2)

### FIXED CODE ###

n,m=map(int,input().split())
print(n+m//2)
import sys
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
C=list(set(L))
x=0
for i in range(len(C)):
  a = L.count(C[i])
  x += int(a*(a-1)/2)  
for K in range(N):
  print(x-L.count(L[K])+1)

### FIXED CODE ###

a=int(input())
print((a/3)**3)
import sys

# a not yum, bc yum
a = int(sys.argv[1])
b = int(sys.argv[2])
c = int(sys.argv[3])

if (a+b) >= c:
    return(b+c)
else:
    return(a+b+1+b)


### FIXED CODE ###

import sys


if __name__ == '__main__':
    # a not yum, bc yum
    a, b, c = [int(i) for i in input().split()]

    if (a+b) >= c:
        print(b+c)
    else:
        print(a+b+1+b)