peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
from collections import defaultdict
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
towns = [1]
town_dic = defaultdict(lambda : 0)
prev = 1
count = 0
while True:
    next = a[prev - 1]
    count += 1
    if count == k:
        print(next)
        sys.exit()
    if town_dic[next] == 1:
        break
    else:
        town_dic[next] += 1
    towns.append(next)
    prev = next
i = towns.index(next)
repeat = towns[i:]
unit = len(repeat)
rest = k - count + 1
print(repeat[(rest % unit) - 1])
# Judge status: Accepted
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = sum(a[0::2])
y = sum(a[1::2])
print(abs(x - y))
# Judge status: Accepted
n = int(input())

if n == 1:
    print(0)
    exit(0)

mod = 10 ** 9 + 7

ans = pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)
ans %= mod

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

ab.sort()
now = 0
count = 0
for i in range(N):
  now = ab[i][0]
  count += ab[i][1]
  if count >= K:
    print(now)
    break
# Judge status: Accepted
if 22 > sum(map(int, input().split())):
    print('win')
else:
    print('bust')
# Judge status: Wrong Answer
n=int(input())

ans=0
for i in range(1,n+1):
  num=n//i
  ans+=num*i

print(ans)
# Judge status: Accepted
import itertools
import math

n, d = map(int,input().split())
vecList = []
for i in range(n):
  vecList.append(list(map(int,input().split())))

cVec = list(itertools.combinations(vecList,2))
count = 0

for i in cVec:
  sqT = 0
  for j in range(d):
    sqT += (i[0][j]-i[1][j])**2
  sqT = math.sqrt(sqT)
  if sqT.is_integer():
    count += 1

print(count)
# Judge status: Accepted
n, m = map(int,input().split())
A = ['']*n
B = ['']*m
for i in range(n):
    A[i] = input()
for i in range(m):
    B[i] = input()

w_dif = len(A[0])-len(B[0])
w_w = len(B[0])
ans = 'No'
for h in range(n-m+1):
    for w in range(w_dif+1):
        window = [wh[w:w+w_w] for wh in A[h:h+m]]
        if window==B:
            ans = 'Yes'
            break
print(ans)
# Judge status: Accepted
N, M = [int(x) for x in input().split()]
print(abs((N - 2) * (M - 2)))
# Judge status: Accepted
s = input()
t = input()
scnt = {}
tcnt = {}
sres = []
tres = []
for x in s:
    if x not in scnt:scnt[x] = 1
    else:scnt[x] +=1
for x in t:
    if x not in tcnt:tcnt[x] = 1
    else:tcnt[x] +=1
for k in scnt:
    sres.append(scnt[k])
for k in tcnt:
    tres.append(tcnt[k])
sres.sort()
tres.sort()
n = max(len(sres),len(tres))
ok = True
for i in range(n):
    if sres[i] != tres[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')
# Judge status: Accepted
H1, M1, H2, M2, K = map(int, input().split())

#print(H1, M1, H2, M2, K)

mm1 = H1*60+M1
mm2 = H2*60+M2

if mm2 > mm1:
    mmm = mm2-mm1
else:
    mmm = mm2+24*60 - mm1

if mmm > K:
    print(mmm-K)
else:
    print(0)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

sum=0
min=10**9
for i in a:
  if i>=0:
    sum=sum+i
    if min>i:
      min=i
  else:
    sum=sum-i
    if min>-i:
      min=-i
print(sum if len(a)%2==0 else sum-min)
# Judge status: Accepted
n,p=map(int,input().split())
a=list(map(int, input().split()))

a_new=[]
for i in range(n):
    a_new.append(a[i]%2)
even=a_new.count(0)
odd=a_new.count(1)

if odd==0 and p==0:
    print(2**n)
elif odd==0 and p==1:
    print(0)
else:
    print(2**(n-1))
# Judge status: Accepted
n = int(input())
w = list(map(int,input().split()))
ans = sum(w)
for i in range(1,n):
  ans = min(ans, abs(sum(w[:i])-sum(w[i:])))
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a == b and a == c:
  print('3')
elif a==b or a == c or b== c:
  print('2')
else:
  print('1')
# Judge status: Accepted
A,B,C,D=map(int,input().split())

turn=True
while A>0 and C>0:
    if turn==True:
        C=C-B
        turn=False
    else:
        A=A-D
        turn=True

if A<=0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n, m = map(int, input().split())
P = sorted([tuple(map(int, input().split())) for i in range(n)])
ans = 0
for x, y in P:
	q = min(m, y)
	ans += x*q
	m -= q
	if m == 0:
		print(ans)
		exit()
# Judge status: Accepted
import collections
Sls = list(input())
counter = collections.Counter(Sls)
ans = 'yes'
for i in counter.values():
    if i > 1:
        ans = 'no'
        break
print(ans)
# Judge status: Accepted
n=int(input())
num=1
while(num**2<n+1):
    num +=1
print((num-1)**2)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = input()
if "##" in S[A - 1: max(C, D)]:
	print("No")
	exit()
for i in range(B - 1, D):
	if S[i] == "." and S[i - 1] == ".":
		if D == N or C < D:
			print("Yes")
			exit()
		else:
			if S[i + 1] == ".":
				print("Yes")
				exit()
print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
if a[0]:
  if n==0 and a[0]==1:
    print(1)
  else:
    print(-1)
  exit()
b=[0]*n
b.append(a[-1])
for i in range(n)[::-1]:
  b[i]=b[i+1]+a[i]
ro=1
ans=1
for i in range(1,n+1):
  t=min(ro*2,b[i])
  ans+=t
  ro=t-a[i]
  if ro<0:
    print(-1)
    exit()
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
if n==1 or m==1:
  if n+m==2:
    print(1)
  else:
    print(n*m-2)
else:
  print(n*m-(n+m)*2+4)
# Judge status: Accepted
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n<=k:
    print(1)
    exit()
c=1
while 1:
    if n<=k:
        break
    n-=(k-1)
    c+=1
print(c)
# Judge status: Wrong Answer
a, b = map(int,input().split())
c = a* b

if  c%2 == 0:
    print('Even')
else:
    print('odd')
# Judge status: Wrong Answer
n,k = map(int,input().split())
h = list(input().split())
h.sort()
ans = int(0)
if k >= n:
    print(ans)
else:
    for i in range(n - k):
        ans += int(h[i])
    print(ans)
# Judge status: Accepted
import sys
n=int(input())
ab=[]
for i in range(n):
  AB=[int(x) for x in input().rstrip().split()]
  ab.append(AB)
ab=sorted(ab,key=lambda x :x[0])
ab=sorted(ab,key=lambda x :x[1])

time=0
for a,b in ab:
  if time+a<=b:
    time+=a
  else:
    print("No")
    sys.exit()

print("Yes")
# Judge status: Accepted
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))

A = []
B = [[0,0,0],[0,0,0],[0,0,0]]
ans = "No"
for i in range(3):A.append(ILI())
n = int(input())
for k in range(n):
	b = int(input())
	for i in range(3):
		for j in range(3):
			if A[i][j] == b:B[i][j]=1
B2 = list(zip(*B))
for i in range(3):
	if sum(B[i])==3 or sum(B2[i])==3:
		ans = "Yes"
if B[0][0]+B[1][1]+B[2][2]==3:ans="Yes"
if B[0][2]+B[1][1]+B[2][0]==3:ans="Yes"
print(ans)
# Judge status: Wrong Answer
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
minX=0
maxX=W
minY=0
maxY=H
for i in range(N):
  x[i],y[i],a[i]=map(int,input().split())
  if a[i]==1:
    minX=max(minX,x[i])
  if a[i]==2:
    maxX=min(maxX,x[i]) 
  if a[i]==3:
    minY=max(minY,y[i])
  if a[i]==4:
    maxY=min(maxY,y[i])  
print(max(0,(maxX-minX)*(maxY-minY)))
# Judge status: Accepted
N, M = map(int, input().split())

if N == 1 and M == 1:
    print('1')
elif N == 1:
    print(max(0, M-2))
elif M == 1:
    print(max(N-2, 0))
else:
    print(max(0, N-2)*max(0, M-2))
# Judge status: Accepted
k =int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  if k % 7 == 0:
    k //= 7
  if k == 1:
    print(1)
  else:
    k *= 9
    i = 1
    num = 10
    while num % k != 1:
      num %= k
      num *= 10
      i += 1
    print(i)
# Judge status: Accepted
#APC001_B
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

plus, minus = 0, 0
for i in range(n):
    if a[i] < b[i]:
        plus += (b[i] - a[i]) // 2
    if a[i] > b[i]:
        minus += (a[i] - b[i])
        
print('Yes' if minus <= plus else 'No')
# Judge status: Accepted
w,h,n = map(int,input().split())
w0 = 0
h0 = 0

for _ in range(n):
    x,y,a = map(int,input().split())

    if a == 1:
        w0 = max(w0,x)
    
    if a == 2:
        w  = min(w,x)

    if a == 3:
        h0 = max(h0,y)
    
    if a == 4:
        h  = min(h,y)

print(max(0,w-w0)*max(0,h-h0))
# Judge status: Accepted
l = int(input())

print((l/3)**3)
# Judge status: Wrong Answer
x,y = list(map(int, input().split()))
count=0
for i in range(x+1):
    for j in range(x+1):
        k=y-i-j
        if k<x and k>0:
          count+=1
print(count)
# Judge status: Accepted
import bisect

n = int(input())
a,b,c = [list(sorted(map(int, input().split())))  for _ in range(3)]

ans = 0
for i in b:
    x = bisect.bisect_left(a, i)
    y = len(c) - bisect.bisect_right(c, i)
    ans += x*y

print(ans)
# Judge status: Wrong Answer
# Hello World program in Python
from collections import Counter as cn

d=int(input())
l = []
for k in range(d):
  p = cn(input())
  l.append(p)

oi = l[0]

for g in range(len(l)):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))
# Judge status: Accepted
import sys

N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

if N == 1:
	cnt = 1
	H -= AB[0][1]
	if H > 0:
		cnt += -(-H//AB[0][0])
	print(cnt)
	sys.exit()



AB.sort(reverse = True)
max_A = AB[0][0]
AB.sort(reverse = True, key = lambda x: x[1])

cnt = 0

for i in range(N):
	katana_B = AB[i][1]
	if katana_B < max_A:
		break
	else:
		H -= katana_B
		cnt += 1

	if H <= 0:
		break

if H > 0:
	cnt += -(-H//max_A)

print(cnt)
# Judge status: Accepted
D,T,S=map(int,input().split())
if S*T >= D:
    print("Yes")
else:
    print("No")
# Judge status: Accepted

c = str(input())
vowels = ['a','e','i','o','u']

if c in vowels:
    answer = "vowel"
else:
    answer = "consonant"

print(answer)
# Judge status: Accepted
a,b,c = map(int,input().split())
print("Yes" if min(a,b) < c < max(a,b) else "No")
# Judge status: Accepted
r, g, b = map(str,input().split())
n = int(r+g+b)
if n % 4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import math

h = int(input())

print(2**(int(math.log2(h)+1))-1)
# Judge status: Wrong Answer
n = int(input())
time=0
alist=[]
ans='Yes'
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b>time:
    time=b
  if b>a:
    ans='No'
alist.sort(key=lambda x: x[1])
for i in range(n-1,-1,-1):
  if time<alist[i][1]:
    ans='No'
  time=time-alist[i][0]
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a <= c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
carry=0
ans=0
for i in range(n):
  a=int(input())
  carrycopy=carry
  carry=(carry+a)%2
  ans+=(a+carrycopy)//2
  if a==0:
    carry=0
print(ans)
# Judge status: Wrong Answer
n=int(input())
A=list(map(int,input().split()))

cnt=0
for i in range(n):
    for j in range(i+1,n):
        if A[j]!=A[i]:
            cnt+=1
print(cnt)
if cnt>1:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a, b = list(map(int, input().split()))

if a > 8 or b > 8:
  print(':(')
else:
  print('Yay!')
# Judge status: Accepted
s=sorted(input())
r=sorted(input(),reverse=True)
if(s<r):
    print("Yes")
else:
    print("No")
# Judge status: Accepted

def main():
    a, b = map(int, input().split(" "))
    print(a*b)

if __name__ == "__main__":
    main()
# Judge status: Accepted
import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = []
for i in range(n):
    s += [input()]
c0 = s.count("AC")
c1 = s.count("WA")
c2 = s.count("TLE")
c3 = s.count("RE")
print("AC × " + str(c0))
print("WA × " + str(c1))
print("TLE × " + str(c2))
print("RE × " + str(c3))
# Judge status: Accepted
c1 = input()
c2 = input()
if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N=int(input())
A=sorted(map(int,input().split()))
ans=0
for i in range(1,N-1):
  ans+=A[i]
if ans>=A[N-1]:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
x = int(input())
while True:
    flag = True
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            flag = False
            break
    if flag:
        print(x)
        break
    x += 1
# Judge status: Wrong Answer
value = int(input())
kyu_rated = 8
flag = 0
lvalue = 400
rvalue = 599
if 400 <= value <= 1999:
    for i in range(0, 7):
        if lvalue <= int(value) <= rvalue:
            print(kyu_rated)
            flag = 1
            break
        else:
            lvalue += 200
            rvalue += 200
            kyu_rated -= 1
# Judge status: Wrong Answer
from sys import setrecursionlimit
n = "0"+input()
N = len(n)
point = 0
for i in range(1,N):
    if int(n[i]) >= 6:
        point += 10-int(n[i])
    else:
        point += int(n[i])
print(point)
# Judge status: Accepted
def main():
    from bisect import bisect_right

    N = int(input())
    *e, = map(int, input().split())

    e.sort()

    ans = 0
    for j in range(2, N):
        for i in range(1, j):
            d = e[j] - e[i]
            ans += max(0, i - bisect_right(e, d))

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
# Judge status: Accepted
n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]
T.sort()
cnt = 0
ans = 1
t = T[0]
for i in range(n):
    cnt += 1
    if cnt > c or T[i] > t + k:
        ans += 1
        cnt = 1
        t = T[i]
print(ans)
# Judge status: Wrong Answer
today_weather = input()

if today_weather == 'Sunny':
    tomorrow_weather = 'Cloudy'

elif today_weather == 'Cloudy':
    tomorrow_weather = 'Rainy'

elif today_weather == 'Rainy':
    tomorrow_weather = 'Sunny'

print('tomorrow_weather')
# Judge status: Wrong Answer
from collections import Counter
print(2*min(Counter(list(input())).values()))
# Judge status: Accepted

k=int(input())
 
from math import gcd
s6=0
for i in range(2,k-1):
    for j in range(i+1,k):
        for jj in range(j+1,k+1):
            s6+=gcd(gcd(i,j),jj)
 
s3=0
for i in range(2,k):
    for j in range(i+1,k+1):
        s3+=gcd(i,j)
 
s1=int((k+1)*k/2)
 
 
print(s1+s3*6+s6*6+(k-1)*6+(k-2)*(k-1)*3)
# Judge status: Accepted
S = int(input())
p = 10 ** 9
if S > p:
    r = S % p
    r = 0 if r == 0 else p - r 
    print(p, 1, r, (S + r) // p,  0, 0)
else:
    print(1, 0, 0, S, 0, 0)

    print()
# Judge status: Accepted
N = int(input())
L1 = []
for i in range(N):
    L1.append(list(input().split()))

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if int(i[1]) < int(j[1]):
                seq += 1
    ans.append(seq)
    
for i in range(N):
    print(ans.index(i+1)+1)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if a//b >= c:
  print(c)
else:
  print(a//b)
# Judge status: Accepted
# S,Wの入力
S,W = map(int,input().split())

# S,Wの比較
if S > W:
    print("safe")
else:
    print("unsafe")
# Judge status: Accepted
a,b,c = map(int, input().split())
k = int(input())

ans = a+b+c + (max(a,b,c))*(2**k-1)
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
if len(a)==len(b):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n = int(input())

if n <= 599:
    print("8")
elif n <=799:
    print("7")
elif n <=999:
    print("6")
elif n <=1199:
    print("5")
elif n <=1399:
    print("4")
elif n <=1599:
    print("3")
elif n <=1799:
    print("2")
elif n <=1999:
    print("1")
# Judge status: Accepted
N=int(input())

c=input()

C=[a for a in c]

number=0
answer=0
red=C.count('R')

if red==0 or red==N:
    print(0)
else:
    words=C[red:]
    print(words.count('R'))
# Judge status: Accepted
A, B, K = map(int, input().split())

L = [i for i in range(1, A+1) if A%i==0 and B%i==0]
print(L[-K])
# Judge status: Accepted
a = int(input())
import math
b = math.factorial(a)%(10**9+7)
print(b)
# Judge status: Accepted
# A

S=input()

if S=="AAA" or S=="BBB":
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N,K = map(int,input().split())
S = str(input())
T = list(map(str,S))

for i in range(N):
    if i == K-1:
        T[i] = str.lower(T[i])

print("".join(T))
# Judge status: Accepted
N,K,S=map(int,input().split())
ans=[]
for _ in range(K):
  ans.append(S)
for _ in range(N-K):
  ans.append(S+1 if S!=10**9 else 1)
for i in range(N):
  print(ans[i])
# Judge status: Accepted
a,b,c,k = map(int,input().split())
if a >= k:
    print(k)
else:
    if a+b >= k:
        print(a)
    if a+b < k:
        d = k-a-b
        print(a-d)
# Judge status: Accepted
S = input()
T = input()
ans = 0
for i in range(len(S) - len(T) + 1):
  count = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      count += 1
  ans = max(ans, count)
print(len(T) - ans)
# Judge status: Accepted
d,t,s=map(int,input().split())
if d<=t*s:print('Yes')
else:print('No')
# Judge status: Accepted
a,b,x=map(int,input().split())
print(b//x-(a-1)//x)
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))
DL = [0] * N
mod = 998244353
if D[0] != 0:
    print(0)
    exit()

for d in D:
    DL[d] += 1

if DL[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(1, N):
    if DL[i] == 0:
        if sum(DL[i:]) != 0:
            print(0)
            exit()
        else:
            print(ans%mod)
            exit()

    ans *= pow(DL[i-1], DL[i], mod)
    ans %= mod
# Judge status: Accepted
k, n = list(map(int, input().split()))

a = list(int(i) for i in input().split())
s = []
for i in range(n-1):
   s.append(a[i+1] - a[i])

s.append(k - a[n-1] +a[0])

print(k - max(s))
# Judge status: Wrong Answer
A = list(map(int , input().split()))
if A[0] == A[1] and A[0] != A[2]:
    print('Yes')
elif A[0] == A[2] and A[0] != A[1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())

print((a + b) * h // 2)
# Judge status: Accepted
S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
# Judge status: Accepted
line = input().split()
s = int(line[0])
w = int(line[1])

if w >= s:
  print("unsafe")
else :
  print("safe")
# Judge status: Accepted
L, R = map(int, input().split())

ans = 2018
for i in range(L, L+2019):
    for j in range(R-2019, R+1):
        if not i<j:
            continue
        ans = min(ans, (i*j)%2019)

print(ans)
# Judge status: Accepted
k = int(input())
if k%2 == 0:
    print((k//2)**2)
else:
    print((k-1)*(k+1)//4)
# Judge status: Wrong Answer
N = int(input())
n = 0
for i in range(N-int((N*0.08)), N):
    
    if int(i*1.08) == N:
        print(i)
        n = 1
        break
if n ==0 :
    print(':(')
# Judge status: Accepted
A,B=map(int,input().split())
print(A*B if 1<=A<=9 and 1<=B<=9 else "-1")
# Judge status: Accepted
def resolve():
    A, B, T = map(int, input().split())

    ans = T // A * B

    print(ans)


resolve()
# Judge status: Wrong Answer
x,y = map(int,input().split())
if x > y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x))+2)
    if x >= 0 and y < 0:
        print(abs(abs(y)-abs(x))+1)
    if x >= 0 and y >= 0:
        print(abs(abs(y)-abs(x))+2)
elif x < y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x)))
    if x < 0 and y >= 0:
        print(abs(abs(y)-abs(x))+1)
    if x >= 0 and y >= 0:
        print(abs(abs(y)-abs(x)))
# Judge status: Accepted
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    r = A - B
else:
    r = B - A
print(r if r <= 10**18 else "Unfair")
# Judge status: Accepted
n,k=map(int,input().split())
r=input()

c=0
for i in range(1,n):
  if r[i-1]==r[i]:
    c+=1
  
print(min(n-1,c+2*k))
# Judge status: Accepted
num = int(input())
list = list(map(int,input().split()))
sorted(list)
count = 0
for i in range(len(list)):
    for j in range(len(list)):
        for k in range(len(list)):
            if ( list[i] < list[j] < list[k] ) and ( list[i] + list[j] >  list[k] ):
                count += 1
print(count)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
# Judge status: Accepted
k = int(input())
if k % 2 == 0:
    print(int((k // 2) ** 2))
else:
    print((k // 2) * (k // 2 + 1))
# Judge status: Accepted
n = list(input())
if n[-1] == "s":
    n.append("e")
    n.append("s")
else:
    n.append("s")

print("".join(n))
# Judge status: Wrong Answer
n = int(input())
w = list(map(int, input().split()))

a = [0]*n

for i in range(n):
  a[0] += w[i]
  
for i in range(n):
  if a[i] > 0:
    a[i] -= 2*w[i]
  else:
    j = i
    break
    
if a[j-1] < -a[j]:
  print(a[j-i])
else:
  print(-a[j])
# Judge status: Accepted
s=input()
pos=-1
ans=0
for i,c in enumerate(s):
    if c=='Z' and pos!=-1:
        ans=max(ans,i-pos+1)
    if c=='A' and pos==-1:
        pos=i
print(ans)
# Judge status: Wrong Answer
A,B=map(int,input().split())

print((A+B)//24)
# Judge status: Accepted
a = int(input())
s = input()

if a >= 3200:
    print(s)
if a < 3200:
    print("red")
# Judge status: Accepted
import math
n=int(input())
res=2*math.pi*n
print(res)
# Judge status: Accepted
# solution
import io
from fractions import gcd

data=int(input())
array=list(map(int,input().split()))
k=[0]
l=[0]
for i in range(data-1):
    k.append(gcd(k[i],array[i]))
    l.append(gcd(l[i],array[data-i-1]))
ans=0
for i in range(data):
    ans=max(ans,gcd(k[i],l[data-i-1]))
print(ans)
# Judge status: Accepted
S = input()
K = int(input())

def ctoi(c):
    return ord(c) - ord('a')
def toa(c):
    i = ctoi(c)
    return (26-i)%26

ans = ''
for c in S:
    if len(ans)+1 == len(S):
        ans += chr((ctoi(c) + K)%26 + ord('a'))
    else:
        to = toa(c)
        if to <= K:
            ans += 'a'
            K -= to
        else:
            ans += c
print(ans)
# Judge status: Accepted
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    if N%2 == 1:
        for i in range(0, M):
            print(f'{2+i} {1+2*M-i}')
    else:
        k = N//4
        for i in range(M):
            if i < k:
                print(f'{i+1} {N-i}')
            else:
                print(f'{i+2} {N-i}')
resolve()
# Judge status: Wrong Answer
N = input()

a = len(N) - 1
b = int(N[0])

ans = (b-1) + 9 * a

if int(str(b) + "9"*a) < int(N):
    print(ans)
else:
    ans = b + 9 * a
    print(ans)
# Judge status: Accepted
A, B = input().split()
A = int(A)
C = int(B[0])*100 + int(B[2:])
print((A*C)//100)
# Judge status: Wrong Answer
import math
from functools import reduce
print(reduce(math.gcd,map(int,input().split())))
# Judge status: Accepted
N = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
# Judge status: Wrong Answer
N = input()
N = [int(s) for s in N]
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

count = 0
for x in range(N[0]):
    # print("x",x)
    flag = 1
    for i in range(x+1):
        # print("i",i)
        if Line[x] > Line[i] :
            # print(Line[x],Line[i])
            flag = 0
    # print("ss")
    if flag == 1 :
        # print("OK")
        count += 1

print(count)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
res = 0 #余力
for i in range(n):

    ch = min(a[i],res)
    cnt += ch
    a[i] -= ch
    if b[i] > a[i]:
        cnt += a[i]
        res = b[i] - a[i]
    else:
        cnt += b[i]
        res = 0

cnt += min(a[n],res)

print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ki=a[0::2]
ki2=[]
for i in ki[::-1]:
    ki2.append(i)
guu=a[1::2]
guu2=[]
for i in guu[::-1]:
    guu2.append(i)

if n%2==0:
    kotae=guu2+ki
else:
    kotae=ki2+guu
kotae=" ".join(map(str,kotae))
print(kotae)
# Judge status: Accepted
x,y = [int(x) for x in input().split()]

if y == 0:
    print(abs(x) + (x>0))
elif x < y < 0:
    print(y-x)
elif 0 < y < x:
    print(x-y+2)
else:
    print(abs(abs(y) - abs(x)) + (x < 0) + (y < 0))
# Judge status: Wrong Answer
S=input()
X=len(S)
A=S
for i in range(10**3+1):
  A=A.replace("10","").replace("01","")
if X==1:
  print(0)
else:
  print(X-len(A))