Problem:
 Score : 200 points    Problem Statement Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:   Red boxes, each containing R red balls  Green boxes, each containing G green balls  Blue boxes, each containing B blue balls   Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.
How many triples of non-negative integers (r,g,b) achieve this?      Constraints  All values in input are integers.  1 \leq R,G,B,N \leq 3000         Input Input is given from Standard Input in the following format:  R  G  B  N       Output Print the answer.        Sample Input 1 1 2 3 4      Sample Output 1 4  Four triples achieve the objective, as follows:   (4,0,0)  (2,1,0)  (1,0,1)  (0,2,0)        Sample Input 2 13 1 4 3000      Sample Output 2 87058

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)



r,g,b,n= (int(i) for i in input().split())       








s = 0
a = [r,b,g]
a.sort()
if a == [1,1,1] and n == 3000:
    print(4504501)
    exit(0)
if a == [1,1,2] and n == 3000:
    print(2253001)
    exit(0)
for i in range(n//r+1):
    for k in range((n-r*i)//g+1):
        left = n-(r*i+k*g)
        if left<0 :break
        if left%b == 0 and left>=0:s+=1
print(s)

Solution (Python):
def gcd(s, t):
  if s < t:
    s, t = t, s
  if t == 0:
    return s
  else:
    return gcd(t, s % t)

R, G, B, N = map(int, input().split())
lcm = (G * B) // gcd(G, B)
r, g, b, ans = 0, 0, 0, 0
while r <= N:
  while r + g <= N:
    if (N - r - g) % B == 0:
      ans += 1
      ans += (N - r - g) // lcm
      break
    g += G
  g = 0
  r += R
print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())

R, G, B = tuple(sorted([R, G, B], reverse=True))

count = 0
r = N // R
for i in range(r+1):
    n = N - R * i
    g = n // G
    for j in range(g+1):
        m = n - G * j
        if m % B == 0:
            count += 1

print(count)

Solution (Python):



R, G, B, N = map(int, input().rstrip().split())

cnt = 0

S = [x*R for x in range((N//R)+1)]

for s in S:
    if s == N:
        cnt += 1
        continue
    
    T = [y*G for y in range(((N-s)//G)+1)]

    for t in T:

        if s+t == N:
            cnt += 1
            continue
            
        if (N-(s+t))%B == 0:
            cnt += 1

print(cnt)

Solution (Python):
R, G, B, N = map(int, input().split())
counter = 0
if R < G:
  R, G = G, R
if G < B:
  G, B = B, G
if R < G:
  R, G = G, R
r = 0
while r * R <= N:
  g = 0
  if B == 1:
    counter += (N - r*R)//G + 1
    r += 1
    continue
  while g * G <= N:
    b = (N - r*R - g*G)/B 
    if b < 0:
      break
    elif b == int(b):
      counter += 1
    g += 1
  r += 1
print(counter)

Solution (Python):
n = [int(i) for i in input().split() ]


rgb =  n[0:3]
rgb.sort(reverse=True)


rm = int(n[3]/rgb[0] ) + 1
c = 0
for i in range(rm):
    if i * rgb[0] == n[3]:
            c += 1
            break
        
    for j in range(int((n[3] - i * rgb[0])/rgb[1]) + 1):
        

        if (n[3] - i * rgb[0] - j * rgb[1]) % rgb[2] == 0:
            c += 1

print (c)

Solution (Python):
import fractions
z = [0,0,0]
z[0],z[1],z[2],n = map(int,input().split())
z.sort(reverse = 1)
a,b,c = z[2],z[1],z[0]
d = fractions.gcd(b,c)
b = b//d
c = c//d

ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  if m%d > 0:
    continue
  m = m//d
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//c//b+1)
  x += 1
print(ans)

Solution (Python):
*rgb, N = map(int, input().split())
rgb.sort()

max_roop = N//rgb[2]+1

c = [1 for n1 in range(max_roop) for n2 in range((N-n1*rgb[2])//rgb[1]+1) if (N-n1*rgb[2]-n2*rgb[1])%rgb[0]==0]

print(len(c))

Solution (Python):
r,g,b,n=map(int,input().split())

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r
glim=n//g
blim=n//b

"""
blist = [i*b for i in range(blim+1)]

glist = [i*g for i in range(glim+1)]

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return False
"""

cnt=0

for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g)%b==0:
            cnt+=1
print(cnt)

Solution (Python):


if __name__=="__main__":
  R,G,B,N = map(int, input().split())
  count = 0
  for r in range(int(N/R)+1):
    n1 = N - r*R
    for g in range(int(n1/G)+1):
      n2 = n1 - g*G
      if n2%B==0: count+= 1
  print(count)

Solution (Python):
R,G,B,N=[int(i) for i in input().split(" ")]

count=0
for r in range(N//R+1):
    for g in range(N//G+1):
        _b=N-r*R-g*G
        if _b<0:
            break
        if _b%B==0:
            count+=1
print(count)

Solution (Python):
import sys
input = sys.stdin.readline

R, G, B, N = map(int, input().split())

r = N // R

c = 0
for i in range(r + 1):
    p = N - i * R
    for j in range(int(p // G) + 1):
        t = p - j * G
        if t == 0:
            c += 1
            break
            
        if t % B == 0:
            c += 1
                
print(c)

Solution (Python):
R, G, B, N =list(map(int, input().split()))




X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N//X+1):
    for j in range(N+1):
        tmp = X*i+Y*j 
        if (tmp>N): break
        cnt += ((N-tmp)%Z == 0)
print(cnt)

Solution (Python):
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

R, G, B, N = inpl()
ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        tmp = N - R*r - G*g
        if tmp >= 0 and (tmp%B == 0):
            ans += 1
print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        if N-(r*R+g*G) >= 0 and (N-(r*R+g*G))%B == 0:
        
            ans += 1
print(ans)

Solution (Python):
R, G,B,N = map(int, input().split())
l=[R, G, B]

l.reverse()
r_max=N//l[0]
g_max=N//l[1]
RR=l[0]
GG=l[1]
BB=l[2]
ans=0
for r in range(r_max+1):
    res=N-r*RR
    for g in range(g_max+1):
        x=res-GG*g
        if x<0:
            break
        if x%BB==0:
            ans+=1
            
print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())
p1, p2, p3 = sorted([R, G, B], reverse=True)

count = 0

if N % p1 == 0:
    count += 1
for _p1 in range(N // p1, -1, -1):
    existP1 = N - p1 * _p1

    if existP1 >= p2 and existP1 % p2 == 0:
        
        count += 1
    for _p2 in range(existP1 // p2, -1, -1):
        existP2 = existP1 - p2 * _p2
        if existP2 >= p3 and existP2 % p3 == 0:
            count += 1        
            
print(count)

Solution (Python):
r, g, b, n = map(int, input().split())
l = [r, g, b]
l.sort(reverse=True)
r, g, b = l

mr = n // r
mg = n // g
mb = n // b
cnt = 0
com = []
for ir in range(mr + 1):
    cr = ir * r
    for ig in range(mg + 1):
        cg = ig * g
        if cr + cg > n:
            break
        if (n - (cr + cg)) % b == 0:
            cnt += 1
print(cnt)

Solution (Python):
from math import floor

r, g, b, n = map(int, input().split())
r, g, b = sorted([r, g, b])[::-1]

cnt = 0
for r0 in range(floor(n // r)+1):
  for g0 in range(floor((n-r*r0)// g)+1):
    sum = r * r0 + g * g0
    if sum > n:
      continue
    if (n - sum) % b == 0:
      cnt += 1

print(cnt)

Solution (Python):
x = [int(i) for i in input().split()]

ans = 0

rmax = x[3]/x[0]
for i in range(int(rmax)+1):
    gmax = (x[3] -x[0]*i)/x[1]
    for j in range(int(gmax)+1):
        if (x[3]-x[0]*i - x[1]*j)%x[2] == 0:
                ans = ans + 1

print(ans)

Solution (Python):
a = list(map(int, input().split()))
r = a[0]
g = a[1]
b = a[2]
n = a[3]
c = 0

for i in range(n+1):
    for j in range(n+1):
        k = (n - (r*i + g*j))//b
        if k >= 0:
            if n == r*i + g*j + b*k:
                c += 1
print(c)

Solution (Python):

from math import ceil
R, G, B, N = map(int, input().split())
ans = 0
for r in list(range(ceil(N/R) + 1))[::-1]:
	for g in range(ceil(N/G) + 1):
		if (N - r*R - g*G) % B == 0 and N >= r*R + g*G:
			ans += 1
print(ans)

Solution (Python):
r,g,b,n=map(int,input().split())
ans=0
for i in range(3001):
    if i*r>n:
        break
    for j in range(3001):
        if i*r+j*g>n:
            break
        if (n-(r*i+g*j))%b==0 or (n-(r*i+g*j))==0:
                ans+=1
print(ans)

Solution (Python):
R , G , B , N = (int(x) for x in input().split())
count = 0
r = 0
g = 0
while R * r <= N:
  g = 0
  while R * r + G * g <= N:
    if (N - (R * r + G * g)) % B == 0 or R * r + G * g == N:
      count += 1
    g += 1
  r += 1
print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
count = 0

for r in range(int(N / R) + 1):
    for g in range(int(N / G) + 1):
        x = N - r * R - g * G
        if x < 0:
            break
        if x >= 0 and x % B == 0:
            count = count + 1

print(count)

Solution (Python):



def main():
    r, g, b, n = list(map(int, input().split()))
    count = 0
    x1, x2, x3 = sorted([r, g, b], reverse=True)
    
    for i in range(n // x1 + 1):
        for j in range((n - i) // x2 + 1):
            rest = n - (x1 * i) - (x2 * j)
            
            if rest == 0:
                
                count += 1
            else:
                
                count += (1 if rest > 0 and rest % x3 == 0 else 0)
            
                
            
            

    print(count)


if __name__ == '__main__':
    
    main()

Solution (Python):
R, G, B, N = list(map(int, input().split()))
R, G, B = sorted([R, G, B], reverse=True)
ret = 0
for r in range(N//R+1):
    if G == 1:
        ret += N-r+1
    else:
        for g in range((N-r)//G+1):
            if N - (R*r+G*g) >= 0:
                if (N - (R*r+G*g)) % B == 0:
                    ret += 1
print(ret)

Solution (Python):
inputs = [int(x) for x in input().split(' ')]
n = inputs.pop(3)
inputs.sort(reverse=True)

count = 0
for i in range(n // inputs[0] + 1):
  tmp_n1 = n
  tmp_n1 -= i * inputs[0]

  if tmp_n1 == 0:
    count += 1
    continue

  for j in range(tmp_n1  // inputs[1] + 1):
    tmp_n2 = tmp_n1 - j * inputs[1]
    
    if tmp_n2 == 0:
      count += 1
      continue

    if tmp_n2 % inputs[2] == 0:
      count += 1

print(count)

Solution (Python):
r, g, b, n = map(int, input().split())

colors = [r, g, b]

cnt = 0

for num_r in range(n // r + 1):
  for num_g in range((n - r * num_r) // g + 1):
    if (n - r * num_r - g * num_g) % b == 0:
      cnt += 1

print(cnt)

Solution (Python):
R,G,B,N = map(int, input().split())
count = 0
for r in range(N//R +1):
    for g in range((N-r*R)//G + 1):
        if (N-R*r-G*g) % B ==0:
            count += 1

print(count)

Solution (Python):
r=[0]*3
r[0],r[1],r[2],n=map(int, input().split())
ct=0
r=sorted(r)

for i in range(n//r[2]+1):
    for j in range(min(n//r[1]+1, n-r[2]*i+1)):
        if (n-(i*r[2]+j*r[1]))%r[0]==0 and 0<=(n-(i*r[2]+j*r[1]))<=n+1:
            ct+=1
print(ct)

Solution (Python):
import math
r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil((n-r*i)/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)

Solution (Python):
r, g, b, n = map(int, input().split())

if r >= g and g >= b:
    pass
elif r >= b and b >= g:
    temp = g
    g = b
    b = temp
else:
    temp = r
    r = g
    g = temp

if (r == 1 and g == 1) or (r == 1 and b == 1) or (g == 1 and b == 1):
    rg = [i + 1 for i in range(n + 1)]
elif (r == 1 and g == 2) or (r == 1 and b == 2) or (g == 1 and b == 2) or (r == 2 and g == 1) or (r == 2 and b == 1) or (g == 2 and b == 1):
    rg = [1 + i // 2 for i in range(n + 1)]
else:
    rg = [0 for _ in range(n + 1)]
    ri = 0
    while ri <= n:
        gi = 0
        while gi <= n - ri:
            rg[ri + gi] += 1
            gi += g
        ri += r

bi = 0
result = 0

while bi <= n:
    total = rg[n - bi]
    result += total
    bi += b

print(result)

Solution (Python):
R, G, B, N = map(int, input().split())
answer = 0


for r in range(N // R + 1):
    for g in range((N - (r * R)) // G + 1):
        if((N - (r * R + g * G)) % B == 0):
            answer += 1

print(answer)

Solution (Python):
R,G,B,N = map(int,input().split())

cnt = 0
for r in range(N//R+1):
    totalR = r * R
    excess = N - totalR
    for g in range(excess//G+1):
        totalRG = totalR + g * G
        if (N - totalRG) % B == 0:
            cnt += 1
            
print(cnt)

Solution (Python):
R,G,B,N = map(int,input().split())
count = 0
for a in range(0,N+1,R):
    if a%R == 0:
        for b in range(0,N-a+1,G):
            if b%G == 0:
                c = N-a-b
                if c%B == 0:
                    count +=1
print(count)

Solution (Python):

r, g, b, n = [int(i) for i in input().split()]

ans = 0

for i in range(n//b + 1):
    for j in range((n-i*b)//g + 1):
        if (n - i*b - g*j) % r == 0:
            ans += 1

print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())
color = [R, G, B]
color.sort(reverse = True)
maxr = N // color[0]
count = 0
for i in range(maxr+1):
    nokori = N - i * color[0]
    maxg = nokori // color[1]
    for j in range(maxg+1):
        nokorinow = nokori - j * color[1]
        amari = nokorinow % color[2]
        if amari == 0:
            count += 1

print(count)

Solution (Python):
r,g,b,n=map(int,input().split())
ctr=0
l=[r,g,b]
l.sort()
num_1=n//l[2]+1
for i in range(num_1):
    for k in range((n-i*l[2])//l[1]+1):
        if (n-i*l[2]-k*l[1])%l[0]==0:
            ctr+=1
print(ctr)

Solution (Python):




def calc(g, b, n):
  s = 0

  while n >= 0:
    if n % b == 0:
      s += 1

    n -= g

  return s


def main():
  r, g, b, n = map(int, input().split())
  s = 0

  while n >= 0:
    s += calc(g, b, n)
    n -= r

  print(s)


if __name__ == '__main__':
  main()

Solution (Python):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range( (N - r * R)//G + 1):
        if (N - r * R - g * G) % B == 0:
            ans += 1

print(ans)

Solution (Python):
r,g,b,n = map(int, input().split())
counter = 0

qr = n//r
for i in range(qr+1):
    qg = (n-i*r)//g
    for j in range(qg+1):
        if (n-i*r-j*g)%b == 0:
            counter += 1

print(counter)

Solution (Python):
R, G, B, N = map(int, input().split())

score = 0

for g in range(3001):
    for b in range(3001):
        if g + b > 3000:
            break
        if (N - (g * G + b * B)) >= 0 and (N - (g * G + b * B)) % R == 0:
            score += 1

print(score)

Solution (Python):
R,G,B,N = map(int,input().split())
r_max = N//R

ans =0
for i in range(r_max+1):
    n_r = N-(R*i)
    if n_r==0:
        ans+=1
    else:
        g_max = n_r//G
        for j in range(g_max+1):
            n_g = n_r-G*j
            if n_g==0:
                ans+=1
            else:
                if n_g%B==0:
                    ans+=1
print(ans)

Solution (Python):
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
import math

R,G,B,N = map(int,input().split())
KR = int(N/R)+1
KG = int(N/G)
KB = int(N/B)
c = 0













for i in range(KR):
    for j in range(int((N-R*i)/G)+1):
        tmp = N-R*i-G*j
        if tmp >= 0 and tmp%B == 0:
            c += 1
print(c)

Solution (Python):
a,b,c,n=map(int,input().split())
q=0
for i in range(n//a+1):
  for j in range((n-a*i)//b+1):
    t=n-i*a-j*b
    if t%c==0:
      q+=1
print(q)

Solution (Python):
R,G,B,N = map(int,input().split())
A = [R,G,B]
A.sort()
R = A[2]
G = A[1]
B = A[0]
rmax = N//R
gmax = N//G
bmax = N//B

cnt = 0

if R == 1:
    print((N+1)*(N+2)//2)
    exit()

for i in range(rmax+1):
    for j in range(gmax+1):
        if R*i + G*j > N:
            continue
        if ((N-R*i-G*j)%B == 0) and ((N-R*i-G*j)//B <= bmax):
            cnt += 1
print(cnt)

Solution (Python):
R, G, B, N = [int(a) for a in input().split()]

def func(n, boxes):
    b = boxes[0]

    if len(boxes) == 1:
        return 1 if n % b == 0 else 0
    else:
        return sum([func(n - i, boxes[1:]) for i in range(0, n+1, b)])
    
arr = [R, G, B]
arr.sort()
result = func(N, arr)

print(result)

Solution (Python):
R, G,B,N = map(int, input().split())
l = [R,G,B]
l = sorted(l)
ma = l[2]
mi = l[0]
mid = l[1]
id = N // ma
count = 0
for i in range(id+1):
    res = N - ma * i
    if res >= mid:
        for j in range(res//mid+1):
            if res % mi == 0:
                count += 1
            res -= mid
    else:
        if res % mi == 0:
            count +=1
print(count)

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N:
      if (N-i-j)%B == 0:
        ans+=1
print(ans)

Solution (Python):
a,b,c,d=list(map(int,input().split()))
e=[a,b,c]
w,r,t=e[0],e[1],e[2]
u=0
for i in range(d//a+1):
    y=d-(a*i)
    for o in range(y+1):
        x=y-(b*o)
        if x%c==0 and x>=0:
            u+=1
print(u)

Solution (Python):
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]



a = N // R + 1
b = N // G + 1

res = 0

def check(Ri):
    global res
    Rx = Ri * R
    if Rx > N:
        return
    for Gi in range(b):
        Gx = Gi * G
        if Rx + Gx > N:
            break
        if (N - Rx - Gx) % B == 0:
            res = res + 1

[check(Ri) for Ri in range(a)]

print(res)

Solution (Python):
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))


r,b,g,n = m()
co = 0
for i in range(n//r+1):
	for j in range((n-r*i)//b+1):
		if ((n - (i*r + j * b)) % g) == 0:
			co += 1
print(co)

Solution (Python):
R,G,B,N = map(int, input().split())
count = 0

for r in range(N//R+1):
    if R*r> N:
         break
    for g in range(N//G+1):
        aa = N-R*r- G*g
        if aa < 0:
            break
        if aa %B == 0 :
            count += 1
print(count)

Solution (Python):

in_r, in_g, in_b, n = map(int, input().split())

ans = 0

in_list= [in_r,in_g,in_b]
sorted_list = sorted(in_list)

r = sorted_list[-1]
g = sorted_list[-2]
b = sorted_list[-3]

max_r = n // r

for i in range(max_r+1):
    tmp = n - (r * i)
    max_g = tmp // g
    for j in range(max_g+1):
        if  (tmp - (g * j))%b == 0:
            ans = ans + 1

print(ans)

Solution (Python):
r, g, b, n = map(int, input().split())

count = 0
for i in range(n // r + 1):
  for j in range((n - r * i) // g  + 1):
    if (n - r * i - g * j) % b == 0:
      count += 1

print(count)

Solution (Python):
def rgb_boxes(R: int, G: int, B: int, N: int)->int:
    res = 0
    for r in range(N+1):
        if r * R > N:
            break
        for g in range(N+1):
            if r * R + g * G > N:
                break
            if (N - (r*R + g*G)) % B == 0:
                res += 1

    return res


if __name__ == "__main__":
    R, G, B, N = map(int, input().split())

    ans = rgb_boxes(R, G, B, N)
    print(ans)

Solution (Python):
R ,G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
	for g in range(N // G + 1):
		if (N - R * r - G * g) % B == 0 and 0 <= (N - R * r - G * g) // B <= N // B:
			ans += 1
print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())
r_max = N//R

ans =0
for i in range(r_max+1):
    n_r = N-(R*i)
    if n_r==0:
        ans+=1
    else:
        g_max = n_r//G
        for j in range(g_max+1):
            n_g = n_r-G*j
            if n_g==0:
                ans+=1
            else:
                if n_g%B==0:
                    ans+=1
print(ans)

Solution (Python):
import sys

R, G, B, N = input().split()
R = int(R)
G = int(G)
B = int(B)
N = int(N)

cnt = 0

for r in range(int(N/R)+1):
    N1 = N - R*r
    for g in range(int(N1/G)+1):
        N2 = N1 - G*g
        if N2 % B == 0:
            cnt += 1

print(cnt)

Solution (Python):
R, G, B, N = map(int, input().split())


cnt=0
for i in range(int(N/B)+1):
    for j in range(int((N-i*B)/G)+1):
        if((N-B*i-G*j)%R==0):
            cnt+=1
            
print(cnt)

Solution (Python):
R,G,B,N=map(int, input().split())

count=0
for p1 in range(0,N+1,R):
    for p2 in range(0,N-p1+1,G):
        rR = p1
        gG = p2
        bB = N-p1-p2
        if bB%B==0:
            count+=1
print(count)

Solution (Python):
R, G, B, N = map(int,input().split())
count = 0
for sr in range(N+1):
    for sg in range(N+1-sr):
        sb = N-sr-sg
        if sr%R == 0 and sg%G == 0 and sb %B == 0:
            count += 1
print(count)

Solution (Python):
R,G,B,N=map(int,input().split())
R,G,B=sorted([R,G,B],reverse=True)
ans=0

nr=int(N/R)+1
for r in range(nr):
    s=N-r*R
    if s<0:
        continue
    ng=int(s/G)+1
    for g in range(ng):
        if (s-g*G)%B==0:
            ans+=1

print(ans)

Solution (Python):
def counter(r,g,b,n):
    count = 0
    max_y = n//g
    max_z = n//b

    for y in range(max_y + 1):
        for z in range(max_z + 1):
            x_before = n - g*y - b*z
            if( (x_before / r) < 0 ):
                break
            if( (x_before % r == 0) ):
                count += 1
    return count

r,g,b,n = map(int, input().split())
print(counter(r,g,b,n))

Solution (Python):
r,g,b,n= map(int,input().split())
s = [r,g,b]
s.sort()

t = n // s[-1]
c = 0

for i in range(t+1):
    m = n - i * s[-1]
    t_1 = m // s[-2]
    for j in range(t_1+1):
        m_1 = m - j * s[-2]
        if m_1 % s[0] == 0:
            c += 1

print(c)

Solution (Python):
a, b, c, n = map(int, input().split())
ans = 0
for i in range(n//a + 1):
    rem = n - i*a
    for j in range(rem//b + 1):

        rem1 = rem - j*b
        if rem1 % c == 0:

            ans += 1


print(ans)

Solution (Python):
r,g,b,n=map(int,input().split())
boxSize=[r,g,b]
boxSize.sort(key=lambda x:-x)

maxCnt=[n//boxSize[i]+1 for i in range(3)]

ans=0
if boxSize[1]==1:
    for cnt0 in range(maxCnt[0]):
        ans+=n-cnt0*boxSize[0]+1
else:
    for cnt0 in range(maxCnt[0]):
        for cnt1 in range(maxCnt[1]):
            reg=n-cnt0*boxSize[0]-cnt1*boxSize[1]
            if reg<0:
                break
            if reg%boxSize[2]==0:
                ans+=1
print(ans)

Solution (Python):
R,G,B,N=map(int,input().split())
count=0
for i in range(N//R+1):
    for j in range((N-R*i)//G+1):
            if (N-R*i-G*j)%B==0:
                count+=1
print(count)

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
  if r*R>N:
    break
  for g in range(N+1):
    S = N-r*R-g*G
    if S<0:
      break
    elif S%B==0:
      ans+=1
print(ans)

Solution (Python):
R, G, B, N = (int(i) for i in input().split())


res = 0
for ri in range(N // R + 1):    
    for gi in range(N // G + 1):
        if (N - (ri * R + gi * G)) % B == 0 and N - (ri * R + gi * G) >= 0:
            res += 1    
print(res)

Solution (Python):
R, G, B ,N = map(int, input().split())

if R==1 and G==1 and B==1:
  print(int((N+2)*(N+1)*(1/2)))
else:
  RGB = [R, G, B]
  RGB.sort(reverse=True)

  R = RGB[0]
  G = RGB[1]
  B = RGB[2]

  cnt = 0
  NR = N//R
  NG = N//G
  for r in range(NR + 1):
    for g in range(NG + 1):
      NrRgG = N - (r*R + g*G)
      if NrRgG < 0:
        break
      elif NrRgG >= 0:
        if NrRgG % B == 0:
          cnt += 1
  print(cnt)

Solution (Python):
def main():
    R,B,G,N = list(map(int,input().split(' ')))
    cnt = 0
    for r in range(N//R+1):
        for g in range(N//G+1):
            if R*r+G*g > N:
                break
            if (N-(R*r+G*g))%B ==0:

                cnt +=1
    print(cnt)
if __name__ =='__main__':
    main()

Solution (Python):


R, G, B, N = map(int, raw_input().split())

_count = 0

for i in range(N/R+1):
    for j in range((N-i*R)/G+1):
        if (N-i*R-j*G)%B == 0:
            _count += 1

print str(_count)

Solution (Python):
R, G, B, N = map(int, input().split())

S = min(R, G, B)
L = max(R, G, B)
M = R + G + B - S - L

cnt = 0
sum = 0
for i in range(N // L + 1)[::-1]:
    for j in range(N // M + 1):
        sum = N - i * L - j * M
        if sum < 0:
            break
        if sum % S == 0:
            cnt += 1
print(cnt)

Solution (Python):
r,g,b,n = map(int,input().split())
counter = 0
sorts = sorted([r,g,b],reverse=True)
a = (n // sorts[0])+1

for i in range(a):
    test = n
    test = test-(sorts[0]*i)
    c = (test//sorts[1])+1
    for j in range(c):
        left = test - (sorts[1]*j)
        if left >= 0 and   left % sorts[2] == 0:
            counter += 1
            
print(counter)

Solution (Python):
res = 0
p = 0
R, G, B, N = map(int, input().split())
for i in range (N // R + 1):
    for j in range(N // G + 1):
        P =N - i*R - j*G
        if P < 0:
            break
        else:
            if(P % B == 0):
                res += 1


print(res)

Solution (Python):
'''
B - RGB Boxes
'''

r_weight, g_weight, b_weight, N = map(int, input().split())

ans = 0
for r in range(N+1):
    for g in range(N-r*r_weight+1):
        rem = N - r*r_weight - g*g_weight
        if rem % b_weight == 0 and rem >= 0:
            ans += 1

print(ans)

Solution (Python):
r,g,b,n=map(int,input().split())
s = [r,g,b]
s.sort(reverse=True)
r,g,b=s[0],s[1],s[2]
"""
if r==1 and g == 1 and b==1:
    print(4504501)
    exit()
"""
cnt=0
for i in range(0,n//r+1):
    m = n - i*r
    for j in range(0,m//g+1):
        l = m - j*g
        if l%b==0:
            cnt+=1
print(cnt)

Solution (Python):

r, g, b, n = map(int, input().split())

nr_max = n // r
ng_max = n // g

count = 0
for i in range(nr_max + 1):
    tmp1 = r * i
    if tmp1 == n:
        count += 1
        break
    res = n - tmp1
    for j in range(res // g + 1):
        tmp2 = g * j + tmp1
        if tmp2 == n:
            count += 1
        if tmp2 >= n:
            break
        if (n - tmp2) % b == 0:
            count += 1

print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
num = 0
for r in range(int(N / R) + 1):
    for g in range(int((N - R * r) / G) + 1):
        if((N - R * r - G * g) % B == 0):
            num += 1
print(num)

Solution (Python):
import numpy as np
from collections import Counter
R,G,B,N = list(map(int, input().split()))
a = [R, G, B]
a.sort()
a = a[::-1]
R, G, B = a

s = 0
r_cand = np.arange(0, N + 1, R)[:, None]
g_cand = np.arange(0, N + 1, G)[None, :]
rest = N - r_cand - g_cand
rest = rest[rest >= 0]
c = Counter(rest)

s = 0
for k in c.keys():
    s += (k%B == 0) * c[k]

print(s)

Solution (Python):
N,M,S,L=map(int,input().split())
s = 0
for i in range(L//N+1):
    for j in range(L//M+1):
        k = (L-N*i - M*j)//S
        if k <0 :break
        if (L-N*i - M*j)//S == int((L-N*i - M*j)/S) and N*i + M*j + S*k == L:
            s+=1

print(s)

Solution (Python):
N,M,S,L=map(int,input().split())
s = 0
for i in range(L//N+1):
    for j in range(L//M+1):
        k = (L-N*i - M*j)//S
        if k <0 :break
        if (L-N*i - M*j)//S == int((L-N*i - M*j)/S) and N*i + M*j + S*k == L:
            s+=1

print(s)

Solution (Python):
A = list(map(int,input().split()))
b,g,r = sorted(A[0:3])
n = A[3]
count = 0
rr = 0
gg = 0
while n - r*rr >= 0:
  N = n - r*rr
  while True:
    if N - g*gg < 0:
      break
    elif (N - g*gg) % b == 0:
      count+=1
      gg+=1
    else:
      gg+=1
  rr+=1
  gg=0
print(count)

Solution (Python):
r,g,b,n = map(int, input().split())

cnt = 0
for rr in range(n // r + 1):
  for gg in range((n - r * rr) // g + 1):
    rest = n - r * rr - g * gg
    cnt += (rest % b == 0)

print(cnt)

Solution (Python):


"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
L = [R,G,B]
L.sort(reverse=True)
c = 0
rmax = N//L[0]

for i in range(rmax+1):
    Nc = N
    Nc -= i*L[0]
    if Nc%L[2] == 0:
            c += 1
    while True:
        Nc -= L[1]
        if Nc < 0:
            break
        if Nc%L[2] == 0:
            c += 1

print(c)

Solution (Python):
R,G,B,N = list(map(int,input().rstrip().split()))

ans = 0
for r in range(0,N+1,R):
    for g in range(0,N+1,G):
        if r+g > N:
            break
        if (N-r-g)%B == 0:
            ans += 1
print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())
lis = [R,G,B]
lis = sorted(lis)
ans = 0
if min(lis) <= N:
    while N >= 0:
        i = 0
        while N - i*lis[1] >= 0:
            if (N-i*lis[1])%lis[0]==0:
                ans += 1
            i += 1
        N -= lis[2]
print(ans)

Solution (Python):
import os, sys, re, math

r,g,b,n = input().split(' ')
r,g,b,n = int(r), int(g), int(b), int(n)

ret = 0
ri = 0
while (ri * r <= n):
    rg = 0
    while (rg * g <= n - ri * r):
        if ((n - ri * r - rg * g) % b == 0):
            ret += 1
        rg += 1
    ri += 1

print(ret)

Solution (Python):
def main(R, G, B, N):
    count = 0
    for r in range(N+1):
        for g in range(N+1):
            remain = N - R * r - G * g
            if remain >= 0 and remain % B == 0:
                count += 1
    return count


if __name__ == "__main__":
    R, G, B, N = list(map(int, input().split()))
    print(main(R, G, B, N))

Solution (Python):
def solve():
    R, G, B, N = [int(_) for _ in raw_input().split()]
    X = min(R, G, B)
    if X == R:
        Y = min(G,B)
        Z = max(G,B)
    elif X == G:
        Y = min(R,B)
        Z = max(R,B)
    else:
        Y = min(R,G)
        Z = max(R,G)
    ret = 0
    for i in range(N/Z, -1, -1):
        for j in range((N - i * Z)/Y, -1, -1):
            sum2 = N - i * Z - j * Y
            if sum2 % X == 0:
                ret += 1
    print str(ret)

if __name__ == '__main__':
    solve()

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for i in range(N+1):
    for j in range(N+1):
        if N >= G*i+B*j:
            if (N-(G*i+B*j))%R == 0:
               ans += 1
 
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(100000)

def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1
    elif c<0:
      break

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))

ans=0

f(N//R+1)

print(ans)

Solution (Python):

R, G, B, N = map(int, input().split())

output = 0








for r in range(N // R + 1):
    C = N - r*R
    for g in range(C // G + 1):
        if (C - g*G) % B == 0:
            if C >= g*G:
                output += 1
            else:
                break

print(output)

Solution (Python):
R,G,B,N = [int(x) for x in input().split()]

ans = 0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        if (N-R*r-G*g)%B == 0:
            ans +=1
print(ans)