peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[0] + [-1] * (L+3) for _ in range(N+3)]
dp[0] = [0] * (L+4)

for w in range(L+1):
    for i in range(1, N+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - W[i-1]] + V[i-1]
                       ) if w - W[i-1] >= 0 else dp[i-1][w]
#print(*dp, sep='\n')
print(dp[N][L])
# Judge status: Wrong Answer
import sys

s=input()
t=input()
r=""

for i in range(len(t)):
  if s==t:
    print("Yes")
    sys.exit()
    
  r=s[-1]
  s=s.strip(s[-1])
  s=r+s
  print(s,r)
  
if s==t:
  print("Yes")
  
else:
  print("No")
# Judge status: Accepted
from math import sqrt, cos, radians
a, b, h, m = map(int, input().split())
x = h * 30
if m != 0:
    x += 30 / (60 / m)
y = m * 6
c = min(abs(x - y), 360 - abs(x - y))
#print(abs(x - y) % 180, 2 * a * b * cos(abs(x - y) % 180), cos(radians(abs(x - y) % 180)))
print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(radians(c))))
# Judge status: Accepted
n=list(map(int,input().split()))
print(sum(n)+max(n)*9)
# Judge status: Accepted
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    X = int(input())
    print(10 - X // 200)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt = 0
    for a, b in zip(A, B):
        if a < b:
            cnt += (b - a) // 2
        else:
            cnt -= a - b

    if cnt < 0:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import fractions
from functools import reduce

n, m = map(int, input().split())
a = list(map( (lambda x: int(x)//2), input().split()))

div_num = [0 for _ in range(n)]
same = True
for i in range(n):
    tmp = a[i]
    while tmp%2 == 0:
        tmp //= 2
        div_num[i] += 1
if len(set(div_num)) != 1:
    same = False

if same:
    lcm = reduce(lambda x, y: (x*y)//fractions.gcd(x, y), a)
    print(int((m/lcm + 1)//2))
else:
    print(0)
# Judge status: Accepted
def main():
    S = input()

    N = len(S)
    ans = 1

    i = 1
    chars = ''
    buf = S[0]
    while i < N:
        chars += S[i]
        if buf == chars:
            pass
        else:
            ans += 1
            buf = chars
            chars = ''
        i += 1
    print(ans)
main()
# Judge status: Accepted
n = int(input())
l = [input()]
for i in range(1, n):
  s = input()
  if s in l or s[0] != l[i-1][-1]:
    print("No")
    break
  else:
    l.append(s)
else:
  print("Yes")
# Judge status: Accepted
n,m = map(int,input().split())
li = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
 
li.sort()
bc.sort(key=lambda x:x[1],reverse=True)
l = []
l_len = 0
for b,c in bc:
    l += [c]*b
    l_len += b
    if l_len>n:
        break
    
ans = 0
for i in range(n):
    if i>=l_len:ans += li[i]
    else:ans += max(li[i],l[i])
print(ans)
# Judge status: Wrong Answer
var = input()


if var.isupper():
    print ('A')
else:
    print ('B')
# Judge status: Accepted
X = int(input())

if X == 1:
    print(1)
    exit()

ans = [False] * (X + 1)
for i in range(2, X + 1):
    v = i * i
    while v <= X:
        ans[v] = True
        v *= i

for i in range(X, -1, -1):
    if ans[i]:
        print(i)
        exit()
# Judge status: Wrong Answer
from collections import Counter
s = input().rstrip()
ctr = Counter(s)
if len(ctr) > 2:
    x = min(ctr.values())
else:
    x = 0
print(x * 2)
# Judge status: Wrong Answer
x = input().split()
n = int(x[0])
m = int(x[1])
if n == 0:
  print(m * (m -1) /2)
elif m == 0:
  print(n * (n - 1) / 2)
else:
  k = m * (m -1) /2 + n * (n - 1) / 2
  print(k)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
  if a[i] == cnt+1:
    cnt += 1
print(-1 if cnt == 0 else n-cnt)
# Judge status: Accepted
n = int(input())
S = list(input())
x = 0
ans = 0
for s in S:
    if s == 'I':
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)
# Judge status: Accepted
h, n = input().split()
h = int(h)
n = int(n)
attack = sorted(list(map(int, input().split())), reverse=True)
while  n > 0:
    m_attack = attack[0]
    if h - m_attack <= 0:
        h = h - m_attack
        print("Yes")
        break
    else:   
        h = h - m_attack
        attack.remove(m_attack)
        n = n-1
if h > 0:
    print("No")
# Judge status: Accepted
import math
A,B,H,M = map(int,input().split(" "))

a_angle = 360*H/12 + 15*2*M/60
b_angle = 360*M/60

angle = a_angle - b_angle
if angle>180:
    angle = 360 - angle

ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))
print(ans**0.5)
# Judge status: Accepted
N = int(input())
alpha = [chr(i) for i in range(97, 97+26)]
dic = {i:100 for i in alpha}
for _ in range(N):
    tmpdic = {i:0 for i in alpha}
    S = input()
    for s in S:
        tmpdic[s] += 1
    for i in alpha:
        if tmpdic[i] < dic[i]:
            dic[i] = tmpdic[i]
ans =[]
for i in alpha:
    for _ in range(dic[i]):
        ans.append(i)
print(''.join(ans))
# Judge status: Accepted
import math
A,B,N=map(int,input().split())
if B-1>=N:
    print(math.floor(A*N/B))
else:
    print(math.floor(A*(B-1)/B))
# Judge status: Accepted
N, M = map(int, input().split())
res = 0
L_max = 0
R_min = 100000
for _ in range(M):
  L, R = map(int, input().split())
  if L_max < L: L_max = L
  if R < R_min: R_min = R
  
  
print(max(0, (R_min - L_max + 1)))
# Judge status: Accepted
N, X, T = [int(x) for x in input().split()]
result = -(-N // X) * T

print(result)
# Judge status: Accepted
def is_no_odd(x, y, z):
    return x % 2 == 0 and y % 2 == 0 and z % 2 == 0


def exchange(x, y, z):
    new_x = y / 2 + z / 2
    new_y = x / 2 + z / 2
    new_z = x / 2 + y / 2
    return new_x, new_y, new_z


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

while is_no_odd(a, b, c):
    if a == b == c:
        cnt = -1
        break

    a, b, c = exchange(a, b, c)
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
A,B = map(int,input().split())

a=-(-A//0.08)
b=-(-B//0.1)
c=-(-(A-1)//0.08)
d=-(-(A+1)//0.08)

if a==b or c < b < d:
    print(a)
else:
    print(-1)
# Judge status: Accepted
N,K  =map(int,input().split())
A= list(map(int,input().split()))
for i in range(N-K):
    if A[i+K] > A[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import math
a, b = map(int, input().split(' '))
print(math.ceil((a+b)/2))
# Judge status: Accepted
n = int(input())

arr = [i for i in range(n+1) if i%3 != 0 and i%5 != 0]

ans = sum(arr)

print(ans)
# Judge status: Accepted
[a,b,c]=list(map(int,input().split()))
ans="NO"
if b-a==c-b:
    ans="YES"
print(ans)
# Judge status: Wrong Answer
from collections import Counter
s = list(input())
n = len(s)
if n == 1:
    print('YES')
elif n == 2:
    if s[0] != s[1]:
        print('YES')
    else:
        print('NO')
else:
    d = Counter(s)
    if len(d) <= 2:
        print('NO')
    else:
        if 2*d['a'] <= n and 2*d['a'] <= n and 2*d['a'] <= n:
            print('YES')
        else:
            print('NO')
# Judge status: Accepted
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            k = bisect.bisect_left(l, l[i]+l[j])
            res += max(k-(j+1), 0)
    print(res)
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
# a,b,cからなる三文字のsを入力
s = input()
# 並べ替えたらabcになるならYes 
if "a" in s and "b" in s and "c" in s:
    print("Yes")
else:
    print("NO")
# Judge status: Accepted
from collections import defaultdict
from bisect import bisect_left
N, M = map(int,input().split())
A = list(map(int,input().split()))
D = defaultdict(int)
for i in A:
  D[i]+=1
for _ in range(M):
  a, b = map(int,input().split())
  D[b]+=a
D_sorted = sorted(D.items(), key=lambda x:x[0], reverse = True)
ans = 0
count = 0
for x, c in D_sorted:
  if count+c < N:
    ans+=x*c
    count+=c
  else:
    ans+=x*(N-count)
    break
print(ans)
# Judge status: Accepted
l=list(map(int,input().split()))
for i in range(5):
    if l[i]==0:
        print(i+1)
        break
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
import bisect
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        k = bisect.bisect_left(L,a+b)
        l = bisect.bisect_left(L,b-a)
        ans += k-max(j+1,l)
print(ans)
# Judge status: Wrong Answer
S = input()

def check_2019(txt):
  amari = int(txt) % 2019
  if amari == 0:
    return True
  else:
    return False

N = len(S)

ans = 0

i = 0
j = i + 3

while(i <= N):
  j = i + 3
  while(j <= N):
    if check_2019(S[i:j]):
      ans += 1
      i = j
      break
    j += 1
  i += 1

print(ans)
# Judge status: Wrong Answer
c = list(map(int, input().split()))
n, d = c[0], c[1]

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

print(x, y)

count = 0

for l in range(n-1):
    a = x[l]*x[l] + y[l]*y[l]
    if a <= d*d:
        count += 1
print(count)
# Judge status: Wrong Answer
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    if s[i] == "#" and s[i+1] == ".":
        ans += 1
print(ans)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())
ans = 0
if c < a and c < b:
  ans += c * max(x, y)*2
  print(ans)
  exit()
if (c-a+c-b) > 0:
  ans += a*x + b*y
else:
  s = min(x, y)
  ans += min(c*s*2 + min(a, b)*(max(x, y) - s), c*max(x, y)*2)
print(ans)
# Judge status: Wrong Answer
Moji = input().split()
Ball = input().split()
Takahasi = input()

if Moji == Takahasi:
  print(int(Ball[0])-1,int(Ball[1]))
else:
  print(int(Ball[0]),int(Ball[1])-1)
# Judge status: Accepted
S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        L[i]=max(L[i+1]+1,L[i])
print(sum(L))
# Judge status: Wrong Answer
N, K = map(int, input().split())
listp = list(map(int, input().split()))
listans1 = []
for n in range(N-K+1):
    b = sum(listp[n:n+K])
    listans1.append(b)
print(listans1) 
print((max(listans1)+K)/2)
# Judge status: Accepted
N, R = tuple(int(n) for n in input().split())

print(R + max(0, 100*(10-N)))
# Judge status: Wrong Answer
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1): 
        
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==m**2:
            c+=1
if c>0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A,B,C = map(int,input().split())
if A == B and  B == C and C == A:
  print(-1 if A%2==0 else 0 )
else:
  count = 0
  while(A%2==0 and B%2 == 0 and C%2==0):
    A_ = A
    B_ = B
    A = (B+C)/2
    B = (A_+C)/2
    C = (A_+B_)/2
    count+=1
  print(count)
# Judge status: Accepted
X, Y = map(int, input().split())
ans_list = []
ans_list.append(X)
while(1):
    temp = ans_list[-1]*2
    if temp<=Y:
        ans_list.append(temp)
    else:
        break
print(len(ans_list))
# Judge status: Accepted
a, b, c = map(int, input().split())

if a == b + c or b == a + c or c == a + b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
R = lambda: map(int, input().split())
n, k = R()
print(sum(sorted(R())[:n - k]))
# Judge status: Wrong Answer

def count(s):
	c=0
	
	for i in range(len(s)-1):
		if s[i+1] == s[i]:
			c += 1
	return c
	
n, k = map(int, input().split())
s = input()
a = [str(c) for c in s]
cmax = n-1
p = count(a)
while k>0:
	if p == cmax:
		break
	if p == cmax +1:
		break
	if p <=cmax:
		p += 2
		k -= 1
		
print(p)
# Judge status: Wrong Answer
s = input()
for a in range(len(s)):
  if s[a]=='A':
    break
s = s[::-1]
for z in range(len(s)):
  if s[z] =='Z':
    break
s= s[::-1]
print(s[a:-z+1])
# Judge status: Accepted
n = int(input())
A = list(input())

B = [0]
for i in A:
    if i == "I":
        B.append(B[-1] + 1)
    else:
        B.append(B[-1] - 1)
print(max(B))
# Judge status: Wrong Answer
a, b = map(int, input().split())

print(min(a, b))
# Judge status: Wrong Answer
s = input()
D = ['dream', 'dreamer']
E = ['erase', 'eraser']
T = ['dream', 'dreamer', 'erase', 'eraser']

if s[0] == 'd':
    for d in D:
        for t in T:
            if s == d+t:
                print('YES')
                exit()

if s[0] == 'e':
    for e in E:
        for t in T:
            if s == e+t:
                print('YES')
                exit()

print('NO')
# Judge status: Accepted
a,b,c,d = map(int, input().split())

ans = max(a*c,a*d, b*c,b*d)
print(ans)
# Judge status: Accepted
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M,K = MI()
a = sum(K == i*(M-j)+j*(N-i) for i in range(N+1) for j in range(M+1))
print('Yes' if a != 0 else 'No')
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())
S = input()

left = [] 

for i, s in enumerate(S):
    if s == "(":
        left.append("(")
    else:
        if len(left) > 0:
            left.pop()
        else:
            S = "(" + S

for _ in range(len(left)):
    S += ")"

print(S)
# 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
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
print(abs(((N-2)*(M-2))))
# Judge status: Accepted
#python3

def main():
    n,r = map(int, input().split())
    if n>=10:
        print(r)
    else:
        print(r+100*(10-n))
main()
# Judge status: Accepted
d,n=map(int,input().split())
if n==100:n+=1
print(100**d*n)
# Judge status: Accepted
K, A, B = map(int, input().split())

if A+2>=B:
    ans = 1+K
else:
    k = K-A+1 #初回にA枚まで増やした後の回数
    ans = A + k//2 * (B-A)
    if k%2:
        ans += 1
print(ans)
# Judge status: Accepted
ab = input().split()
a, b = int(ab[0]), str(ab[1])
c = int(b[0]) * 100 + int(b[2]) * 10 + int(b[3]) 
print(a * c // 100)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
min=200001
ans=0
for x in p:
  if min>x:
    min=x
    ans+=1
    if x==1:
      break

print(ans)
# Judge status: Accepted
# coding: utf-8
from math import pi
r = int(input())
print(2 * pi * r)
# Judge status: Accepted
#!/usr/bin/env python

x, y = map(int, input().split())
tmp = x 

if x%y == 0:
    print(-1)
    exit()

while True:
    x += tmp 
    if x%y != 0:
        print(x)
        exit()
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
if b >= c:
    if a >= c:
        print(b - c)
    else:
        print((b - c) - (c - a))
else:
    print(0)
# Judge status: Accepted
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

if sum(c1)+sum(c2)+sum(c3) == 3*(c1[0]+c2[1]+c3[2]):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,X = I()
if X < A:
    print('NO')
elif A+B < X:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
count=0

newp=sorted(p)
for i in range(len(newp)):
  ans1=p[i]
  ans2=newp[i]
  if ans1!=ans2:
    count+=1
    
if count==2 or newp==p:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
i = [int(input()) for i in range(4)]
A=i[0]
B=i[1]
C=i[2]
X=i[3]

cnt=0
for a in range(A):
    if 500*a >X:
        break
    else:
        for b in range(B):
            if 500*a + 100*b >X:
                break
            elif (X-500*a-100*b)/50<=C:
                cnt+=1
            else:
                continue
print(cnt)
# Judge status: Accepted
'''Author- Akshit Monga'''
list=[0 for i in range(10**4+1)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            var=x**2 +y**2 +z**2 +x*y +y*z +z*x
            if var<=10**4:
                list[var]+=1
            
n=int(input())
for i in range(1,n+1):
    print(list[i])
# Judge status: Accepted
n = int(input())
for i in range(n//4+1):
    for j in range(n//7+1):
        if 4*i + 7*j == n:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(N-1):
    if A[i]<A[i+1]:
        if money >= A[i]:
            kabu = money//A[i]
            money = money%A[i]
    elif A[i]>A[i+1]:
        if kabu > 0:
            money += kabu*A[i]
            kabu = 0
if kabu>0:
    money += kabu*A[-1]
print(max(money,1000))
# Judge status: Accepted
import sys


N,M=map(int,input().split())
A=[sys.stdin.readline().strip() for _ in range(N)]
B=[sys.stdin.readline().strip() for _ in range(M)]

for i in range(N-M+1):
  for j in range(N-M+1):
    As=[x[i:i+M] for x in A[j:j+M]]
    if B==As:
      print('Yes')
      sys.exit()
print('No')
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))

l=[0]*((10**5)+2)

for v in a:
    l[v]+=1
    l[v+1]+=1
    l[v+2]+=1

print(max(l))
# Judge status: Accepted
def solve():
  x, y = map(int, input().split())
  if y==0:
    return abs(x)+(x>0)
  if x==0:
    return abs(y)+(y<0)
  if y<x and x<0:
    return abs(abs(y)-abs(x))+2
  if x>y and y>0:
    return abs(abs(y)-abs(x))+2
  return abs(abs(y)-abs(x))+(x*y<0)
print(solve())
# Judge status: Accepted
x,a,b = [int(x) for x in input().split()]

if a-b >= 0:
    print("delicious")
elif b-a > 0 and b-a <= x:
    print("safe")
else:
    print("dangerous")
# Judge status: Wrong Answer
# 符号が同じ 
# -> x <= y なら差分だけ1足すだけ
#    x > y なら差分だけ1足して2回反転
# 符号が違う
# -> x <= yなら絶対値の差分だけ1足して、1回反転
#    x > yなら絶対値の差分だけ1足して、1回反転

import sys
readline = sys.stdin.readline

x,y = map(int,readline().split())

if x * y >= 0:
  print(abs(x - y) + (x > y) * 2)
else:
  print(abs(abs(x) - abs(y)) + 1)
# Judge status: Accepted
S = input()
s_set = set()
for s in S:
  s_set.add(s)
if len(s_set) == 4:
  print('Yes')
elif len(s_set) == 2 and (('W' in s_set and 'E' in s_set) or \
('S' in s_set and 'N' in s_set)):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input())
p = list(map(int, input().split()))
ans = 0
q = []
for i in range(N):
  if i+1 == p[i]:
    q += [0]
  else:
    q += [1]

for i in range(N-1):
  if (q[i+1] == 1 and q[i] == 0):
    ans += 1
    q[i] = 1
  elif (q[i+1] == 0 and q[i] == 1):
    ans += 1
    q[i+1] = 1
  elif q[i+1] == 0 and q[i] == 0:
    ans += 1
    q[i+1] = 1
    q[i] = 1
print(ans)
# Judge status: Accepted
A,B= map(int, input().split())
print(A*B)
# Judge status: Accepted
A,B,C,D = map(int,input().split())
while True:
  C = C - B
  if C <= 0:
    print('Yes')
    break
  A = A - D
  if A <= 0:
    print('No')
    break
# Judge status: Accepted
A=list(input())
B=list(input())
A.sort()
B.sort(reverse=True)
C = [A,B]
C.sort()
if "".join(B) == "".join(C[1]) and A != B:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
X,Y = map(int, input().split())

var=Y-2*X
var2=var/2
print(var2)
if  var2.is_integer()==True:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
print(sum(arr[:k]))
# Judge status: Wrong Answer
import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]

B.sort(key=lambda B:B[1],reverse=True)
heapq.heapify(A)

for i in range(M):
    for j in range(B[i][0]):
        if A[0] < B[i][1]:
            heapq.heappop(A)
            heapq.heappush(A,B[i][1])
            print(A)
        else:
            break

print(sum(A))
# Judge status: Wrong Answer
import math

x,y = map(int,input().split(" "))

n = int(math.log2(y/x))

print(n+1)
# Judge status: Accepted

n,m = map(int,input().split())
 
lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい
 
for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
 
 
if set(lis[-1]).isdisjoint(set(lis[0])): #交叉しているか？
    print('IMPOSSIBLE')
else:
  print('POSSIBLE')
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
import numpy.random as random
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    # D = 365
    #お試し
    random.seed(2020)
    D = int(readline())
    C = list(map(int, readline().split()))
    S = list(list(map(int, readline().split())) for _ in range(D))

    for _ in range(D):
        print(random.randint(1,26))


if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c = map(int, input().split())

if a == b and b == c:
    print(1)
elif a == b and b != c:
    print(2)
elif a != b and b == c:
    print(2)
elif a == c and a != b:
    print(2)
elif a != b and b != c:
    print(3)
# Judge status: Accepted
N = int(input())
S = input()

cumdots = [0] * (N+1)

for i in range(N):
  cumdots[i+1] = cumdots[i] + (1 if S[i]=="." else 0)
  
#print(cumdots)

hands = N+1
for i in range(N):
  #i番目までをdot, i+1番目からsharpとする
  leftops = i - cumdots[i]
  rightops = cumdots[N] - cumdots[i+1]
  hands = min(hands, leftops + rightops)
  
print(hands)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=A.copy()
for i in range(N):
    if A[i]-B[i]>=0:
        A[i]=A[i]-B[i]
    elif A[i]+A[i+1]-B[i]>=0:
        A[i+1]=A[i]+A[i+1]-B[i]
        A[i]=0
    else:
        A[i]=0
        A[i+1]=0
#print(A)
print(sum(ans)-sum(A))
# Judge status: Wrong Answer
count = 0
input_str1 = input()
input_str2 = input()
for i in range(len(input_str1)):
    if input_str1[i]!=input_str2[i]:
        count += 1
# Judge status: Accepted
a, b = map(int, input().split())
print((a + b + 1) // 2)
# Judge status: Wrong Answer
import math
X, Y = map(int, input().split())
ans = math.ceil(math.log2(Y/X))
if Y % X == 0:
  print(ans+1)
else:
  print(ans)
# Judge status: Accepted
N = input()
if N[0] == "9":
    if N[1:] == "9"*len(N[1:]):
        print(9*len(N))
    else:
        print(9*len(N)-1)
else:
    if N[1:] == "9"*len(N[1:]):
        print(int(N[0]) + 9*len(N[1:]))
    else:
        print(int(N[0]) + 9*len(N[1:]) - 1)
# Judge status: Accepted
n=int(input())
a=map(int,input().split())
a=sorted(a)
a=list(reversed(a))
h,w=0,0
tmp=0
f=0
for x in a:
    if tmp==x:
        if w!=0:
            h=x
            break
        else:
            w=x
            tmp=0
            continue
    tmp=x
print(w*h)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0: ans += i
print(ans)
# Judge status: Accepted
n=int(input())
c=list(map(int, input().split()))
d = c[1:]
k = 1000

for i in range(n-1):
    if c[i] >= d[i]:
        pass
    if c[i] < d[i]:
        l = k//c[i]
        k -= c[i]*l
        k += l*d[i]

print(k)
# Judge status: Accepted
s = input()

now_try = 0
idx = 0
while idx < len(s) - 1:

    if s[idx] == 'T':
        idx += 1
        continue

    if s[idx] == 'S':
        if s[idx + 1] == 'T':
            s = s[:idx] + s[idx + 2:]
            now_try += 1
            idx = idx - 1 if idx - 1 >= 0 else 0
        else:
            idx += 1

print(len(s))
# Judge status: Accepted
a,b,c = map(int,input().split())
if a**2+b**2==c**2:
    ans = a*b//2
elif a**2+c**2==b**2:
    ans = a*c//2
else:
    ans = b*c//2
print(ans)
# Judge status: Accepted
N = int(input())

for i in range(30):
  for j in range(30):
    if 4*i + 7*j == N:
      print("Yes")
      exit()

print("No")
# Judge status: Accepted
A, B = input().split()
a = int(A)
b = round(float(B) * 100)
c = a * b // 100
print(c)