peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted

l=list(map(str,input().split()))

# print(l)
l2=list(l[1])
axc=str('A'+l2[0]+'C')
print(axc)
# Judge status: Wrong Answer
n = int(input())
if 1 <= n < 1000:
  print('ABC' + str(n).zfill(3))
else:
  n -= 999
  print('ABD' + str(n).zfill(3))
# Judge status: Wrong Answer
import itertools as it
s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
  if s[i] == "<":
    a[i+1] = +1
  if s[i] == ">":
    a[i+1] = -1
l = [0]*(n+1)
for i in range(n):
  if i < n-1:
    if s[i] == ">" and s[i+1] == "<":
      l[i+1] = 0
    else:
      l[i+1] += l[i] + a[i+1]
  else:
    l[i+1] += l[i] + a[i+1]
m = min(l)
r = [i + abs(m) for i in l]
print(sum(r))
# Judge status: Accepted
k = int(input())
n = 0
for i in range(k+1):
    n += pow(10, i, k)*7
    n %= k
    if n==0:
        print(i+1)
        break
else:
    print(-1)
# Judge status: Wrong Answer
s = str(input())

if s[0] == 9 or s[1] == 9:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import itertools
t = input().split()
ans = 0
for i in itertools.permutations(t, 3):
    ans = max(ans, int(i[0]+i[1])+int(i[2]))
    #print(i, i[0]+i[1],i[2])
    #print(ans)
print(ans)
# Judge status: Accepted
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
# Judge status: Accepted
def resolve():
	a = []
	bingo = [(0,3,6),(1,4,7),(2,5,8),(0,1,2),(3,4,5)
			 ,(6,7,8),(0,4,8),(2,4,6)]
	for _ in range(3):
		a += list(map(int,input().split()))
	for i in range(int(input())):
		r = int(input())
		if r in a:
			a[a.index(r)]=0
	ans = 'No'
	for i in bingo:
		if a[i[0]] == 0 and a[i[1]]==0 and a[i[2]]==0:
			ans ='Yes'
	print(ans)
resolve()
# Judge status: Wrong Answer
from math import factorial
n,m=map(int,input().split())
mod=10**9+7
f=factorial(n)
if abs(n-m)>1:
  print(0)
elif abs(n-m)==1:
  print((f**2)%mod)
else :
  print((2*f**2)%mod)
# Judge status: Wrong Answer
l = [int(i) for i in input().split()]
K, X = l
if K * 500 > X:
    print('Yes')
else:
    print("No")
# Judge status: Accepted

def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    else:
        print(a, b-1)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s = input()
flg = 1
if (s[0] != 'A'):
    flg = 0
cnt = 0
for i in s[2:-2]:
    if (i == 'C'): cnt+= 1
if (cnt != 1):
    flg = 0 

cap = 0
for i in s:
    if ('A' <= i <= 'Z'): cap += 1
if (cap != 2):
    flg = 0
if (flg): print("AC")
else: print("WA")
# Judge status: Accepted
a, b, c = map(int, input().split())
k = int(input())

print(a + b + c + max(a, b, c) * (2 ** k - 1))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())
for i in range(k+1):
    if a>b:
        b=b*2
    else:
        if b>c:
            c=c*2
        else:
            break

if a<b<c:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t = 0

t += math.ceil(N / A)

t += math.ceil(A / B)
t += math.ceil(B / C)
t += math.ceil(C / D)
t += math.ceil(D / E)

print(t)
# Judge status: Accepted
from collections import deque

K = int(input())
l = [9,8,7,6,5,4,3,2,1]
lunlun = deque(l)
ans = l
for _ in range(K - 9):
    x = lunlun.pop()
    tmp = 10 * x + (x % 10)
    if x % 10 != 0:
        lunlun.appendleft(tmp - 1)
        ans.append(tmp - 1)
    lunlun.appendleft(tmp)
    ans.append(tmp)
    if x % 10 != 9:
        lunlun.appendleft(tmp + 1)
        ans.append(tmp + 1)
ans.sort()
print(ans[K - 1])
# Judge status: Accepted
h = int(input())

count = 0
while h > 1 :
    h = h // 2
    count += 1

sum = 0
for i in range(count+1) :
    sum = sum + 2**i

print(sum)
# Judge status: Accepted
s = input()
t = input()

if (s == t[:-1]) & (len(s) + 1 == len(t)):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
import numpy as np
mod = 10**9+7
def lcm(x,y):
  return (x*y)//gcd(x,y)%mod
l = reduce(lcm, a)
print(sum(l//(np.array(a)))%mod)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int,input().split()))
  
count = 0
for i in range(n-1):
    if p[i] > p[i+1]:
        count += 1
        if count == 2:
            print("NO")
            exit()
print("YES")
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))


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

q = sorted(p)

ans = 0
for i in range(n):
    if p[i] != q[i]:
        ans += 1
if (ans <= 2):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n,m=map(str,input().split())
n=int(n)
m1=''
for i in m:
    if i=='.':
        continue
    else:
        m1+=i
print(n*int(m1)//100)
# Judge status: Accepted
import sys
input = sys.stdin.readline

x, y = [int(x) for x in input().split()]

ans = 0

while x <= y:
    x *= 2
    ans += 1


print(ans)
# Judge status: Accepted
n,T=map(int,input().split())
ans=1001
for i in range(n):
  c,t=map(int,input().split())
  if t<=T:
    ans=min(ans,c)
if ans==1001:
  print('TLE')
else:
  print(ans)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

colors = [0] * 8
over = 0

for i in arr:
    if i >= 3200:
        over += 1
    else:
        colors[i // 400] += 1

res = 8 - colors.count(0)
if res:
    print(res, res+over)
else:
    print(1, over)
# Judge status: Wrong Answer
X = int(input())

A = X ** (1 / 5)
A = int(A)
A_ = A ** 5

B_ = X - A_

B = B_ ** (1 / 5)
B = int(B)
print(A, B)
# Judge status: Wrong Answer
n = int(input())
ab = [map(int, input().split()) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
 
a.reverse()
b.reverse()
ans = 0
num = 0
ruisekiwa = 0

for j in range(n):
  a[j] += ruisekiwa
  syou = a[j]//b[j]
  if a[j] == 0:
    num = b[j]
  elif b[j] == 1:
    num = 0
  else:
    num = b[j]*(syou+1) - a[j]
  ruisekiwa += num
  ans += num

print(ans)
# Judge status: Accepted
import collections

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

cc = dict(collections.Counter(lst))
ans = 0
for i in cc.values():
  if (i % 2 != 0):
    ans += 1
print(ans)
# Judge status: Accepted
N = int(input())

c = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
    s = int(str(n)[0])
    e = int(str(n)[-1])

    c[s][e] += 1

ans = 0
for x in range(10):
    for y in range(10):
        ans += c[x][y] * c[y][x]

print(ans)
# Judge status: Wrong Answer
import bisect
N = int(input())
L = list(map(int, input().split()))
L = sorted(set(L))

ans = 0
for i in range(len(L)-2):
  for j in range(i+2, len(L)):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    if b-a < a:
      right += 1
    left = max(right, i+1)
    ans += j - left
print(ans)
# Judge status: Wrong Answer
N = int(input())
v = list(map(int, input().split()))
v.sort()
if N == 2:
  print((v[0] + v[1]) / 2)
else:
  s = (v[0]+v[1])/2
  for i in range(3, N):
    s = (s + v[i])/2
  print(s)
# Judge status: Accepted
N = int(input())
s = input()
t = input()
for i in range (N+1):
  k = s[:i] + t
  if k[:N] == s:
    print(N+i)
    break
# Judge status: Accepted
w,h,n=map(int,input().split())
y_max,x_max=h,w
y_min,x_min=0,0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    x_min=max(x_min,x)
  elif a==2:
    x_max=min(x_max,x)
  elif a==3:
    y_min=max(y_min,y)
  elif a==4:
    y_max=min(y_max,y)

width=max(x_max-x_min,0)
height=max(y_max-y_min,0)
print(int(width*height))
# Judge status: Accepted
N = int(input())
a = [int(0.5*i*(i+1)) for i in range(10)]
import math
res = 0
top = int(math.sqrt(N))
for i in range(2,top+1):
    count = 0
    while N%i == 0:
        N = N//i
        count += 1
    for j in range(10):
        if count < a[j]:
            res += (j-1)
            break
if N != 1:
    print(res+1)
else:
    print(res)
# Judge status: Accepted
[n, d], *a = [[int(i) for i in x.split()] for x in open(0)]
print(sum(x**2 + y**2 <= d**2 for x, y in a))
# Judge status: Accepted
#045_B
S={}
S['a']=list(input())
S['b']=list(input())
S['c']=list(input())
s='a'
while len(S[s]):
    s=S[s].pop(0)
print(s.upper())
# Judge status: Accepted
import math
def lcm(a, b):
  return abs(a*b) // math.gcd(a, b)
n=int(input())
t=int(input())
for i in range(n-1):
  t=lcm(t,int(input()))
print(t)
# Judge status: Wrong Answer
n,m,x,y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z='No War' if max(x)<min(y) else 'War'
print(z)
# Judge status: Accepted
K, X = map(int, input().split())
if K * 500 >= X:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n,m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
    
elif abs(n-m) == 1:
    x = max(n,m)
    for i in range(1,min(n,m)+1):
        x = x*i**2 % (10**9 + 7)
    print(x)
else:
    x = 2
    for i in range(1,n+1):
        x = x*i**2 % (10**9 + 7)
    print(x)
# Judge status: Accepted
A,B,C,K = map(int,input().split())
ans = A-B
if abs(ans) > 10**18:
  ans = 'Unfair'
else:
  if K%2 != 0:
    ans = B-A
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
d=b-a
e=c-b
if d==e:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
l=[A,B,C]
l.sort()

print(l[0]*l[1])
# Judge status: Accepted
n = int(input())

for i in range(n):
    x,y = map(int,input().split())
    if i == 0:
        summax = x+y
        summin = x+y
        diffmax = x-y
        diffmin = x-y

    if x+y > summax:
        summax = x+y
    if x+y < summin:
        summin = x+y
    if x-y > diffmax:
        diffmax = x-y
    if x-y < diffmin:
        diffmin = x-y

a = summax-summin
b = diffmax-diffmin
sol = max(a,b)
print(sol)
# Judge status: Accepted
import math
a,b,h,m = map(int,input().split())
s = 3600*h+60*m
r = 2*math.pi*s*(1/43200-1/3600)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(r)))
# Judge status: Wrong Answer
N = int(input())
C = [0]*100
for i in range(N):
  s = str(i)
  C[10*int(s[0])+int(s[-1])] += 1
print(sum([C[10*i+j]*C[10*j+i] for i in range(10) for j in range(10)]))
# Judge status: Accepted
n,k,x,y = [int(input()) for i in range(4)]
cost = (min(n,k)*x+max(0,n-k)*y)
print(cost)
# Judge status: Wrong Answer
N,M = list(map(int,input().split()))
a = 0
b = 0
c=[0,0]*M
if N %2 == 0:
	a =int(N/2)
	b=a+1
else:
	a=int((N-1)/2)
	b=a+1
for i in range(M):
	c[i] =a,b
	a-=1
	b+=1
for i in range(M) :
	print(c[M-1-i][0],c[M-1-i][1])
# Judge status: Accepted
a,b=map(int,input().split())

if a>0:
    print("Positive")
elif b<0:
    if (b-a+1)%2==0:
        print("Positive")
    else:
        print("Negative")
else:
    print("Zero")
# Judge status: Wrong Answer
n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(100*(10-n))
# Judge status: Accepted
a, b, c = [int(x) for x in input("").split(" ")]
print((a+b+c) - max(a, b, c))
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn < mx:
  m = (mx+mn)//2
  if m == 0:
    break
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

k = 1
p = False
for i in range(n-1):
    if a[k-1] == 2:
        print(i+1)
        p = True
    k = a[k-1]
if not p:
    print(-1)
# Judge status: Wrong Answer
S = int(input())

for i in range(8) :
    i += 1
    if S % i == 0 and S // i <=9 :
        result = "Yes"
    else:
        result = "No"
print(result)
# Judge status: Wrong Answer
import math

N,M=map(int,input().split())
m=0
i=1
while math.sqrt(M)>=i and M//N>=i:
    if M%i==0:
        m=i
    i=i+1
print(m)
# Judge status: Accepted
a,b=map(int,input().split())
print(int((a+b)/2) if (a+b)/2%1==0 else "IMPOSSIBLE")
# Judge status: Accepted
import math

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

n=math.gcd(a,b)

cnt=1

f=2
d=n
while f*f<=n:
    if d%f==0:
        cnt+=1
        while d%f==0:
            d=d//f
    f+=1
if d!=1:
    cnt+=1

print(cnt)
# Judge status: Accepted
N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N//2] - d[N//2-1])
# Judge status: Accepted
A, B, M = map(int, input().split())

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

miniC = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    miniC = min(miniC, a[x] + b[y] - c)

print(miniC)
# Judge status: Accepted
c1 = input().strip()
c2 = input().strip()

if c2[::-1] == c1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N=int(input())
h=list(map(int, input().split()))
cnt=0
ans=0

for i in range(N-1):
    if h[i]>=h[i+1]:
        cnt+=1
        if cnt>=ans:
            ans=cnt
    else:
        cnt=0
        
print(cnt)
# Judge status: Wrong Answer
n = int(input())
print(int(((1+n)/2)*n - n))
# Judge status: Accepted
N, Y =map(int, input().split())
X = [-1,-1,-1]
for i in range(2001):
  y = (Y-1000*N-9000*i)/4000
  if not float.is_integer(y):
    continue
  if 0<= N-i-y <= 2000 and 0<= y <= 2000:
    X=[i, y, N-i-y]
    X=list(map(int, X))
    break
print(*X)
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    X, A, B = map(int, input().split())
    if X - A < 0:
        print('dangerous')
    elif A - B <= 0:
        print('safe')
    else:
        print('delicious')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
#!/usr/bin/env python3

def main():
    S = input()
    S_re = list(reversed(S))
    S = list(S)

    print(S)
    print(S_re)

    cnt = 0
    for i in range(0, len(S)//2):
        if not S[i] == S_re[i]:
            cnt = cnt + 1
    print(cnt)


main()
# Judge status: Wrong Answer
n,m = map(int, input().split())
if n > m:
    n,m = m,n
ans = 1
if m==n:

    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    ans = (2*(ans**2))%(10**9+7)
    print(ans)

elif m - n == 1:
    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    
    ans = (ans * (ans*m % 10**9+7)) % (10**9+7)
    print(ans)
else:
    print(0)
# Judge status: Accepted
import bisect

n,c,k = list(map(int, input().split()))
t = []
for i in range(n):
	t.append(int(input()))
t.sort()

ans = 0
remain = c-1
if c==1:
	print(n)
	exit()
time = t[0]
for i in range(1,len(t)):
	if time+k<t[i]:
		time = t[i]
		remain = c
		ans+=1
	if remain==0:
		remain=c
		time = t[i]
		ans+=1
	remain-=1

print(ans+1)
# Judge status: Accepted
P = 10**9 + 7
X, Y = map(int, input().split())

def factorial(n):
    res = 1
    for i in range(2, n+1):
        res *= i
        res %= P
    return res

if (2*X-Y)%3 == 0 and (-X+2*Y)%3 == 0 and 2*X-Y >= 0 and -X+2*Y >= 0:
    a = (-X+2*Y)//3
    b = (2*X-Y)//3
    print((factorial(a+b)*pow(factorial(a), P-2, P)*pow(factorial(b), P-2, P))%P)
else:
    print(0)
# Judge status: Accepted
from collections import Counter

N = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)

MX = sum(v*(v-1) for v in C.values())//2
for i in range(N):
    print(MX-C[A[i]]+1)
# Judge status: Accepted
a,b=input().split(' ',)
a=int(a)
b=int(b[0]+b[2:])
print(a*b//100)
# Judge status: Accepted
n = int(input())
A = sorted(map(int,input().split()),reverse = True)
print(sum(A[::2]) - sum(A[1::2]))
# Judge status: Accepted
n = int(input())
a = 2
b = 1
c = 3
for i in range(n):
    c = b + a
    a = b
    b = c
print(a)
# Judge status: Accepted
import heapq
N = int(input())
A = list(map(int, input().split()))
heapq.heapify(A)
while True:
  m = heapq.heappop(A)
  n = heapq.heappop(A)
  if m + n >= 0:
    heapq.heappush(A, m)
    heapq.heappush(A, n)
    break
  else:
    heapq.heappush(A, -m)
    heapq.heappush(A, -n)
print(sum(A))
# Judge status: Accepted
s = input()
n = len(s)
for i in range(n):
	for j in range(i, n):
		if s[:i] + s[j:] == "keyence":
			print("YES")
			exit()
print("NO")
# Judge status: Wrong Answer
X = int(input())

ans = X
m = int(X ** .5)
t = m * (m + 1) // 2
while True:
  if X <= t and t % 2 == 0:
    break
    
  m += 1
  t = m * (m + 1) // 2

print(m)
# Judge status: Accepted
n, m = map(int,input().split())
ab_l = []
for _ in range(n):
    ab_l.append(list(map(int,input().split())))
cd_l = []
for _ in range(m):
    cd_l.append(list(map(int,input().split())))
ans_l = [0]*n

for i in range(n):
    distance_min = float('inf')
    for j in range(m):
        distance = abs(ab_l[i][0]-cd_l[j][0]) + abs(ab_l[i][1]-cd_l[j][1])
        if distance < distance_min:
            distance_min = distance
            ans_l[i] = j+1

for val in ans_l:
    print(val)
# Judge status: Wrong Answer
N = input()
if N[0] == 9 or N[1] == 9:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import deque
k = int(input())
lun = deque([i for i in range(1, 10)])
for i in range(1, k+1):
    num = lun.popleft()
    if num % 10 != 0:
        lun.append(num * 10 + ((num % 10) - 1))
    lun.append(num * 10 + (num % 10))
    if num % 10 != 9:
        lun.append(num * 10 + (num % 10) + 1)
print(num)
# Judge status: Accepted
N = int(input())

if N <= 999:
    print("ABC")
else:
    print("ABD")
# Judge status: Wrong Answer
n=int(input())
x=0
for i in range(1,n+1):
  cnt=0
  for j in range(1,i+1):
    if n%j==0:
      cnt+=1
  if cnt==8:
    x+=1
print(x)
# Judge status: Accepted
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
                 
print(dp[N-1])
# Judge status: Accepted
N=int(input())
a=N//100
b=(N-a*100)//10
c=N%10

if b<=a and c<=a:
    print(a*100+a*10+a)
else:
    print((a+1)*100+(a+1)*10+(a+1))
# Judge status: Wrong Answer
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

max_index_list = [i for i, x in enumerate(p_list) if x == max(p_list)]

max_ex_value = 0
for max_index in max_index_list :
  for i in range(max_index-k+1,max_index-1):
    x = 0
    for j in range(0, k):  
      x += (p_list[i+j]+1)/2
    if x >= max_ex_value:
      max_ex_value = x
               
print(max_ex_value)
# Judge status: Wrong Answer
s = input()

l = list(s)
t = list(s)

t.reverse()

count = 0
for i in range(len(s)):
  if l[i] != t[i]:
    count += 1
print(count / 2)
# Judge status: Accepted
import heapq
n,m=map(int,input().split())
ab=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    ab[a-1].append(-b)
l=[]
ans=0
for i in range(m):
  for j in ab[i]:
    heapq.heappush(l,j)
  if l:
    ans+=-heapq.heappop(l)
print(ans)
# Judge status: Wrong Answer
#ABC061.B
N,M = map(int,input().split())
L = []
for i in range(M):
    a,b = map(int,input().split())
    L.append([a,b])
for m in range(1,N+1):
    ans = L.count(m)
    print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	dp[x] = mn(map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1))))
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
P = int(sum(X) / N) - 1
cost = []
for i in range(3):
    L = [(x - P) ** 2 for x in X]
    cost.append(sum(L))
    P += 1
print(min(cost))
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[list(input()) for _ in range(n)]
b=[list(input()) for _ in range(m)]

eq = False
ans = 'No'
for i in range(n-m+1):
  for j in range(n-m+1):
    for p in range(m):
      for q in range(m):
        if a[p+i][q+j] == b[p][q]:
          eq = True
        else:
          eq = False
          break
      else:
        ans = 'Yes'
      if not eq:
        break
print(ans)
# Judge status: Wrong Answer
x = input()
print((n := len(x)) - x[:n // 2].count("S") * 2)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
K = int(input())
for i in range(1,8):
    B_after = B * (2 ** i)
    if B_after > A:
        i_ans = i
        break
for j in range(1,8):
    C_after = C * (2 ** j)
    if C_after > B_after:
        j_ans = j
        break
if i_ans + j_ans <=K:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
X,Y=map(int,input().split())

print(X+Y/2)
# Judge status: Accepted
A,B,C = map(int, input().split())

for n in range(A, 10 ** 6, A):
    if n % B == C:
        print("YES")
        exit()

print("NO")
# Judge status: Accepted
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [collections.defaultdict(int) for _ in range(N+1)] #1_indexed
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for dw,dv in dp[i-1].items():
        dp[i][dw] = max(dp[i][dw],dv)
        if dw+w<=W:
            dp[i][dw+w] = max(dp[i][dw+w],dv+v)
print(max(dp[-1].values()))
# Judge status: Wrong Answer
N,L = map(int,input().split())
s = []
for i in range(N):
    s.append(input())
ans = s[0]
for i in range(N):
    if s[i]<ans:
        ans = s[i]
print(ans)
# Judge status: Accepted
p,q,r = list(map(int, input().split()))

print(min((p+q),(q+r),(p+r)))
# Judge status: Wrong Answer
import math
import numpy as np

a, b = map(int, input().split())
c = (int(str(a) + str(b)))
d = math.sqrt(c)

z = np.rint(d)

if z**2== c:
    print("Yes")
    print(c)
else:
    print("No")
    print(c)
# Judge status: Accepted
n, a, b = map(int, input().split())

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit()

if n == 2:
    if a > b:
        print(0)
    else:
        print(1)
    exit()

if a > b:
    print(0)
    exit()

ans = (n - 2) * (b - a) + 1
print(ans)
# Judge status: Wrong Answer
a = list(map(int, input().split()))
cnt_five = 0
cnt_seven = 0

for i in range(3):
    if (a[i] == 5):
        cnt_five += 1
    if (a[i] == 7):
        cnt_seven += 1

if(cnt_five == 2 and cnt_seven == 1):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
l = h[-3::]
print(max(l)-min(l))
# Judge status: Accepted
A = [list(map(int,input().split())) for _ in range(3)]

R1 = [A[i][1] - A[i][0] for i in range(3)]
R2 = [A[i][2] - A[i][1] for i in range(3)]
C1 = [A[1][i] - A[0][i] for i in range(3)]
C2 = [A[2][i] - A[1][i] for i in range(3)]

ok = True
for x in [R1,R2,C1,C2]:
  if len(set(x)) != 1:
    ok = False
    break
    
if not ok:
  print('No')
else:
  print('Yes')
# Judge status: Wrong Answer
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
print(sum(L[N:2*N]))
# Judge status: Wrong Answer
k=int(input())

now=7
for i in range(k+10):
	if now%7==0:
		print(i+1)
		exit()
	now*=10
	now+=7
print(-1)
# Judge status: Wrong Answer
colors = list(map(int, input().split()))

kinds = set(colors)
print(kinds)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

rem = A%B
ans = rem

if ans == 0 and C != 0:
    print("NO")
    exit()

for i in range( A+B+C + 1):
    ans = rem*i
    print(ans, ans%B)
    if ans%B == C:
        print("YES")
        exit()


print("NO")
# Judge status: Wrong Answer
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
#print(l[0][0])
#print(l[0][1])
ans = n-3
ans1 = 0

for m in range(ans):
  if l[m][0]  == l[m][1] and l[m+1][0] == l[m+1][1] and l[m+2][0] == l[m+2][1]:
    ans1 += 1
  else:
    ans1 = 0
    
    
if ans1 >= 1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == x:
                ans += 1

print(ans)
# Judge status: Accepted
import numpy as np

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

a = np.array(a)
s = a.cumsum()
ans = abs(2*s - sum(a))


print(min(ans))