Harryxun/stf_run huggingface dataset:
n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

def qwe(y):
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in y:
        if i == 'M':
            m += 1
        elif i == 'A':
            a += 1
        elif i == 'R':
            r += 1
        elif i == 'C':
            c += 1
        elif i == 'H':
            h += 1
        else:
            pass
    q = [m,a,r,c,h]
    return q

def qwer(arr):
    count = 0
    coun = 0
    for j in range(len(arr)):
        if arr[j] == 0:
            count += 1
            arr.pop(j)
        else:
            coun += 1
    if count == 5:
        return 0
    if coun == 4:
        asd_1 = arr[0]*arr[1]*arr[2]
        asd_2 = arr[0]*arr[1]*arr[3]
        asd_3 = arr[0]*arr[2]*arr[3]
        asd_4 = arr[1]*arr[2]*arr[3]
        return (asd_1 + asd_2 + asd_3 + asd_4)
    if coun == 5:
        asf_1 = arr[0]*arr[1]*arr[2]
        asf_2 = arr[0]*arr[1]*arr[3]
        asf_3 = arr[0]*arr[1]*arr[4]
        asf_4 = arr[0]*arr[2]*arr[3]
        asf_5 = arr[0]*arr[2]*arr[4]
        asf_6 = arr[0]*arr[3]*arr[4]
        asf_7 = arr[1]*arr[2]*arr[3]
        asf_8 = arr[1]*arr[2]*arr[4]
        asf_9 = arr[1]*arr[3]*arr[4]
        asf_10 = arr[2]*arr[3]*arr[4]
        return (asf_1 + asf_2 + asf_3 + asf_4 + asf_5 + asf_6 + asf_7 + asf_8 + asf_9 + asf_10)
v = qwe(s)
print(qwer(v))


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

def qwe(y):
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in y:
        if i == 'M':
            m += 1
        elif i == 'A':
            a += 1
        elif i == 'R':
            r += 1
        elif i == 'C':
            c += 1
        elif i == 'H':
            h += 1
        else:
            pass
    q = [m,a,r,c,h]
    return q

def qwer(arr):
    count = 0
    for j in range(len(arr)):
        if arr[j] == 0:
            count += 1
            arr[j] = "D"
    while "D" in arr:
        arr.remove("D")
    if count == 5:
        return 0
    if count == 4:
        return 0
    if count == 3:
        return 0
    if count == 2:
        wer = arr[0] * arr[1] * arr[2]
        return wer
    if count == 1:
        asd_1 = arr[0]*arr[1]*arr[2]
        asd_2 = arr[0]*arr[1]*arr[3]
        asd_3 = arr[0]*arr[2]*arr[3]
        asd_4 = arr[1]*arr[2]*arr[3]
        asde = asd_1 + asd_2 + asd_3 + asd_4
        return asde
    if count == 0:
        asf_1 = arr[0]*arr[1]*arr[2]
        asf_2 = arr[0]*arr[1]*arr[3]
        asf_3 = arr[0]*arr[1]*arr[4]
        asf_4 = arr[0]*arr[2]*arr[3]
        asf_5 = arr[0]*arr[2]*arr[4]
        asf_6 = arr[0]*arr[3]*arr[4]
        asf_7 = arr[1]*arr[2]*arr[3]
        asf_8 = arr[1]*arr[2]*arr[4]
        asf_9 = arr[1]*arr[3]*arr[4]
        asf_10 = arr[2]*arr[3]*arr[4]
        asdf =  asf_1 + asf_2 + asf_3 + asf_4 + asf_5 + asf_6 + asf_7 + asf_8 + asf_9 + asf_10
        return asdf
v = qwe(s)
print(qwer(v))
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * (n + 1)
ans = []
for i in range(n):
    l[i + 1] = l[i] + (p[i] + 1) / 2
for i in range(n - k + 1):
    ans.append(l[i + k] - l[i])
print(max(ans))

### FIXED CODE ###

input1 = input().split()
input2 = list(map(int,input().split()))
U = input()
S = input1[0]
T = input1[1]
A = input2[0]
B = input2[1]
if U == S:
  A -= 1
else:
  B -= 1
print(str(A) + " " + str(B))
#!/usr/bin/python3
# abc060_b
"""
Choose Integers
"""

import math  # greatest common divisor, 最大公約数
test = False

def lcm(x, y):
    """
    最小公倍数 least common multiple
    """
    return (x * y) // math.gcd(x, y)

def answer():
    """
    Aの倍数の中に条件を満たすものがあるか調べる。
    """
    A, B, C = map(int, input().split())
    upper_limit = int(lcm(A, B) / A)
    if test:
        print(lcm(A, B), upper_limit)

    for i in range(1, upper_limit+1):
        if (A * i) % B == C:
            if test:
                print(A * i)
            return 'YES'
    return 'NO'


def main():
    """
    main関数
    """
    print(answer())


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3
# abc060_b
"""
Choose Integers
"""

test = False


def answer():
    """
    Aの倍数の中に条件を満たすものがあるか調べる。
    """
    A, B, C = map(int, input().split())

    for i in range(1, A*B+1):
        if (A * i) % B == C:
            if test:
                print(A * i)
            return 'YES'
    return 'NO'


def main():
    """
    main関数
    """
    print(answer())


if __name__ == '__main__':
    main()
import sys
s = list(input())
check =['dream','dreamer','erase','eraser']
while len(s) >= 8:
    if ''.join(s[-5:]) == check[0]:
        print(s)
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-7:]) == check[1]:
        print(s)
        for _ in range(7): s.pop()
        continue
    if ''.join(s[-5:]) == check[2]:
        print(s)
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-6:]) == check[3]:
        print(s)
        for _ in range(6): s.pop()
        continue
    print('No')
    sys.exit()
if ''.join(s) == check[0] or ''.join(s) == check[1] or ''.join(s) == check[2] or ''.join(s) == check[3]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
s = list(input())
check =['dream','dreamer','erase','eraser']
while len(s) >= 8:
    if ''.join(s[-5:]) == check[0]:
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-7:]) == check[1]:
        for _ in range(7): s.pop()
        continue
    if ''.join(s[-5:]) == check[2]:
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-6:]) == check[3]:
        for _ in range(6): s.pop()
        continue
    print('NO')
    sys.exit()
if ''.join(s) == check[0] or ''.join(s) == check[1] or ''.join(s) == check[2] or ''.join(s) == check[3]:
    print('YES')
else:
    print('NO')
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2
 
n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
 
d = [INFTY for i in range(n)]
color = [WHITE for i in range(n)]
 
for i in range(n):
    u = int(input())
    k = int(input())
    for j in range(k):
        v = int(input())
        c = int(input())
        M[u][v] = c
        
def dijkstra():
    global M, d, color
    d[0] = 0
    color[0] = GRAY
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if (d[v] > d[u] + M[u][v]):
                    d[v] = d[u] + M[u][v]
                    color[v] = GRAY
    for i in range(n):
        if(d[i] = INFTY):
            d[i] == -1
            print(str(i) + " " + str(d[i]))
dijkstra()

### FIXED CODE ###

from sys import stdin

INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(stdin.readline())
M = [[INFTY for i in range(n)] for j in range(n)]

for u in range(n):
    U = list(map(int, stdin.readline().split()[2:]))
    for j in range(0, len(U), 2):
        M[u][U[j]] = U[j+1]

d = [INFTY for i in range(n)]
color = [WHITE for i in range(n)]

def dijkstra():
    global n
    d[0] = 0
    color[0] = GRAY
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if(d[v] > d[u] + M[u][v]):
                    d[v] = d[u] + M[u][v]
                    color[v] = GRAY
    for i in range(
n):
        print(i, (-1 if d[i] == INFTY else d[i]))
dijkstra()
X=input()
Y=input()
crain = (4 * X - Y) / 2
if crain.is_integer() and crain > 0:
    crain = int(crain)
    print("yes")
else:
    print("no")

### FIXED CODE ###

X,Y=map(int,input().split())
q=0

if(Y%2==1):
    q=1
    print("No")

if q==0:
    print(X*2<=Y and Y<=X*4 and "Yes" or "No")
dat =list(input().split())

for i in dat:
   i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0

for i in range(len(dat)):
#	if i%2==0:
#		asum = asum + dat[i]
#	else:
#		bsum = bsum + dat[i]
		
print(asum-bsum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
h,n=map(int,input().split())
a=[]
ab=[]

for i in range(n):
    aabb=list(map(int,input().split()))
    ab.append(aabb)
    a.append(aabb[0])

loop=h+max(a)
cost=[-1 for i in range(loop)]
cost[0]=0
i=0
costlist=[]
while i<loop:
    costlist.clear()
    for j in range(n):
        ii=i-ab[j][0]
        if (0<=ii<h)&(cost[ii]>=0):
            costlist.append(cost[ii]+ab[j][1])
    if len(costlist)!=0:
        cost[i]=min(costlist)
    i+=1
acost=[i for i in cost[h:] if i!=-1]
ans=min(acost)
print(ans)

### FIXED CODE ###

h,n=map(int,input().split())
a=[]
ab=[]

for i in range(n):
    aabb=list(map(int,input().split()))
    ab.append(aabb)
    a.append(aabb[0])

loop=h+max(a)
cost=[-1 for i in range(loop)]
cost[0]=0
i=0
costlist=[]
while i<loop:
    costlist=[]
    for j in range(n):
        ii=i-ab[j][0]
        if (0<=ii<h)&(cost[ii]>=0):
            costlist.append(cost[ii]+ab[j][1])
    if len(costlist)!=0:
        cost[i]=min(costlist)
    i+=1
acost=[i for i in cost[h:] if i!=-1]
ans=min(acost)
print(ans)
num=int(input())
fig=list(map(int,input().split()))

Even_flag=0
count=0

while Even_flag=0:
  for i in range(num):
    if fig[num]%2==1:
      Even_flag==1:
      break
    else:
      fig[num]=fing[num]/2
  count+=1
  
print(count)
    
	

### FIXED CODE ###

num=int(input())
fig=list(map(int,input().split()))
 
Even_flag=0
count=0
 
while Even_flag==0:
  for i in range(num):
    if fig[i]%2==1:
      Even_flag=1
      break
    else:
      fig[i]=fig[i]/2
      if i==num-1:
        count+=1
        
print(count)
v=[int(input()) for_ in range(6)]
print('Yay!' if all([v[i+1]-v[i]<=v[5] for i in range(4)]) else ':(')


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a <= k:
    print('Yay!')
else:
    print(':(')
x = int(input()
for i in range(120):
  for j in range(120):
    if i**5-j**5 == x:
        print(i, j)
        break

### FIXED CODE ###

x = int(input())
for i in range(-120, 120):
    for j in range(-120, 120):
        if i**5+j**5 == x:
            print(i,-j)
            exit(0)
# -*- coding: utf-8 -*-
N = int(input())
print int(N/3)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
print (int(N/3))
S = input()
T = input()

start = len(S) - len(T)
end = len(S)

ans = ''
while start >= 0:
	test = S[start:end]
	solve = True
	for i in range(len(T)):
		c1,c2 = test[i],T[i]
		if c1 != c2 and c1 != '?':
			solve = False
			break
	if solve:
		ans = S[:start] + T + S[end:]
		break
	start -= 1
	end -= 1
if len(ans > 0):
	print(ans.replace('?', 'a'))
else:
	print('UNRESTORABLE')

### FIXED CODE ###

S = input()
T = input()

start = len(S) - len(T)
end = len(S)

ans = ''
while start >= 0:
	test = S[start:end]
	solve = True
	for i in range(len(T)):
		c1,c2 = test[i],T[i]
		if c1 != c2 and c1 != '?':
			solve = False
			break
	if solve:
		ans = S[:start] + T + S[end:]
		break
	start -= 1
	end -= 1
if len(ans) > 0:
	print(ans.replace('?', 'a'))
else:
	print('UNRESTORABLE')
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()
if U == S:
  print(A-1 B)
else:
  print(A B-1)

### FIXED CODE ###

S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()
if U == S:
  print(A-1,B)
else:
  print(A,B-1)
n = int(input())
n_list = [i for i in range(1,n)]
print(sum(n))

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
n = int(input())
l = []
for i in range(n):
  a = input()
  l.append(a)
print(f"{'AC'} x {l.count('AC')"}
print(f"{'WA'} x {l.count('WA')"}
print(f"{'TLE'} x {l.count('TLE')"}
print(f"{'RE'} x {l.count('RE')"}

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
  a = input()
  l.append(a)
print(f"{'AC'} x {l.count('AC')}")
print(f"{'WA'} x {l.count('WA')}")
print(f"{'TLE'} x {l.count('TLE')}")
print(f"{'RE'} x {l.count('RE')}")
import math
x_sq = math.sqrt(x)
x_sq_it = int(x_sq)

pnlist = [2]

countn = 0
for i in range(3,x_sq_it+1):
    for j in range(len(pnlist)):
        if i % pnlist[j] == 0:
            break
        else:
            countn += 1
    if countn == len(pnlist):
        pnlist.append(i)
        countn = 0
# print(pnlist)

countn = 0
for i in range(x,10**5):
    for j in range(len(pnlist)):
        if i % pnlist[j] == 0:
            break
        else:
            countn += 1
    if countn == len(pnlist):
        print(i)
        exit()
    else:
        countn = 0

### FIXED CODE ###

x = int(input())
while any(x % i == 0 for i in range(2,x)):
    x += 1
print(x)
t= int(input())
for i in range(t):
    k=input().split()
    a=int(k[0])
    b=int(k[1])
	c=a*b
    d=int(c**.5)
    print(2*d-1-((d*d)==c)-(c==d*d and a!=b))

### FIXED CODE ###

t= int(input())
for i in range(t):
    k=input().split()
    a=int(k[0])
    b=int(k[1])
    c=a*b
    d=int(c**.5)
    print(2*d-1-((d*(d+1))>=c)-(c==d*d and a!=b))
input_line1 = raw_input()
print(input_line1^3)

### FIXED CODE ###

c = int(input())
print(c*c*c)
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

for i in range(10 * N):
    num = str(i)
    flag = True
    for pair in sc:
        if (num[pair[0] - 1] != pair[1]) or len(i) < pair[0]:
            flag = False
            break
    if flag:
        ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)
N, Q = map(int, input().split())
gyaku_lis = [0] * N
plus_lis = [0] * N
for i in range(N-1):
  a,b = map(int, input().split())
  gyaku_lis[b-1] = a-1
for i in range(Q):
  p,x = map(int, inpu().split())
  plus_lis[p-1] += x
ans_lis = [0]*N
ans_lis[0] = plus_lis[0]
for i in range(1,N):
  ans_lis[i] = ans_lis[gyaku_lis[i]] + plus_lis[i]
print(*ans_lis)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def dfs(fr, now, num):
    global graph, addsum, ans
    tmp = num + addsum[now]
    for a in graph[now]:
        if a == fr:
            continue
        dfs(now, a, tmp)
    ans[now] = tmp


def main():
    global graph, addsum, ans
    N, Q = map(int, readline().split())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, readline().split())
        a -= 1; b -= 1
        graph[a].append(b)
        graph[b].append(a)
    addsum = [0]*N
    for _ in range(Q):
        p, x = map(int, readline().split())
        p -= 1
        addsum[p] += x
    
    ans = [0]*N
    dfs(-1, 0, 0)

    print(*ans)


if __name__ == "__main__":
    main()
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        if k != 0:
            count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]

last = {}
for i in range(1,27):
    last[i] = 0

satisfaction = 0
for d in range(1,D+1):
    satisfaction += s[d-1][t[d-1]-1]
    last[t[d-1]] = d
    for i in range(26):
        satisfaction -= c[d-1]*(d-last[t[d-1]])
    print(satisfaction)


### FIXED CODE ###

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]

last = {}
for i in range(1,27):
    last[i] = 0

satisfaction = 0
for d in range(1,D+1):
    satisfaction += s[d-1][t[d-1]-1]
    last[t[d-1]] = d
    for i in range(1,27):
        satisfaction -= c[i-1]*(d-last[i])
    print(satisfaction)
import numpy as np
N,M=map(int,input().split())

A=np.zeros((N,M))
def re(x,y):
    global A
    try:
        if x>=0 and y>=0:
            if A[x][y]==0:
                A[x][y]=1
            else:
                A[x][y]=0
    except:
        pass
    return A


for i in range(N):
    for j in range(M):
        for X in range(-1,2):
            for Y in range(-1,2):
                re(i+X,j+Y)

print(np.count_nonzero(A))



### FIXED CODE ###

N,M=map(int,input().split())

if N==1 and M==1:
    print(1)
elif N==1 or M==1:
    print(max(N,M)-2)
else:
    print((N-2)*(M-2))
a,b　=　input().split()
 
print(min(a*int(b),b*(int(a) ) )

### FIXED CODE ###

a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )
n = int(input())
a = [[0]*n for i in range(n)]
  
for i in range(n):
    v = list(map(int, input().split()))
    u = v[0]
    k = v[1]
    for j in range(k):
        a[u - 1][v[2 + j] - 1] = 1

d = [0] * n
f = [0] * n
isDiscovered = [False] * n
time_stamp = 0

def dfs(x):
    global time_stamp
    isDiscovered [x] = True
    time_stamp++
    d[x] = time_stamp
    for i in range(n):
        if a[x][i] == 1 and isDiscovered[i] == False:
            dfs(i)
    time_stamp++
    f[x] = time_stamp

for i in range(n):
    if isDiscovered[i] == False:
        dfs(i)

for i in rane(n):
    print(i+1, d[i], f[i])

### FIXED CODE ###

n = int(input())
a = [[] for i in range(n)]

for i in range(n):
    v = list(map(int, input().split()))
    u = v[0] - 1
    for j in v[2:]:
        a[u].append(j-1)

d = [0] * n
f = [0] * n
isDiscovered = [False] * n
time_stamp = 0

def dfs(x):
    global time_stamp
    isDiscovered [x] = True
    time_stamp += 1
    d[x] = time_stamp
    for i in a[x]:
        if not isDiscovered[i]:
            dfs(i)
    time_stamp += 1
    f[x] = time_stamp

for i in range(n):
    if not isDiscovered[i]:
        dfs(i)

for i in range(n):
    print(i+1, d[i], f[i])
import math

N = int(input())
num_list = [0] + [0] * N  # 0~N
pn_list = []
for i in range(2, N+1):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])

count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N//(pn**e)>=1:
        N //= (pn**e)
        e += 1
        count += 1
print(count)

### FIXED CODE ###

N = int(input())

div_counts = []
for i in range(2, int(N**0.5)+1):
  count = 0
  while N%i == 0:
    count += 1
    N //= i
    if N == 1:
      break
  div_counts.append(count)
  
if N != 1:
  div_counts.append(1)

ans = 0
for count in div_counts:
  for i in range(1, count+1):
    if count >= i:
      ans += 1
      count -= i
print(ans)
s = input()
s[3] = '8'
print(s)

### FIXED CODE ###

s = input()
print(s[:3]+'8'+s[4:])
from collections import defaultdict
vertices, edges = (int(n) for n in input().split(" "))
connect = defaultdict(list)
cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)]
for e in range(edges):
    v1, v2, weight = (int(n) for n in input().split(" "))
    connect[v1].append([v2,weight])
    connect[v2].append([v1,weight])
    cost_dp[v1][v2] = weight
for neg in range(2):
    updated = 0
    for t in range(vertices + 1):
        for i in range(vertices):
            for k in range(vertices):
                if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:
                    updated = 1
                    cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]
if neg == 1 and updated:
    print("NEGATIVE CYCLE")
else:
    for ve in range(vertices):
        ans = ["INF" if n == float("inf") else n for n in cost_dp[ve]]
        print(*ans)
    break

### FIXED CODE ###

vertices, edges = (int(n) for n in input().split(" "))
cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)]
for e in range(edges):
    v1, v2, weight = (int(n) for n in input().split(" "))
    cost_dp[v1][v2] = weight
for neg in range(2):
    updated = 0
    for t in range(vertices):
        for i in range(vertices):
            for k in range(vertices):
                if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:
                    updated = 1
                    cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]
if neg == 1 and updated:
    print("NEGATIVE CYCLE")
else:
    for ve in range(vertices):
        ans = ["INF" if n == float("inf") else n for n in cost_dp[ve]]
        print(*ans)
N,M= map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
for i in range(0,N):
    if  A[i]*M*4>=K:
        continue
    else:
        answer=i
        break
if answer>=M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N,M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
answer=0
breakflag=0
for i in range(0,N):
  if  A[i]*M*4>=K:
    if i==N-1:
      breakflag=1
    continue
  else:
    answer=i
    break
if breakflag==1:
  answer=N
if answer>=M:
    print("Yes")
else:
    print("No")
import math
from functools import reduce
input()
N=list(map(int,input().split()))
print(reduce(math.gcd,N))

### FIXED CODE ###

import fractions
from functools import reduce
input()
N=list(map(int,input().split()))
print(reduce(fractions.gcd,N))
N, K = map(int, input())

ans = 0
while True:
    N //= K
    ans += 1
    if N == 0:
        break

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())

ans = 0
while True:
    N //= K
    ans += 1
    if N == 0:
        break

print(ans)