Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2*10**5)

def rec(i, A, memo):
    if memo[i] != -1:
        return memo[i]

    for a in A:
        if i - a >= 0 and not rec(i - a, A, memo):
            memo[i] = True
            return True
    memo[i] = False
    return False


def main():
    N, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    memo = [-1] * (K + 1)
    print("First" if rec(K, A, memo) else "Second")


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**5)

def rec(i, A, memo):
    if memo[i] != -1:
        return memo[i]

    for a in A:
        if i - a >= 0 and not rec(i - a, A, memo):
            memo[i] = True
            return True
    memo[i] = False
    return False


def main():
    N, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    memo = [-1] * (K + 1)
    print("First" if rec(K, A, memo) else "Second")


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
ans = []
for an in A:
    if an in ans:
        del ans[ans.index(an)]
    else:
        ans.append(an)
print(len(ans))

### FIXED CODE ###

import sys
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
stack = A[0]
count_num = 1
ans = 0
for i in range(1,N):
        if A[i] == stack:
                count_num += 1
        else:
                if count_num % 2 == 1:
                        ans += 1
                count_num = 1
        stack = A[i]
if count_num%2 == 1:
        ans +=1
print(ans)
### BUGGY CODE ###

def int_cards(cards, operations):
    operations.sort(reverse=True)
    for i in range(len(operations)):
        cards = sorted(cards)
        for j in range(operations[i][1]):
            if cards[j] < operations[i][0]:
                cards[j] = operations[i][0]
            
    print(sum(cards))

N, M = map(int, input().split())
A = list(map(int,input().split()))
operations = []
for i in range(M):
    B, C = map(int, input().split())
    operations.append([C, B])

int_cards(A, operations)   

### FIXED CODE ###

import collections

def int_cards(N, cards, operations):
    col_cards = collections.deque(sorted(cards), N)
    operations.sort(reverse=True)
    for c, b in operations:
        for _ in range(b):
            if col_cards[0] >= c:
                break
            col_cards.popleft()
            col_cards.append(c)
            
    print(sum(col_cards))
    
N, M = map(int, input().split())
A = list(map(int,input().split()))
operations = []
for i in range(M):
    B, C = map(int, input().split())
    operations.append([C, B])
    
int_cards(N, A, operations)
### BUGGY CODE ###

from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ok2 = True
for i in a:
    for (j, _) in p(i):
        if j in pp:
            ok2 = False
        else:
            pp.add(j)
if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")


### FIXED CODE ###

from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ma = 2*10**6
table = [0]*ma
for i in a:
    table[i] += 1
ok2 = True
for i in range(2,ma):
    s = 0
    for j in range(i,ma,i):
        s += table[j]
    if s>1:
        ok2 = False

if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")
### BUGGY CODE ###

n = int(input())
numbers = list(map(int, input().split()))
 
sum = 0
for i in range(n):
    for j in range(i + 1, n):
        sum += numbers[i] * numbers[j]
        sum %= (1000000000 + 7)
print(sum)

### FIXED CODE ###

n = int(input())
numbers = list(map(int, input().split()))
result = 0
sum_of_numbers = sum(numbers)
for i in range(n - 1):
    sum_of_numbers -= numbers[i]
    result += numbers[i] * sum_of_numbers
    result %= 1000000007
print(result)
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  

K = int(input())
ans = 0

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(a,b,c)
      

print(ans)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  

K = int(input())
ans = 0

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(a,b,c)
      

print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline


def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12

ans=0
for index,item in enumerate(a):
    ans+=(calc)//item
    ans%=(10**9+7)

print(int((ans)%(10**9+7)))
    



### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)


N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12


ans=0
for index,item in enumerate(a):
    ans+=(calc)//item

print(int((ans)%(10**9+7)))
### BUGGY CODE ###

import bisect
n = int(input())
l_li = [int(x) for x in input().split()]
l_li.sort()

count = 0
  
for i in range(n):
  for j in range(i+1,n):
    wa = l_li[i] + l_li[j]
    target = l_li[j+1:]
    count += bisect.bisect_left(target, wa)
    
print(count)

### FIXED CODE ###

import bisect
n = int(input())
l_li = [int(x) for x in input().split()]
l_li.sort()

count = 0
  
for i in range(n):
  for j in range(i+1,n):
    wa = l_li[i] + l_li[j]
    count += bisect.bisect_left(l_li, wa) - j - 1
    
print(count)
### BUGGY CODE ###

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
c = 0
for i in T:
    if i in S:
        c+= 1
print(c)


### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
c = 0
for i in range(q):
    l = 0
    r = n
    t = T[i]
    while r-l > 1:
        m = (r + l)//2
        if (S[m] > t):
            r = m
        else:
            l = m
    if (S[l] == T[i]):
        c += 1
print(c)
### BUGGY CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]

pos = 1
route = []
success = False
while 1:
    route.append(pos)
    pos = a[pos - 1]
    if pos == 2:
        print(len(route))
        break
        
    if pos in route:
        print(-1)
        break

### FIXED CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]

pos = 1
route = []
success = False
"""
while 1:
    route.append(pos)
    pos = a[pos - 1]
    if pos == 2:
        print(len(route))
        break
        
    if pos in route:
        print(-1)
        break
"""
for i in range(N):
    pos = a[pos - 1]
    if pos == 2:
        success = True
        print(i+1)
        break
if not(success):
    print(-1)
### BUGGY CODE ###

n,k = map(int,input().split())
mod = 10**9+7
answer = 0

for i in range(k,n+2):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(0,i))
  answer = answer + max_value - lowest_value + 1

print(answer % mod)

### FIXED CODE ###

n,k = map(int,input().split())
mod = 10**9+7
answer = 0

for i in range(k,n+2):
  answer = answer + (n-i+1)*i + 1

print(answer % mod)
### BUGGY CODE ###

N = int(input())
A=[]
B=[]
for i in range(N):
    a,b=[int(n) for n in input().split()]
    A.append(a)
    B.append(b)

cnt=0

# print(list(reversed(range(N))))
for i in reversed(range(N)):
    while A[i]%B[i]!=0:
        cnt+=1
        A=[A[n]+1 if n<=i else A[n] for n in range(N)]

print(cnt)



### FIXED CODE ###

N = int(input())
A=[]
B=[]
for i in range(N):
    a,b=[int(n) for n in input().split()]
    A.append(a)
    B.append(b)

cnt=0

# print(list(reversed(range(N))))
for i in reversed(range(N)):
    if (A[i]+cnt)%B[i]==0:
        d=0
    else:
        d=B[i]-(A[i]+cnt)%B[i]
    cnt+=d
#    A=[A[n]+r if n<=i else A[n] for n in range(N)]

print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

def gcd(i,j):
  if i>j:
    i,j=j,i
  if j%i==0:
    return i
  return gcd(i,j-i)

n=int(input())
l=[int(i) for i in input().split()]
g=gcd(l[0],l[1])
for i in range(2,len(l)):
  g=gcd(g,l[i])
print(g)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def gcd(i,j):
  if i>j:
    i,j=j,i
  if j%i==0:
    return i
  return gcd(j-i,i)

n=int(input())
l=[int(i) for i in input().split()]
l.sort()
g=gcd(l[0],l[1])
for i in range(2,len(l)):
  g=gcd(g,l[i])
print(g)
### BUGGY CODE ###

import itertools

while 1:
    try:
      a, b= map(int, raw_input().split())
    except:
      break
    GCD = a * b
    LCM = 0
    # GCD
    for i, j in itertools.product(range((a if a > b else b) / 2), repeat=2):
        if a * (i+1) == b * (j+1) and GCD > a * (i+1):
            GCD = a * (i+1)
    # LCM
    for i in range(a if a > b else b, 1, -1):
        if a % i == 0 and b % i == 0:
            LCM = i
            break
    print "{} {}".format(str(GCD), str(LCM))

### FIXED CODE ###

def get_gcd(a,b):
	if a > b: a, b = b, a
	if b % a == 0:
		return a
	else:
		return get_gcd(a, b % a)

def get_lcm(a,b,g):
	return a * b / g

while True:
	try:
		a,b = map(int, sorted(raw_input().split()))
		GCD = get_gcd(a,b)
		LCM = get_lcm(a,b,GCD)
		print "{} {}".format(GCD, LCM)
	except EOFError:
		break
### BUGGY CODE ###

_, Q = [int(s) for s in input().strip().split(' ')]
S = input().strip()
ls = []
for i in range(Q):
    l, r = [int(s) for s in input().strip().split(' ')]
    ls.append((l, r))

for l, r in ls:
    cnt = 0
    s = S[l - 1:r]
    for j in range(len(s) - 1):
        if s[j] == 'A' and s[j + 1] == 'C':
            cnt += 1

    print(cnt)


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

t = [0] * (N + 1)

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
### BUGGY CODE ###



n, w = map(int, raw_input().split())
oo = w + 1
items = []
v = 0
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))
    v += vi

dp = [[oo] * (v + 1) for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 0
for i in range(1, n + 1):
    wi, vi = items[i - 1]
    for j in range(1, v + 1):
        dp[i][j] = dp[i - 1][j]
        if j >= vi:
            dp[i][j] = min(dp[i][j], wi + dp[i - 1][j - vi])
for i in range(v, -1, -1):
    if dp[n][i] <= w:
        print(i)
        break


### FIXED CODE ###


n, w = map(int, raw_input().split())
oo = w + 1
items = []
v = 0
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))
    v += vi

dp = [[oo] * (v + 1) for _ in range(n + 1)]
for i in xrange(n + 1):
    dp[i][0] = 0
for i in xrange(1, n + 1):
    wi, vi = items[i - 1]

    for j in range(1, vi):
        dp[i][j] = dp[i - 1][j]

    for j in range(vi, v + 1):
        if j >= vi:
            dp[i][j] = min(dp[i - 1][j], wi + dp[i - 1][j - vi])
for i in xrange(v, -1, -1):
    if dp[n][i] <= w:
        print(i)
        break
### BUGGY CODE ###

import sys
for line in sys.stdin:
    n=int(line)
    ans=0
    plist = [1 for i in xrange(n+1)]
    plist[0]=0
    plist[1]=0
    for x in xrange(len(plist)):
        if plist[x] == 1:
            ans+=1
            i=2
            while True:
                pos0 = x*i
                if pos0 < len(plist):
                    plist[pos0] = 0
                else:
                    break
                i+=1
    print ans

### FIXED CODE ###

#! -*- coding:utf-8 -*-
import sys
# import time
for line in sys.stdin:
  n=int(line)
  # n=input()
  # start = time.time()
  #plist = [1 for i in xrange(n+1)]
  #??¨??¨1???????????????
  #1?????¨???????????????????´???°??¨??????
  plist = [1]*(n+1)
  #0??¨1????´???°?????????????????§0???????????????
  plist[0]=plist[1]=0
  i=2
  #??¶??°????????????????????????
  while True:
      pos0 = 2*i
      if pos0 < len(plist):
          plist[pos0] = 0
      else:
          break
      i+=1
  #???????????¨????????????????????????
  for x in xrange(3,int(n**0.5)+1):
    if plist[x]:
      for pos0 in xrange(x**2,n+1,x):
        plist[pos0] = 0
  # elapsed_time = time.time()-start
  # print elapsed_time
  print plist.count(1)
### BUGGY CODE ###

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

multi=1
for i in range(len(input)):
  multi *= input[i]
  
if(multi > (10 ** 18)):
  print(-1)
else:
  print(multi)

### FIXED CODE ###

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

for i in range(len(input)):
  if(input[i]==0):
    print(0)
    exit(0)

multi=1
for i in range(len(input)):    
  multi *= input[i]
  if(multi > (10 ** 18)):
    print(-1)
    exit(0)

print(multi)
### BUGGY CODE ###

N = int(input())
Alist = list(map(int,input().split()))
for i in range(N):
    if int(i+1) in Alist:
        a=i+1
        print(Alist.count(a))
    else:
        print(0)

### FIXED CODE ###


N = int(input())
Alist = list(map(int,input().split()))#iの上司

result = [0]*N

for i in range(N-1):#最後の社員に部下いない
    result[Alist[i]-1] +=1#上司の順番の要素に+1

for i in range(N):
    print(result[i])
### BUGGY CODE ###

N = int(input())
len_n = len(str(N))
top_n = N // (10 ** (len_n - 1))
bot_n = N % 10

count = 0

for i in range(1, N + 1):
  p = len(str(i))
  a = i // (10 ** (p - 1))
  b = i % 10
  if a == b:
    count += 1
  s = 2
  while len_n > s:
    count += 10 ** (s - 2)
    s + 1
  if i > 9:
    if top_n > b:
      count += 10 ** (s - 2)
    elif top_n == b:
      if bot_n > a:
        count += 1
      if i > 99:
        count += N // 10 - top_n * 10 ** (len_n - 1)
    
print(count)

### FIXED CODE ###

N = int(input())
C = [[0] * 10 for i in range(10)]

for i in range(1, N + 1):
  p = len(str(i))
  a = i // (10 ** (p - 1))
  b = i % 10
  C[a][b] += 1
  
count = 0
for i in range(10):
  for j in range(10):
    count += C[i][j] * C[j][i]
    #if C[i][j] * C[j][i] > 0:
      #print(i, j)
print(count)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
prev = 1
for i in range(k):
  prev *= a[i]
for i in range(k,n):
  cur = (prev//a[i-k])*a[i]
  print("Yes" if cur > prev else "No")
  prev = cur

### FIXED CODE ###

import math as m

n,k = map(int,input().split())
a = list(map(int,input().split()))
prev = 1
for i in range(k):
  prev += m.log(a[i])
for i in range(k,n):
  cur = prev + m.log(a[i])
  cur -= m.log(a[i-k])
  print("Yes" if cur > prev else "No")
  prev = cur
### BUGGY CODE ###


N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])

ans = float("inf")
for i in range(N-K+1):
  t = H[i:i+K]
  ans = min(ans, t[K-1]-t[0])
print(ans)

### FIXED CODE ###


N, K = map(int, input().split())
H = [int(input())  for i in range(N)]

H = sorted(H)
ans = 999999999999999999999
for i in range(N-K+1):
  ans = min(ans, H[i+K-1] - H[i])

print(ans)
### BUGGY CODE ###

N,M,L=map(int, input().split())
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k] + d[k][j])
    return d

d=[[float("inf")]*N for i in range(N)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    x,y,z=map(int,input().split())
    d[x-1][y-1]=z
    d[y-1][x-1]=z
for i in range(N):
    d[i][i]=0 #自身のところに行くコストは０
D=warshall_floyd(d)
E=[[float("inf")]*N for i in range(N)] 
for i in range(N):
  for j in range(N):
    if D[i][j]==0:
      E[i][j]=0
    elif D[i][j]<=L:
      E[i][j]=1
F=warshall_floyd(E)
N=int(input())
for i in range(N):
  x,y=map(int,input().split())
  if F[x-1][y-1]==float("inf"):
    print(-1)
  else:
    print(F[x-1][y-1]-1)

### FIXED CODE ###

N,M,L=map(int, input().split())
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k] + d[k][j])
    return d

d=[[float("inf")]*N for i in range(N)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    x,y,z=map(int,input().split())
    d[x-1][y-1]=z
    d[y-1][x-1]=z
for i in range(N):
    d[i][i]=0 #自身のところに行くコストは０
D=warshall_floyd(d)
E=[[float("inf")]*N for i in range(N)] 
for i in range(N):
  for j in range(N):
    if D[i][j]==0:
      E[i][j]=0
    elif D[i][j]<=L:
      E[i][j]=1
F=warshall_floyd(E)
N=int(input())
for i in range(N):
  x,y=map(int,input().split())
  if F[x-1][y-1]==float("inf"):
    print(-1)
  else:
    print(F[x-1][y-1]-1)
### BUGGY CODE ###

N,K,Q = (int(x) for x in input().split())
Win = ['No']*N
A = [int(input()) for I in range(Q)]
    
for TT in range(0,N):
    if K-Q+A.count(TT+1)>0:
        Win[TT] = 'Yes'
print('\n'.join(Win))

### FIXED CODE ###

def Convert(N):
    if N>0: return 'Yes'
    else: return 'No'

N,K,Q = (int(x) for x in input().split())
Win = [K-Q]*N
for T in range(0,Q):
    Win[int(input())-1] += 1
print('\n'.join(list(map(Convert,Win))))
### BUGGY CODE ###

n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)

### FIXED CODE ###

n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)
### BUGGY CODE ###

def main():
    import sys
    from collections import deque
    def input(): return sys.stdin.readline().rstrip()
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if 0 <= nx < h and 0 <= ny < w:
                    if field[nx][ny] == '@': break
                    if dist[nx][ny] <= dist[x][y]: break
                    if dist[nx][ny] > dist[x][y] + 1:
                        dist[nx][ny] = dist[x][y] + 1
                        que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                if dist[nx][ny] > dist[x][y] + 1:
                    dist[nx][ny] = dist[x][y] + 1
                    que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

R, G, B, n = map(int, input().split())
cnt = 0
for r in range(n//R+1):
  for g in range((n-r*R)//G+1):
    b = (n - r * R - g * G) // B
    if r * R + g * G + b * B == n:
      cnt += 1
print(cnt)

### FIXED CODE ###

R, G, B, n = map(int, input().split())
cnt = 0
for r in range(n//R+1):
  for g in range((n-r*R)//G+1):
    b = (n-r*R-g*G)//B
    if r * R + g*G + b*B == n:
      cnt += 1
print(cnt)
### BUGGY CODE ###

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

x = []
for i in range(M):
    j = X[i]-min(X)
    x.append(j)
x =sorted(x)

y = []
for i in range(M-1):
    m = x[i+1] - x[i]
    y.append(m)
y = sorted(y)

z = 0
for i in range(len(y)-N+1):
    z += y[i]
print(z)

### FIXED CODE ###

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

X =sorted(X)

y = []
for i in range(M-1):
    m = X[i+1] - X[i]
    y.append(m)
y = sorted(y)

z = 0
for i in range(len(y)-N+1):
    z += y[i]
print(z)
### BUGGY CODE ###

import math

n=int(input())
for i in range(int(math.sqrt(n))):
    while (i+1)**2 < n:
        pass
print((i+1)**2)

### FIXED CODE ###

n=int(input())
print((int(n**0.5))**2)
### BUGGY CODE ###

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

N,M = map(int,input().split(" "))
S = input()
T = input()
Answer = int(len(S)*len(T)/gcd(len(S),len(T)))
X = [0 for i in range(Answer)]

if (gcd(len(S),len(T)) == 1)and(S[0] == T[0]):
    print(Answer)
    exit()

for i in range(len(S)):
    X[int(i*Answer/len(S))] = S[i]

for i in range(len(T)):
    if (X[int(i*Answer/len(T))] == 0)or(X[int(i*Answer/len(T))] == T[i]):
        continue
    else:
        print(-1)
        exit()
print(Answer)


### FIXED CODE ###

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

N,M = map(int,input().split(" "))
S = input()
T = input()
N = len(S)
M = len(T)
x = gcd(N,M)
y = int(N*M/x)

for i in range(x):
    if S[int(i*y/M)] == T[int(i*y/N)]:
        continue
    else:
        print(-1)
        exit()
print(y)
### BUGGY CODE ###

S = input()
l = list(S)
count = 0
end = False
while end != True:
    temp_count = 0
    for i in range(len(l)-1):
        if l[i] == "B" and l[i+1] == "W":
            l[i] = "W"
            l[i+1] = "B"
            count += 1
            temp_count += 1
    if temp_count == 0:
        end = True
print(count)

### FIXED CODE ###

S = input()
l1 = list(S)
l2 = sorted(l1,reverse=True)
m1 = [i for i, x in enumerate(l1) if x == 'W']
m2 = [i for i, x in enumerate(l2) if x == 'W']
count = 0
for i in range(len(m1)):
    count += m1[i] - m2[i]
print(count)