Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

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

### FIXED CODE ###

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

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

N=int(input())
S=input()
ret = 0
for j in range(1,N-1):
  if S[j]=='R':
    ret += S[:j].count('G')*S[j+1:].count('B')
    ret += S[:j].count('B')*S[j+1:].count('G')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='R' and S[j+(j-i)]!='R':
          ret -=1
  elif S[j]=='G':
    ret += S[:j].count('B')*S[j+1:].count('R')
    ret += S[:j].count('R')*S[j+1:].count('B')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='G' and S[j+(j-i)]!='G':
          ret -=1
  elif S[j]=='B':
    ret += S[:j].count('R')*S[j+1:].count('G')
    ret += S[:j].count('G')*S[j+1:].count('R')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='B' and S[j+(j-i)]!='B':
          ret -=1
print(ret)

### FIXED CODE ###

N=int(input())
S=input()
ret = 0
for j in range(1,N-1):
  if S[j]=='R':
    ret += S[:j].count('G')*S[j+1:].count('B')
    ret += S[:j].count('B')*S[j+1:].count('G')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='R' and S[j+(j-i)]!='R':
          ret -=1
  elif S[j]=='G':
    ret += S[:j].count('B')*S[j+1:].count('R')
    ret += S[:j].count('R')*S[j+1:].count('B')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='G' and S[j+(j-i)]!='G':
          ret -=1
  elif S[j]=='B':
    ret += S[:j].count('R')*S[j+1:].count('G')
    ret += S[:j].count('G')*S[j+1:].count('R')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='B' and S[j+(j-i)]!='B':
          ret -=1
print(ret)
### BUGGY CODE ###

import collections
import sys
input = sys.stdin.readline

n=int(input())
strs = [input() for i in range(n)]

str_dict = [0]*(n)

for i in range(n):
    str_dict[i] = collections.Counter(strs[i])

ans = 0

for i in range(n):
    for j in range(n):
        if i != j:
            if str_dict[i] == str_dict[j]:
                ans += 1

print(int(ans/2))

### FIXED CODE ###

import collections
n = int(input())
strs = ["".join(sorted(input())) for _ in range(n)]
d = collections.Counter(strs)
ans=0
for x in d.values():
  ans += x*(x-1)/2

print(int(ans))
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
questions = []
for i in range(q):
    l, r = map(int, input().split())
    questions.append([l - 1, r])

result = [0 for _ in range(q)]
for i in range(1, len(s)):
    if 'A' == s[i - 1] and 'C' == s[i]:
        for index, question in enumerate(questions):
            if question[0] <= i - 1 and question[1] > i:
                result[index] += 1
for num in result:
    print(num)


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
t = [0 for _ in range(n+1)]
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)

questions = []
for i in range(q):
    l, r = map(int, input().split())
    questions.append([l, r])
for qestion in questions:
    print(t[qestion[1] - 1] - t[qestion[0] - 1])
### BUGGY CODE ###

while True:
    n,x=[int(i) for i in input().split()]
    if n==x==0:
        break
    c = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            if (i != j):
                for k in range(1,n+1):
                    if (i != k and j != k):
                        if(i<j<k):
                            if i+j+k == x:
                                c+=1

    print(c)

### FIXED CODE ###

while True:
    n,x=[int(i) for i in input().split()]
    if n==x==0:
        break
    c = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if (i+j+n >= x):
                for k in range(j+1,n+1):
                    if(i+j+k == x):
                        c+=1
                        break

    print(c)
### BUGGY CODE ###

MOD = 10**9 + 7
S = input()
dp = [[0] * 4 for _ in [0] * (len(S) + 1)]
dp[0][0] = 1
for i, c in enumerate(S):
    for j in range(4):
        dp[i + 1][j] += dp[i][j] * (1 + (c == '?') * 2)
    if c in 'A?':
        dp[i + 1][1] += dp[i][0]
    if c in 'B?':
        dp[i + 1][2] += dp[i][1]
    if c in 'C?':
        dp[i + 1][3] += dp[i][2]
print(dp[-1][3] % MOD)

### FIXED CODE ###

M = 10**9 + 7
dp = [0] * 4
dp[0] = 1
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        N, A, AB, ABC = dp
        dp = [(N * 3) % M, (A * 3 + N) % M, (AB * 3 + A) % M, (ABC * 3 + AB) % M]
    else:
        dp[idx[c]] += dp[idx[c] - 1]
print(dp[3] % M)
### BUGGY CODE ###

N,M=map(int,input().split())
list1=list(map(int,input().split()))
list2=[]
for _ in range(M):
  B,C=map(int,input().split())
  list2+=[C]*B
list3=list1+list2
list3.sort(reverse=True)
list5=list3[:N]
SUM=sum(list5)
print(SUM)

### FIXED CODE ###

N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

listA.sort(reverse=True)
print(sum(listA[:N]))
### BUGGY CODE ###

import numpy as np
N, M = map(int, input().split())

list = [[0 for i in range(N + 1)] for j in range(M)]

for m in range(M):
    l, r = map(int, input().split())
    for i in range(l,r+1):
        list[m][i] = 1
#print(list)
list = np.array(list)
sum = list.sum(axis=0)
#print(sum)
count = 0
for i in range(len(sum)):
    if sum[i] == M:
        count += 1
print(count)

### FIXED CODE ###

N, M = map(int, input().split())
l_max = -1
r_min = N + 1
for m in range(M):
    l, r = map(int, input().split())
    if l > l_max:
        l_max = l
    if r < r_min:
        r_min = r
print(max(r_min - l_max + 1, 0))
### BUGGY CODE ###

from math import factorial

num=int(input())
stl=[]

count=0

for i in range(num):
    str=input()
    str=''.join(sorted(str))
    stl.append(str)

duplicate=[x for x in set(stl) if stl.count(x) > 1]
if duplicate:
    for dup in duplicate:
        count=count+factorial(stl.count(dup)) // factorial(2) // factorial(stl.count(dup) - 2)

    
print(count)

### FIXED CODE ###

num=int(input())
stl =[''.join(sorted(input())) for i in range(num)]

#duplicate=[x for x in set(stl) if stl.count(x) > 1]

t = {}
for i in range(num):
  if stl[i] in t:
    t[stl[i]] += 1
  else:
    t[stl[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))
### BUGGY CODE ###

s = input()
q = int(input())
def rev_string(original_string):
  reverse_string = ""
  for a in original_string:
    reverse_string = a + reverse_string
  return reverse_string
ans = ""
l = ""
r = ""
c = 0
for _ in range(q):
  t = input().split()
  if t[0] == '1':
    c += 1
    a = l
    l = r
    r = a
  else:
    if t[1] == '1':
      l += t[2]
    else:
      r += t[2]
if c%2 ==0:
  print(rev_string(l) + s + r)
else:
  print(rev_string(l) + rev_string(s) + r)

### FIXED CODE ###

s = input()
q = int(input())
l = []
r = []
c = 0
for _ in range(q):
  t = input().split()
  if t[0] == '1':
    c += 1
    a = l
    l = r
    r = a
  else:
    if t[1] == '1':
      l.append(t[2])
    else:
      r.append(t[2])
l = "".join(l[::-1])
r = "".join(r)
if c%2 ==0:
  print(l + s + r)
else:
  print(l + s[::-1] + r)
### BUGGY CODE ###

X=int(input())
l=[2]
for j in range(3,100004):
    for i in l:
        if j%i==0:
            break
    else:
        if j>=X:
            t=j
            break
        l.append(j)
if X==2:
    t=2
print(t)


### FIXED CODE ###

X=int(input())
l=[2]
t=3
while 1:
    for i in l:
        if t%i==0:
            break
    else:
        if t>=X:
            break
        l.append(t)
    t+=1
if X==2:
    t=2
print(t)
### BUGGY CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
m = max(a)
half_idx = bisect.bisect_left(a, m//2)

def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p
p=10**9+7 

if n == 2:
    print(a[1], a[0])
    exit()

if 1 <= half_idx < n-1:
    if ncr(m, a[half_idx-1], p) >= max(ncr(m, a[half_idx], p), ncr(m, a[half_idx+1], p)):
        print(m, a[half_idx-1])
    elif ncr(m, a[half_idx], p) >= max(ncr(m, a[half_idx-1], p), ncr(m, a[half_idx+1], p)):
        print(m, a[half_idx])
    elif ncr(m, a[half_idx+1], p) >= max(ncr(m, a[half_idx], p), ncr(m, a[half_idx-1], p)):
        print(m, a[half_idx+1])
elif half_idx == 0:
    if ncr(m, a[half_idx], p) >= ncr(m, a[half_idx+1], p):
        print(m, a[half_idx])
    elif ncr(m, a[half_idx+1], p) >= ncr(m, a[half_idx], p):
        print(m, a[half_idx+1])
elif half_idx == n-1:
    if ncr(m, a[half_idx], p) >= ncr(m, a[half_idx-1], p):
        print(m, a[half_idx])
    elif ncr(m, a[half_idx-1], p) >= ncr(m, a[half_idx], p):
        print(m, a[half_idx-1])

### FIXED CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
m = max(a)
half_idx = bisect.bisect_left(a, m//2)

def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p
p=10**9+7 

if n == 2:
    print(a[1], a[0])
    exit()

if 1 <= half_idx < n-1:
    if min(a[half_idx-1], m-(a[half_idx-1])) >= max(min(a[half_idx], m-(a[half_idx])), min(a[half_idx+1], m-(a[half_idx+1]))):
        print(m, a[half_idx-1])
    elif min(a[half_idx], m-(a[half_idx])) >= max(min(a[half_idx-1], m-(a[half_idx-1])), min(a[half_idx+1], m-(a[half_idx+1]))):
        print(m, a[half_idx])
    elif min(a[half_idx+1], m-(a[half_idx+1])) >= max(min(a[half_idx], m-(a[half_idx])), min(a[half_idx-1], m-(a[half_idx-1]))):
        print(m, a[half_idx+1])
elif half_idx == 0:
    if min(a[half_idx], m-(a[half_idx])) >= min(a[half_idx+1], m-(a[half_idx+1])):
        print(m, a[half_idx])
    elif min(a[half_idx+1], m-(a[half_idx+1])) >= min(a[half_idx], m-(a[half_idx])):
        print(m, a[half_idx+1])
elif half_idx == n-1:
    if min(a[half_idx], m-(a[half_idx])) >= min(a[half_idx-1], m-(a[half_idx-1])):
        print(m, a[half_idx])
    elif min(a[half_idx-1], m-(a[half_idx-1])) >= min(a[half_idx], m-(a[half_idx])):
        print(m, a[half_idx-1])
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
N,D=map(int,input().split())
l=[[0]*D for i in range(D)]
for i in range(N):
    x,y=map(lambda x: int(x)%D,input().split())
    l[x][y]+=1
M=0
for i in l:
    M=max(M,max(i))
for i in range(1,318):
    if i**2>=M:
        m=i
        break
s0=[]
s1=[]
for i in range(D):
    for j in range(D):
        if l[i][j]<=(m-1)**2:
            continue
        if l[i][j]<=(m-1)*m:
            s0.append((i,j))
        else:
            s1.append((i,j))
a=D
for i in range(D):
    for j in range(D):
        c=0
        for k in s0:
            t=min((k[0]-i)%D,(k[1]-j)%D)
            if c<t:
                c=t
        for k in s1:
            t=max((k[0]-i)%D,(k[1]-j)%D)
            if c<t:
                c=t
        if a>c:
            a=c
print(D*(m-1)+a)

### FIXED CODE ###

n,d = map(int,input().split())
num = [[0]*d for i in range(d)]
a = 0
for i in range(n):
  x,y = map(int,input().split())
  x %=d
  y%=d
  num[x][y] += 1
  a = max(a,num[x][y])
x=1
while x*x<a:
  x += 1
r = (x-1)*d
a = x-1
dai = d-1
syo = 0
anum = [[[0]*d for i in range(d)]for i in range(3)]
rui = [[[0]*(2*d+1) for i in range(2*d+1)]for i in range(3)]
for i in range(d):
  for j in range(d):
    z = num[i][j]
    if z > (a+1)**2:
      anum[0][i][j]=1
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z> a*(a+1):
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z > a*a:
      anum[1][i][j]=1
for x in range(3):
  for i in range(1,2*d+1):
    for j in range(1,2*d+1):
      rui[x][i][j]+=rui[x][i-1][j]+rui[x][i][j-1]-rui[x][i-1][j-1]+anum[x][(i-1)%d][(j-1)%d]
def cheak(kon):
  for i in range(1,d+1):
    for j in range(1,d+1):
      if rui[0][i+kon][j+kon] - rui[0][i - 1][j+kon] - rui[0][i+kon][j - 1] + rui[0][i - 1][j - 1]:
        continue
      if rui[1][i+d-1][j+d-1] - rui[1][i+kon+1 - 1][j+d-1] - rui[1][i+d-1][j+kon+1 - 1] + rui[1][i+kon+1 - 1][j+kon+1 - 1]:
        continue
      if rui[2][i+d-1][j+kon] - rui[2][i+kon+1 - 1][j+kon] - rui[2][i+d-1][j - 1] + rui[2][i+kon+1 - 1][j - 1]:
        continue
      if rui[2][i+kon][j+d-1] - rui[2][i - 1][j+d-1] - rui[2][i+kon][j+kon+1 - 1] + rui[2][i - 1][j+kon+1 - 1]:
        continue
      return 1
  return 0 
kon = (dai+syo)//2
while True:
  if dai-syo <= 1:
    if cheak(syo) == 1:
       dai = syo
    break
  kon = (dai+syo)//2
  c = cheak(kon)
  if c == 1:
    dai = kon
  else:
    syo = kon
print(dai+r)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [1]*n
for i in range(k):
    ans[0] *= a[i]
for i in range(n-k):
    ans[i+1] = ans[i] * a[i+k] // a[i]
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

def grundy(a, k):
    while True:
        if a < k:
            return 0
        d, m = divmod(a, k)
        if m == 0:
            return d
        a -= d + 1


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')


### FIXED CODE ###

import sys

sys.setrecursionlimit(10000000)
from math import ceil


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    d1 = d + 1
    if d > k:
        return grundy(a - d1, k)
    e = ceil(m / d1) * d1
    return grundy(a - e, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')
### BUGGY CODE ###

N, Q = map(int, input().split(" "))
S = input().strip()

check = [0 for i in range(N+2)]

for i in range(N):
    if S[i:i+2] == "AC":
        check[i+1] = 1

ans = [0 for i in range(Q)]

for i in range(Q):
    l, r = map(int, input().split())
    ans[i] = sum(check[l:r])

for i in range(Q):
    print(ans[i])


### FIXED CODE ###

N, Q = map(int, input().split(" "))
S = input().strip()

check = [0 for i in range(N+1)]

tmp = 0
for i in range(N):
    check[i+1] = tmp
    if S[i:i+2] == "AC":
        tmp += 1

ans = [0 for i in range(Q)]

for i in range(Q):
    l, r = map(int, input().split())
    ans[i] = check[r] - check[l]

for i in range(Q):
    print(ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

n,q = map(int,input().split())

g = [[] for _ in range(n)]
c = [0] * n
visited = [False] * n

#根に近い順に累積和
def dfs(i):
    visited[i] = True
    for j in g[i]:
        if visited[j] == True:
            continue
        c[j]+=c[i]
        dfs(j)

for i in range(n - 1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p - 1]+=x

dfs(0)
print(*c)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())

g = [[] for _ in range(n)]
c = [0] * n
visited = [False] * n

#根に近い順に累積和
def dfs(i):
    visited[i] = True
    for j in g[i]:
        if visited[j] == True:
            continue
        c[j]+=c[i]
        dfs(j)

for i in range(n - 1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p - 1]+=x

dfs(0)
print(*c)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=[0]*(N+1)
for i in range(N):
    B[i+1]=B[i]+A[i]
    C[i+1]=C[i]^A[i]
ans=0
for l in range(1,N+1):
    for r in range(l,N+1):
        if C[r]^C[l-1]==B[r]-B[l-1]:
            ans+=1
print(ans)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=0
right=0
sum=0
for left in range(N):
    while(right<N and (sum^A[right])==(sum+A[right])):
        sum+=A[right]
        right+=1
    ans+=right-left
    if left==right:
        right+=1
    else:
        sum-=A[left]
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    A.sort(reverse=True)
    A[0] = A[0] // 2

x = sum(A)
print(x)

### FIXED CODE ###

import heapq

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = [-1 * i for i in A]

    heapq.heapify(A)

    for i in range(M):
        a = heapq.heappop(A)
        a = -1 * (-1 * a // 2)
        heapq.heappush(A, a)


    x = -1 * sum(A)
    print(x)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,K = map(int,input().split())
S = [0] + list(map(int,input().split()))

for i in range(1,N+1):
    S[i] += S[i-1]
for i in range(N+1):
    S[i] -= i
    S[i] %= K
cnt = 0
for i in range(N):
    cnt += S[i+1:min(N+1,i+K)].count(S[i])
print (cnt)


### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,K = LI()
    A = LI()

    c = 0
    d = collections.Counter()
    d[0] = 1
    ans = 0
    r = [0] * (N+1)
    for i,x in enumerate(A):
        if i >= K-1:
            d[r[i-(K-1)]] -= 1
        c = (c + x - 1) % K
        ans += d[c]
        d[c] += 1
        r[i+1] = c

    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from functools import reduce
N = int(input())
A = list(map(int, input().split()))
ans = reduce(lambda x, y: x*y, A)
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()

print(ans)
### BUGGY CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

h,w,a,b = map(int,input().split())
res = 0
kai = min(w-b,h-a)
for i in range(0,kai):
    res += (cmb(h-a-1+b,b+i) * cmb(a+w-b-1,a+i) ) % (10**9+7)
    if res  > 10**9+7:
        res %= 10**9+7

print(res)

### FIXED CODE ###

h, w, a, b = map(int, input().split())
res = 0
kai = min(w - b, h - a)
mod = 10 ** 9 + 7

kaijo = [0] * (h + w + 1)
kaijo[0] = 1
for i in range(1, h + w + 1):
    kaijo[i] = (kaijo[i - 1] * i) % mod
gyaku = [0] * (h + w + 1)
gyaku[h + w] = pow(kaijo[h + w], mod - 2, mod)
for i in range(h + w, 0, -1):
    gyaku[i - 1] = (gyaku[i] * i) % mod


def conb(x, k):
    return (kaijo[x] * gyaku[k] * gyaku[x - k]) % mod


conb1 = conb(h - a - 1 + b, b)
conb2 = conb(a + w - b - 1, a)
combi = conb1 * conb2
res = combi

for i in range(1, kai):
    res += conb(h - a - 1 + b, b + i) * conb(a + w - b - 1, a + i)

res %= mod
print(int(res))
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
count = 0
for ri in range(0, n+1, r):
  for gi in range(0, n+1, g):
    val = (n - ri - gi) / b
    if val.is_integer() and val >= 0:
      count += 1
print(count)

### FIXED 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)
### BUGGY CODE ###

n = int(input())
p = 1
for i in range(1, n + 1):
    p *= i
print(p % (10 ** 9 + 7))

### FIXED CODE ###

n = int(input())
p = 1
for i in range(1, n + 1):
    p = i * p % (10 ** 9 + 7)
print(p)
### BUGGY CODE ###

import math

n, m = map(int, input().split(" "))
aL = list(map(int, input().split(" ")))

d = {}
for i, a in enumerate(aL):
    if a in d:
        d[a].append(i)
    else:
        d[a] = [i]

cnt = 0
while True:
    if len(d) == 0:
        break
    dMax = max(d)
    while True:
        if cnt == m:
            ans = 0
            for k, v in d.items():
                ans += k * len(v)
            print(ans)
            exit()
        nxt = d[dMax].pop(0)

        if (dMax // 2) in d:
            d[dMax // 2].append(nxt)
        else:
            d[dMax // 2] = [nxt]

        cnt += 1

        if len(d[dMax]) == 0:
            del d[dMax]
            break

ans = 0
for k, v in d.items():
    ans += k * len(v)
print(ans)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
aL = list(map(lambda x: int(x) * (-1), input().split(" ")))

heapq.heapify(aL)

for i in range(m):
    a = heapq.heappop(aL)
    a = int(a / 2)
    heapq.heappush(aL, a)

print(int(sum(aL) * -1))
### BUGGY CODE ###

from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
for i in range(n-1):
  edge[i].append(i+1)
  edge[i+1].append(i)
visited=[[-1]*n for _ in range(n)]
def bfs(s):
  q=deque([s])
  visited[s][s]=0
  while q:
    x=q.popleft()
    for nx in edge[x]:
      if visited[s][nx]==-1:
        visited[s][nx]=visited[s][x]+1
        q.append(nx)
for i in range(n):
  bfs(i)
ans=[0]*n
for i in range(n):
  for j in range(n):
    if i<j:
      continue
    if visited[i][j]>=1:
      ans[visited[i][j]]+=1
for i in range(1,n):
  print(ans[i])


### FIXED CODE ###

from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
for i in range(n-1):
  edge[i].append(i+1)
  edge[i+1].append(i)
visited=[[-1]*n for _ in range(n)]
def bfs(s):
  q=deque([s])
  visited[s][s]=0
  while q:
    x=q.popleft()
    for nx in edge[x]:
      if visited[s][nx]==-1:
        visited[s][nx]=visited[s][x]+1
        q.append(nx)
for i in range(n):
  bfs(i)
ans=[0]*n
for i in range(n):
  for j in range(n):
    if i<j:
      continue
    if visited[i][j]>=1:
      ans[visited[i][j]]+=1
for i in range(1,n):
  print(ans[i])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
k = int(input())
k_range = range(1, k + 1)


def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b


sum_gcd = 0
for l in k_range:
    for m in k_range:
        for n in k_range:
            sum_gcd += gcd(n, gcd(l, m))

print(sum_gcd)

### FIXED CODE ###

import math

k = int(input())
k_range = range(1, k + 1)

sum_gcd = 0
for l in k_range:
    temp = 0
    for m in k_range:
        temp = math.gcd(l, m)
        for n in k_range:
            sum_gcd += math.gcd(n, temp)

print(sum_gcd)
### BUGGY CODE ###

# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = map(int, input().split())
# 整数を格納するリスト（list_num）を定義する
list_num = []
# 各操作において、、
for _ in range(N):
    # 挿入する整数（a）とその個数（b）を入力する
    a, b = map(int, input().split())
    # list_numにaをb個だけ挿入する
    list_num.extend([a] * b)
# list_numを昇順にソートする
list_num.sort()
# K番目に小さい数を返す
print(list_num[K - 1])

### FIXED CODE ###

# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = map(int, input().split())
# 挿入する整数（a）とその個数（b）の組を格納するリスト（list_ab）を定義する
list_ab = []
# 各操作において、、
for _ in range(N):
    # aおよびbを入力する
    a, b = map(int, input().split())
    # list_abにaとb個の組を追加する
    list_ab.append((a, b))
# list_abをaが昇順に並ぶようにソートする
list_ab.sort()
# bの合計を計算する変数（sum_b）を定義する
sum_b = 0
# 各a、bの組について、、
for a, b in list_ab:
    # sum_bにbを足す
    sum_b += b
    # sum_bがK以上になった場合、、
    if sum_b >= K:
        # aを出力する
        print(a)
        break