Harryxun/stf_run huggingface dataset:
check

### FIXED CODE ###

n,k_ = map(int,input().split())
a_li = list(map(int,input().split()))
a_li_o = [0]*n
for i in range(k_):
    for l in range(n):
        a_li_o[l] = a_li[l]
    dum_li = [0]*n
    for j in range(n):
        left = j - a_li[j]
        right = j + a_li[j] + 1
        if left < 0:
            left = 0
        dum_li[left] += 1
        if right > n-1:
            continue
        dum_li[right] -= 1
    total = 0
    for k in range(n):
        total += dum_li[k]
        dum_li[k] = total
    for k in range(n):
        a_li[k] = dum_li[k]
    if a_li_o == a_li:
        break
print(" ".join(map(str,a_li)))
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(n):
  ans.append(abs((t-h[i]*0.06)-a))
print(ans.index(min(a))+1)
  


### FIXED CODE ###

n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(n):
  ans.append(abs((t-h[i]*0.006)-a))
print(ans.index(min(ans))+1)
while True:
    N,M = map(int,input().strip().split(" "))
    if [N,M] == [0,0]:
        break
    L = []
    S = 0 
    for i in range(N):
        l = list(map(int,input().strip().split(" ")))
        l.reverse() 
        L.append(l)
        S = S + l[0]*l[1]
    L.sort()
    j = 0
    while M > 0:
        if M >= L[N-j-1][1]:
            S = S - L[N-j-1][0]*L[N-j-1][1]
            M = M - L[N-j-1][1]
            j = j + 1
        else:
            S = S - L[N-j-1][0]*M
            M = M - L[N-j-1][1]
    print(S)




### FIXED CODE ###

while True:
    N,M = map(int,input().strip().split(" "))
    if [N,M] == [0,0]:
        break
    L = []
    S = 0
    for i in range(N):
        l = list(map(int,input().strip().split(" ")))
        l.reverse()
        L.append(l)
        S = S + l[0]*l[1]
    L.sort()
    for j in range(0,N):
        t = N-j-1
        if M >= L[t][1]:
            S = S - L[t][0]*L[t][1]
            M = M - L[t][1]
        elif 0 < M:
            S = S - L[t][0]*M
            M = M - L[t][1]
    print(S)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
tmp = 0
for i in range(n):
    if a[i] == a[-1]:
        break
    if cmb(a[-1],a[i],mod) > ans:
        ans = cmb(a[-1],a[i],mod)
        tmp = a[i]
print(a[-1],tmp)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 10**18
for i in range(n-1):
    if abs(a[i] - a[-1]/2) < abs(ans - a[-1]/2):
        ans = a[i]
print(a[-1],ans)
n, k, x, y = [(int(input()) for i in range(4))]
print(x*n - (x - y)*max(0, n-k))


### FIXED CODE ###

n,k,x,y=[int(input()) for i in range(4)]
print(n*x-(x-y)*max(n-k,0))
n = int(input())
s = str(input())

ans = 0
max = 0
for i in range(0, n):
    if s[i]=="I":
        ans+=1
        max = max(ans, max)
    else:
        ans-=1
print(max)

### FIXED CODE ###

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

ans = 0
x = 0
for i in range(n):
    if s[i]=="I":
        ans+=1
        x = max(ans, x)
    else:
        ans-=1
        x = max(ans, x)
print(x)
N,A,B=map(int,input().split())
def bc(N,A,B):
    ballb=[]
    ballr=[]
    ballb.append('b')
    ballb=ballb*A
    ballr.append('r')
    ballr=ballr*B
    ball=(ballb+ballr)*N
    count=0
    for i in range(N):
        if ball[i]=='b':
            count+=1
    print(count)
bc(N,A,B)

### FIXED CODE ###

N,A,B=map(int,input().split())
a=N//(A+B)*A
c=N%(A+B)
b=min(A,c)
print(a+b)
# -*- coding: utf-8 -*-
correct = 'CODEFESTIVAL2016'
wrong = str(raw_input())
sum = 0
for index in xrange(0, len(wrong)):
    if correct[i] != wrong[i]:
        sum += 1
print sum




### FIXED CODE ###

 # -*- coding: utf-8 -*-
correct = 'CODEFESTIVAL2016'
wrong = raw_input()
sum = 0
for index in xrange(0, len(wrong)):
    if correct[index] != wrong[index]:
        sum += 1
print sum
n=int(inpit())
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

### FIXED CODE ###

n=int(input())
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
#create date: 2020-07-03 22:02

import sys
stdin = sys.stdin
from itertools import groupby, accumulate

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    s = ns()
    a = list()
    if s[0] == "0":
        a.append(0)
    gr = groupby(s)
    for key, group in gr:
        a.append(len(list(group)))
    if s[-1] == "0":
        a.append(0)
    acum = list(accumulate(a))
    m = len(acum)
    l = 2*k + 1
    if m == 1:
        print(acum[0])
        quit()
    ans = acum[l-1]
    for i in range(0, m-l+1, 2):
        ans = max(ans, acum[i+l-1] - acum[i-1])
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-07-03 22:02

import sys
stdin = sys.stdin
from itertools import groupby, accumulate

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    s = ns()
    a = list()
    if s[0] == "0":
        a.append(0)
    gr = groupby(s)
    for key, group in gr:
        a.append(len(list(group)))
    if s[-1] == "0":
        a.append(0)
    acum = list(accumulate(a))
    m = len(acum)
    l = 2*k + 1
    if m == 1:
        print(acum[0])
        quit()
    if l > m:
        print(acum[-1])
        quit()
    ans = acum[l-1]
    for i in range(0, m-l+1, 2):
        ans = max(ans, acum[i+l-1] - acum[i-1])
    print(ans)

if __name__ == "__main__":
    main()
R,G= map(int,input().split())
print(2*G-R)

### FIXED CODE ###

r=int(input())
g=int(input())
print(2*g-r)
n = int(input())

a = input().split()
print(1/sum(a.map(lambda x:1/x)))

### FIXED CODE ###

n = int(input())

a = input().split()
print(1/sum(map(lambda x:1/int(x), a)))
N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
 print(sum(A),sum(W))


### FIXED CODE ###

N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
print(sum(A),sum(W))
N=int(input())

a=[0]*10**4

for x in range(1,100):
     for y in range(1,100):
         for z in range(1,100):
             n=(x+y+z)**2-(x*y+y*z+z*x)
             if n<=10000:
                 a[n-1]+=1

for n in range(1,N+1):
    print(a[n])







### FIXED CODE ###

N=int(input())

a=[0]*10**4

for x in range(1,100):
     for y in range(1,100):
         for z in range(1,100):
             n=(x+y+z)**2-(x*y+y*z+z*x)
             if n<=10000:
                 a[n-1]+=1

for n in range(N):
    print(a[n])
x = range(m)
y = range(m)
n, m = list(map(int, input().split()))
for i in range(m):
   x[i], y[i] = list(map(int, input().split()))

z = x.extend(y)
N = range(n)
for i in range(n):
    N[i] = z.count(i+1)

ans = 0
for i in range(n):
    ans = ans + N.count(i)/(2**i)
print(ans)


### FIXED CODE ###

n, k = list(map(int, input().split()))
s = list(str(input()))

if s[k-1] == "A":
    s[k-1] = "a"
if s[k-1] == "B":
    s[k-1] = "b"
if s[k-1] == "C":
    s[k-1] = "c"
print("".join([str(i) for i in s]))
input = S
if(input = 'Sunny'):
  print('Rainy')
else if(input = 'Cloudy'):
  print('Sunny')
else:
  print('Cloudy')


### FIXED CODE ###

s=input()
if s=='Sunny':
  print('Cloudy')
elif s=='Cloudy':
  print('Rainy')
else:
  print('Sunny')
from collections import Counter as co
hit,te,ji=map(int,input().split())
l=list(co(sorted([int(input()) for u in range(hit)])).items())
inc=0
ans=0
ef=len(l)
if ef==1:print(-(-l[0][1]//te));break
for ix in range(hit):
  k,v=l[0]
  ans-=(-v//te)
  nokori=te-v%te if v%te else 0
  inc+=1
  while nokori:
    if l[inc][0]>k+ji:break
    if l[inc][1]<=nokori:
      nokori-=l[inc][1]
      inc+=1
      if inc==ef:
        break
    else:
      l[inc][1]-=nokori
      break
  if inc==ef:
    break
print(ans+1 if nokori else ans)

### FIXED CODE ###

n,c,k=map(int,input().split())
ans=0
cnt=1
t=sorted([int(input())for s in range(n)])
while t:
    now=t.pop()
    ans+=1
    while t and cnt<c and t[-1]+k>=now:
        cnt+=1
        t.pop()
    cnt=1

print(ans)
m=[]
cnt=0
for i in range(5):
    x=int(input())
    m.append(x)
m10=[i % 10 for i in m if i %10 >=1]
t=min(m10)
for i in m:
    if i %10==0:
        cnt += i
    else:
        cnt += ((i//10)+1)*10
print(cnt-10+t)



### FIXED CODE ###

m=[]
cnt=0
for i in range(5):
    x=int(input())
    m.append(x)
m10=[i % 10 for i in m if i %10 >=1]
if m10:
    t=min(m10)
    for i in m:
        if i %10==0:
            cnt += i
        else:
            cnt += ((i//10)+1)*10
    print(cnt-10+t)
else:
    print(sum(m))
n,a,b = map(int, input().split)
print(min(n*a,b))

### FIXED CODE ###

n,a,b = map(int, input().split())
print(min(n*a,b))
inp = map(str,input())

print(inp.count(1))



### FIXED CODE ###

inp = input()
print(inp.count("1"))
a=input()
b=input()

if 1>a and b>10000 and isinstance(a,int) and isinstance(b,int):
    if 0==a%2 or 0==b%2:
        print('Even')
    else:
        print("Odd")


### FIXED CODE ###

a, b = map(int, input().split())  
if 1<=a and b<=10000:             
    if (a*b)%2==0:                
        print('Even')             
    else:                         
        print('Odd')
#!/usr/bin/env python3
import sys
from math import factorial



MOD = 1000000007  # type: int


def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r)))

def solve(N: int, K: int):
    c = N-K+1
    if c >= 0: 
        print(c)
    else:
        print(0)

    for i in range(2,K+1):
        # i回の操作でとるために両端を除くセパレータの数はi-1個
        b = cmb(K-1, i-1, MOD)
        # 両端を含めたセパレータの数はi-1+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-(i-1)個
        # この赤玉をi+1個のセパレータに配属させる
        # i+1 H N-K-(i-1)
        if c-i<0:
            print(0)
        else:
            k = cmb(c, c-i, MOD)
        print(b*k%MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import factorial
MOD = 1000000007  # type: int

def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r))%p)

def solve(N: int, K: int):
    c = N-K

    for i in range(K):
        # i+1回の操作でとるために両端を除くセパレータの数はi個
        # 両端を含めたセパレータの数はi+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-i個
        # この赤玉をi+2個のセパレータに配属させる
        # i+2 H c-i
        if c-i<0:
            print(0)
        else:
            b = cmb(K-1, i, MOD)
            k = cmb(c+1, c-i, MOD)
            print(b*k%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
N, H, W = map(int, input().split())
n = 0
for i in range(N):
  A, B = map(int, input().split)
  if A >= H and B >= W:
    n += 1
print(n)

### FIXED CODE ###

n = 0
N, H, W = map(int, input().split())
for i in range(N):
  A, B = map(int, input().split())
  if A >= H and B >= W:
    n += 1
print(n)
n=int(input())
d,x=map(int,input().split())
a=list(map(int,input().split('\n')))
b=[]
cnt=n
for i in range(n):
    b[i] = 1
    while b[i]<=d:
        b[i] += a[i]
        cnt += 1
print(cnt+x)

### FIXED CODE ###

n=int(input())
d,x=map(int,input().split())
cnt=n
for i in range(n):
    a=int(input())
    b = a+1
    while b <= d:
        cnt += 1
        b += a
print(cnt+x)
if int(input())<int(input()):
  print(0)
else:
  print(10)

### FIXED CODE ###

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

if a[0]<a[1]:
  print(0)
else:
  print(10)
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))


def switch(bit, ans):
    check = [(bit >> i) & 1 for i in range(N)]
    light = 0
    for i in range(M):
        num = 0
        for l in s[i]:
            if check[l - 1] == 1:
                num += 1
        if num % 2 == p[i]:
            light += 1
    if light == M:
        ans += 1
    if bit == 1:
        return ans
    else:
        return switch(bit - 1, ans)


print(switch(2 ** N, 0))


### FIXED CODE ###

import sys
import math
from collections import deque
import itertools
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()
ans = 0
N, M = map(int, input().split())
ks = [tuple(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
t = []
for i in range(N):
    tt = list(itertools.combinations(range(1, N+1), i+1))
    for l in tt:
        t.append(l)
t.append(tuple())
for i in range(len(t)):
    pp = 0
    for l in range(M):
        if len(set(ks[l][1:]) & set(t[i])) % 2 == p[l]:
            pp += 1
    if pp == M:
        ans += 1
print(ans)
def A(x):
  return x + x**2 + x**3



def main():
  print(A(input()))


if __name__ == '__main__':
  main()


### FIXED CODE ###

def A(x):
  return x + x**2 + x**3


def B(n, k, p_list):
  pass


def C(N):
  pass


def main():
  print(A(int(input())))
  # letter = input()
  # A(letter)
  # for x in ['A', 'Z', 'a', 'z']:
  #   A(x)


if __name__ == '__main__':
  main()
import numpy as np
def main():
	A, B, H, M = map(float, input().split())
	R = H/12 + M*0.5/360
	r = M/60
	cos = math.cos((R-r)*2*np.pi)
	C = np.sqrt(A*A + B*B - 2*A*B*cos)
	print(C)
 
if __name__ == '__main__':
	main()

### FIXED CODE ###

import numpy as np
A, B, H, M = map(np.float32, input().split())

R = H/12 + M*0.5/360

r = M/60

Rad_c = np.cos((R-r)*2*np.pi)

C = np.sqrt(A*A + B*B -2*A*B*Rad_c)
print(C)
import numpy as np
n = int(input())
a_n = list(map(int, input().split()))
def UF(num):
    if num==0:
        return 1
    else:
        return num*UF(num-1)
def comb(a1, a2):
    return UF(a1)/(UF(a2)*UF(a1-a2))
result = np.zeros([n, n])
for i in range(n):
    for ii in range(n):
        if a_n[i] > a_n[ii]:
            result[i, ii] = comb(a_n[i], a_n[ii])
a = np.argmax(result)
res1 = a//n
res2 = a%n

print(a_n[res1], a_n[res2])

### FIXED CODE ###

n = int(input())
a_n = list(map(int, input().split()))
result1 = max(a_n)
min_delta = max(a_n)
result2 = max(a_n)
for num in a_n:
    if num == result1:
        pass
    elif abs(num-result1/2)<=min_delta:
        min_delta = abs(num-result1/2)
        result2 = num
print('{} {}'.format(result1, result2))
n=int(input())
a=[int(x) for x in input().split()]
if 0 in s:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
if 0 in a:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)
n,m = map(int,input().split())
ab = {i:[] for i in range(m+1)}
for i in range(n):
    a,b = map(int,input().split())
    if a in ab:
        ab[a].append(b)
    else:
        ab[a] = [b]
#print(ab)
ans = 0
for i in range(m)[::-1]:
    rem = m - i
    if ab[rem]:
        job = ab[rem]
        ans += max(job)
        del ab[rem][job.index(max(job))]
        if rem < m:
            ab[rem+1] += ab[rem]
    #print(ans)
print(ans)


### FIXED CODE ###

from heapq import *
n,m = map(int,input().split())
t = [[] for i in range(10**5+1)]
for i in range(n):
    a,b = map(int,input().split())
    t[a].append(b)

ans = 0
h = []
for i in range(1,m+1):
    #print(i,"日目")
    for j in t[i]:
        heappush(h, -j)
        #print("heappush",j)
    if h:
        a = -heappop(h)
        #print("heappop",a)
        ans += a
print(ans)
A,B,K = map(int, input().split())
lista = []
listb = []
for i in range(1, (A + 1)):
        if A%i==0:
                lista.append(i)
for i in range(1, (B + 1)):
        if B%i==0:
                listb.append(i)
common_list = []
for i in lista:
        for j in listb:
                if i == j:
					common_list.append(i)
print(common_list[-K])


### FIXED CODE ###

A,B,K = map(int, input().split())
A = [i for i in range(1, (A+1)) if A%i==0]
B = [i for i in range(1, (B+1)) if B%i==0]
common_list = []
for i in A:
        for j in B:
                if i == j:
                        common_list.append(i)
print(common_list[-K])
import math

n = int(input())
nn = math.floor(math.log2(abs(n)))
keta = 0
under = 0
s = ""

if n > 0:
    if n <= sum([2**i for i in range(0,nn+1,2)]):
        keta = nn+1
        under = sum([2**i for i in range(0,nn,2)])
    else:
        keta = nn+3
        under = sum([2**i for i in range(0,nn+1,2)])

    for i in range(1,keta):
        remainder = (n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "0" if i%2==1 else "1"
        else:
            s += "1" if i%2==1 else "0"
    else:
        s+="1"
    print(s[::-1])

elif n < 0:
    if n >= sum([(-2)**i for i in range(1,nn+1,2)]):
        keta = 2*(nn)
        under = sum([(-2)**i for i in range(1,nn-1,2)])
    else:
        keta = 2*(nn+1)
        under = sum([(-2)**i for i in range(1,nn+1,2)])
    for i in range(1,keta):
        remainder = abs(n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "1" if i%2==1 else "0"
        else:
            s += "0" if i%2==1 else "1"
    else:
        s+="1"
    print(s[::-1])

else:
    print(0)




### FIXED CODE ###

import math
import sys

n = int(input())
if n == 0:
  print(0)
  sys.exit()
  
keta = 0
under = 0
s = ""
nn = 1

if n > 0:
    while True:
      if sum([2**i for i in range(0,nn,2)])+1<= n and n <= sum([2**i for i in range(0,nn+1,2)]):
          keta = nn+1
          under = sum([2**i for i in range(0,nn,2)])
          break
      else:
          nn+=1

    for i in range(1,keta):
        remainder = (n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "0" if i%2==1 else "1"
        else:
            s += "1" if i%2==1 else "0"
    else:
        s+="1"
    print(s[::-1])

else:
    while True:
        if n <= sum([(-2)**i for i in range(1,nn,2)]) and n >= sum([(-2)**i for i in range(1,nn+1,2)]):
            keta = nn+1
            under = sum([(-2)**i for i in range(1,nn,2)])
            break
        else:
            nn+=1

    for i in range(1,keta):
        remainder = abs(n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "1" if i%2==1 else "0"
        else:
            s += "0" if i%2==1 else "1"
    else:
        s+="1"
    print(s[::-1])
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0]*(n-n//2)+a_list[(n-n//2):]

for i in range(n//2+1):
    k = int(n//2-i-1)
    if a_list[k] != sum(b_list[k::k+1])%2:
        b_list[k] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

### FIXED CODE ###

r = int(input())


print(3*r**2)
import sys

def main():
    input = sys.stdin.readline

    _, _, m = input().split()
    m = int(m)
    alist = input().split()
    blist = input().split()

    waribiki = [input().split() for _ in range(m)]
    
    res = [20000] * (len(alist)*len(blist) + m)
    count = 0
    for a in alist:
      for b in blist:
        res[count] = int(a)+int(b)
        count += 1

    for i in range(m):
        res[count] = int(alist[int(waribiki[i][0])-1]) + int(blist[int(waribiki[i][1])-1]) - int(waribiki[i][2])
        count += 1
      
    print(min(res))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline

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

    waribiki = [input().split() for _ in range(m)]
    
    res = [200000] * (m + 1)
    count = 0

    for i in range(m):
        res[count] = alist[int(waribiki[i][0])-1] + blist[int(waribiki[i][1])-1] - int(waribiki[i][2])
        count += 1

    res[count] = min(alist) + min(blist)
      
    print(min(res))


if __name__ == '__main__':
    main()
import collections

MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
d.sort()

c = collections.Counter(d)
if c[0] != 1:
    print('0')
else:
    ans = 1
    k = list(c.keys())
    for i in range(1, len(v)):
        print(ans)
        ans *= v[i-1]**v[i]
    print(ans % MOD)


### FIXED CODE ###

import collections

MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
    exit()

d.sort()

c = collections.Counter(d)
if c[0] != 1:
    print('0')
else:
    ans = 1
    k = list(c.keys())
    v = list(c.values())
    for i in range(1, len(v)):
        if k[i]-1 != k[i-1]:
            ans *= 0
        ans *= (v[i-1]**v[i]) % MOD
    print(ans % MOD)
a, b = map(int,input().split())
return (a*b%2 == 0) ? 'Even':'Odd'

### FIXED CODE ###

str = input()
a = str.split(" ")
c = int(a[0])*int(a[1])
if c%2 == 0:
    print("Even")
else:
    print("Odd")
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_a = sum(a)
a = a.sort()
cnt = 0
for i in a:
    if i >= 1 / (4*sum_a):
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

sum_a = sum(a)
a = sorted(a)

cnt = 0
for i in a:
    if i >= sum_a / (4*m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')