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())

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

print(res)

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

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

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

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

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

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

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

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

print(ans)

Solution (Python):
R,G,B,N=map(int,input().split())
ans=0
for r in range(0,int(N//R)+1):
    for g in range(0,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())
c = 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:
            c += 1
print(c)

Solution (Python):
R,G,B,N=map(int,input().split())
ans=0
for r in range(0,int(N//R)+1):
    for g in range(0,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 // r + 2):
    for j in range(n // g + 2):
        k = n - i * r - j * g
        if k < 0:continue
        if k % b == 0:cnt += 1
print(cnt)

Solution (Python):
*RBG, n = map(int, input().split())
RBG.sort()
a, b, c = RBG
ans = 0
for i in range(n//c + 1):
    t = n - c*i
    for j in range(t//b + 1):
        ans += (t - j*b) % a == 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-r*i)//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
x = n//min(r,g,b)

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

print(ans)

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

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

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

ans = 0
for i in range(1+n//r):
  tmp = n - r*i
  for j in range(1+tmp//g):
    mod = (n - g*j - r*i)%b
    if mod == 0:
      ans += 1
        
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-R*i)//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

r,g,b = sorted([r,g,b], reverse=True)
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        k = n-i*r-j*g
        
        if k%b==0:
            ans += 1
print(ans)

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

Solution (Python):






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





mylist = sorted(rgbn[:3], reverse=True)
ans = 0
for i in range(rgbn[3]//mylist[0] + 1):

    for j in range((rgbn[3] - mylist[0]*i)//mylist[1] + 1):

        rest = (rgbn[3] - mylist[0]*i - mylist[1]*j)
        if rest%mylist[2] == 0:

            ans += 1
print(ans)

Solution (Python):
r,g,b,n = map(int,input().split())
cnt = 0
l = [r,g,b]
l.sort()
r = l[2]
g = l[1]
b = l[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())
index = 0
ans = 0
for_sort = [R,G,B]
for_sort.sort()
r = for_sort[2]
g = for_sort[1]
b = for_sort[0]
while N >=0:
  mid = N
  N -= r
  while mid >= 0:
    if mid % b == 0:
      ans += 1
    mid -= g
      
print(ans)

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

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

max_r = N // R
max_g = N // G
max_b = N // B

count = 0
for r in range(max_r + 1):
    for g in range(max_g + 1):
        now_n = r * R + g * G
        if now_n <= N and (N - now_n) % B == 0:
            b = (N - now_n) // B
            count += 1

ans = count

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-r*R) :
        b = n-r*R-g*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 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:
      ans=ans+1
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


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


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


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




R,G,B,N = IL()
count = 0
for r in range(N+1):
  for g in range(N+1):
    if r*R+g*G <= N and (N-(r*R+g*G))%B == 0:
      count += 1
print(count)

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

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

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

if __name__ == "__main__":
    main()

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


cnt=0
for i in range(n+1):
    for j in range(n+1):

        hB = n - (r*i) - (j*g)

        if hB >= 0 and hB%b==0:
            cnt+=1

print(cnt)

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):

            res = (N - (R*r + G*g)) 

            if res < 0 :
                break

            if res % B == 0:
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

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):

            res = (N - (R*r + G*g)) 

            if res < 0 :
                break

            if res >= 0 and res % B == 0:
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

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

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
R, G, B, N = map(int, input().split())
M = N - np.add.outer(np.arange(0, N + 1, R, dtype=np.int32), np.arange(0, N + 1, G, dtype=np.int32))
print(((M >= 0) & (M % B == 0)).sum())

Solution (Python):
import sys

input = sys.stdin.readline


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

    dp = [0] * (N + 1)
    dp[0] = 1
    for c in [R, G, B]:
        for i in range(N - c + 1):
            dp[i + c] += dp[i]

    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


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

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


if __name__ == "__main__":
    main()

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

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


if __name__ == "__main__":
    main()

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

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

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

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 + 1):
        c = n - (i*R + j*G)
        if c >= 0 and c%B == 0:
            cnt += 1
        else:
            pass
                
print(cnt)

Solution (Python):
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
dp = [0]*(N+1)
dp[0] = 1
for x,i in itertools.product([R,G,B],range(N+1)):
    if i-x>=0:
        dp[i] += dp[i-x]
print(dp[-1])

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

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
ans = 0
for i in range(N+1):
    for j in range(N+1):
        temp = N-(R*i+G*j)
        if temp>=0 and temp%B==0:
            ans += 1
print(ans)

Solution (Python):

import sys, math


def solve(R: int, G: int, B: int, N: int):
    count = 0
    for r in range(N // R + 1):
        for g in range(N // G + 1):
            nokori = N - r * R - g * G
            if nokori < 0:
                continue
            if nokori % B == 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):
R,G,B,N = map(int,input().split())

rn = N // R
gn = N // G

ans = 0

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

 
R, G, B, N = MAP()
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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


R, G, B, N = MAP()
ans = 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 b == b//1 :
			ans += 1

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


R, G, B, N = MAP()
ans = 0

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

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


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

print(ans)

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

Solution (Python):

r,g,b,n=map(int,input().split())
ans=0
r,g,b=sorted([r,g,b])[::-1]
for i in range(n//r+1):
    for j in range(n//g+1):
        k=n-i*r-j*g
        if(k<0):
            break
        if(k>=0 and k%b==0):
            ans+=1
print(ans)

Solution (Python):
r, b, g, n=map(int, input().split())
rm=n//r
bm=n//b
ans=0
for i in range(rm+1):
  for j in range(bm+1):
    sa=n-r*i-b*j
    if sa<0:
      break
    elif sa%g==0:
      ans+=1
print(ans)

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

cnt = 0
for r in range(N//R+1):
    Rr = R*r
    for g in range((N-Rr)//G+1):
        if (N-(Rr + G*g)) % 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):
    Rr = R*r
    for g in range((N-Rr)//G+1):
        if (N-(R*r + G*g)) % 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-(R*r))//G+1):
        if (N-(R*r + G*g)) % B == 0:
            cnt += 1
print(cnt)

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

Solution (Python):
def answer(R, G, B, N):
    r_count = N // R
    g_count = N // G
    ans = 0
    for i in range(r_count+1):
        for j in range(g_count+1):
            k = N - (R * i) - (G * j)
            if k < 0: continue
            if k % B == 0: ans += 1
    return ans  
    
R, G, B, N = map(int, input().split())
print(answer(R, G, B, N))

Solution (Python):
import collections

def useOne(a, b, c, n):
    count = 0
    if n%a == 0: count += 1
    if n%b == 0: count += 1
    if n%c == 0: count += 1
    return count

def useTwo(a, b, n):
    a, b = sorted([a, b])
    count = 0
    maxCountOfA = n//a
    maxCountOfB = n//b
    
    startCount = 1
    for i in range(maxCountOfA, 0, -1):
        for j in range(startCount, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum == n:
                count += 1
                startCount = j+1
                break
            if _sum > n:
                startCount = j
                break
    return count

def useThree(a, b, c, n):
    a, b, c = sorted([a, b, c])
    maxCountOfA = n//a
    maxCountOfB = n//b
    maxCountOfC = n//c
    count = 0
    for i in range(1, maxCountOfA+1):
        startCountOfC = maxCountOfC
        for j in range(1, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum >= n:
                maxCountOfB = j
                break
            for k in range(startCountOfC, 0, -1):
                _sum = i*a + j*b + k*c
                if _sum == n:
                    count += 1
                    startCountOfC = k-1
                    break
                if _sum < n:
                    startCountOfC = k
                    break
    return count

def answer(a, b, c, n):
    count = useOne(a, b, c, n)
    count += useTwo(a, b, n)
    count += useTwo(a, c, n)
    count += useTwo(b, c, n)
    count += useThree(a, b, c, n)
    return count
    
a, b, c, n = map(int, input().split())
print(answer(a, b, c, n))

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


print(solve())

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

lst = [R, G, B]
lst.sort()
k2, k1, k0 = lst

ans = 0
if lst != [1, 1, 1]:
    for n0 in range(N//k0 + 1):
        for n1 in range(N//k1 + 1):
            nn = (N - n0 * k0 - n1 * k1)
            if nn >= 0 and nn % k2 == 0: ans += 1
    print(ans)
else:
    for n0 in range(N+1):
        for n1 in range(n0, N+1):
            if n0 + n1 > N:continue
            if n0 == n1: ans += 1
            else: ans += 2
    print(ans)

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

count = 0
for r in range(3001):
    for g in range(3001):
        rest = N - r * R - g * G
        if rest >= 0 and rest % B == 0:
            count += 1

print(count)

Solution (Python):
r, g, b, n = [int(i) for i in input().split()]
t1 = n // r + 1
t2 = n // g + 1
ans = 0
for i in range(t1):
    for j in range(t2):
        t = r * i + g * j
        if (n - t) >= 0 and (n - t) % b == 0: ans += 1
print(ans)

Solution (Python):

import sys
input = sys.stdin.readline
def main():
    R, G, B, N = map(int, input().split())
    r_count = N // R
    g_count = N // G
    ans = 0
    for i in range(r_count+1):
        for j in range(g_count+1):
            k = N - R * i - G * j
            if k % B == 0 and k >= 0:
                ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A,B,C,N = map(int,input().split())
    ans = 0
    for i in range(N + 1):
        if i*A > N:
            break
        a = i*A
        for j in range(N + 1):
            if j*B + a > N:
                break
            b = j*B
            if (N - a - b)%C == 0:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
r, g, b, n = map(int, input().split())
count = 0
for x in range(n//r + 1):
	for y in range((n - r*x)//g + 1):
		if (n - (r*x + g*y)) % 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))%b == 0 and (n-(r*x)-(g*y))>=0:
            ans += 1
print(ans)

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

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

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

print(cnt)

Solution (Python):
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    r, g, b, n = input_list()
    ans = 0
    for x in range(n+1):
        for y in range(n+1):
            z = n - (x*r) - (y*g)
            if z < 0:
                continue
            if z % b != 0:
                continue
            ans += 1
    print(ans)


def get_camulative(l):
    import itertools
    
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush




def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    

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

    l1=[0]*(N+1)
    for r in range(N//R+1):
        for g in range(N//G+1):
            count=R*r+g*G
            if count>N:
                break
            l1[count]+=1
    ans=0
    
    for b in range(N//B+1):
        ret=N-b*B
        ans+=l1[ret]
    print(ans)



if __name__ == "__main__":
    main()

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 (n - i * r - j * g) % b == 0:
            cnt += 1
print(cnt)

Solution (Python):
r,g,b,n=map(int,input().split())
p=0
i,j=0,0
while j < n+1:
    k=i*r+j*g
    if (n-k)%b==0 and k <= n:
        
        p+=1
    i+=1
    if i>n:
        i=0
        j+=1
print(p)

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

for i in range(n + 1):
    for j in range(n + 1):
        tmp = n - i * r  - j * g
        if 0 <= tmp and tmp % b == 0:
            cnt += 1
print(cnt)

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


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

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


def read():
    R, G, B, N = map(int, input().strip().split())
    return R, G, B, N


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


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    R,G,B,N=map(int, input().split())
    cnt=0
    rnum=N//R
    gnum=N//G
    for r in range(rnum+1):
        for g in range(gnum+1):
            x=R*r+G*g
            if x>N:
                break
            else:
                if (N-x)%B==0:
                    cnt+=1
    print(cnt)
resolve()

Solution (Python):
def pat(R,G,B,N):
    output = 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:
                output += 1
    return output

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

    ans = pat(R,G,B,N)

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
R, G, B, N = map(int, input().split())
MAX_R = N // R + 1
MAX_G = N // G + 1
ans = 0
for i in range(MAX_R):
    for j in range(MAX_G):
        b_cnt = N - R * i - G * j
        if b_cnt >= 0 and b_cnt % 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-r*i)//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(n // r + 1):
    for j in range((n - i * r) // g + 1):
        k = n - (i * r + j * g)
        if k % b == 0:
            ans += 1

print(ans)

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

print(cnt)

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

ans = 0
for i in range(3001):
    for j in range(3001):
        b = (N-i*R-j*G)/B
        if b.is_integer() and b >= 0:
            ans += 1
        if b < 0:
            break

print(ans)