peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    if i + 1 == p[i]:
        if i != n - 1:
            p[i], p[i + 1] = p[i + 1], p[i]
        else:
            p[i], p[i - 1] = p[i - 1], p[i]
        ans += 1
print(ans)
# Judge status: Wrong Answer
A,B,C,D = list(map(int,input().split()))
count = 0

for i in range(A,B):
    x = i+1
    c = (i+1)%C
    d = (i+1)%D
    if A <= x:
        if c==0 or d==0:
            count += 1

print(B-A-count)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("Yes" if c-a-b > 0 and a*b*4 < (c-a-b)**2 else "No")
# Judge status: Accepted
from sys import stdin
inp = lambda : stdin.readline().strip()

a,b,c,d = [int(x) for x in inp().split()]

print(max(a*c,b*d,a*d,b*c))
# Judge status: Wrong Answer
rev_s = "".join(sorted(input(),reverse=True))
rev_t = "".join(sorted(input(),reverse=True))
# print(rev_s)
# print(rev_t)
if rev_t > rev_s:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
M = input().split()
i = 0
a = ''
b = ''
c = [0,0]
for i in range(int(M[0])):
    a += str(M[1])
for i in range(int(M[1])):
    b += str(M[0])
c[0] = int(a)
c[1] = int(b)  
c.sort()
print(c[0])
# Judge status: Accepted
import math
n,k = map(int,input().split())
a_list = list(map(int,input().split()))

min_num = 1
max_num = 10**9+1
while True:
    #print(min_num)
    x = int((min_num+max_num)/2)
    if sum([math.ceil(a/x)-1 for a in a_list])>k:
        min_num = x
    else:
        max_num = x
    if max_num-min_num<=1:
        break
    #print(x)
if sum([math.ceil(a/min_num)-1 for a in a_list])>k:
    print(min_num+1)
else:
    print(min_num)
# Judge status: Wrong Answer
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
rx = x
for i in range(N):
  if a[i] > rx:
    print(c)
    exit()
  c += 1
  rx -= a[i]
print(N)
# Judge status: Accepted
N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N-i+1):
        if(Y==i*10000+j*5000+(N-i-j)*1000):
            print('{i} {j} {k}'.format(i=i,j=j,k=N-i-j))
            exit()
print('-1 -1 -1')
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
k = 0
flg = False
for ai in a:
  if ai == k + 1:
    k += 1
  else:
    flg = True
if k == 0 and flg:
  print(-1)
else:
  print(n - k)
# Judge status: Accepted
l, r, d=map(int,input().split())
cnt=0
for i in range(l, r+1):
  if i%d==0:
    cnt+=1
print(cnt)
# Judge status: Accepted
A, B, C, D = list(map(int, input().split()))

a = A // D
b = C // B
N = max(a, b) + 1
for i in range(N):
    if C > 0:
        C -= B
        if C <= 0:
            break
    if A > 0:
        A -= D
        if A <= 0:
            break

ans = "No"
if A > C:
    ans = "Yes"

print(ans)
# Judge status: Wrong Answer
xx, kk, dd= list(map(int,input().split()))

xx = abs(xx)

aa_double = (xx/dd)

if aa_double >= kk:
    ans = xx - dd*kk
else:
    aa_int = int(aa_double)
    remaining_move = kk - aa_int
    if (aa_int % 2) == 0:
        ans = xx - dd*aa_int
    else:
        ans = xx - dd*(aa_int+1)

print(abs(ans))
# Judge status: Accepted
N=int(input())
CSF=[list(map(int,input().split())) for _ in range(1,N)]

for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        while True:
            if (ans>=s_) and (ans%f_==0):
                ans+=c_
                break
            ans+=1
    print(ans)
print(0)
# Judge status: Accepted
import math
N,D = map(int, input().split())
zone = 2*D+1
print(math.ceil(N/zone))
# Judge status: Accepted
import math
a, b = input().split()
x = math.sqrt(int(a+b))
print('Yes' if x.is_integer() else 'No')
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
m = min(4*q, 2*h, s)
if n % 2:
    print(min(d * (n//2) + m, m * n))
else:
    print(min(d * (n//2), m * n))
# Judge status: Accepted
import itertools
def modelAnswer(X:int):
   lis = [i for i in range(100,106)]
   C = X//100
   for p in itertools.combinations_with_replacement(lis,C):
      if(sum(p)==X):
         return 1
   return 0

def main():
   X = int(input())
   print(modelAnswer(X))

if __name__ == '__main__':
   main()
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(A))
# Judge status: Accepted
N,*A=map(int, open(0).read().split())
acc=A[0]&1
ans=A[0]//2
for a in A[1:]:
    b=min(acc,a)
    ans+=b
    a-=b
    ans+=a//2
    acc=a&1
ans+=acc//2
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
cnt = [0]*3

for x in A:
  x %= 4
  if x == 0:
    cnt[2] += 1
  elif x == 2:
    cnt[1] += 1
  else:
    cnt[0] += 1

if cnt[0] <= cnt[2] or ( N == 3 and cnt[0] == 2 and cnt[2] == 1):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N, M = map(int,input().split())

if M >= N:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)

A_idx = np.argsort(A)+1
print(*A_idx)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
d= int(input())

print(b*c+(a-b)*d)
# Judge status: Wrong Answer
S = input()
F = int(S[:2])
L = int(S[2:])

if (F >= 13 and L >= 13) or (F == 0 and L == 0):
    print('NA')
elif F >= 13 or F == 0:
    print('YYMM')
elif L >= 13 or L == 0:
    print('MMYY')
else:
    print('AMBIGUOUS')
# Judge status: Wrong Answer
def solve():
    D, N = [int(i) for i in input().split()]
    print(f"{N}{'00' * D}")

if __name__ == "__main__":
    solve()
# Judge status: Accepted
# 129 B-Balance
N = int(input())
W =list(map(int, input().split()))
ans = 10000
for i in range(1,N):
    if abs(sum(W[0:i])-sum(W[i:N])) < ans:
        ans = abs(sum(W[0:i])-sum(W[i:N]))
print(ans)
# Judge status: Accepted
def solve(n, s, t):
    count = 0
    for i in range(n):
        if s[i:] == t[:n - i]:
            return 2 * n - (n - i)
    return 2 * n

_n = int(input())
_s = input()
_t = input()
print(solve(_n, _s, _t))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())

one = int(a + b)
two = int(one/2)
ans = int(two*h)

print (ans)
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while True:
    for i in range(BC[index][0]):
        if pt < N:
            A[pt] = max(A[pt],card)
        else:
            break
        pt += 1

    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))
# Judge status: Accepted
from functools import reduce
from fractions import gcd
N = int(input())
l = list(map(int, input().split()))
print(reduce(gcd,l))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ans = [-1] * N
for i,a in enumerate(A):
  ans[a-1] = (i+1)
  
print(*A)
# Judge status: Accepted
winput = [i for i in input().split()]
wlist = []
for i in range(3) :
    if not winput[i] in wlist :
        wlist.append(winput[i])
print(len(wlist))
# Judge status: Accepted
N=int(input())
ans=0
if N%2==0:
    f=1
    while N>=2*5**f:
        ans+=N//(2*5**f)
        f+=1
print(ans)
# Judge status: Accepted
def main():
    A,B,C=map(int,input().split())
    K=int(input()) 
    for _ in range(K):
        if not A<B: 
            B *=2
            continue
        if not B < C:
            C *=2
            continue
        break
    if A<B<C:
        print("Yes")
    else:
        print("No")

main()
# Judge status: Accepted
x=int(input())

if x<=6:
    print("1")
    exit()
elif x<=11:
    print("2")
    exit()
else:
    ans=((x//11)*2)
    if x%11==0:
        print(ans)  
    elif x%11<=6:
        print(ans+1)
    else:
        print(ans+2)
# Judge status: Accepted
def main():
  n,k=map(int,input().split())
  s=input()
  
  # first score
  ans=0
  x=s[0]
  for i in range(1,n):
    if x==s[i]:
      ans+=1
    else:
      x=s[i] 
  print(min(ans+2*k,n-1))

  
if __name__=='__main__':
  main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
res = 10**9
for i in range(1,N):
    left = sum(A[0:i])
    right = sum(A[i:N])
    if abs(right-left) < res:
        res = abs(right-left)
print(res)
# Judge status: Accepted
n,k,q = map(int, input().split())
Points = [k-q]*n

for i in range(q):
    a = int(input())-1
    Points[a] += 1

for p in Points:
    if p > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
N=int(input())
A=[int(input()) for i in range(N)]
print(A)
M=max(A)
sort_A=sorted(A, reverse=True)

for j in range(N):
    if A[j]==M:
        if A.count(M)==1:
            print(sort_A[1])
        else:
            print(M)
    else:
        print(M)
# Judge status: Accepted
N,K = map(int,input().split())
A = []
c = 0

for i in range(N+2):
    A.append(i*(i-1)//2)

for i in range(K,N+2):
    c += A[N+1]-A[N-i+1]-A[i]+1
    
print(c%(10**9+7))
# Judge status: Accepted
s = list(input())
s = list(map(int,s))
k = int(input())
for _ in s[:k]:
    if _ != 1:
        print(_)
        exit(0)
print(1)
# Judge status: Wrong Answer
import math

a, b, c = map(int, input().split())

aa = math.sqrt(a)
bb = math.sqrt(b)
ab = aa*bb

if ab < (c-a-b)/2:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = list(input())
l = len(s)
ans = "NO"
for i in range(l):
    for j in range(1, l):
        t = s.copy()
        del t[i:j]
        if t == ["k","e","y","e","n","c","e"]:
            ans = "YES"
            break
print(ans)
# Judge status: Accepted
n=int(input())
t,x,y=[0],[0],[0]
for i in range(n):
    T,X,Y=map(int,input().split())
    t.append(T)
    x.append(X)
    y.append(Y)
#print(t,x,y)
for i in range(n):
    time=t[i+1]-t[i]
    dx=abs(x[i+1]-x[i])
    dy=abs(y[i+1]-y[i])

    if time<dx+dy or (time+dx+dy)%2!=0:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
import math

a = [float(input()) for _ in range(5)]
a_ceil = [math.ceil(0.1*a[n])*10 for n in range(len(a))]
a_p10 = [a[n] % 10 for n in range(len(a))]

for i in range(len(a)):
    if a_p10[i] == 0:
        a_p10[i] += 10
last = a_p10.index(min(a_p10))
total = int(sum(a_ceil) - a_ceil[last] + a[last])
print(total)
# Judge status: Accepted
import sys
S=input()
T=input()
s=[]
t=[]
for i in S:
    s.append(i)
for i in T:
    t.append(i)
count=0
for i in range(len(s)):
    s_last=s[-1]
    s.insert(0,s_last)
    del s[-1]
    #print(s)
    #print(t)
    for p in range(len(s)):
        if s[p]==t[p]:
            count+=1
    #print(count)
    if count==len(s):
        print("Yes")
        sys.exit()
    else:
        count=0
print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())
a -= c
print(a//(b+c))
# Judge status: Accepted
s=input()
abst=[]
for i in range((len(s)-2)):
    t=s[i]+s[i+1]+s[i+2]
    ti=int(t)
    abst.append(abs(753-ti))
ans=sorted(abst)
print(ans[0])
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))

cnt = 0
mini = float('inf')

P = max(X)

for i in range(1, P):
    for j in range(len(X)):
        cnt += (X[j] - i)**2
    if cnt < mini:
        mini = cnt
    cnt = 0

print(mini)
# Judge status: Wrong Answer
N,M = map(int,input().split(" "))
students = [tuple(map(int,input().split(" "))) for _ in range(N)]
checkpoints = [tuple(map(int,input().split(" "))) for _ in range(M)]
Ans = [(0,100)]*N

# print(students)
# print(checkpoints)

i = 0
for n in students:
    j=1
    for m in checkpoints:
        dist = abs(n[0]-m[0])+abs(n[1]-m[1])
        if dist<Ans[i][1]:
            Ans[i] = (j,dist)
        j+=1
        
    i+=1
    
# print(Ans)

for ans in Ans:
    print(ans[0])
# Judge status: Wrong Answer
s = input()
print("A"+s[10]+"C")
# Judge status: Wrong Answer
A,B=map(int,input().split())

if (A-1)<=B:
	print(A+B)
elif (B-1)>=A:
	print(B+B)
else:
	 print(A+(A-1))
# Judge status: Wrong Answer
a,b,c = (int(x) for x in input().split())
half_pack = int((a+b+c)/2)
if(a == half_pack) and ((b+c) == half_pack):
    print("YES")
elif(b == half_pack) and ((a+c) == half_pack):
    print("YES")
elif(c == half_pack) and ((b+a) == half_pack):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
a,b = map(int,input().split())
c = input()
d = c[0:b]
e = c[b:a]
print(str.lower(d) + e)
# Judge status: Accepted
s=input()=='';b=[0]
for i in input():t=i=='.';b+=[b[-1]+1-t*2];s+=t
print(min([i+s for i in b]))
# Judge status: Wrong Answer
n = int(input())

sum = 0
for i in range(n):
  if i % 3 != 0 and i % 5 !=0:
    sum += i
print(sum)
# Judge status: Accepted
a,b,c,d = map(int,input().split(" "))

if a <= c < b:
    print(min(b,d)-c)
elif c <= a < d:
    print(min(d,b)-a)
else:
    print(0)
# Judge status: Wrong Answer
def main2():
    N, K = map(int, input().split())
    ins_num = [0 for i in range(10**5 + 1)]

    for i in range(N):
        a, b = map(int, input().split())
        ins_num[a] += b

    ins_count = 0

    for i in range(1, N + 1):
        ins_count += ins_num[i]

        if ins_count >= K:
            print(i)
            exit()

if __name__ == "__main__":
    main2()
# Judge status: Accepted
n = int(input())
print(int(n**0.5)**2)
# Judge status: Accepted
n = int(input())
s = list(input())
x = 0
Mx = 0
for i in range(len(s)):
  if s[i] == "D": x -= 1
  else: x += 1
  Mx = max(Mx, x)
print(Mx)
# Judge status: Accepted
s = input()
k = int(input())
ans = ""
for i in s:
    if k >= (123 - ord(i)) % 26:
        k -= (123 - ord(i)) % 26
        ans += "a"
    else:
        ans += i
print(ans[:-1] + chr((ord(ans[-1]) - 97 + k) % 26 + 97))
# Judge status: Accepted
n,x,y = map(int, input().split())

dis = [0]*n

for i in range(n):
    for j in range(i+1, n):
        kyori = min(j-i, abs(x - (i+1)) + 1 + abs(y - (j+1)))
        dis[kyori] += 1

for k in range(1, n):
    print(dis[k])
# Judge status: Accepted
n=int(input())
ans=n
for i in range(n+1):
    buf=0
    j=n-i
    while i>0:
        i0=i%6
        i=(i-i0)//6
        buf+=i0
    while j>0:
        j0=j%9
        j=(j-j0)//9
        buf+=j0
    if buf<ans:
        ans=buf
print(ans)
# Judge status: Accepted
N, K = (int(x) for x in input().split())

D = 0

while N > 0:
    N //= K
    D += 1

print(D)
# Judge status: Wrong Answer
N = int(input())
alst = list(map(int, input().split()))

x = 'increase' or 'decrease'
cnt = 1
for i in range(1, N):
    if alst[i] - alst[i - 1] > 0:
        tmp = 'increase'
    else:
        tmp = 'decrease'

    if tmp != x:
        cnt += 1
    x = tmp

print(cnt)
# Judge status: Accepted
H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)

DP = [0]*(H+A_max)
for i in range(1, H+A_max):
    dp = float('inf')
    for a, b in zip(A,B):
        if i-a>=0:
            dp = min(dp, DP[i-a] + b)
    DP[i] = dp
print(min(DP[H:]))
# Judge status: Wrong Answer
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
S,T = [S() for _ in range(2)]
num = 0
for i in range(len(S)-len(T)):
    str = S[i:i+len(T)]
    count = 0
    for j in range(len(T)):
        if str[j]==T[j]:
            count += 1
        num = max(num,count)
print(len(T)-num)
# Judge status: Accepted
N,K = map(int,input().split()) #KはN以下
P = list(map(int,input().split()))
for i,p in enumerate(P):
    P[i] = (p+1)/2
q = [0]
for p in P:
    q.append(q[-1]+p)
s,e = 0,K
ans = q[K]-q[0]
while e<len(q):
    ans = max(ans,q[e]-q[s])
    s += 1
    e += 1
print(ans)
# Judge status: Wrong Answer
t = int(input())
n = [ int(i) for i in input().split(" ") ]
temp_n = n
ans = 0
cur = 0

for i in range(0, len(n)-1):
  if i == 0:
    if n[0] == 1:
      cur = 1
    else:
      ans += 1
  else:
    if cur+1 == n[i]:
      cur += 1
    else:
      ans += 1

if ans == len(n)-1 and n[-1] != 1:
  print(str(-1))
else:
  print(ans)
# Judge status: Accepted
from fractions import gcd
n, x, *a = list(map(int, open(0).read().split()))
ans = abs(a[0] - x)
for i in range(1, n):
    ans = gcd(ans, abs(x - a[i]))
print(ans)
# Judge status: Wrong Answer
import collections

n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)

values, counts = zip(*c.most_common())

counts = set(counts)
counts = list(counts)
num = counts[-1]


for i in range(num):
  print(string_list[i])
# Judge status: Accepted
K,S = map(int,input().split())

cnt = 0
for a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)
# Judge status: Accepted
s = int(input())
a, b = s // 100, s % 100
x = "YY" if a == 0 or a > 12 else "MM"
y = "YY" if b == 0 or b > 12 else "MM"
print(x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS")
# Judge status: Accepted
n=int(input())
s=[]
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for i in range(m):
    t.append(input())

s1=set(s)
m=0
for i in s1:
    cnt=s.count(i)-t.count(i)
    m=max(cnt,m)
print(m)
# Judge status: Accepted
def main():
    S, T = input().split(' ')
    A, B = map(int, input().split(' '))
    U = input()

    if U == S:
        A -= 1
    if U == T:
        B -= 1
    
    print('{} {}'.format(A,B))


if __name__ == '__main__':
    main()
# Judge status: Accepted
def m():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N//i

        ans += (n * (n + 1) // 2)*i
        pass
    return ans


print(m())
# Judge status: Accepted
N = input()
A = input()

if len(N) == len(A)-1:
  if N == A[:-1]:
    print('Yes')
  else:
    print('No')
else:
  print('No')
# Judge status: Accepted
s = input()
before = ""
flag = 0
for i in s:
    if before == i:
        flag = 1
    before = i
if flag == 1:
    print("Bad")
else:
    print("Good")
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import numpy as np

N,M = map(int,readline().split())
LR = np.array(read().split(),np.int32)

L = LR[::2]; R = LR[1::2]

x = R.min() - L.max() + 1
if x < 0: x = 0
print(x)
# Judge status: Accepted
import math
N = int(input())
x = math.ceil((-1+math.sqrt(1+8*N))/2)
y = x*(x+1)//2 - N
for i in range(1, x+1):
    if i != y:
        print(i)
# Judge status: Accepted
from collections import Counter
n = int(input())
count=0
res = 0
for _ in range(n):
  a = int(input())
  if res < a:
    tmp = (a-res)%2
    count += res+(a-tmp-res)//2
    res = tmp
  else:
    count += a
    res = 0
    
print(count)
# Judge status: Accepted
n,m = map(int,input().split())

if n > 1 and m > 1: 
    print((m-2)*(n-2))
else:
    if n == 1 and m == 1:
        print(1)
    else:    
        print(max(n,m)-2)
# Judge status: Accepted
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
h_list=list(map(int,input().split()))
h_list.sort()
if k>=n:
    print(0)
else:
    ans=0
    for i in range(n-k):
        ans+=h_list[i]
    print(ans)
# Judge status: Wrong Answer
S=input()
print(S.find('a')-S.rfind('z')+1)
# Judge status: Accepted

from collections import defaultdict


def submit():
    n = int(input())
    a = list(map(int, input().split()))

    j_aj = [(i + 1) - a[i] for i in range(n)]
    j_aj_cnt = defaultdict(int)    
    for j in j_aj:
        j_aj_cnt[j] += 1

    ans = 0
    for i in range(n):
        j_aj_cnt[j_aj[i]] -= 1
        t = (i + 1) + a[i]
        ans += j_aj_cnt[t]
    print(ans)


submit()
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
ans=0
temp=[0]*n
temp[0]=0
temp[1]=abs(h[1]-h[0])
for i in range(2,n):
  temp[i]=min(temp[i-1]+abs(h[i]-h[i-1]),temp[i-2]+abs(h[i]-h[i-2]))
print(temp[n-1])
# Judge status: Wrong Answer
def main():
    n = int(input())
    a = list(map(int, input().split()))
    half_length = sum(a) / 2 

    sum_peace_1 = 0
    idx = -1
    for i in range(n):
        sum_peace_1 += a[i]

        if half_length <= sum_peace_1:
            idx = i
            break

    sum_peace_2 = 0
    for i in range(idx+1, n):
        sum_peace_2 += a[i]
    
    print(abs(sum_peace_1-sum_peace_2))


if __name__ == "__main__":
    main()
# Judge status: Accepted
x = int(input())
q,mod = divmod(x,11)
count=q*2
while True:
    if mod <= 0:
        print(count)
        break
    mod -= 6
    count += 1
    if mod <= 0:
        print(count)
        break
    mod -= 5
    count += 1
# Judge status: Accepted
def main():
    n, *a = map(int, open(0).read().split())

    c = 1
    f = 0
    d = {True: 1, False: -1}
    for i, j in zip(a, a[1:]):
      if i == j:
        continue
      else:
        g = d[i < j]
        if f * g == -1:
          f = 0
          c += 1
        else:
          f = g
    
    print(c)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s=input()
print("A"+s[0]+"C")
# Judge status: Accepted
a , b , c , k = map(int , input().split())
if k % 2 == 0:
  print(a - b)
else:
  print(b - a)
# Judge status: Accepted
from fractions import*
n,m,*a=map(int,open(0).read().split())
s=1
d=set()
for i in a:
  i//=2
  s*=i//gcd(s,i)
  t=0
  while i%2<1:
    t+=1
    i//=2
  d|={t}
print((0--(m//s)//2)*(len(d)<2))
# Judge status: Wrong Answer
a, b, t = map(int, input().split())
ans = 0
while a <= t:
    ans += b
    a += a
print(ans)
# Judge status: Accepted
n, x, y = map(int, input().split())
l = [0]*(n - 1)


for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans = min(abs(y - j) + abs(x - i) + 1, abs(j - i))
        l[ans - 1] += 1

for i in l:
    print(i)
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)
# Judge status: Accepted
A,B,K = map(int,input().split())
li = []
for i in range(1, min(A, B) + 1, 1):
    if A % i == 0 and B % i == 0:
        li.append(i)
print(li[-K])
# Judge status: Wrong Answer
A = int(input())
ans = A*(A-1)/2

print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
c=[0]*(n+1)
c[1]=1
q=[0,1]
while True:
  i=a[q[-1]]
  if c[i]:break
  c[i]=c[q[-1]]+1
  q+=[i]
k-=c[i]-1
t=c[q[-1]]-c[i]+1
print(q[c[i]+k%(t)])
# Judge status: Wrong Answer
N = int(input())
A = list(input().split())
for i in range(len(A)-1):
  count=0
  j=i+2
  for j in range(len(A)-1):
    if A[i+1]==A[j]:
      count=count+1
  print(count)
# Judge status: Accepted

s = input()
q = int(input())

front = []
back = []
cnt = 0
for i in range(q):
    t = input()
    if t[0] == '1':
        cnt ^= 1
    else:
        f = 1 if int(t[2]) == 1 else 0
        c = t[4]
        if cnt ^ f:
            front.append(c)
        else:
            back.append(c)

ans = ''.join(front)[::-1] + s + ''.join(back)
print(ans[::-1] if cnt else ans)
# Judge status: Wrong Answer
s = input()
n = len(s)
count1 = 0
count2 = 0
for i in range(n//2+n%2):
    if s[i*2] == "R" or s[i*2] == "U" or s[i*2] == "D":
        count1 += 1
if count1 == n//2+n%2:
    for j in range (n//2):
        if s[j*2+1] == "L" or s[j*2+1] == "U" or s[j*2+1] == "D":
            count2 += 1
if count2 == n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
w=[input() for i in range(n)]
if len(w)!=len(set(w)):
    print("No")
else:
    for i in range(n-1):
        if w[i][len(w[i])-1]!=w[i+1][0]:
            print("No")
            break
    else:
        print("Yes")
# Judge status: Accepted
X, Y = list(map(int,input().split()))

from functools import reduce

def cmb(n, r):
    INF = 10 ** 9 + 7
    r = min(n - r, r)
    if r == 0:  return 1
    numer = reduce(lambda x, y: (x * y) % INF, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % INF, range(1, r + 1))
    return (numer * pow(denom, INF - 2, INF)) % INF

temp1 = 2 * X - Y
temp2 = 2 * Y - X
if temp1 % 3 or temp2 % 3:  print(0)
elif temp1 < 0 or temp2 < 0:  print(0)
else:
    a = temp1 // 3
    b = temp2 // 3
    print(cmb(a + b, a))