Harryxun/stf_run huggingface dataset:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
problems = [False] * N
AC = [0] * N
WA = [0] * N
for _ in range(M):
    p, S = sr().split(); p = int(p) - 1
    if not problems[p] and S == 'WA':
        WA[p] += 1
    if not problems[p] and S == 'AC':
        problems[p] = True
        AC += 1

AC_total = sum(AC)
WA_total = sum(y for x, y in zip(AC, WA) if x)
print(AC_total, WA_total)


### FIXED CODE ###

import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
solve = [False] * (N+1)
count = [0] * (N+1)
penalty = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if solve[p]:
        continue
    if s == 'WA':
        count[p] += 1
    else:
        solve[p] = True
        penalty += count[p]

print(sum(solve), penalty)
H, W = int(input().split())

while True:
    if (H + W == 0) : break
    
    for i in range(0, W-1):
        print('#' * H)        


### FIXED CODE ###

while True:
    H, W = map(int, input().split())

    if (H + W == 0) : break
    
    for i in range(H):
        print('#' * W)

    print()
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

s = 0
for i in range(1, n + 1):
    tf = True
    k = i
    for j in range(len(ab)):
        if ab[j][0] == i:
            k = ab[j][1]
        elif ab[j][1] == i:
            k = ab[j][0]
        if (k != i) & (h[i - 1] <= h[k - 1]):
            tf = False
            del ab[j]
            break
    if tf == True:
        s += 1

print(s)

### FIXED CODE ###

S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
import numpy as np
from decimal import Decimal
n = int(input())
a = list(map(int, input().split()))
S = np.int64(np.prod(a))
T = 0
for x in a:
    T += Decimal(S / x)
print(Decimal(S / T))


### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array([input().split()], np.float64)
print(1/(1 / a).sum())
import sys,math

inputs = sys.stdin.readlines()
inputs = list(map(lambda x:list(map(int,x.split())),inputs))

for n in inputs:
	print(math.floor(math.log10(n[0]*n[1]))+1)

### FIXED CODE ###

import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)
n, k = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
nums.sort()
if 0 in nums:
  index = nums.index(0)
  if index == 0:
    print(nums[1] * nums[k]
    break
  if index == n-1:
    print(nums[-2] * nums[-k - 1]
  else:
      num_neg = index
      num_pos = n - index
      if k < num_neg * num_pos:
          s = k // num_pos
          f = k % num_pos
          if f == 0:
              print(nums[-s] * nums[index+1])
          else:
              print(nums[-s-1] * nums[-f-1])
      else:
          new_list = nums[index:] + [-x for x in nums[:inedex]]
          new_list.sort()
          print(new_list[1] * new_list[k]
else:
    l, h = 0, n - 1
    while l < h:
        m = (l+h) // 2
        if nums[m] >= 0:
            h = m
        else:
            l = m + 1
        index = l
    num_neg = index
    num_pos = n - index
    if k < num_neg * num_pos:
        s = k // num_pos
        f = k % num_pos
        if f == 0:
            print(nums[-s] * nums[index+1])
        else:
            print(nums[-s-1] * nums[-f-1])
    else:
        new_list = nums[index:] + [-x for x in nums[:inedex]]
        new_list.sort()
        print(new_list[0] * new_list[k-1]

### FIXED CODE ###

a,b,c = [int(x) for x in input().split()]

if (a==b and c!= a) or (a==c and a!=b) or (b == c and a!=b):print('Yes')
else:print('No')
n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

### FIXED CODE ###

n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n-1):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)
#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, E * water / 100) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (map(int, input().split()))
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns= 0
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        print("if called")
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)

### FIXED CODE ###

#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, int(E * water / 100)) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (int(_) for _ in input().split())
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns = 100 * A
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
 
for i in np.arange(N-1):
  if A[i+1]%(2**c)!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(2**(c+1))==0:
    print(0)
    l=1
    break
  else:
    k=int(A[i+1]/(2**c)+0.5)
    test=int(test*k/math.gcd(test,k)+0.5)
if l==0:
  k=test*(2**(c-1))
  print(M//k//2 + M//k%2)

### FIXED CODE ###

import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=lcm_base(test, k)
if l==0:
  k=test*c//2
  print(M//k//2 + M//k%2)
n = int(input())
a = [int(input()) for i in range(n)]
now = 0
ans = -1
for i in range(n):
  value = a[now]
  if value == 2:
    ans = i+1
    break
  now = value
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
now = 0
ans = -1
for i in range(n):
  value = a[now]
  if value == 2:
    ans = i+1
    break
  now = value - 1
print(ans)
from math import gcd, ceil


def ramp(x):
    if x > 0:
        return x
    else:
        return 0


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a_lcm = a[0]
    for i in range(1, n):
        a_lcm = a_lcm * a[i] // gcd(a_lcm, a[i])
    print(ramp(ceil(m / a_lcm - 0.5)))


### FIXED CODE ###

from functools import reduce


def count_factors(a, factor):
    count = 0
    while a % factor == 0:
        count += 1
        a //= factor
    return count


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(set(map(lambda x: int(x) // 2, input().split())))
    num_of_two = count_factors(a[0], 2)
    for ai in a[1:]:
        if count_factors(ai, 2) != num_of_two:
            print(0)
            exit()

    a_lcm = reduce(lambda x, y: lcm(x, y), a)
    if a_lcm > m:
        print(0)
        exit()

    print((m // a_lcm + 1) // 2)
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

count = int(input())

for c in range(count):
    (b, f, r, v) = [int(x) for x in input().split()]
    data[b][f][r] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(data[b][f][r], end=' ')
        print()
    print('#' * 20) if b < 4 - 1 else print()

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

# ??\??????????????????????????§????????????????????????????????????
count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
        print('#' * 20)
N, M, L = map(int, input().split())

# 町間の道の長さのマトリックスを初期値無限で作成
S = [[float("INF") for i in range(N)] for i in range(N)]

# 町間の道の長さ情報をマトリックスに入力
for i in range(M):
    a, b, c = map(int,input().split())
    S[a-1][b-1] = c
    S[b-1][a-1] = c

# ワーシャルフロイド法で最短距離のマップを生成
Sf = fw(S)

T = [[float("INF")for i in range(N)] for i in range(N)]

# 町間を補給なしで通行可能な場合は1、不可能な場合はINFとしてマトリックスを作成
# （町間距離がタンク容量より大きい場合は通行不可）
for i in range(N):
    for j in range(N):
        if Sf[i][j] <= L:
            T[i][j] = 1

# ワーシャルフロイド法で町間移動可否のマップを生成
# すぐ上のfor文で、補給なしで移動できない町間の移動コストはINFにしたが、
# この処理で複数回の補給を行えば移動できる距離を
Tf = fw(T)

for i in range(int(input())):
    a, b = map(int, input().split())
    if Tf[a-1][b-1] != float("INF"):
        print(int(Tf[a-1][b-1])-1)
    else:
        print(-1)

### FIXED CODE ###


from scipy.sparse.csgraph import floyd_warshall as fw
N, M, L = map(int, input().split())

# 町間の道の長さのマトリックスを初期値無限で作成
S = [[float("INF") for i in range(N)] for i in range(N)]

# 町間の道の長さ情報をマトリックスに入力
for i in range(M):
    a, b, c = map(int,input().split())
    S[a-1][b-1] = c
    S[b-1][a-1] = c


# ワーシャルフロイド法で最短距離のマップを生成
Sf = fw(S)

T = [[float("INF")for i in range(N)] for i in range(N)]

# 町間を補給なしで通行可能な場合は1、不可能な場合はINFとしてマトリックスを作成
# （町間距離がタンク容量より大きい場合は通行不可）
for i in range(N):
    for j in range(N):
        if Sf[i][j] <= L:
            T[i][j] = 1

# ワーシャルフロイド法で町間移動可否のマップを生成
# すぐ上のfor文で、補給なしで移動できない町間の移動コストはINFにしたが、
# この処理で複数回の補給を行えば移動できる距離を
Tf = fw(T)

for i in range(int(input())):
    a, b = map(int, input().split())
    if Tf[a-1][b-1] != float("INF"):
        print(int(Tf[a-1][b-1])-1)
    else:
        print(-1)
while True:
    h, w = map(int, raw_input().split())

    if h == 0 and w == 0:
        break
    
    hcnt = 1
    for i in range(0, h):
        wid = ""
        if hcnt == 1 or hcnt == h:
            for j in range(0, w):
                 wid += "#"
             print wid
        else:
            wid += "#"
            for j in range(1, w-1):
                 wid += "."
            wid += "#"
            print wid
       hcnt += 1

### FIXED CODE ###

while True:
    h, w = map(int, raw_input().split())

    if h == 0 and w == 0:
        break
    
    hcnt = 1
    for i in range(0, h):
        wid = ""
        if hcnt == 1 or hcnt == h:
            for j in range(0, w):
                wid += "#"
            print wid
        else:
            wid += "#"
            for j in range(1, w-1):
                wid += "."
            wid += "#"
            print wid
        hcnt += 1
    print ""
import numpy as np
while(1):
    N,A,B = map(int,input().split())
    x=abs(A-B)
    

    if x%2==0:
        print(x//2)
    else:
        y,z=max(N-A,N-B),max(A-1,B-1)
        a,b=min(A-1,B-1),min(N-A,N-B)
        c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
        e,f=c//2+a+1,d//2+b+1
        if y>z:
            print(min(z,e,f))
        else:
            print(min(y,e,f))

### FIXED CODE ###

import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
    

if x%2==0:
    print(x//2)
else:
    y,z=max(N-A,N-B),max(A-1,B-1)
    a,b=min(A-1,B-1),min(N-A,N-B)
    c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
    e,f=c//2+a+1,d//2+b+1
    if y>z:
        print(min(z,e,f))
    else:
        print(min(y,e,f))
#import itertools
list1=[k for k in input()]
#print(list1)
num1=len(list1)
#print(num1)
list00=[format(int(k), 'b') for k in range(2**(num1-1))]
#print(list00)

list0=['','+']

list01=[]
for count1 in range(num1):
  x=list00[count1]
  list01.extend(x)
#print(list01)
total=0

for step1 in range(2):
  for step2 in range(2):
    list2=[list0[step2],list0[step1]]
    num = min(len(list1), len(list2))
    result = [None]*(num*2)
    result[::2] = list1[:num]
    result[1::2] = list2[:num]
    result.extend(list1[num:])
    result.extend(list2[num:])
    result1 = ''.join(result)
#    print(result1)
    total+=eval(result1)

print(total)
#176

### FIXED CODE ###

import itertools
s=input()
length=len(s)

ans=0
mylist=list(itertools.product('01',repeat=length-1))

for j in range(len(mylist)):
    tmp=s[0]
    for i in range(length-1):
        if mylist[j][i]=='1':
            tmp+="+"+s[i+1]
        else:
            tmp+=s[i+1]
    tmp=eval(tmp)
    ans+=tmp
print(ans)
s = input("")
ans = s * s * s
print(ans)


### FIXED CODE ###

user = input("")
num = int(user)
ans = num * num * num
print(ans)
A, B, C = map(int, input().split())
if B//A>C:
    print(C)
else:
    print(b//A)


### FIXED CODE ###

A, B, C = map(int, input().split())
if B//A>C:
    print(C)
else:
    print(B//A)
s = list(input())
cnt = 0
while True:
    if s[0] == 'T':
        s.pop(0)
        cnt += 1
    else:
        break
    
while True:
    if s[-1] == 'S':
        s.pop(-1)
        cnt += 1
    else:
        break

cs = 0
ct = 0
for i in range(len(s)):
    if s[i] == 'S':
        cs += 1
    else:
        ct += 1
print(cnt + abs(cs-ct))

### FIXED CODE ###

s = input()
ans = 0
cnt = 0
for a in s:
    if a == 'S':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            ans += 1
print(ans+cnt)
N = int(input())
T,A = map(int,input().split())

num = 0
pre = A
for i in range(N):
    x = input()
    ave = T - x*0.006
    if abs(A-ave)<pre:
        pre = abs(A-ave)
        num = i
print(i)

### FIXED CODE ###

N = int(input())
T,A = map(float,input().split())
H = list(map(int,input().split()))

dis = []
for i in range(N):
    dis.append(abs(A-(T-H[i]*0.006)))
print(dis.index(min(dis))+1)
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
    if A[i]<=0:
        B.append(-A[i])
    else:
        C.append(A[i])
if len(B)%2==0:
       print(sum(B)+sum(C))
else:
       print(sum(B)+sum(C)-2*min(min(B),min(C))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
    if A[i]<=0:
        B.append(-A[i])
    else:
        C.append(A[i])
if len(B)%2==0:
       print(sum(B)+sum(C))
else:
        if C==[]:
            print(sum(B)+sum(C)-2*min(B))
        else:
            print(sum(B)+sum(C)-2*min(min(B),min(C)))
N = int(input())
usa = list(map(int, input().split()))
flag = [0 for x in range(N)]
count = 0
for i, j in enumerate(usa):
    if(flag[i]):
        continue
    if(usa[j-1]-1 == i):
        count+=1
        flag[usa[j - 1]] = 1

print (count)


### FIXED CODE ###

N = int(input())
usa = list(map(int, input().split()))
flag = [0 for x in range(N)]
count = 0
for i, ai in enumerate(usa):
    if(flag[i]):
        continue
    if(usa[ai-1]-1 == i):
        count+=1
        flag[ai - 1] = 1

print (count)
import sys
from heapq import heappush, heappop, heapify
input = sys.stdin.readline
    
def dfs(v, c, p=-1):
    dist[v] = c
    for u, d in g[v]:
        if u == p: continue
        dfs(u, c+d, v)

def main():    
    for i in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1; b -= 1
        g[a].append((b, c))
        g[b].append((a, c))
        
    Q, K = map(int, input().split())
    K -= 1
    
    dfs(K, 0)
    
    for i in range(Q):
        x, y = map(int, input().split())
        print(dist[x-1]+dist[y-1])
    
if __name__ == '__main__':
    N = int(input())
    g = [[] for i in range(N)]
    dist = [0] * N
    main()

### FIXED CODE ###

import heapq


N = int(input())
tree = {i+1:[] for i in range(N)}
route = [10**20 for i in range(N+1)]
visited = [False for i in range(N+1)]

for i in range(N-1):
    a, b, c = list(map(int, input().split()))
    tree[a].append((c, b))
    tree[b].append((c, a))

Q, K = list(map(int, input().split()))

route[K], visited[K] = 0, True
queue = tree[K]

while len(queue):
    c, r = heapq.heappop(queue)

    if not visited[r]:
         visited[r], route[r] = True, c
         for cost, next_r in tree[r]:
             if not visited[next_r]:
                 heapq.heappush(queue, (route[r]+cost, next_r))

for i in range(Q):
    x, y = list(map(int, input().split()))
    print(route[x]+route[y])
a,b,t=map(int,input.split())
c = t // a
if t >= a:print(b*c)
else:print(0)

### FIXED CODE ###

a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
if n == 0:
    ans = x
else:
    p = sorted(p)
    min_p = min(p)
    max_p = max(p)
    j = 0
    ans = 0
    if x < min_p:
        ans = x
    elif x > max_p:
        ans = x
    elif x == min_p:
        if min_p+1 == p[1]:
            ans = min_p-1
        else:
            ans = min_p+1
    elif x == max_p:
        if max_p-1 == p[len(p)-1]:
            ans = max_p+1
        else:
            ans = max_p-1
    else:
        for i in range(min_p+1, max_p):
            if i == p[j+1]:
                j += 1
            else:
                if abs(ans-x) > abs(i-x):
                    ans = i
print(ans)

### FIXED CODE ###

x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
if n == 0:
    ans = x
else:
    p = sorted(p)
    min_p = min(p)
    max_p = max(p)
    j = 0
    ans = 0
    if x < min_p:
        ans = x
    elif x > max_p:
        ans = x
    elif x == min_p:
        ans = min_p-1
    elif x == max_p:
        if max_p-1 == p[len(p)-2]:
            ans = max_p+1
        else:
            ans = max_p-1
    else:
        for i in range(min_p-1, max_p+1):
            if i == p[j]:
                j += 1
                if len(p) == j:
                    im_i = p[j-1] +1
                    if abs(ans-x) > abs(im_i-x):
                        ans = im_i
            else:
                if abs(ans-x) > abs(i-x):
                    ans = i
print(ans)
print(date = input().replace('2017', '2018'))

### FIXED CODE ###

print(input().replace('2017', '2018'))
length, num = map(int, input().split())
dist=[int(i) for i in input().split()]

Max=0
for i in range(num):
    Max = max([abs(dist[(i+1)%num]-dist[i]),Max])

print(length-Max)
input()


### FIXED CODE ###

length, num = map(int, input().split())
dist=[int(i) for i in input().split()]

Max=0
for i in range(num-1):
    Max = max([dist[i+1]-dist[i],Max])

Max=max(Max,length-dist[-1]+dist[0])
print(length-Max)
n = input()
if n[0] == "9" or n[1] == "9"
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = input()
if n[0] == "9" or n[1] == "9":
    print("Yes")
else:
    print("No")
from functools import lru_cache
import sys
sys.setrecursionlimit(10**5)
N , M = map(int ,input().split())
mod = 10 ** 9 + 7
A = []
for i in range(M):
    A.append(int(input()))
    if A[i] - 1 == A[i - 1] and i > 0:
        print("0")
        exit()

@lru_cache(maxsize=None)
def fib(n):
    if n == 0 or n == 1:
        return 1
    else:
        return fib(n - 1)+fib(n - 2)
ans = 1
now = 0
for a in A:
    next = a - 1
    ans *= fib(next - now)
    now = a + 1
if now == 0:
    ans = fib(N)
else:
    ans *= fib(N - now)
print(ans % mod)

### FIXED CODE ###

N , M = map(int ,input().split())
mod = 10 ** 9 + 7
A = []
crash = 0
idx = 0
for i in range(M):
    A.append(int(input()))
    if i == 0:
        crash = A[0]
    if A[i] - 1 == A[i - 1] and i > 0:
        print("0")
        exit()
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1 , N + 1):
    if i == crash:
        idx += 1
        if idx < M:
            crash = A[idx]
    else:
        if i == 1:
            dp[1] = 1
        else:
            dp[i] = dp[i - 1] + dp[i - 2]
            dp[i] %= mod
print(dp[-1])
A, gomi = map(int, input().split())
print('Yes' if A <= list(map(int,input().split())) else 'No')

### FIXED CODE ###

A, gomi = map(int, input().split())
print('Yes' if A <= sum(list(map(int,input().split()))) else 'No')
n = int(input())
line = list(map(int,input().split()))
box = []
for j in line:
  for i in range(30):
    if j % 2**i != 0:
      box.append(i-1)
      break
print(min(box))

### FIXED CODE ###

def how_many(n):
  ans = 0
  while n % 2 == 0:
    n /= 2
    ans += 1
  return ans

n = int(input())
line = map(int , input().split())
answer = min(map(how_many , line))
             
print(answer)
a=int(input())
b=input()
r_num=0
w_num=0
for i in b :

  if i=='W' :
    w_num+=1
  else :
    r_num+=1

count=0
if r_num<w_num
  for i in range(r_num) :
    if b[i]=='R' :
      count+=1
else :
  for i in range(w_num) :
    if b[i]=='W' :
      count+=1
print(count)


### FIXED CODE ###

a=int(input())
b=input()
r_num=0
w_num=0
for i in b :

  if i=='W' :
    w_num+=1
  else :
    r_num+=1

count=0

for i in range(r_num) :
  if b[i]=='W' :
    count+=1


print(count)
A,B = int(input())
print(A*B)

### FIXED CODE ###

A,B = map(int,input().split())
print(A*B)
n,m=map(int,input().split())
ans=[-1]*n
a,b=map(int,input().split())
ans[a-1]=b

for i in range(m-1):
    a,b=map(int,input().split())
    if ans[a-1]!=-1 and ans[a-1]!=b:
        print(-1)
        exit()
    else:
        ans[a-1]=b
       


if n>1 and ans[0]==0:
    print(-1)
elif n==1:
    if ans[0]==-1:
        print(0)
    else:
        print(ans[0])

elif n==2:
    for j in range(2):
        if ans[j]==-1:
            ans[j]=0
    print(10*ans[0]+ans[1])
else:
    for j in range(3):
        if ans[j]==-1:
            ans[j]=0
    
    print(100*ans[0]+10*ans[1]+ans[2])
    
          

### FIXED CODE ###

n,m=map(int,input().split())
ans=[]

for i in range(m):
    ans.append(list(map(int,input().split())))
for j in range(10**n):
    if len(str(j))==n and all(str(j)[s-1]==str(c) for s,c in ans):
        print(j)
        break
else:
    print(-1)
import numpy as np
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = 1
town_list = [0]*n
town_list[0] = 1
tn_list = [1]

while(1):
    next = a[now-1]
    now = next
    if town_list[now-1] == 0:
        town_list[now-1] = 1
        tn_list.append(now)

    else:
        idx = tn_list.index(now)
        initial = tn_list[:idx]
        cycle = tn_list[idx:]
        break

if k > len(initial):
    end_idx = (k-len(initial))%len(cycle)
    print(cycle[end_idx])
else:
    print(initial[k])

### FIXED CODE ###

import numpy as np
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = 1
town_list = [0]*n
town_list[0] = 1
tn_list = [1]

while(1):
    next = a[now-1]
    now = next
    if town_list[now-1] == 0:
        town_list[now-1] = 1
        tn_list.append(now)

    else:
        idx = tn_list.index(now)
        initial = tn_list[:idx]
        cycle = tn_list[idx:]
        break

if k >= len(initial):
    end_idx = (k-len(initial))%len(cycle)
    print(cycle[end_idx])
else:
    print(initial[k])