peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,k=map(int,input().split())
d=set(map(int,input().split()))
d_=set((1,2,3,4,5,6,7,8,9,0))
abl=d_-d
ans=''
a0=True
a1=True
for i in str(n):
  if a0 and int(i) in abl:
    ans+=str(i)
  elif a0:
    b=[ai for ai in abl if int(i)<ai]
    if len(b)==0:
      a1=False
      break
    b.sort()
    ans+=str(b[0])
    a0=False
  else:
    ans+=str(min(abl))
if a1==False:
  print(str(min(abl-{0}))+str(min(abl))*len(str(n)))
else:
  print(ans)
# Judge status: Accepted
a,b,t = list(map(int,input().split()))
print(t//a*b)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
if (b-a+1)>n or a>b:exit(print(0))
mi=b+(n-1)*a
ma=a+(n-1)*b
print(ma-mi+1)
# Judge status: Wrong Answer
n = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
tmp = H[0]
for h in H[1:]:
    if h <= tmp:
        cnt += 1
    ans = max(ans, cnt)
    tmp = h
if ans > 0:
    ans -= 1
print(ans)
# Judge status: Accepted
n = int(input())
L = []
for i in range(n):
  a,b = map(int,input().split())
  L.append([a+b,a-b])
L.sort()
ans = 0
right = -10**10
for i in range(n):
  if L[i][1] >= right:
    ans += 1
    right = max(right,L[i][0])
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a>b>c or a<b<c:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N=int(input())
count=0
if N//100000==1:
    count=90909
elif N//10000>0:
    count=N%10000+910    
elif N//1000>0:
    count=909
elif N//100>0:
    count=N%100+10
elif N//10>0:
    count=9
else:
    count=N%10
print(count)
# Judge status: Accepted
x=input()
a=0
ans=0
for i in range(len(x)):
  if x[i]=="T":
    a=a+1
    if a>ans:
      ans=a
  else:
    a=a-1
print(ans*2)
# Judge status: Wrong Answer
a,b = map(int,input().split())
l = [i*(i+1)//2 for i in range(1,101)]
ans = 1

for i in range(100):
  a += 1
  b += 1
  if a in l and b in l:
    print(ans)
    break
  else:
    ans += 1
# Judge status: Accepted
N,Y=map(int,input().split())
answer=0
for n in range(0,N+1):
    for n_ in range(0,N+1-n):
        n__=N-n-n_
        if 10000*n+5000*n_+1000*n__==Y:
            answer=1
            kotae=str(n)+' '+str(n_)+' '+str(n__)
            break
if answer==0:
    print(-1,-1,-1)
else:
    print(kotae)
# Judge status: Accepted
N, K = map(int, input().split(" "))
mod = 10 ** 9 + 7
ans = 0
for k in range(K, N + 2):
    ans += (k * (2 * N + 1 - k) // 2) - (k * (k - 1) // 2) + 1
    ans %= mod
print(ans)
# Judge status: Wrong Answer
a, b, c = [int(x) for x in input().split()] 

if a - b > a - c:
   print("B")
else:
   print("A")
# Judge status: Accepted
x, a, b = list(map(int, input().split()))

if a - b >= 0:
  print('delicious')
elif b - a <= x:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
s = input()
t = input()

cnt = len(s)

if s[:cnt] == t[:cnt]:
    if len(t) == cnt + 1:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
K, X = [int(i) for i in input().split()]
if K*500 >= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#136_B
n=int(input())
print(sum([len(str(i))%2==1 for i in range(1,n+1)]))
# Judge status: Accepted
from decimal import Decimal

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

print(int(a * b))
# Judge status: Accepted
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())

ac = np.zeros(n)
wa = np.zeros(n)

for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == 1:
        continue
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] = 1

acc = 0
wac = 0
for a, w in zip(ac, wa):
    if a == 1:
        acc += 1
        wac += w

print(acc, int(wac))
# Judge status: Wrong Answer
s = list(input())
n = len(s)
res = 0

for i in range(n):
    if s[i] != s[n-1-i]:
        res += 1

print(res)
# Judge status: Wrong Answer
a,b = map(int, input().split())

if (a == 1) :
  if (b == 1):
    print(1)
  else:
    print(b -2)
else :
  print((a-2)*(b-2))
# Judge status: Accepted
a,b,t = map(int,input().split())
print( t//a * b)
# Judge status: Accepted
s = input()
if len(s)==len(set(s)):
    print('yes')
else:
    print('no')
# Judge status: Accepted
h,n=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>=h:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

a, b = 2, 1


for i in range(1, N):
    a, b = b, a + b

print(b)
# Judge status: Wrong Answer
N,M = map(int,input().split())
L = input().split()

L = sorted(L)

total = 0
i = 0
while M > 0 and i < N:
    M -= int(L[0])
    L.pop(0)
    total += 1
    i += 1

print(total)
# Judge status: Accepted
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
t = defaultdict(int)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    t[a]+=1
    t[b]+=1
for j in range(1, n+1):
    print(t[j])
# Judge status: Wrong Answer
a=input()
if a.islower():
    print('B')
else:
    print('A')
# Judge status: Accepted
c = input()
print("vowel" if c in ["a","e","i","o","u"] else "consonant")
# Judge status: Accepted
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    n=int(input())
    s=str(input())

    print(max(len(set(s[:i])&set(s[i:])) for i in range(n)))

resolve()
# Judge status: Accepted
A,B,C,K=map(int,input().split())
if K%2==0:
    val=A-B
    if abs(val)>pow(10,18):
        print("Unfair")
    else:
        print(val)
else:
    val=B-A
    if abs(val)>pow(10,18):
        print("Unfair")
    else:
        print(val)
# Judge status: Accepted
import math
a,b,k = map(int,input().split())

g = math.gcd(a,b)
c = 0
i = 1
for i in range(g,0,-1) :
    if g%i == 0 :
        c+=1
        if c==k :
            break
print(i)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import decimal


if __name__ == "__main__":
    s = input()
    d = ""
    c = ""
    ans = 0
    for i in s:
        d += i
        if d != c:
            c = d
            d = ""
            ans+=1
    print(ans)
# Judge status: Accepted
n = int(input())
ans = [0]*n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            b =  x**2 + y**2 + z**2 + x*y + x*z + y*z - 1
            if b < n:
                ans[b] += 1
for a in ans:
    print(a)
# Judge status: Wrong Answer
from math import sqrt
n=int(input())
k=int(sqrt(n))
ans=0
for c in range(1,n):
  for b in range(1,k):
    if n%b==0:
      ans+=2
    if k*k==n:
      ans+=1
print(ans)
# Judge status: Wrong Answer
N = int(input())
*A, = map(int, input().split())
A = sorted(A, reverse=True)
ans = sum(A[:-1])
print(ans)
# Judge status: Wrong Answer
a, b = map(int,input().split())
a_b = len(str(a))*b
b_a = len(str(b))*a
if a_b <= b_a:
    print(a_b)
else:
    print(b_a)
# Judge status: Wrong Answer
p = list(map(int, input().split()))
n = int(input())
l = []
s = [0.25, 0.5, 1, 2]

l = [[p[0]*4, 0], [p[1]*2, 1], [p[2], 2], [p[3]/2, 3]]
l.sort()


def only1L():
    return min(p[0]*4, p[0]*2+p[1], p[1]*2, p[2])


if (s[l[0][1]] == 2):
    print(int(p[l[0][1]] * (n // s[l[0][1]])) + only1L())
elif (n == 1):
    print(only1L())
else:
    print(int(l[0][0] * (n / s[l[0][1]])))
# Judge status: Accepted
import itertools
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]

def func(A):
    res = 0
    for i in range(Q):
        a,b,c,d = abcd[i]
        a -= 1
        b -= 1
        if A[b]-A[a]==c:
            res += d
    return res

ans = 0
for A in itertools.combinations_with_replacement([i+1 for i in range(M)],N):
    A = list(A)
    A.sort()
    ans = max(ans,func(A))

print(ans)
# Judge status: Wrong Answer
a,b,x = map(int,input().split())


print(b//x - a//x + 1)
# Judge status: Accepted
a,b,c=map(int,input().split())
if max(a,b,c)==a+b+c-max(a,b,c):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def is_month(t):
    return 1 <= int(t) <= 12

s = input()
pre, suf = s[:2], s[2:]

if is_month(pre) and is_month(suf):
    print('AMBIGUOUS')
elif not is_month(pre) and not is_month(suf):
    print('NA')
elif is_month(pre) and not is_month(suf):
    print('MMYY')
else:
    print('YYMM')
# Judge status: Accepted
a, b = map(int, input().split())

ans = 0
for i in range(a, b + 1):
  for j in range(len(str(i))):
    if str(i)[j] != str(i)[(-1) * j - 1]:
      break
  else:
    ans += 1
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
mod = 10**9 + 7

dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1
for i in range(m):
    dp[a[i]] = 0
#print(dp)
for i in range(n-1):
    if dp[i+2] == -1:
        dp[i+2] = (dp[i+1] + dp[i]) % mod
    elif dp[i+2] == 0:
        dp[i+2] = 0
#print(dp)
print(dp[n] % mod)
# Judge status: Accepted
l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=list(input())
A=set(A)
for i in range(26):
    if l[i] in A:
        pass
    else:
        print(l[i])
        exit()
print("None")
# Judge status: Wrong Answer
N, A, B, C, D = (int(i) for i in input().split())  
S = input()

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i <= A-1:
    print('No')
    exit()
  
  if s == '.':
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s
  
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')
# Judge status: Accepted
a,b = map(int,input().split())
mod = 10**9+7
x = (2*a-b)//3
y = (2*b-a)//3

if (2*a-b)%3 != 0 or (2*b-a)%3 != 0 or 2*b < a or 2*a < b or (a+b)%3 != 0:
    print(0)
    exit()

def comb(n,r):
    fact = 1
    invfact = 1
    for i in range(r):
        fact *= n-i
        fact %= mod
        invfact *= i+1
        invfact %=mod
    return fact*pow(invfact,mod-2,mod)%mod

print(comb(x+y,y))
# Judge status: Accepted
import math

def isPrime(y):
  if y == 2 or y == 3:
    return True
  for i in range(2, int(math.sqrt(x) + 2)):
    if y % i == 0:
      return False
  return True

x = int(input())
while not isPrime(x):
  x += 1
print(x)
# Judge status: Accepted
import math

n, k = map(int, input().split())

# for small
score = 0
times = []
for i in range(1, min(n + 1, k)):
    times.append(math.ceil(math.log2((k / i))))

if len(times):
    bottom_max = times[0]
    for t in times:
        score += 2 ** (bottom_max - t)
    score /= 2 ** (bottom_max) * n

# for big
big = [i for i in range(k, max(k, n + 1))]
score += len(big) / n
print('{:.10f}'.format(score))
# Judge status: Accepted
import math
from functools import reduce

N,M=map(int,input().split())
A=[int(x)//2 for x in input().split()]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

LCM=lcm(*A)
for a in A:
  if LCM//a%2==0:
    print(0)
    break
else:
  print((M//LCM+1)//2)
# Judge status: Accepted
n, m = map(int, input().split())
L = sorted([list(map(int, input().split())) for _ in range(n)])
ans = 0
for l in L:
    tmp = min(l[1], m)
    ans += l[0]*tmp
    m -= tmp
    if m == 0:
        break
print(ans)
# Judge status: Accepted
N = int(input())
h = input().split()
h = [int(i) for i in h]
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(1, N-1):
    dp[i+1] = min(dp[i] + abs(h[i]-h[i+1]), dp[i-1] + abs(h[i-1]-h[i+1]))
print(dp[N-1])
# Judge status: Accepted
n = int(input())
 
if n < 1000:
    print('ABC')
else:
    print('ABD')
# Judge status: Accepted
n = int(input())
d = []
for _ in range(n):
    d.append(list(map(int, input().split())))

cnt = 0
for i in d:
    if i[0] == i[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
li = list(map(int,input().split()))
li.sort()
ans = 0
for i in range(2):
    ans = ans + li[i]
else:
    print(ans)
# Judge status: Accepted
import math
import sys
readline = sys.stdin.readline


def main():
    s, w = map(int, readline().rstrip().split())
    print("unsafe" if s <= w else "safe")


if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
A=list(int(x) for x in input().split())
A.sort()
sum = 0
for i in range(N-1):
  k=i+1
  sum+=A[N-int(k/2)-1]
print(sum)
# Judge status: Wrong Answer
a=int(input())
print(a*2+a+a*3)
# Judge status: Wrong Answer
a,b,c=map(int,input().split());print((a//c)*b)
# Judge status: Accepted
n, m, q = map(int, input().split())
e = [list(map(int, input().split())) for i in range(q)]

w = [0]*n
res = 0
def dfs(x, y):
    global w, res
    if x == n:
        tmp = 0
        for a, b, c, d in e:
            if w[b-1]-w[a-1] == c: tmp += d
        res = max(res, tmp)
        return
    for i in range(y, m+1):
        w[x] = i
        dfs(x+1, i)

dfs(0, 1)
print(res)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    flg = False
    idx_A = 0
    idx_Z = -1
    for idx, i in enumerate(s):
        if i == "A" and not flg:
            idx_A = idx
            flg = True

        if i == "Z" and flg:
            idx_Z = idx

    print(max(0, idx_Z - idx_A + 1))


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    m = A.pop()
    B = [[a, abs(a - (m / 2))] for a in A]
    B.sort(key = lambda x: x[1])
    print('{} {}'. format(m, B[0][0]))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = input()
for _ in range(len(s)):
  print('x')
# Judge status: Wrong Answer
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss=set(s)
ans = [1]
for i in ss:
  ans.append(s.count(i)-t.count(i))
print(max(ans))
# Judge status: Accepted
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = [0] * 2
for k, v in a.items():
    if 4 <= v:
        b.append(k)
    if 2 <= v:
        b.append(k)
else:
    b.sort()
    print(b[-1] * b[-2])
# Judge status: Accepted
a, b, c = sorted([int(x) for x in input().split()])
ans = c - b
a += ans
if (c - a) % 2 == 0:
    print(ans + (c - a) // 2)
else:
    print(ans + (c - a) // 2 + 2)
# Judge status: Wrong Answer
L=list(map(int,input().split()))
print('Yes' if sum(L)%2==0 else 'No')
# Judge status: Accepted
s,t = input().split()
a,b = map(int, input().split())
u = input()

if u == s:
    a -= 1
elif u == t:
    b -= 1
print("{} {}".format(a, b))
# Judge status: Wrong Answer
import numpy as np
import sys
import math

# n = map(int,input().split())

ans = 0
n = int(input())

for x in range(n):
    if x % 3 == 0 and x % 5 == 0:
        continue

    if x % 3 == 0:
        continue

    if x % 5 == 0:
        continue

    ans += x

print(ans)
# Judge status: Accepted
n=int(input())
if n%2:
  print(n//2 + 1)
else:
  print(n//2)
# Judge status: Accepted
import heapq

from typing import List


def main():
    n, m = map(int, input().split())
    v = map(int, input().split())
    print(pdt(v, m))


def pdt(v: List[int], m: int) -> int:
    vv = [-a for a in v]
    heapq.heapify(vv)

    for _ in range(m):
        k = -heapq.heappop(vv)
        k = k // 2
        heapq.heappush(vv, -k)

    return -sum(vv)


if __name__ == '__main__':
    main()
# Judge status: Accepted
numbers = [str(e) for e in range(10)]
n, k = map(int, input().split())
hate_list = [e for e in input().split()]
available = set(numbers) - set(hate_list)
for i in range(n, 100000):
    nums = set(str(i))
    if nums <= available:
        print(i)
        break
# Judge status: Accepted
N = int(input())
A_list = list(map(int, input().split()))
A_dict = {}
res = 0
for a in A_list:
    res += a
    if a in A_dict.keys():
        A_dict[a] += 1
    else:
        A_dict[a] = 1

Q = int(input())
for i in range(Q):
    b,c = map(int, input().split())
    tmp = A_dict[b] if b in A_dict.keys() else 0
    A_dict[b] = 0

    if c in A_dict.keys():
        A_dict[c] += tmp
    else:
        A_dict[c] = tmp

    res += c*tmp - b*tmp
    print(res)
# Judge status: Accepted
N,L=map(int,input().split())
taste=[L+i-1 for i in range(1,N+1)]
j=0
for i in range(N):
    if abs(taste[j])>abs(taste[i]):
        j=i
print(sum(taste)-taste[j])
# Judge status: Wrong Answer
n = list(input())
m = max(n)
print(m*3)
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
tot=sum(a)
v=[1]
for q in a:
  tot-=q
  vt=min(2*(v[-1]-q),tot)
  if vt<0:
    print(-1)
    exit()
  v.append(vt)
print(sum(v))
# Judge status: Accepted
x, y, a, b, c = map(int, input().split())
ps = sorted(list(map(int, input().split())), reverse=True)[:x]
qs = sorted(list(map(int, input().split())), reverse=True)[:y]
rs = list(map(int, input().split()))
apples = sorted(ps + qs + rs, reverse=True)
print(sum(apples[:x+y]))
# Judge status: Wrong Answer
a=input()
b=input()
c=len(a)
d=0
for i in range(c):
  if a[i]==b[i]:
    d=d+1
print(d)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
a.sort()
print(sum(a[(3*N)-2*N:(3*N)-N]))
# Judge status: Accepted
N=int(input())
W=[input() for _ in range(N)]
ans='Yes'

for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        ans='No'
        break

if len(set(W))!=N:
    ans='No'

print(ans)
# Judge status: Accepted
S =  input()

for i in range(3):
    if S[i] == S[i+1]:
        print("Bad")
        exit()
print("Good")
# Judge status: Wrong Answer
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(100**3)

def rec(n, dp):
	if n == 1:
		return 1
	if dp[n] < float('inf'):
		return dp[n]
	pow6 = 6
	pow9 = 9
	dp[n] = min(n, dp[n])
	while n > pow6:
		dp[n] = min(dp[n], rec(n-pow6, dp) + 1)
		pow6 *= 6
	while n > pow9:
		dp[n] = min(dp[n], rec(n-pow9, dp) + 1)
		pow9 *= 9
	return dp[n]

def resolve():
	n = int(input())
	dp = [float('inf')]*(n+1)
	print(rec(n, dp))
resolve()
# Judge status: Wrong Answer
n = int(input())

dist = []

for i in range(n):
    x, y = map(int, input().split())
    dist.append(x + y)

dist.sort()

print(abs(dist[0] - dist[-1]))
# Judge status: Accepted
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N,M = input().split(' ')
numlist = []
for i in range(int(N)):
    numlist.append('0')
for i in range(int(M)):
    S,C = input().split(' ')
    numlist[int(S)-1] = C
num = ''.join(numlist)
num = int(num)
if len(str(num)) == int(N):
    print(int(num))
elif N == 1 & num == 0:
    print(0)
else:
    print(-1)
# Judge status: Accepted
n, k, s = map(int, input().split())
dat = [999999999] * n

for i in range(k):
    dat[i] = s

dat = list(map(str, dat))
print(" ".join(dat))
# Judge status: Accepted
from collections import Counter
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)

for i in range(k):
	if i <= (n-1):
		h[i] = 0
	else:
		break
	

print(sum(h))
# Judge status: Accepted
A,B,M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 10**9
for i in range(M):
    x,y,c = [int(i) for i in input().split()]
    if ans > a[x-1] + b[y-1] - c:
        ans = a[x-1] + b[y-1] - c
if ans > min(a) + min(b):
    ans = min(a) + min(b)
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
H = list(map(int,input().split()))
ans = []
cut =[]
for i in range(m):
  a,b = map(int,input().split())
  ans.append(a)
  ans.append(b)
  if a in cut:
    cut.append(a)
  else:
    cut.append(min(a,b))
    
ansset = set(ans)
cutset = set(cut)

print(len(ansset)-len(cutset))
# Judge status: Wrong Answer


n,m = map(int, input().split())
ans = n*m
tmp = n + m - 2
print(ans - tmp * 2)
# Judge status: Accepted
n=int(input())
if(n%2==0 or n%5==0):
    print(-1)
else:
    a=7 
    ans=1
    flag=1  
    while(flag):
        if(a%n==0):
            print(ans)
            flag=0
            break 
        else:
            ans+=1 
            s=str(a)
            s1='7'
            s2=int(s+s1)
            a=(int(s2))%n
# Judge status: Accepted
W,H,N = map(int, input().split())
m = [[0]*W]*H
import numpy as np
arr = np.array(m)

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        arr[:,:x] = 1
    if a == 2:
        arr[:, x:] = 1
    if a == 3:
        arr[H - y:,:] = 1
    if a == 4:
        arr[:H-y,:] = 1
print(np.count_nonzero(arr == 0))
# Judge status: Accepted
A, B = map(int, input().split())

print(int((B - A )*( B - A +1)/2 - B ))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
p = 0
for i in range(n):
    p = p ^ a[i]
for i in range(n):
    print(p ^ a[i], end=' ')
# Judge status: Accepted
import math
X=int(input())
a = (-1+(1+8*X)**(0.5))/2
print(int(math.ceil(a)))
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().strip().split()))

dp=[0 for n in range(max(a)+1)]
for n in range(N):
    dp[a[n]]+=1

ans=0
for n in range(1,len(dp)-2):
    ans=max(ans,dp[n-1]+dp[n]+dp[n+1])

print(ans)
# Judge status: Accepted
import collections
n=int(input())
s=["".join(sorted(input())) for i in range(n)]
c=list(collections.Counter(s).values())
r=0
for x in c:
    if x!=1:r+=(x*(x-1)//2)
print(r)
# Judge status: Accepted
N = int(input())

N_list = [1,3,3,7,7,7,14,22,22,22,33,33,46,60,60]
N_add15 = [1,2,2,3,3,3,4,5,5,5,6,6,7,8,8]


num_15 = N // 15

n_list = N_list[N%15-1] + 15 * N_add15[N%15-1] * (num_15)

if(N < 16):
    ans = N_list[N-1]
else:
    ans = num_15 * num_15 * 60 + n_list

print(ans)
# Judge status: Wrong Answer
def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)[:X+Y]
  
  j = 0
  sum_list = sorted(aka_list + midori_list)
  for i in range(len(sum_list)):
    if sum_list[i] < mu_list[j]:
      sum_list[i] = mu_list[j]
      if j < C-1: 
        j += 1
  print(sum(sum_list))
  
main()
# Judge status: Wrong Answer
k=int(input())
n=k-1
val=n
for i in range(2,n):
    val+=n//i
print(val+1)
# Judge status: Accepted
n=int(input())
V=list(map(int, input().split()))

V = sorted(V)

while True:
    if len(V) == 1:
        break
    new = (V[0]+V[1])/2
    V = V[2:]
    V.append(new)
    V = sorted(V)

print(V[0])
# Judge status: Accepted
x, k, d = map(int, input().split())
x = abs(x)


lap, rem = divmod(x, d)
if lap >= k:
    print(x - k * d)
    exit()

nokori = k - lap
rem0, rem1 = rem, d - rem
if nokori % 2 == 0:
    print(rem0)
else:
    print(rem1)
# Judge status: Accepted
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
  a,b=map(int,input().split())
  w.append(a)
  v.append(b)
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  for j in range(W+1):
      if j-w[i]>=0:
          dp[i+1][j]=dp[i][j-w[i]]+v[i]
      dp[i+1][j]=max(dp[i+1][j],dp[i][j])
print(dp[N][W])
# Judge status: Accepted
n = int(input())
s = input()
ans = 0
x = 0
for i in s:
  if i == 'I':
    x += 1
  else:
    x -= 1
  ans = max(ans,x)
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())

overlap = max(0,(min(b,d)-max(a,c)))
print(overlap)
# Judge status: Wrong Answer
K=int(input())
print((K/2)*((K+1)/2))