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



Sample input:
1 2 3 4


Sample output:
4

Submission status: Runtime Error

Solution code:
import numpy as np
import pandas as pd

R, G, B, N = map(int, input().split())
r = np.arange(0, int(N/R)+1)
g = np.arange(0, int(N/G)+1)
rg = r[:, np.newaxis]*R+g[np.newaxis, :]*G
mask = (rg<=N) & ((N-rg)%B==0)
print(np.sum(mask))

Submission status: Runtime Error

Solution code:
import numpy as np
R, B, G, N = (int(x) for x in input().split())
a = np.array([R, B, G])
a = np.sort(a)
b = a[2]
d = a[1]
f = a[0]
c = int(N / b)

count = 0

for i in range(c + 1):
    n = N - b * i
    e = int(n / d)
    for j in range(e + 1):
        m = n - d * j
        if m % a[0] == 0:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#B
import numpy as np
import math
import re
     
a,b,c,n = list(map(int,re.split(" ",input())))
N = n
s = []
s.append(a)
s.append(b)
s.append(c)
s.sort()
a,b,c = s
#print(a,b,c)
ans = 0
for i in range(int(N/c)+1):
  for j in range(int((N-i*c)/b)+1):
	if (N - i*c  - j*b)%a == 0:
		ans += 1
print(ans)

Submission status: Runtime Error

Solution code:

def main():
     
    a,b,c,n = list(map(int,re.split(" ",input())))
    N = n
    s = []
    s.append(a)
    s.append(b)
    s.append(c)
    s.sort()
    a,b,c = s
    #print(a,b,c)
    ans = 0
    for i in range(int(N/c)+1):
        for j in range(int((N-i*c)/b)+1):
                if (N - i*c  - j*b)%a == 0:
                    ans += 1

    print(ans)
    
main()

Submission status: Runtime Error

Solution code:
def main():	
  	#!/usr/bin/env python3
	#B
	import numpy as np
    import math
    import re
     
    a,b,c,n = list(map(int,re.split(" ",input())))
    N = n
    s = []
    s.append(a)
    s.append(b)
    s.append(c)
    s.sort()
    a,b,c = s
    #print(a,b,c)
    ans = 0
    for i in range(int(N/c)+1):
        for j in range(int((N-i*c)/b)+1):
                if (N - i*c  - j*b)%a == 0:
                    ans += 1
                
    print(ans)
main()

Submission status: Runtime Error

Solution code:
R = int(input("R:"))
G = int(input("G:"))
B = int(input("B:"))
N = int(input("N:"))
r = 0
g = 0
X = N - r*R - g*G
num = 0
while X >= 0:
	while X >= 0:
			if X % B == 0:
				num += 1
			r += 1
			X = N - r*R - g*G
	g += 1
	r = 0
	X = N - r * R - g * G

print(num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

l.sort(reverse=True)
count=0

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

for i in range(N+1):
	for j in range(N-(R*i+G*j)):
		if N-R*i>=0:
			a=N-R*i
			#print("a",a)
			if a-G*j>=0:
				b=a-G*j
				#print("a,b",a,b)
				if b%B==0:
					count+=1
print(count)

Submission status: Runtime Error

Solution code:
a,b,c,n=map(int,input().split())
count=0
for i in range(n//a)
  for j in range(n//b)
  	if n-i*a-j*b>=0 and n-i*a-j*b%c==0:
      count++
print(count)

Submission status: Runtime Error

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if (n - (x + y) < 0:
            break
        if (n-(x+y))%l[0] == 0:
            count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]]  
    K = [0]*(CI[2]+1)
    for k in range(CI[2]+1):
        K[k] = C[2]*k
    for i in range(CI[0]+1):
      if C[0]*i > N:
            break
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) in K:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]]  
    K = [0]*(CI[2]+1)
    for k in range(CI[2]+1):
        K[k] = C[2]*k
    for i in range(CI[0]+1):
     　 if C[0]*i > N:
            break
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) in K:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]]  
    K = [0]*(CI[2]+1)
    for k in range(CI[2]+1):
        K[k] = C[2]*k
    for i in range(CI[0]+1):
      　if C[0]*i　> N:
            break
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) in K:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import bisect

"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
"""
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]] 
    K  = C[2]*list(range(CI[2]+1))
    for i in range(CI[0]+1):
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) == K[bisect.bisect_left(K, N - (C[0]*i+C[1]*j))]:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
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() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    R, G, B, N = i2nn()
    #a = []
    cnt = 0
    R, G, B = sorted((R, G, B), revere=True)
    for r in range(N // R + 1):
        for g in range((N - R * r) // G + 1):
            #print([r, g, 0], N - R * r - G * g)
            if (N - R * r - G * g) % B == 0:
                cnt += 1
                #a.append([r,g,(N - R * r - G * g) // B])
    #print(a)
    print(cnt)
main()

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
ans=0
for x in range(n//r):
    for y in range(n//g):
        if (d-x*a+y*b)//c==0:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
# coding: UTF-8
import sys
sys.setrecursionlimit(10**5)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
r,g,b,n=map(int,input().split())
num=0
fot i in range(g+1):
  for j in range (b+1):
    if i+j>N:
      break
    if 0<=N-i-j<=r:
      num+=1
print(num)

Submission status: Runtime Error

Solution code:
import itertools

R, G, B, N = [int(x) for x in input().split()]
#RGB = sorted([R, G, B], reverse=True)
RGB = [R, G, B]

cnt = 0
r_range = N//RGB[0]+1
for i in range(N//RGB[0]+1):
    g_range = (N - RGB[0]*i)//RGB[1]+1
    for j in range(g_range):
        rem = N - (RGB[0]*i) - (RGB[1]*j)
        if rem >= 0:
            num = rem // RGB[2]
            if rem == 0 or rem % (RGB[2]*num) == 0:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    for i in range(n + 1):
      if i*r > n:
        break
        for j in range(n + 1):
            if r*i + g*j <= n:
                if (n-(r*i + g*j)) % b==0:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = tmp.sort(reverse=True)
    res = 0
    for i in range(n//r + 1):
        for j in range(n//g + 1):
            if r*i + g*j <= n:
                if (n-(r*i + g*j)) % b==0:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
str_dict = [0, 0, 0] 
val1 = 0
for i in range(int(input())):
  line = input()
  val1 += line.count('AB')
  if line[0] == 'B' and line[-1] == 'A':
    str_dict[2] += 1
  elif line[0] == 'B':
    str_dict[0] += 1
  elif line[-1] == 'A':
    str_dict[1] += 1
# if str_dict[2] == 0:
#   print(val1+min(str_dict[0], str_dict[1]))
# else:
#   if str_dict[0]+str_dict[1] > 0:
#     print(val1+str_dict[2]+min(str_dict[0], str_dict[1]))
#   else:
#     print(val1+str_dict[2]-1)
val2 = min(str_dict[0], str_dict[1])
tmp = max(str_dict[0]-val2, str_dict[1]-val2)
val3 = min(tmp, str_dict[2])
val4 = str_dict[2]-val3
if val3 == 0:
  val4 -= 1
print(val1+val2+val3+val4)

Submission status: Runtime Error

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

ans = 0
rsum = 0
for r in range(0, N+1):
    rsum += R
    if N < rsum:
        break
    rgsum = rsum
    for g in range(0, N+1):
        rgsum += G
        if N < grsum:
            break
        left = N - rgsum
        if left % B == 0:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
r, g, b, n = (int(i) for i in input().split())  
 
rmax = int(n/r)
gmax = int(n/g)
count = 0
 
for i in range(0, rmax + 1):
  while j <= gmax and n - r * i - g * j <= 0:
    tmp = n - r * i - g * j
    if (tmp % b == 0 and tmp >=0):
      count += 1
    j += 1
  
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
aaa

Submission status: Runtime Error

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

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

print(cnt)

Submission status: Runtime Error

Solution code:
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools
r , g , b ,n = map(int, input().split())

count =0

x = np.array([r,g,b])
for i in itertools.product(range(n+1),repeat=3):
    i = np.array[(i)]
    if i % x ==1:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
// 入力
int R,G,B,N;
int n=3;

// DPテーブル
int dp[4][3001];
int a[4];


int main() {
  for (int i = 0; i < n; ++i) cin >> a[i];
  cin >> N;

  memset(dp, 0, sizeof(dp));   // 一旦すべて 0 に
  dp[0][0] = 1;                // dp[0][0] だけ 1 に

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i+1][j] += dp[i][j];
      if (j >= a[i]) (dp[i+1][j] += dp[i][j-a[i]]);
    }
  }
  cout << dp[n][N] << endl;
}

Submission status: Runtime Error

Solution code:
N = int(input())

n_fin_is_A = 0
n_ini_is_B = 0
n_each_ab = 0

for n in range(N):
    S = input()
    n_each_ab += S.count('AB')
    n_fin_is_A += int(S[-1]=='A')
    n_ini_is_B += int(S[0]=='B')

_min = min(n_fin_is_A, n_ini_is_B)
if _min > N-1:
    _min + N-1

print(n_each_ab + _min)

Submission status: Runtime Error

Solution code:
r, b, g, n=map(int, input().split())  #複数数値入力

import numpy as np

arr =  np.array([r, b, g])
arr.sort()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

comb = 0
for i in range(int(n / arr[2])+1):
#     print(i)
    for j in range(int((n - i*arr[2]) / arr[1])+1):
#         print(j)
        if (n - i*arr[2] - j*arr[1]) % arr[0] == 0:
#             print(i, j)
            comb += int((n - i*arr[2] - j*arr[1]) / lcm(arr[1], arr[2])) + 1
            break
print(comb)

Submission status: Runtime Error

Solution code:
#include<stdio.h>

int main(){
  int r, g, b, n;
  int cnt = 0;
  scanf("%d %d %d %d\n", &r, &g, &b, &n);
  int x = n / r;
  for(int i=x;i>=0;i--){
    int y = (n - (i * r)) / g;
    for(int j=y;j>=0;j--){
      int z = n - (i * r) - (j * g);
      if(z % b == 0){
        cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split(" "))
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if(i*R+j*G+k*B==N):
      	ans ++ 
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
input = sys.stdin.readline


def main():
    R, G, B, N = [int(ele) for ele in input().split()]
    ans = 0
    for i in range(N+1):
        tmp = N - i*R

        for j in range(N+1):
            tmp2 = tmp - j*G
            if tmp2 < 0:
                break
            if tmp2 % B == 0:
                ans += 1

    print(ans)


def make_prim_nu(n):
    np.set_printoptions(threshold=np.inf)   # 配列の ... 表示を抑制
    N = n                  # 引数の上限値を含める
    is_prime = np.ones((N,), dtype=bool)
    is_prime[:2] = 0
    N_max = int(np.sqrt(N))
    for j in range(2, N_max+1):
        if(is_prime[j]):
            is_prime[j*j::j] = False        # 素数jの間隔で消していく
    primes = np.arange(N)[is_prime]
    return primes


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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;
 
int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i=0; i<=3001-R; ++i) {
    for (int j=0; j<=3001-G; ++j) {
      int diff = N - (i*R + j*G);
      if ((diff>=0)&&(diff%B==0)) {
          ++ans;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Submission status: Runtime Error

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

C=sorted([R,G,B])



if(C==[1,1,1]):
	print(N*(N-1)//2)
    exit()







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

Submission status: Runtime Error

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

divR = N // R
divG = N // G
divB = N // B
count = 0

for i in range(0, divR):
	if R*i == N:
		count++
	for j in range(0, divG):
		if R*i + G*j == N:
			count++ 
		for k in range(0, divB):
			if R*i + G*j + B*k == N:
				count++
print(count)

Submission status: Runtime Error

Solution code:
import itertools

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

cnt = 0

for i in range(N//RGB[0]+1):
    g_range = (N - RGB[0]*i)//RGB[1]+1
    for j in range(g_range):
        rem = N - (RGB[0]*i) - (RGB[1]*j)
        if rem >= 0:
            num = rem // RGB[2]
            if rem == 0 or rem % (RGB[2]*num) == 0:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
# B
import itertools

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

cnt = 0
for i in range(N//RGB[0]+1):
    for j in range(N//RGB[1]+1):
        rem = N - (RGB[0]*i) - (RGB[1]*j)
        if rem >= 0:
            num = rem // RGB[2]
            if rem == 0 or rem % (RGB[2]*num) == 0:
                cnt += 1
print(cnt)

Submission status: Runtime Error

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

divR = N // R
divG = N // G
divB = N // B
count = 0

for i in range(0, divR):
	if R*i == N:
		count++
	for j in range(0, divG):
		if R*i + G*j == N:
			count++ 
		for k in range(0, divB):
			if R*i + G*j + B*k == N:
				count++
print(count)

Submission status: Runtime Error

Solution code:
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    la = max(a, b)
    sm = min(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la - sm)


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


R, G, B, N = inpl()
ans = 0
for r in range(N // R + 1):
    rest = N - r * R
    for i in range(B):
        if (G * i) % B == rest % B:
            x = i
            break
    else:
        # print(r)
        continue
    if rest - G * x < 0:
        continue
    ans += (rest - G * x) // lcm(B, G) + 1
    # print(r, rest, x, ans)

print(ans)

Submission status: Runtime Error

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

def dfs(r, g, b, flag_r, flag_g, flag_b) : 
    if R*r +G*g +B*b == N : 
#        print(r, g, b)
        return 1
    elif R*r +G*g +B*b > N : 
        return 0

    if flag_r != 1 : 
        ret1 = dfs(r+1, g, b, flag_r, flag_g, flag_b)
    else : 
        ret1 = 0
        
    if flag_g != 1 : 
        ret2 = dfs(r, g+1, b, 1, flag_g, flag_b)
    else : 
        ret2 = 0
        
    if flag_b != 1 : 
        ret3 = dfs(r, g, b+1, 1, 1, flag_b)
    else : 
        ret3 = 0
    

    return(ret1 + ret2 + ret3)


print(dfs(0, 0, 0, 0, 0, 0))

Submission status: Runtime Error

Solution code:
import numpy as np 
r, g, b, n = list(map(int, input().split()))

ary = np.sort([r, g, b])[::-1]
r_ary = np.arange(0, n+1, ary[0])
g_ary = np.arange(0, n+1, ary[1])
b_ary = np.arange(0, n+1, ary[2])

rg = (r_ary.reshape(1, -1) + g_ary.reshape(-1, 1)).reshape(-1)
rg = rg[rg <= n]
rgb = (rg.reshape(1, -1) + b_ary.reshape(-1, 1)).reshape(-1)
print(len(np.where(rgb==n)[0]))

Submission status: Runtime Error

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

def getR(N):
   N = N-R
   if N == 0:
      global ans
      ans += 1
      return
   elif N > 0: 
      getR(N)
      getG(N)
      getB(N)
   else:
      return  

def getG(N):
   N = N-G
   if N == 0:
      global ans
      ans += 1
      return
   elif N > 0: 
      getR(N)
      getG(N)
      getB(N)
   else:
      return 

def getB(N):
   N = N-B
   if N == 0:
      global ans
      ans += 1
      return
   elif N > 0: 
      getR(N)
      getG(N)
      getB(N)
   else:
      return  

getR(N)
getG(N)
getB(N)
ans = ans - 1 if N%R else ans
ans = ans - 1 if N%G else ans
ans = ans - 1 if N%B else ans
print(ans)

Submission status: Runtime Error

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

C=sorted([R,G,B])



if(C==[1,1,1]):
	input()
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()






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

Submission status: Runtime Error

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

if (R<G and R<B):
    x = R
    if(G<B):
        y = G
        z = B
    else:
        y = B
        z = G

elif (G<R and G<B):
    x = G
    if(R<B):
        y = R
        z = B
    else:
        y = B
        z = R

elif (B<G and B<R):
    x = B
    if(G<R):
        y = G
        z = R
    else:
        y = R
        z = G

sum = N
nx,ny,nz = 0,0,0

while  (sum >= z):
    sum -= z
    nz += 1

while (sum >= y):
    sum -= y
    ny += 1

while (sum >= x):
    sum -= x
    nx += 1

ans = 1

nx,ny = 0,0
sum = N
while(nz > 0):
    nz -= 1
    while (sum >= y):
        sum -= y
        ny += 1

    while (sum >= x):
        sum -= x
        nx += 1

    if(sum == 0):
        ans += 1

nx = 0
sum = N
while(ny > 0):
    ny -= 1

    while (sum >= x):
        sum -= x
        nx += 1

    if(sum == 0):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
R,G,B,N = (int(i) for i in input().split())
maxr = N // R
result = 0

for i in range(maxr + 1):
    for j in range(((N - R * i) // G ) + 1):
        if N - R * i - G * j) >= 0:
            if (N - R * i - G * j) % B == 0:
                result += 1
        else:
            break

print(result)

Submission status: Runtime Error

Solution code:




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

C=sorted([R,G,B])



if(C==[1,1,1]):
	input()
    print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()

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

Submission status: Runtime Error

Solution code:
n=input()
while True:
       for j in range(n):
              j=input()
       
nm=0
nm1=0
cnt=j
for i in cnt:
      if i=='A' or i=='B':
              nm+=1
              nm1=max(nm1,nm)
      else:
              nm=0
print(nm1)