peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# AtCoder
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]

m = sorted(l, key=lambda x: x[0])
work = 0
mx = 0
for i in range(N):
    mx = max(m[i][1], mx)

for i in range(N):
    work += m[i][0]
    if work > mx:
        print('No')
        exit()

print('Yes')
# Judge status: Wrong Answer
from sys import stdin, stdout

s = stdin.readline().strip('\n')
al = [True for i in range(26)]
for i in s:
  al[ord(i) - 97] = False
for i in range(97, 113):
  if al[i - 97]:
    stdout.write(str(chr(i)) + '\n')
    break
else:
  stdout.write('None\n')
# Judge status: Accepted
from fractions import gcd

A,B = [int(zz) for zz in input().split()]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

x = gcd(A,B)

print(len(set(prime_factorize(x)))+1)
# Judge status: Accepted
char = input()
if char.islower():
  print('a')
else:
  print('A')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i%2 == 1 and A[i]%2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp=1
        for k in range(m):
            for l in range(m):
                # print(i+k,j+m)
                if a[i+k][j+l]!=b[k][l]:
                    tmp=0
        if tmp==1:
            print("Yes")
            quit()
print("No")
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    X, Y, TX, TY = map(int, input().split())
    DX = TX - X
    DY = TY - Y
    result = ''
    result += 'U' * DY + 'R' * DX
    result += 'D' * DY + 'L' * DX
    result += 'L' + 'U' * (DY + 1) + 'R' * (DX + 1) + 'D'
    result += 'R' + 'D' * (DY + 1) + 'L' * (DX + 1) + 'U'
    print(result)


if __name__ == "__main__":
    main()
# Judge status: Accepted
H, N = map(int, input().split())
INF = 10**9
dp= [INF for _ in range(H+1)]

dp[0] = 0

for i in range(N):
  a, b = map(int, input().split())
  for j in range(H):
    if j+a > H:
      dp[H] = min(dp[H], dp[j] + b)
    else:
      dp[j+a] = min(dp[j+a], dp[j] + b)
print(dp[H])
# Judge status: Accepted
n = int(input())
for i in range(1,10):
    if 1 <= n//i <= 9 and (n/i).is_integer():
        print('Yes')
        exit()
print('No')
# Judge status: Wrong Answer
import sys

N = list(map(int, input().split()))
print(N)
A = list(map(int, input().split()))
print(A)

for x in A:
    if (x % 2 == 0) and ((x % 3 != 0) and (x % 5 != 0)):
        print('DENIED')
        sys.exit()

print ('APPROVED')
# Judge status: Wrong Answer
a, b = list(map(int, input().split()))
c = a % b
if a <= b:
  my_result = 1
else:
  my_result = (a - c) / b + 1
print(int(my_result))
# Judge status: Accepted
import numpy as np
from numba import jit
N = int(input(''))
A1 = np.array(list(map(int, input('').split(' '))))

@jit(nopython=True)
def func(A):
    step = 0
    for k in range(0,N-1):
        if A[k] > A[k+1]:
            add = A[k] - A[k+1]
            step += add
            A[k+1] += add
    return step
        
print(func(A1))
# Judge status: Accepted
a,b,x=map(int,input().split())
ans = 0
if a % x == 0:
  ans += 1
b //= x
a //= x
ans += b - a
print(ans)
# Judge status: Accepted
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        res = 0
        for a, b, c, d in X:
            if x[b] - x[a] == c:
                res += d
        return res

    res = 0
    x.append(x[-1])
    while x[-1] <= M:
        res = max(res, dfs(x))
        x[-1] += 1
    x.pop()

    return res

print(dfs([1]))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
s = sorted([a,b,c])
if s[0] == s[1] and s[1] != s[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
N = int(input())
S = []
ans = 0
count = 1
for _ in range(N):
    s = list(input())
    s.sort()
    S.append(''.join(s))
S.sort()
S.append('a')

for i in range(N):
    if S[i] == S[i+1]:
        count += 1
    else:
        if count > 2:
            ans += math.factorial(count)//(math.factorial(count-2)*math.factorial(2))
        elif count == 2:
            ans += 1
        count =1

print(ans)
# Judge status: Accepted
dp = [0, 2]
for d in map(int, reversed(input())):
    dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]

print(min(dp[0], 1 + dp[1]))
# Judge status: Accepted
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s2 <= 12:
        print("YYMM")
    else:
        print("NA")
# Judge status: Accepted
L, R = map(int, input().split())

num = 0
ans = (L * (L + 1)) % 2019
if (R - L) > 2020:
    ans = 0
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                break
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
a = list(map(int, input().split()))
M = sum(a)
if M > n:
    print(-1)
    quit()
else:
    print(n-M)
# Judge status: Wrong Answer
n, x = map(int, input().split())
data = [0] + list(map(int, input().split()))
count = 0
tmp = 0
for d in data:
    tmp += d
    if tmp < x:
        count += 1
    # print(tmp)

print(count)
# Judge status: Wrong Answer
N=int(input())
S=input()
l,r=0,N-1
ans=0
f=0
while l<r:
  while S[l]=='R':
    l+=1
    if l==N:
      f=1
      break
  while S[r]=='W':
    r-=1
    if r==-1:
      f=1
      break
  if f==1:
    break
  ans+=1
  l,r=l+1,r-1
print(ans)
# Judge status: Accepted
N, T = map(int, input().split())
c_t_list = [list(map(int, input().split())) for _ in range(N)]
c_t_list = [c_t for c_t in c_t_list if c_t[1] <= T]
if c_t_list:
    print(sorted(c_t_list)[0][0])
else:
    print('TLE')
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for _ in range(n)]

ans, tmp = 0, 0
for ai in a:
    ans += (ai + tmp) // 2
    tmp = ai % 2
print(ans)
# Judge status: Accepted
a,b,c = map(int, input().split())
print('Yes' if a + b == c or b + c == a or c + a == b else 'No')
# Judge status: Accepted
a,b,c = map(int,input().split())
ans = 0
if b // a >= c:
    ans = c
else:
    ans = b // a

print(ans)
# Judge status: Wrong Answer
def solve(s, t):
    start = -1
    for i in range(len(s) - len(t)):
        if all(s[len(s) - len(t) - i + j] in (t[j], '?') for j in range(len(t))):
            start = i
            break
    if start >= 0:
        return s[:len(s) - len(t) - start].replace('?', 'a') + t + s[len(s) - start:].replace('?', 'a')
    else:
        return 'UNRESTORABLE'

_s = input()
_t = input()
print(solve(_s, _t))
# Judge status: Accepted
n = int( input() )
s = []
for _ in range( n ):
    s.append( input() )

for i in range( n ):
    s[i] = "".join( sorted( s[i] ) )

found = {}
cnt = 0
for s_i in s:
    if s_i in found:
        found[ s_i ] = found[ s_i ] + 1
    else:
        found[ s_i ] = 0

for key in found:
    c = found[key]
    cnt = cnt + c * ( c + 1 ) // 2

print( cnt )
# Judge status: Accepted
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
p=0
for i in range(1,n+1):
    #print(a1[:i]+a2[i-1:])
    p=max(p,sum(a1[:i]+a2[i-1:]))
print(p)
# Judge status: Wrong Answer
n, m = map(int, input().split())

k0 = list(map(int, input().split()))
k0.pop(0)
le = len(k0)
aut = []

for i in range(n-1):
    ka = list(map(int, input().split()))
    ka.pop(0)
    for j in range(le):
        num = k0[j]
        if num not in ka:
            aut.append(num)

print(le-len(aut))
# Judge status: Wrong Answer
k = int(input())
a, b = list(map(int, input().split()))

for i in range(a, b):
    if i % 7 == 0:
        print('OK')
        exit()
print('NG')
# Judge status: Accepted
n, k = map(int, input().split())
ans = 0
for i in range(1,n+1):
  point = i
  cnt = 0
  while point <= k-1:
    point = point*2
    cnt += 1
  ans += (1/n) * (1/2)**cnt
print(ans)
# Judge status: Accepted
import string
import collections
a_prime=[]
b_prime=[]
a,b = map(int, input().split())
def getPrime(a):
  prime=[]
  for i in range(2,int(a**0.5//1)+1):
    if a%i==0:
      while a%i == 0:
        a=a//i
      prime+=[i]
  if a!=1:
    prime.append(a)

  return prime
a_prime=getPrime(a)
b_prime=getPrime(b)
print(len(set(a_prime) & set(b_prime))+1)
# Judge status: Accepted
import sys
input = sys.stdin.readline
n = int(input())
As = [int(input()) for i in range(n)]

ans = 0
for i in range(n-1):
    ans += As[i] // 2 
    As[i] = As[i] % 2
    if As[i] == 1 and As[i+1] > 0:
        As[i+1] -= 1
        ans += 1
ans += As[n-1]//2    

print(ans)
# Judge status: Wrong Answer

s=list(input())
s.sort()
print("Yes" if s[0]==s[1] and s[2]==s[3] else "No")
# Judge status: Wrong Answer


def solution(h):
    n = len(h)
    INF = float('inf')
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in range(i+1,i+3):
            if j < n:
                dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) )
    print(*dp)
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res,end="\n")
# Judge status: Accepted
n = input()
if n[0] == '9' or n[1] == '9':
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n= int(input())
task = [list(map(int,input().split()))for i in range(n)]

task.sort(key= lambda x:x[1])
time = 0
for a,b in task:
    time += a
    if time > b:
        print("No")
        break
    else:
        print("Yes")
# Judge status: Accepted
N,Y = map(int, input().split())

for x in range(2001):
    for y in range(2001):
        z = N-x-y
        if z<0:
            break
        temp = x*10000+y*5000+z*1000
        if temp==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)
# Judge status: Accepted
n = int(input())

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

cnt = 0

for i in range(1, n+1):
    cnt += (i%2==1) and (a[i-1]%2==1)

print(cnt)
# Judge status: Accepted
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A = [min(8, a // 400) for a in A]
CA = Counter(A)
num = 0
for i in range(8):
    if CA[i]:
        num += 1

num_8 = CA[8]
saidai = num + num_8

saisho = max(1, num)
print(saisho, saidai)
# Judge status: Wrong Answer
print('Yes' if sorted(input())=='abc' else 'No')
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
 
a.sort(reverse=True)
 
print(sum(a[::2])-sum(a[1::2]))
# Judge status: Accepted
s=str(input())
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
# AGC 025: A – Digits Sum
N = int(input())
n = N // 2 if N % 2 == 0 else N // 2 + 1
min_sum = 9999

for i in range(1, n + 1):
    sum_digits = 0
    A = i
    B = N - i

    while A != 0:
        sum_digits += A % 10
        A //= 10
    
    while B != 0:
        sum_digits += B % 10
        B //= 10
        
    min_sum = min(min_sum, sum_digits)

print(min_sum)
# Judge status: Accepted
N, K = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
MIN = 10 ** 10
for i in range(N-K+1):
    if x[i+K-1] <= 0:
        MIN = min(MIN, -1 * x[i])
    elif 0 <= x[i]:
        MIN = min(MIN, x[i+K-1])
    else:
        MIN = min(MIN, -1 * x[i] + x[i+K-1] + min(-1 * x[i], x[i+K-1]))
print(MIN)
# Judge status: Wrong Answer
n,m,x,y = map(int,input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
a = max(x)
b = min(y)
if(a < b):
  print("No War")
else:
  print("War")
# Judge status: Wrong Answer
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
def main():
    n=I()
    trans=[I(),I(),I(),I(),I()]
    trans.sort()
    print(n//trans[0]+5)
    

if __name__ == '__main__':
    main()
# Judge status: Accepted
icase=0
if icase==0:
    n,t=map(int,input().split())
    ct=[]
    for i in range(n):
        ci,ti=map(int,input().split())
        if ti<=t:
            ct.append([ci,ti])
    if len(ct)==0:
        print("TLE")
    else:
        ct.sort()
        print(ct[0][0])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))#モンスターの数
b = list(map(int,input().split()))#勇者が倒せる数

count = 0
for i in range(n):
	if b[i] > a[i]:
		count += a[i]
		b[i] = b[i]-a[i]
		a[i] = 0
		count += min(b[i],a[i+1])
		a[i+1] = a[i+1] - min(b[i],a[i+1])
	else:
		count += b[i]

print(count)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("YES") if b-a==c-b else print("NO")
# Judge status: Accepted
S = input()

flg = 0
while flg==0:
    if S[len(S)-5:]=="dream":
        S = S[:len(S)-5]
    elif S[len(S)-7:]=="dreamer":
        S = S[:len(S)-7]
    elif S[len(S)-5:]=="erase":
        S = S[:len(S)-5]
    elif S[len(S)-6:]=="eraser":
        S = S[:len(S)-6]
    else:
        flg = 1
    if len(S)==0:
        flg = 0
        break
if flg==0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
K = int(input())
S = input()

s_l = len(S)
if s_l > K:
  print(S[0:7] + "...")
else:
  print(S)
# Judge status: Accepted
s=input()
if s=='Sunny':
	print('Cloudy')
elif s=='Rainy':
	print('Sunny')
else:
	print('Rainy')
# Judge status: Wrong Answer
def magic_2():
    a,b,c = map(int, input().split())
    k = int(input())
    my_list = [b,c]
    i = 0
    while i <= k-1:
        multiply_list = [items * 5 for items in my_list]
        i += 1
    new_list = [a] + multiply_list
    if new_list[0] < new_list[1] < new_list[2]:
        print("yes")
    else:
        print("No")
   
magic_2()
# Judge status: Wrong Answer
W,N = list(map(int,input().split()))
table = []
for i in range(N):
    x = list(map(int,input().split()))
    table.append(x)    
dp = [[-1]*(W+1) for i in range (N+1)]
for i in range(W):
    dp[N][i] = 0
for i in range(N-1,-1,-1):
    for j in range(W+1):
        if j < table[i][1]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-table[i][1]]+table[i][0])
print(dp[0][W])
# Judge status: Wrong Answer
l = [x for x in input().split(' ')]
l = sorted(l)
print(''.join(l))
# Judge status: Accepted
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

alphas = [chr(x) for x in range(65, 65 + 26)]

new = str()

for i in range(len(s)):
    aI = alphas.index(s[i])
    if aI + n >= 26:
        b = aI + n - 26
        new += alphas[b]
    else:
        new += alphas[aI + n]

print(new)
# Judge status: Wrong Answer
n = int(input())
a = [x-i for i, x in enumerate(list(map(int, input().split())))]


b1 = sum(a)//len(a)


def ceil(a, b):
    return -(-a // b)


b2 = ceil(sum(a), len(a))
ans1 = 0
ans2 = 0

for aa in a:
    ans1 += abs(aa-b1)
    ans2 += abs(aa-b2)
print(min(ans1, ans2))
# Judge status: Accepted
x = int(input())

num_min = x//105
num_max = x//100

for i in range(num_min, num_max+1):
    if x - 100*i <= 5*i:
        print(1)
        exit()
        
print(0)
# Judge status: Accepted
import math
a=[[0,0] for i in range(5)]
for i in range(5):
    a[i][0]=int(input())
    a[i][1]=abs(10*math.ceil(a[i][0]/10)-a[i][0])
a2=sorted(a,key=lambda x:x[1])
ans=0
for i in range(4):
    ans+=10*math.ceil(a2[i][0]/10)
ans+=a2[4][0]
print(ans)
# Judge status: Wrong Answer
N, K = map(int,input().split())
li_ = []
for i in range(K):
    d = int(input())
    li_ += list(map(int,input().split()))
    print(li_)
print(N -len(set(li_)))
# Judge status: Accepted
# 2020/04/28
# CODE FESTIVAL 2017 qual - B

# Input
n, m, k = map(int,input().split())

# Calc
ans = 'No'
eflg = False
for i in range(n+1):
    for j in range(m+1):
        pt = i * (m - j) + j * (n - i)
        if pt == k:
            ans = 'Yes'
            eflg = True
            break
    if eflg:
        break

# Output
print(ans)
# Judge status: Wrong Answer
num = input().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])
if a >= 1 and c >= 1:
  print(b * d)
elif a <= 0 and c <= 0:
  print(a * c)
elif b <= 1:
  print(b * c)
elif d <= 1:
  print(a * d)
# Judge status: Accepted
S=input()
L=len(S)//2-1
while S[:L]!=S[L:2*L]:
    L-=1
print(2*L)
# Judge status: Accepted
s=input()
count=0
for i in range(len(s)//2):
    if s[i]!=s[-i-1]:
        count+=1
print(count)
# Judge status: Accepted
H, A = map(int, input().split())

c = 0
while H > 0:
    H -= A
    c += 1

print(c)
# Judge status: Wrong Answer
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    mul4 = len([a for a in A if a % 4 == 0])
    mul2 = len([a for a in A if a % 4 != 0 and a % 2 == 0])
    less = N - 3*mul4
    print(mul4, mul2, less)
    if less <= 0:
        print("Yes")
    elif less == 1 and 2 <= mul2:
        print("Yes")
    elif 2 <= less <= mul2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

D = []
for i in range(N):
    Da,Db = (map(int,input().split()))
    if Da == Db:
        D.append(1)
    else:
        D.append(0)

for i in range(N-2):
    if D[i]==1 and D[i+1] == 1 and D[i+2] == 1:
        ans = "Yes"
        break
    else:
        ans = "No"
print(ans)
# Judge status: Wrong Answer
n,m = map(int, input().split())
arr = list(map(int, input().split()))

total = sum(arr)

ans =0
for i in arr:
    if (4*m*i)>=total:
        ans+=1

if ans>m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
s = input()
peak = [0]
x = 0
for i in range(n):
  if s[i] == "I":
    x += 1
    peak.append(x)
    
  elif s[i]=="D":
    x -= 1
    peak.append(x)

peak.sort()
print(peak[-1])
# Judge status: Accepted
def main():
    x, y, a, b, c = map(int, input().split())
    p = list(sorted(list(map(int, input().split())), reverse=True))[:x]
    q = list(sorted(list(map(int, input().split())), reverse=True))[:y]
    r = list(map(int, input().split()))
    print(sum(list(sorted(p+q+r, reverse=True))[:(x+y)]))
if __name__ == "__main__":
    main()
# Judge status: Accepted
s=int(input())
a=[]*1000000
a+=[s]
def F(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

for i in range(1,1000000):
    a.append(F(a[i-1]))
    if a[i] in a[:i]:
        ans=i+1
        break 

print(ans)
# Judge status: Accepted
#ABC167-B
a,b,c,k=map(int,input().split())
if a>k:
  print(k)
elif a+b>=k>=a:
  print(a)
else:
  print(a+(a+b-k))
# Judge status: Accepted
d,n=map(int,input().split())
if n==100:
    if d==0:
        print("101")
    elif d==1:
        print("10100")
    else:
        print("1010000")
else:
    print(100**d*n)
# Judge status: Wrong Answer
x = str(input())
print(x.swapcase())
# Judge status: Accepted
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
if N==2 or M==2:
    print(0)
    exit()
if N==1 and M==1:
    print(1)
    exit()
if N==1 or M==1:
    print(max(N,M)-2)
    exit()
print((N-2)*(M-2))
# Judge status: Accepted
X, A, B = map(int, input().split())
if B <= A:
  print('delicious')
elif B <= A + X:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
S=input()

stack=[]
cnt=0
for s in S:
    if not stack:
        stack.append(s)
    elif s!=stack[-1]:
        stack.pop()
        cnt+=2
    else:
        stack.append(s)
        
print(cnt)
# Judge status: Accepted
a, b = map(int, input().split())

if (a*b) % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = list(input())

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    ok = False
    for i in range(b, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')
# Judge status: Wrong Answer
N, L = map(int, input().split())
S_i = [input() for i in range(N)]
s = sorted(S_i)
m = ""
for x in s:
    m += x
    print(m)
# Judge status: Accepted
N, M = map(int, input().split())
if N>M:
    N, M = M, N

ans = 0
if N==1:
    if M==1:
        ans = 1
    else:
        ans = M-2
else:
    ans = (N-2) * (M-2)

print(ans)
# Judge status: Accepted
S = input()
 
for i in range(7):
	if S[:i] + S[i-7:] == "keyence":
		print("YES")
		exit()
print("NO")
# Judge status: Accepted
# ABC 053: B – A to Z String
s = input()
start = s.index('A')
end = s[::-1].index('Z')
print(len(s[start:len(s) - end]))
# Judge status: Wrong Answer
n = int(input())
tot = n//11
rem = n%11
tot = tot*2
if rem<=6:
	print(tot+1)
else:
	print(tot+2)
# Judge status: Wrong Answer
import math

delta=180-int(input())
theta=0
btdt=[]
count=0
while(theta not in btdt):
    btdt.append(theta)
    theta=(theta+delta)%360
    count+=1
print(count)
# Judge status: Accepted
k=int(input())
print((k//2)**2 if k&1!=1 else (k+1)//2 * ((k+1)//2-1))
# Judge status: Accepted
a, b, c = map(int, input().split())
cnt = 1
while b >= cnt:
    if (a*cnt) % b == c:
        print('YES')
        exit()
    
    cnt += 1
print('NO')
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

print('R' * dy + 'U' * dy + 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U' * (dy + 1) + 'R' * dy + 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R')
# Judge status: Accepted
n = int(input())

ans, tmp = 0, 5
if n % 2 == 0:
    n //= 2
    while tmp <= n:
        ans += n // tmp
        tmp *= 5
print(ans)
# Judge status: Wrong Answer
n=int(input())
sum=1
for i in range(n):
  sum*=i
  sum=sum%(10**9+7)
  
print(sum)
# Judge status: Accepted
N,K=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(2*K)]
B=[]
for i in range(K):
    B=B+A[i*2+1]
print(N-len(set(B)))
# Judge status: Wrong Answer
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>=0):
  print(N)
print('-1')
# Judge status: Accepted
import math
n,k = map(int, input().split())

if n==1:
  print(1)
  exit()
  
print(int(math.ceil(math.log(n,k))))
# Judge status: Accepted
def mapt(fn, *args):
    return tuple(map(fn, *args))

def Input():
    return mapt(int, input().split(" "))

def main():
    n = int(input())
    b = Input()
    data = 0
    for i in range(n-1):
        if i == 0:
            data += b[i]
            continue
        data += min(b[i], b[i-1])
    data += b[-1]
    print(data)
main()
# Judge status: Wrong Answer
h,a=map(int, input().split())
a=list(map(int,input().split()))
a_s=sorted(a,reverse=True)

k=0
for i in a_s:
    if(i*2<=h):
        print('No')
        k=-1
        break
    else:
        h-=i
if(k==0):
    print('Yes')
# Judge status: Wrong Answer
n=int(input())
s=input()

t=[]
for i in range(len(s)):
  num=ord(s[i])+n
  if num>122:
    num-=26
  t.append(chr(num))

print("".join(t))
# Judge status: Accepted
N, T = map(int, input().split())
ct = []
for i in range(N):
  tmp = list(map(int, input().split()))
  ct.append(tmp)
ct.sort()

ans = 0
for i in range(len(ct)):
  if ct[i][1] <= T:
    ans = ct[i][0]
    break
if ans == 0:
  print('TLE')
else:
  print(ans)
# Judge status: Accepted
N = int(input())
N2 = int(N/2)
d = [int(x) for x in input().split()]
d.sort()

if d[N2-1] == d[N2]:
  K = 0
else:
  K = d[N2] - d[N2-1]
  
print(K)
# Judge status: Accepted
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    amax = max(a for a, b in ab)
    dp = [0] + [0] * (h + amax)
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,k = map(int, input().split())

for i in range(1000000):
    if k**i >= n:
        print(i)
        break
# Judge status: Wrong Answer
n=int(input())
a=[0]*n
a=map(int,input().split())
    
z=0
p=0
result=0
min=1000000002

for i in a:
    if i<0:
        z+=1
    if i==0:
       p=1 

    i=abs(i)
    result+=i
    if i<min:
        min=i

if p==0 & z//2==1:
    result-=min*2

print(result)