Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())
cnt = 0
for i in range(N//R+1):
    for j in range(N//G+1):
       r,g = i*R, j*G
       if (N-r-g)%B!=0 or r+g > N: continue
       cnt += 1
print(cnt)

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
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 or (n-ball)%B!=0: continue
        ans += 1
print(ans)

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,n = map(int, input().split())
ans = 0
for r in range(n//R+1):
    for g in range(n//G+1):
        ball = R*r + G*g
        if ball > n or (n-ball)%B!=0: continue
        ans += 1
print(ans)

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0

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

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(R * N//R+1):
  for g in range(G * N//G+1):
    if R*r + G*g > N: break
    if (N - R*r - G*g) % B == 0:
      ans += 1
print(ans)

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

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

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)