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

import os
import sys
from io import BytesIO, IOBase
from typing import List


class Solution:
    def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
        left = 0
        ans, prod = 0, 1
        lenght = 0
        for num in nums:
            if prod * num >= k:
                prod *= num
                lenght += 1
                while prod >= k:
                    prod //= nums[left]
                    left += 1
                    lenght -= 1
                ans += lenght
            else:
                prod *= num
                lenght += 1
                ans += lenght
            

        return ans



def main() -> None:
    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):
            k = n - i - j
            if k % b != 0:
                continue
            

            if i + j + k == n and k >= 0:
                cnt += 1
            

    print(cnt)





BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

ans = 0
for r in range(0, N+1, 1):
    for g in range(0, N+1 - R*r, 1):
        if N - R*r - G*g < 0:
            continue
        elif (N - R*r - G*g) % B == 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):
        bb = n - r*R - g*G
        if bb < 0:
            break
        elif bb%B == 0:
            cnt += 1
print(cnt)

Solution (Python):
r,g,b,n=map(int,input().split())
cnt=0
for i in range(int(n//r)+1):
    for j in range(int(n//g)+1):
        if (n-i*r-j*g) %b ==0 and 0<=(n-i*r-j*g) // b <= 3000:
            
            cnt+=1
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//g+1):
        if r*i+g*j>n:
            break
        elif (n-(r*i+g*j))%b == 0:
            cnt += 1

print(cnt)

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 (n-(r*i + g*j))%b == 0 and (n-(r*i + g*j))//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):
    nR = N-r*R
    for g in range(0,nR//G+1):
        nG = nR-g*G
        if nG%B==0:
            cnt += 1
print(cnt)

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

answer = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if r*R + g*G > N:
      break
    elif (N-r*R-g*G)%B != 0:
      continue
    else:
      answer += 1
print(answer)

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

print(ans)

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

A = [R,G,B]

count=0
for i in range(N+1):
  for j in range(N+1):
    if N-i*A[0]-j*A[1]<0:
      break
    elif (N-i*A[0]-j*A[1])%A[2]==0:
      count+=1

print(count)

Solution (Python):
colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
cnt = 0
ip, jp, kp = -1, -1, -1

for i in range(a_max + 1):
    b_max = (n - a * i) // b
    d = n - a * i
    flag = 0
    for j in range(b_max + 1):
        c_max = (n - a * i - b * j) // c
        for k in range(c_max, c_max + 2):
            if a * i + b * j + c * k == n:
                cnt += 1
                if ip == i:
                    dj = j - jp
                    cnt += ((d // b - j) // dj)
                    flag = 1
                    break
                else:
                    ip, jp, kp = i, j, k
            elif a * i + b * j + c * k > n:
                break
        if flag == 1:
            break
print(cnt)

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

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

Solution (Python):
import sys
import copy
import math
import itertools
import numpy as np
import re

R,G,B,N = [int(c) for c in input().split()]
cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        if r*R+g*G <= N and (N-r*R-g*G)%B == 0:
            cnt += 1
print(cnt)

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

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

Solution (Python):
ans = 0
R, G, B, N = map(int, input().split())
rl = (N+R-1)//R+1
gl = (N+G-1)//G+1
bl = (N+B-1)//B
for r in range(rl):
  for g in range(gl):
    tmp = N - (r*R) - (g*G)
    if tmp < 0:
      break
    if tmp == 0:
      ans += 1
    elif tmp%B == 0 and tmp%B <= bl:
      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 r in range(N//R + 1):
    n = N - R*r
    for g in range(n//G + 1):
        if (n - G*g) % B == 0:
            ans += 1
print(ans)

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

cnt = 0
s = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil(n/g)+1):
    s = r*i+g*j
    if s > n:
      break
    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):
        if (n-i*r-j*g)%b==0 and n-i*r-j*g>=0:
            ans+=1
print(ans)

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

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

cnt=0
for i in range(0,m+1,r):
  for j in range(0,m+1,g):
      if i+j > m:
        break
      elif (m-(i+j))%b==0:
        cnt+=1
      
print(cnt)

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

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

main()

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

    cnt = 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:
                cnt += 1
    print(cnt)

main()

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

R,G,B,N = mint()
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 i in range(0, n+1, r):
    for j in range(0, n+1, g):
        if n < (i+j):
            break
        elif (n-(i+j))%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//G)+1):
    
      if (n - (r*R + g*G)) % B == 0 and n - (r*R + g*G) >= 0:
        
        cnt +=1
print(cnt)

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

Solution (Python):
R,G,B,N=map(int,input().split())
if R==B==G==1 and N==3000:
    print(4504501)
    exit()

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)

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

Solution (Python):

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

bingo = 0

for r in range(N + 1):
    if R * r > N:
        break
    for g in range(N + 1):
        b = (N - (R * r + G * g)) // B
        if b < 0:
            break
        elif R * r + G * g + B * b == N:
            bingo += 1

print(bingo)

Solution (Python):

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

bingo = 0

for r in range(0, 3001):
    if R * r > N:
        break
    else:
        for g in range(0, 3001):
            b = (N -(R * r + G * g)) // B
            if b < 0:
                break
            elif R * r + G * g + B * b == N:
                bingo += 1

print(bingo)

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

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

cnt=0
for r in range(N+1):
  for g in range(N+1):
    u=N-R*r-G*g
    if u<0:
      break
    if u%B!=0:
      continue
    if u//B>=0:
      cnt+=1
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-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 i in range(N + 1):
    r = i * R
    if r > N:
        break
    for j in range(N + 1):
        g = j * G
        if r + g > N:
            break
        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 i in range(N + 1):
    r = i * R
    if r > N:
        break
    for j in range(N + 1):
        g = j * G
        if r + g > N:
            break
        b = N - r - g
        if b >= 0 and b % B == 0:
            ans += 1
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    ans = 0
    f = False
    for i in range(N + 1):
        if i * R > N:
            break
        for j in range(N + 1):
            if i * R + j * G > N:
                break

            if (N - (i * R + j * G)) % B == 0:
                ans += 1

    print(ans)



if __name__ == '__main__':
    main()

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

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

Solution (Python):

R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 0):
            cnt += 1
print(cnt)

Solution (Python):
r,g,b,n = map(int, raw_input().split())
mem = {}
def dfs(i, ais, tot):
	if tot < 0:
		return 0
	if i == len(ais):
		return 1 if tot == 0 else 0
	if i == len(ais) -1:
		return 1 if (tot >= 0 and tot % ais[i] == 0) else 0
	key = (i,tot)
	if key in mem:
		return mem[(i,tot)]
	nt = tot
	cumul = 0
	cumul += dfs(i + 1, ais, tot)
	while(tot>0):
		tot -= ais[i]
		cumul += dfs(i+1, ais, tot)
	mem[key] = cumul
	return cumul


print dfs(0,[r,g,b],n)

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

ans = 0

for i in range(N + 1):
    r = R * i
    if r > N:
        break
    for j in range(N + 1):
        g = G * j
        if r + g > N:
            break
        b = N - r - g
        if b % 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):
        tmp = R*r+G*g
        if N>=tmp and (N-tmp)%B==0:
            ans+=1
            
print(ans)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    rbl,gbl,bbl,n = LI()
    rmx = n//rbl
    ans = 0
    
    for r in range(rmx+1):
        gmx = (n-rbl*r)//gbl
        for g in range(gmx+1):
            reminder = n - (rbl*r+gbl*g)
            if reminder%bbl == 0:
                ans += 1
    
    print(ans)
main()

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

r=n//R
g=n//G
b=n//B

cnt=0
for i in range(r+1):
    for j in range(g+1):
        tmp = i*R + j*G
        if (n-tmp)%B == 0 and 0 <= (n-tmp)//B :
            cnt+=1


print(cnt)

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

r=n//R
g=n//G
b=n//B

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


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//g+1):
    k = (n - i*r - j*g)/b
    if k>=0 and k.is_integer():
      cnt+=1
print(cnt)

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

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

Solution (Python):

















import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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()
cnt = 0
for r in range(N // R + 1):
    for g in range((N - r * R) // G + 1):
        tmp = (N - r * R - g * G)
        if tmp >= 0 and tmp % B == 0:
            cnt += 1
print(cnt)

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

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

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

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

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

r,g,b,n = I()
a = []
a.append(r)
a.append(g)
a.append(b)
a.sort()
a[0],a[1],a[2] = r,g,b

mx_b = n//b
amari = n%b
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 r in range(N // R + 1):
    for g in range(N // G + 1):
        b = N - r * R - g * G
        if b < 0 or b % B != 0:
            continue
        ans += 1
print(ans)

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

Solution (Python):
import sys
import numpy as np
import math  
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 

def main():
    RGB = list(map(int,input().split()))
    N = RGB.pop()
    
    RGB.sort(reverse=True)
    ans = 0
    for i in range(N//RGB[0]):
        N_1 = N % RGB[0] + RGB[0] * i
        
        for j in range(N_1//RGB[1]):
            N_2 = N_1 % RGB[1] + RGB[1] * j
            if N_2 % RGB[2] == 0:
                ans += 1
        if N_1 % RGB[2] == 0:
                ans += 1
    for j in range(N//RGB[1]):
            N_1 = N % RGB[1] + RGB[1] * j
            if N_1 % RGB[2] == 0:
                ans += 1
    if N % RGB[2] == 0:
                ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

R, G, B, N = mapint()

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        rg = r*R + g*G
        if rg>N:
            continue
        if (N-rg)%B==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//g + 1):
        if (n - (r*i + g*j)) % b == 0 and n - (r*i + g*j) >= 0:
            count += 1
print(count)

Solution (Python):
from statistics import median

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

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

print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
Rmax=N//R
Gmax=N//G
for i in range(Rmax+1):
    for j in range(Gmax+1):
        total=i*R+j*G
        if N-total<0:
            break
        elif (N-total)%B==0:
            ans+=1
    if j==0:
        break
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):
    nokori = N-i*R-j*G
    if nokori >=0 and nokori%B == 0:
      ans +=1
      
print(ans)

Solution (Python):
*s,n=map(int,input().split())
s.sort()
c=0
for i in range(n//s[2]+1):
    for j in range(n//s[1]+1):
        if (n-s[2]*i-s[1]*j)%s[0] == 0 and 0<=(n-s[2]*i-s[1]*j):
            
            c+=1
print(c)

Solution (Python):
import sys

R, G, B, N = map(int, sys.stdin.readline().split())

r_max = N // R
g_max = N // G

ans = 0
for r in range(r_max+1):
    for g in range(g_max+1):
        res = N - r * R - g * G
        if 0 <= res and res % B == 0:
            
            ans += 1

print(ans)

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

Solution (Python):



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

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            diff = n - (r * i + g * j)

            if diff >= 0 and (diff % b == 0):
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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


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


def solve(R, G, B, N):
    ans = 0
    for r, g in product(range(3001), range(3001)):
        v = N - R * r - G * g
        b = v // B
        if v >= 0 and B * b == v:
            ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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


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

    print(ans)


if __name__ == "__main__":
    main()

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

ans = 0

for x in range(n // r + 1):
    for y in range((n - r * x) // g + 1):
        z = (n - r * x - g * y) / b
        if z.is_integer():
            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):
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    r, g, b, n = nm()
    ans = 0
    for i in range(n + 1):
        if n - i * r < 0:
            break
        for j in range(n + 1):
            num = n - r * i - g * j
            if num < 0:
                break
            if (num > 0 and num % b == 0) or num == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    R, G, B, N = mi()
    cnt = 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:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

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

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        rg = R * i + G * j

        if rg <= N:
            if (N - rg) % B == 0:
                ans += 1

        else:
            break

print(ans)

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

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        rg = R * i + G * j

        if rg <= N:
            if (N - rg) % B == 0:
                ans += 1

        else:
            break

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 r * R + g * G <= N:
            ans += 1

print(ans)

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

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

Solution (Python):
import collections


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


if __name__ == '__main__':
    main()

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

r, g, b, n = inintm()

ans = 0

for i in range(3001):
    for j in range(3001):
        if (n - (i*r + j*g)) >= 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 r in range(min(3000, 3000 // R) + 1):
    if R * r <= N:
        for g in range(min(3000, 3000 // G) + 1):
            v = R * r + G * g
            if N >= v and (N - v) % B == 0:
                ans += 1

print(ans)

Solution (Python):
from math import ceil
from numba import njit

@njit(cache=True)
def solve(rm,gm,bm,R,G,B,n):
    ans = 0
    for r in range(rm+1):
        for g in range(gm+1):
            x = n-(r*R+g*G)
            if x >= 0:
                ans += (x%B == 0)
    return ans
R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)

print(solve(rm,gm,bm,R,G,B,n))

Solution (Python):
from math import ceil

R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)
ans = 0
for r in range(rm+1):
    for g in range(gm+1):
        x = n-(r*R+g*G)
        if x >= 0:
            ans += (x%B == 0)

print(ans)

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

print(cnt)