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):
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) % B == 0:
      ans += 1

print(ans)

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

cnt = 0
for i in range(N+1):
    for j in range(N+1):
        k = N - R*i- G*j
        if k<0 or k % B != 0 : continue
        cnt += 1
            
print(cnt)

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

boxes = [R, G, B]
boxes.sort()
boxes.reverse()

ans = 0
for  a in range(1 + N // boxes[0]):
    for b in range(1 + (N - a*boxes[0]) // boxes[1]):
        if((N - a*boxes[0] - b*boxes[1]) % boxes[2] == 0):
            ans += 1  
print(ans)

Solution (Python):

R, G, B, N = list(map(int, input().split()))
cnt = 0
rmax = N//R
gmax = N//G
bmax = N//B
for r in range(rmax+1):
    for g in range(gmax+1):
        temp = N-r*R-g*G
        if temp < 0:
            continue
        if temp%B == 0:
            cnt += 1
print(cnt)

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

        
print(cnt)

Solution (Python):
r,g,b,n=map(int,input().split())
ct=0
for i1 in range((n//r)+1):
  for i2 in range((n//g)+1):
    if (n-r*i1-g*i2)%b==0 and n-r*i1-g*i2>=0:
      ct+=1
print(ct)

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

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

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

print(count)

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

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

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


print(cnt)

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

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

ans = 0
rmax = n // R
for i in range(rmax + 1):
    gmax = (n - R * i) // G
    for j in range(gmax + 1):
        if (n - R * i - G * j) % B == 0:
            ans += 1
print(ans)

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

ans = 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:
            ans += 1

print(ans)

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

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) % B == 0):
        ans = ans+1
        
print(ans)

Solution (Python):


import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    R, G, B, N = i2nn()
    c = 0
    for r in range(N+1):
        rr = r * R
        if rr > N:
            break
        for g in range(N+1):
            gg = g * G
            if rr + gg > N:
                break
            n2 = N - rr - gg
            if n2 % B == 0:
                c += 1
    print(c)

main()

Solution (Python):
rgbn = list(map(int, input().split()))
R = rgbn[0]
G = rgbn[1]
B = rgbn[2]
N = rgbn[3]
res = 0
r = 0
while R * r <= N:
    b = 0
    while B * b <= N - R * r:
        if (N - R * r -B * b) % G == 0:
            res += 1
        b += 1
    r += 1
print(res)

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

Solution (Python):
import numpy as np

r,g,b,N=map(int,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(count)

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,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):
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) >= 0 and (N-R*r-G*g) % B == 0:
      ans += 1
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):
        bB = N - r*R - g*G
        if bB%B == 0 and 0<=(bB//B):
            ans += 1
print(ans)

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

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

Solution (Python):

def main():
    buf = input()
    buflist = buf.split()
    R = int(buflist[0])
    G = int(buflist[1])
    B = int(buflist[2])
    N = int(buflist[3])
    combination = 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 - (i * R + j * G)) % B == 0:
                combination += 1
    print(combination)


if __name__ == '__main__':
    main()

Solution (Python):
R, G, B, N = map(int, input().split())
num = 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:
            num = num + 1

print(num)

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

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

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

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op



inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    
    r, g, b, n = get_li()
    ans = 0
    for x in range(n // r + 1):
        for y in range(n // g + 1):
            z = n - r * x - g * y
            if z % b != 0 or z < 0:
                continue
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Solution (Python):
r, g, b, n = [int(item) for item in input().split()]

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

print(count)

Solution (Python):



from collections import deque
import heapq
import math
import bisect


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

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

    print(ans)


if __name__ == '__main__':
    main()

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 / g)+1):
        if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) >= 0:
            ans += 1

print(ans)

Solution (Python):
import math
R,G,B,N = map(int,input().split())
ans = 0
r,g,b = 0,0,0
for i in range(math.floor(N/R)+1):
    for j in range(math.floor((N-i*R)/G)+1):
        if (N-R*i-G*j)%B == 0:
            ans += 1
print(ans)

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

Solution (Python):
def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

r,g,b,n = get_nums_l()

ans = 0
for ra in range(n//r + 1):
    for ga in range(n//g + 1):
        now = r * ra + g * ga
        nokori = n - now
        if nokori >= 0 and nokori % b == 0:
            ans += 1

print(ans)

Solution (Python):

"""
AtCoder B
"""








def main():
    R, G, B, N = list(map(int,input().split()))
    tmp=0
    rb=0
    while rb*R<=N:
        ball=rb*R
        gb=0
        while gb<N-rb*R+1:
            ball_g=gb*G
            gball=ball_g+ball
            if N>=gball and (N-gball)%(B)==0:
                tmp+=1
            gb+=1
        rb+=1

    print(tmp)
    
if __name__ == "__main__":
    main()

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

Solution (Python):





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

cnt = 0

for r in range(1 + N // R):
    for g in range(1 + N // G):
        rest = N - (r * R + g * G)

        if rest >= 0 and rest % B == 0:
            cnt += 1
            

print(cnt)

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

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    R, G, B, N = map(int, input().split())
    ans = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            rest = N - R*i - G*j
            if rest >= 0 and rest % B == 0:
                ans += 1

    return ans


if __name__ == '__main__':
    print(main())

Solution (Python):
R,G,B,N=map(int,input().split())
L=sorted([R,G,B])
M=N//L[2]
ans=0
for i in range(M+1):
  n=N-i*L[2]
  MM=n//L[1]
  for j in range(MM+1):
    ans+= 1 if (n-j*L[1])%L[0]==0 else 0
print(ans)

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

Solution (Python):
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    R, G, B, N = map(int, line_input())
    ans = 0
    for r in range(N // R + 1):
        left = N - r * R
        for g in range(left // G + 1):
            if (left - g * G) % B == 0: ans += 1
    print(ans)

    return 0
  
if __name__ == "__main__":
    solve()

Solution (Python):

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
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

Solution (Python):
r,g,b,n=map(int,input().split())
rr=0
ans=0
while rr*r<=n:
    gg=0
    while rr*r+gg*g<=n:
        if (n-(rr*r+gg*g))%b == 0:
            ans+=1
        gg+=1
    rr+=1
print(ans)

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


if __name__ == "__main__":
    main()

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

z = 0
for r in range(3001):
    rR = r * R
    if rR > N:
        break
    for g in range(3001):
        gG = g * G
        if rR + gG > N:
            break
        if (N - rR - gG) % B == 0:
            z = z + 1

print(z)

Solution (Python):

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

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

Solution (Python):


import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode

from fractions import gcd






inf = float('inf')

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

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))




R, G, B, N = input_ints()

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

print(cnt)

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

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

print(score)

Solution (Python):
r, g, b, n = map(int, input().split())
L = [r, g, b]
L.sort(reverse=True)
r, g, b = L[0], L[1], L[2]
ans = 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:
      ans += 1
print(ans)

Solution (Python):
r,g,b,n=map(int,input().split())
l=[r,g,b]
m=max(l)
l.remove(m)
m2=max(l)
l.remove(m2)
m3=l[0]
cnt = 0
for i in range(n//m + 1):
    n_ = n - m*i
    for j in range(n_//m2 + 1):
        if (n_ - m2*j)%m3==0:
            cnt += 1
print(cnt)

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

count = 0
for i in range(n+1):
    rr = i * r
    for j in range(n+1):
        gg = g * j
        bb = (n - rr - gg)
        if bb >= 0 and bb % b == 0:
            count += 1

print(count)

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

Solution (Python):
r,g,b,n=map(int,input().split())
rm=n//r
count=0
for i in range(rm+1):
    rn=n-r*i
    gm=rn//g
    for j in range(gm+1):
        rn1=rn-g*j
        if rn1%b==0:
            count=count+1
print(count)

Solution (Python):


R, G, B, N = map(int, input().split())
rgb = []
for i in range(N + 1):
    for j in range(N - (i * R) + 1):
        key = i * R + j * G
        key = N - key
        if key % B == 0 and key / B >= 0:
            rgb.append([i, j, key // B])


print(len(rgb))

Solution (Python):


import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    r, g, b, n = LI()

    res = 0
    for ri in range(n // r + 1):
        for gi in range(n // g + 1):
            t = n - r * ri - g * gi
            if t >= 0 and t % b == 0:
                res += 1

    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

a = np.zeros(U+1,dtype = np.int64)

for r in range(0,U+1):
  x = R*r
  if x > U:
    break
  a[x::G] += 1


ans = a[N::-B].sum()
print(ans)

Solution (Python):
r,g,b,n=map(int,input().split())
a=0
for i in range(0,n+1,r):
    for j in range(0,n+1,g):
        k=n-i-j
        if k>=0 and not k%b:
            a+=1
print(a)

Solution (Python):
R,G,B,N = map(int, raw_input().split())
count = 0
while True:
	N2 = N
	while True:
		if(N2 % B == 0):
			count += 1
		N2 -= G
		if(N2 < 0):
			break
	N -= R
	if(N < 0):
		break
print(count)

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

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

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

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

print(ans)

Solution (Python):
a, b, c, n = map(int, input().split(" "))
if a > b:
    a, b = b, a
if b > c:
    b, c = c, b
if a > b:
    a, b = b, a

ans = 0
for numc in range(n//c + 1):
    left = n - c * numc
    for numb in range(left//b + 1):
        if (left - b*numb) % a == 0:
            ans += 1
print(ans)

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

cnt = 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:


            cnt += 1
    
print(cnt)

Solution (Python):

import sys


def solve(R: int, G: int, B: int, N: int):
    ret = 0
    for r in range(N // R + 1):
        rest = N - r * R
        for g in range(rest // G + 1):
            if (rest - g * G) % B == 0:
                ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  
    G = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Solution (Python):

R, G, B, N = [int(n) for n in input().split()]





ans = 0
for i in range(3001):
    for j in range(3001):
        le = N - i*R - j*G
        if (le) % B == 0 and le >= 0:
            ans += 1
print(ans)

Solution (Python):


def main():
    r, g, b, n = map(int, raw_input().split())
    s = 0
    for i in range(n // r + 1):
        c = i * r
        if c == n:
            s += 1
            continue
        for j in range((n - c) // g + 1):
            cc = c + j * g
            if cc <= n and (n - cc) % b == 0:
                s += 1
    print s


if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

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

print(ans)

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

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

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

maxR = int(n/r)

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

print(ans)

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

print(solve())

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

print(ans)

Solution (Python):
r,g,b,n = list(map(int,input().split(" ")))
c = 0
rl = n//r + 1
bl = n//b + 1


for i in range(rl):
    for j in range(bl):
        if n-(i*r + b*j) >=0 and (n-(i*r + b*j)) % g == 0:
            c += 1
print(c)

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):
        n = R * r + G * g
        if N - n >= 0 and (N - n) % B == 0:
            ans += 1
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 N - r*R - g*G >= 0:
            ans += 1
print(ans)

Solution (Python):
import sys
range = xrange
input = raw_input

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

count = 0

for x in range(n//r + 1):
    m = n - r*x
    for y in range(m//g + 1):
        k = m - g*y
        if k>=0 and k%b == 0:
            count += 1

print count

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

s = n//r
t = n//g

ans = 0
for i in range(s+1):
    for j in range(t+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())

cnt = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = N - (r * R + g * G)
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

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

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

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

print(cnt)

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

ans = 0

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

print(ans)

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

Solution (Python):
r,g,b,n=map(int, input().split())
r,g,b=sorted([r,g,b],reverse=True)
ans=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:
            ans+=1
print(ans)

Solution (Python):
R,G,B,N=list(map(int,raw_input().strip().split(' ')))
R,G,B=sorted([R,G,B])[::-1]
dic={}
count=0
for i in xrange(0,N//(R)+1):
    temp=i*R
    for j in xrange(0,(N-temp)//G+1):
        temp2=j*G
        if (temp+temp2)<N+1 and (N-temp-temp2)%B==0:
            count+=1
print(count)

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

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

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

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

x = 0
for i in range(N // R + 1):
  for j in range((N - (i * R)) // G + 1):
    k = i * R + j * G
    if  k > N:
      break
    if (N - k) % B == 0:
      x += 1
print(x)

Solution (Python):
a,b,c, n = list(map(int, input().split() ))

ans = 0
for i in range(3001):
	for j in range(3001):
		rest = n - a*i - b*j
		if rest >= 0 and rest % c == 0:
			ans += 1

print(ans)

Solution (Python):


import sys


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

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

R,G,B,N=rl()
ans = [0]*(N+1)
ans[0] = 1
for color in [R,G,B]:
    for i in range(N+1):
        temp = i + color
        if temp <= N:
            ans[temp] += ans[i]
print(ans[N])

Solution (Python):

import sys


def solve(R: int, G: int, B: int, N: int):
    count = 0
    for x in range(N+1):
        for y in range(N+1):
            rest = N - R * x - G * y
            z, q = divmod(rest, B)
            if z < 0:
                break
            if q == 0:
                count += 1
    print(count)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  
    G = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

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

if __name__ == "__main__":
    solve()

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

Solution (Python):
r,g,b,n = map(int,input().split())
a = [0]*(n+1)
a[0] = 1
for i in [r,g,b]:
    for j in range(n+1-i):
        a[j+i]+=a[j]
print(a[n])

Solution (Python):
r,g,b,n = map(int, input().split())
cnt =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:
            cnt+=1

print(cnt)

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

ans=0
for x in range(int(N/R)+1):
    for y in range(int(N/G)+1):
        nokori=N-x*R-y*G
        if nokori>=0 and nokori%B==0:
            ans+=1
print(ans)

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

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

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

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

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

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

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    r,g,b,n = f()
    ans = 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:
                ans += 1

    
    print(ans)

solve()

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):
        bB = N - r * R - g * G
        if bB % B > 0: continue
        b = bB // B
        if b < 0: continue
        ans += 1

print(ans)