Harryxun/stf_run huggingface dataset:
N=int(input())
s=input().split()
r=[]
b=[]
for i in s:
  if i=='R':
    r.append(i)
  else:
    b.append(i)
if len(a) > len(b):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N=int(input())
s=str(input())
r=[]
b=[]
for i in range(N):

  if s[i]=='R':
    r.append(s[i])
  else:
    b.append(s[i])
if len(r) > len(b):
  print('Yes')
else:
  print('No')
n, x = map(int, input().split())
l = list(map(int, input().split()))

a = 0
b = 0
for i in range(n + 1):
    a += l[i]
    b += 1
    if a > x:
        break
print(b)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))
 
a = 0
b = 1
for i in range(n):
    a += l[i]
    b += 1
    if a > x:
        b -= 1
        break
    
print(b)
import sys
sys.setrecursionlimit(10**6)

input=sys.stdin.readline

n,m=map(int,input().split())
G=[[False]*n for _ in range(n)]
used=[False]*n

def dfs(now,depth):
    if used[now]:
        return 0
    if n==depth:
        return 1
    used[now]=True
    ans=0
    for i in range(n):
        if G[now][i]:
            ans+=dfs(i,depth+1)
    used[now]=False
    return ans

for _ in range(n):
    a,b=map(int,input().split())
    G[a-1][b-1]=True
    G[b-1][a-1]=True

print(dfs(0,1))

### FIXED CODE ###

def dfs(n,depth):
    if used[n]:
        return 0
    if depth==N:
        return 1
    used[n]=1
    ans=0
    for i in range(N):
        if connect[n][i]:
            ans+=dfs(i,depth+1)
    used[n]=0
    return ans

N,M=map(int,input().split())
used=[0]*N
connect=[[0 for i in range(N)]for j in range(N)]
a=[];b=[]

for i in range(M):
    x,y=map(int,input().split())
    a.append(x-1)
    b.append(y-1)

for i in range(M):
    connect[a[i]][b[i]]=connect[b[i]][a[i]]=1

print(dfs(0,1))
N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if(self.root[x]<0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M+1)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(N):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in range(N,0,-1):
    print(int(ans[i]))
#print(len(ans))

### FIXED CODE ###

N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if(self.root[x]<0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(M-1):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in ans[::-1]:
    print(int(i))
#print(len(ans))
class edge:
    def __init__(self,_from,_to):
        self._from = _from
        self._to = _to
        self._color = 0

n = int(input())
e_all = []
max_b = 0
for i in range(n):
    a,b = map(int,input().split())
    e_all.append(edge(a-1,b-1))
    max_b =  max(b, max_b)

v = [[] for _ in range(max_b)]
for i in range(n):
    e = e_all[i]
    j = 0
    while True:
        if len(v[e._from]) <= j + 1:
            v[e._from].append(False)
        if v[e._from][j] == False:
            while len(v[e._to]) <= j + 1:
                v[e._to].append(False)
            if v[e._to][j] == False:
                v[e._from][j] = True
                v[e._to][j] = True
                e._color = j + 1
                break
        j += 1
cnt = []
for i in range(max_b):
    cnt.append(v[i].count(True))

print (max(cnt))
for i in range(n):
    print (e_all[i]._color)

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    root = [[] for _ in range(N)]
    node = [0] * N
    color = [0] * (N-1)
    for i in range(N-1):
        a,b = LI()
        root[a-1].append((b-1,i))
        root[b-1].append((a-1,i))

    q = [(0,0)]
    ans = 0
    while q:
        i,c = q.pop()
        node[i] = 1
        next_c = 1
        for d,x in root[i]:
            if node[d]: continue
            if next_c == c: next_c += 1
            color[x] = next_c
            ans = max(ans,next_c)
            q.append((d,next_c))
            next_c += 1
    print(ans)
    print(*color,sep='\n')

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

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    
    c = Counter(A).most_common()

    if c[0][0] == "0" and c[0][1] == N:
        print("Yes")
    elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == "0" and c[1][1] == N//3:
        print("Yes")
    elif len(c) == 3 and int(c[0][0])^int(c[1][0]) == int(c[2][0]) and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    left_smaller = [0]*N
    right_smaller = [0]*N
    for i, a in enumerate(A):
        left_smaller[i] = sum(b < a for b in A[:i])
        right_smaller[i] = sum(b < a for b in A[i+1:])

    ans = sum((l*(K)*(K-1)//2%MOD + r*(K+1)*(K)//2%MOD)%MOD for l, r in zip(left_smaller, right_smaller))%MOD
    print(ans)

if __name__ == "__main__":
    main()
n,k = map(int,input().split())
line = list(map(int,input().split()))

inf = float('inf')
line.extend([inf for i in range(k)])
box = [inf for i in range(n + k)]
  
def frog(x):
  box[0] = 0
  if x == n-1:
    return box[n-1]
    exit()
  else:    
    for i in range(1,k+1):
      cost = abs(line[x] - line[x+i])
      if box[x+i] >= box[x] + cost:
        box[x+i] = box[x] + cost
    return frog(x+1)
print(frog(0))

### FIXED CODE ###

n,k = map(int,input().split())
line = list(map(int,input().split()))
 
inf = float('inf')
line.extend([inf for i in range(k)])
box = [inf for i in range(n + k)]
#out of rangeを避けるため

box[0] = 0
for x in range(n):   
  for i in range(1,k+1):
    cost = abs(line[x] - line[x+i])
    if box[x+i] >= box[x] + cost:
      box[x+i] = box[x] + cost
print(box[n-1])
N = int(input())
L=[]
i = 0
s = 0
M2 = 0
a = 0
for i in range (0,N):
    L.append(int(input()))
M = L[0]
for s in range(1,N):
    if  L[s] > M:
        M = L[s]
for s in range(1,N):
    if L[s] == M:
        a += 1
        continue
    else:
        if L[s] > M2:
            M2 = L[s]
for i in range(0,N):
    if L[i] == M and a != 1:
        print(M2)
    else:
        print(M)


### FIXED CODE ###

r = int(input())
print(3*r*r)
n=int(input())
a=[]
b=[]
for i in range(n):
  s=input()
  overall=0
  minimum=0
  current=0
  for j in range(len(s)):
    if s[j]=='(':
      current+=1
    else:
      current-=1
    minimum=min(current,minimum)
  overall=current
  if overall>=0:
    a.append([overall,minimum])
  else:
    b.append([overall,minimum])
finalsum=0
a=sorted(a, key=lambda t:t[1])
a.reverse()
b=sorted(b, key=lambda t:t[1])
for i in a:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
for i in b:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
if finalsum==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import sys
n=int(input())
a=[]
b=[]
for i in range(n):
  s=input()
  overall=0
  minimum=0
  current=0
  for j in range(len(s)):
    if s[j]=='(':
      current+=1
    else:
      current-=1
    minimum=min(current,minimum)
  overall=current
  if overall>=0:
    a.append([overall,minimum])
  else:
    b.append([overall,minimum])
finalsum=0
a=sorted(a, key=lambda t:t[1])
a.reverse()
b=sorted(b, key=lambda t:t[0]-t[1])
b.reverse()
for i in a:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
for i in b:
  if finalsum+i[1]<0:
    print('No')
    sys.exit()
  finalsum+=i[0]
if finalsum==0:
  print('Yes')
else:
  print('No')
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(200002)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 200000:
        dp[a * c] = True
        c += 1

print(ans)


### FIXED CODE ###

n = int(input())
aL = sorted(list(map(int, input().split(" "))))
# aL = sorted(list(set(aLP)))

dp = [False for _ in range(1000001)]

d = {}
for a in aL:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans = 0
for a in aL:
    if dp[a]:
        continue
    if d[a] > 1:
        c = 1
        while a * c <= 1000000:
            dp[a * c] = True
            c += 1
        continue
    ans += 1

    c = 1
    while a * c <= 1000000:
        dp[a * c] = True
        c += 1

print(ans)
A, B = map(int, input().split())

h, w = 100, 100
grid = [['.'] * 100 for _ in range(50)]+ [['#'] * 100 for _ in range(50)]

for i in range(A - 1):
    A1, A2 = divmod(i, 50)
    grid[2 * A1][2 * A2] = '#'

for j in range(B - 1):
    B1, B2 = divmod(i, 50)
    grid[2 * B1 + 51][2 * B2] = '.'

print(h,w)
for i in range(100):
    print(grid[i])


### FIXED CODE ###

B, A = map(int, input().split())

h, w = 100, 100
grid = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]

for i in range(A - 1):
    A1, A2 = divmod(i, 50)
    grid[2 * A1][2 * A2] = '#'

for j in range(B - 1):
    B1, B2 = divmod(j, 50)
    grid[2 * B1 + 51][2 * B2] = '.'

print(h, w)
for i in range(100):
    print(''.join(grid[i]))
n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
if len(a) = 3:
  if a[1] = 2:
    cnt = 1
    
print (cnt)    

### FIXED CODE ###

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

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)
s=input()
if(s=="SUN")x=7
if(s=="MON")x=6
if(s=="TUE")x=5
if(s=="WED")x=4
if(s=="THU")x=3
if(s=="FRI")x=2
if(s=="SAT")x=1
print(x)

### FIXED CODE ###

s = input()
if s == "SUN":
    x = 7
if s == "MON":
    x = 6
if s == "TUE":
    x = 5
if s == "WED":
    x = 4
if s == "THU":
    x = 3
if s == "FRI":
    x = 2
if s == "SAT":
    x = 1
print(x)
def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod
    else            : return power(x, y//2, mod)**2 * x % mod


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x

def combination(n, a, mod):
    nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
    return nCa

mod = int(1e9) + 7



x, y  = map(int, input().split())
s = x + y
if s % 3 != 0:
    print(0)
else:
    s = s // 3
    x -= s
    y -= s
    def fac(n):
        if n == 1:
            return 1
        return n * fac(n - 1)
    print(combination(x + y, x, mod))

### FIXED CODE ###

def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod
    else            : return power(x, y//2, mod)**2 * x % mod


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x

def combination(n, a, mod):
    if a == 0:
        return 1
    nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
    return nCa

mod = int(1e9) + 7



x, y  = map(int, input().split())
s = x + y
if s % 3 != 0:
    print(0)
else:
    s = s // 3
    x -= s
    y -= s
    if x < 0:
        print(0)
    elif y < 0:
        print(0)
    else:
        print(combination(x + y, x, mod))
import numpy as np

MOD = 10**9+7

D,T,E = int(input().split())
n= int(D)
arr = np.zeros((n+1,n+1),dtype=np.int16)
for i in range(3,n+1):
    arr[0,i] = 1

for i in range(1,n+1):
    sum_ = 0
    for j in range(3*i,n+1):
        sum_ += arr[i-1,j]
        sum_ %= MOD
        if j+3 >= n + 1:
            break
        arr[i,j+3] = sum_

ans = 0
for i in range(n+1):
    ans += arr[i,n]
    ans %= MOD
print(ans)










### FIXED CODE ###

D,T,S = [int(i) for i in input().split()]
out = 'Yes' if D <= T * S else 'No'
print(out)
s = input()
if s == 'RRR': print(3)
elif s == 'RRS' print(2)
elif s == 'SRR': print(2)
else: print(1)

### FIXED CODE ###

s = input()
if s == 'RRR': print(3)
elif s == 'RRS': print(2)
elif s == 'SRR': print(2)
elif s == 'SSS': print(0)
else: print(1)
list=[1, 1, 1, 1, 1]
for i in range(1, 7):
  list.append(6**i)
for j in range(1, 7):
  list.append(9**i)
sorted(list, reverse=True)
N=int(input())
count=0
for i in range(19):
  if N <= i:
    N=N-i
    count=+1
      if N==0:
        print(count)

### FIXED CODE ###

N=int(input())

A=[1]

i = 1
while True:
    if 6**i <= 100000:
        A.append(6**i)
    else:
        break
    i += 1

i = 1
while True:
    if 9**i <= 100000:
        A.append(9**i)
    else:
        break
    i += 1

A.sort()

dp = [N]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(len(A)):
        if i - A[j] >= 0:
            dp[i] = min(1+dp[i-A[j]], dp[i])

print(dp[-1])
While True:
    H, W = map(int, raw_input().split())
    if H == W == 0:
        break
    print "#" * W
    for i in range(H -2):
        print "#" + "." *(W-2) + "#"
    print "#" * W
    print

### FIXED CODE ###

while True:
    H, W = map(int, raw_input().split())
    if H == W == 0:
        break
    print "#" * W
    for i in xrange(H -2):
        print "#" + "." *(W-2) + "#"
    print "#" * W
    print
print((int(input)-1)//2)

### FIXED CODE ###

print((int(input())-1)//2)
n=input()
print(n*n*n)

### FIXED CODE ###

n=input()
print(n*n*n)
n = int(input())
count = 0
for cake in range(0,n+1,4):
    for donatsu in range(0,n+1,7):
        count += 1
print("Yes") if count >= 1 else print("No")
n = int(input())
count = 0
for cake in range(0,n+1,4):
    for donatsu in range(0,n+1,7):
        if donatsu + cake == 0:
            count += 1
print("Yes") if count >= 1 else print("No")


### FIXED CODE ###

n = int(input())
count = 0
for cake in range(0,n+1,4):
    for donatsu in range(0,n+1,7):
        if donatsu + cake == n:
            count += 1
print("Yes") if count >= 1 else print("No")
class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ['mod', 'factorial', 'inverse']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

if not S%3==0:
    print(0)
    exit()
else:
    small = S//3
    s_elm = min(X,Y)
    if s_elm<small:
        print(0)
        exit()
    print('a')
    r = s_elm - small
    print(small,r)
    ans = Combination().combination(small, r)
    ans %= u
print(ans)

### FIXED CODE ###


import sys,itertools
def input():
    return sys.stdin.readline()[:-1]

X,Y = map(int,input().split(' '))
u = 10**9+7

S = X+Y

class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ['mod', 'factorial', 'inverse']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

if not S%3==0:
    print(0)
    exit()
else:
    small = S//3
    s_elm = min(X,Y)
    if s_elm<small:
        print(0)
        exit()
    r = s_elm - small
    ans = Combination().combination(small, r)
    ans %= u
print(ans)
a = input()
b = input()

wa = int(a) + int(b)
sa = int(a) - int(b)
seki = int(a) * int(b)

if wa >= sa and wa >= seki:
    print(wa)
elif sa >= wa and sa >= seki:
    print(sa)
else:
    print(seki)

### FIXED CODE ###

a,b=input().split()

wa = int(a) + int(b)
sa = int(a) - int(b)
seki = int(a) * int(b)

if wa >= sa and wa >= seki:
    print(str(wa))
elif sa >= wa and sa >= seki:
    print(str(sa))
else:
    print(str(seki))
import math

H,N=map(int,input().split())
A_list=[]
B_list=[]
for i in range(N):
    A,B=map(int,input().split())
    A_list.append(A)
    B_list.append(B)

amax=max(A_list)

inf=float('inf')
dp=[0]+[inf]*(H+amax)

for i in range(N):
    A=A_list[i]
    B=B_list[i]
    if A > H and B<dp[-1]:
        dp[-1]=B
        continue

    for j in range(A,1+H):
        if dp[j-A]+B<dp[j]:
            dp[j]=dp[j-A]+B
    
    minA=min(dp[H-A:])+B
    if minA < dp[-1]:
        dp[-1]=minA

print(dp[-1])


### FIXED CODE ###

H,A = map(int,input().split())

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

print(N)
import sys
sys.setrecursionlimit(100000000)

S = input()


while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')
n, a, b = [int(i) for i in input().split()]
if a == 0:
    print(0)
else:
    x = (n // (a + b)) + 1
    balls = [*["b"] * a, *["r"] * b] * x
    ans = 0
    for i in range(n):
        if balls[i] == "b":
            ans += 1
    print(ans)


### FIXED CODE ###

n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)
import numpy as np


def solve():
    n, x = [int(i) for i in input().split()]
    l = np.array([int(i) for i in input().split()])

    d = 0
    ans = 0
    for i in range(1, n + 2):
        d = d + l[i - 1]
        if d <= x:
            ans += 1
        else:
            break

    if l[0] < x:
        ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import numpy as np


def solve():
    n, x = [int(i) for i in input().split()]
    l = np.array([int(i) for i in input().split()])

    if x == 0:
        print(0)
        exit(0)

    d = 0
    ans = 1

    for i in range(1, n + 1):
        d = d + l[i - 1]
        if d <= x:
            ans += 1
        else:
            break

    print(ans)


if __name__ == '__main__':
    solve()
N = int(input())
ls = list(map(int,input().split()))
    
Pls = [0] * (10**6+1)

for i in ls:
    Pls[i] += 1

ii = 0
for j in range(len(Pls)):
    if Pls[j] == 0:
        continue
    elif Pls[j] == 1:
        ii += 1
        t = 2*j
        while t <= 10**6+1:
            Pls[t] = 0
            t += j
    else:
        t = 2*j
        while t <= 10**6+1:
            Pls[t] = 0
            t += j

print(ii)

### FIXED CODE ###

N = int(input())
ls = list(map(int,input().split()))
    
Pls = [0] * (10**6+1)

for i in ls:
    Pls[i] += 1

ii = 0
for j in range(len(Pls)):
    if Pls[j] == 0:
        continue
    elif Pls[j] == 1:
        ii += 1
        t = 2*j
        while t <= 10**6:
            Pls[t] = 0
            t += j
    else:
        t = 2*j
        while t <= 10**6:
            Pls[t] = 0
            t += j

print(ii)
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

def swap(x, K):
    return abs(x-K)

def loops (x, K, mins):
    if x < K:
        ab = swap(x, K)
        return min(ab, x)
    elif x % K == 0:
        return 0
    else:
        x = swap(x, K)
        if x < mins:
            mins = x
            x = loops(x, K, mins)
            return x
        else:
            return mins

N, K = getInput()
x = N
print(loops(x, K, x))


### FIXED CODE ###

def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N, K = getInput()
t = N % K 
print(min(t, K -t))