Harryxun/stf_run huggingface dataset:
import math
#import numpy as np

def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
MOD = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K), 'N, K')
    A = getIntList()
    d.dmp((A), 'A')
    if K == 0:
        x = 0
    else:
        lg = int(math.log2(K))
        mask = 1 << lg
        x = mask
        d.dmp(x,'x')
        mask >>= 1
        lessK = False
        while mask > 0:
            cz, co = 0, 0
            if K & mask == 0 and not lessK:
                pass
            else:
                for i in range(N):
                    if A[i] & mask == 0:
                        cz += 1
                    else:
                        co += 1
                if cz > co:
                    ans += mask
                    lessK = True
            mask >>= 1
            d.dmp((mask,x),'mask,x')
    d.dmp((x),'x')
    ans = 0
    for i in range(N):
        ans += x ^ A[i]
    return ans


ans = prob()
print(ans)


### FIXED CODE ###

import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)
def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def getMask(n):
    mask = 2**60
    while n & mask == 0:
        mask >>= 1
    return mask

def prob():  # WA 2
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K), 'N, K')
    A = getIntList()
    d.dmp((A), 'A')
    if K == 0:
        x = 0
    else:
        #lg = int(math.log2(K+0.1))
        #mask = 1 << lg
        mask = getMask(K)
        x = 0
        d.dmp(x,'x')
        #mask >>= 1
        lessK = False  # x<Kか否か
        while mask > 0:
            cz, co = 0, 0
            for i in range(N):
                if A[i] & mask == 0:
                    cz += 1
                else:
                    co += 1
            if cz > co:
                if K & mask or lessK:
                    x += mask
            if (x & mask == 0) and mask & K:
                lessK = True
            mask >>= 1
            d.dmp((mask,x),'mask,x')
    d.dmp((x),'x')
    ans = 0
    for i in range(N):
        d.dmp((x ^ A[i]),'x ^ A[i]')
        ans += x ^ A[i]
    return ans


ans = prob()
print(ans)
N = int(input())

resultA = N * 100 // 108
resultB = resultA + 1
valueA = resultA * 108 // 100
valueB = resultB * 108 // 100

if N == valueA:
  print(resultA)
elif N == valueB:
  print(resultB)
else:
  print(result)
  print(value)
  print(':(')

### FIXED CODE ###

N = int(input())

resultA = N * 100 // 108
resultB = resultA + 1
valueA = resultA * 108 // 100
valueB = resultB * 108 // 100

if N == valueA:
  print(resultA)
elif N == valueB:
  print(resultB)
else:
  print(':(')
N = int(input())
X = input()
def popcount(k):
    return bin(k).count('1')

K = int(X, 2)
one = popcount(K)
K_MOD   = K % one
K_MOD_M = K % (one-1)
K_MOD_P = K % (one+1)
#print('k_mod_m=', K_MOD_M)
#print('k_mod_p=', K_MOD_P)
T = 2**(N-1)
for i in range(N):
    if X[i] == '1':
        pop = one - 1
        k = K_MOD_M - T
    else:
        pop = one + 1
        k = K_MOD_P + T
    k %= pop

    if pop == 0:
        print(0)
    else:
        ans = 1
        while k != 0:
            pop = popcount(k)
            k %= pop
            ans += 1
        print(ans)
        T //= 2

### FIXED CODE ###

N = int(input())
X = input()
memo = [-1] * (N+1)
memo[0] = 0

def popcount(k):
    return bin(k).count('1')

def calc(k):
    pop = popcount(k)
    #print('  ', k, pop)
    key = k
    if memo[key] < 0:
        k %= pop
        if k == 0:
            memo[key] = 1
        else:
            memo[key] = calc(k) + 1
    return memo[key]

K = int(X, 2)
one = popcount(K)
if one == 0:
    K_MOD = K
elif one == 1:
    K_MOD   = 0
    K_MOD_M = K
else:
    K_MOD   = K % one
    K_MOD_M = K % (one-1)
K_MOD_P = K % (one+1)

T_M = [1]*(N+1)
T_P = [1]*(N+1)
for i in range(1,N+1):
    if one > 1:
        T_M[i] = (T_M[i-1]*2) % (one-1)
    T_P[i] = (T_P[i-1]*2) % (one+1)

for i in range(N):
    if X[i] == '1':
        pop = one - 1
        k = K_MOD_M - T_M[N-i-1]
    else:
        pop = one + 1
        k = K_MOD_P + T_P[N-i-1]

    if pop == 0:
        print(0)
    else:
        k %= pop
        print(calc(k)+1)
#標準入力の読み込み
n=int(input())
x=[int(input()) for i in range(n)]
x.sort(reverse=True)
n=len(x)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    ans=x[0]
else:
    element = x[0]/gcd(x[0], x[1])*x[1]
    if n==2:ans=element
    else:
        for i in range(2,n):
            element=element/gcd(element,x[i])*x[i]
        ans=element
print(int(ans))


### FIXED CODE ###

import fractions
n=int(input())

ans=1
for i in range(n):
  x=int(input())
  ans=ans//fractions.gcd(ans,x)*x

print(int(ans))
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())

sublist = []
for i in range(len(S)-2):
    num =  int("".join(S[i:i+3]))
    sublist.append(abs(num-754)

print(min(sublist))

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())

sublist = []
for i in range(len(S)-2):
    num =  int("".join(S[i:i+3]))
    sublist.append(abs(num-753))

print(min(sublist))
count = 1
t=[]
while True:
    x = input("")
    if x == "0":
        break
    else:
        t.append("Case",str(count)+":",x)
        count = int(count) + 1

for i in t:
    print(t[i])

### FIXED CODE ###

t=[]
while True:
    x = str(input(""))
    if x == "0":
        break
    else:
        t.append(x)
for i,v in enumerate(t):
    print("Case",str(i+1)+":",v)
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))


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


if sub == 1:
	print(sub[0])
elif sub == 2:
	print(gcd(sub[0],sub[1]))
else:
	p = gcd(sub[0], sub[1])
	for i in range(2,len(sub)):
		p = gcd(p,sub[i])
	print(p)

### FIXED CODE ###

n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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


if len(sub) == 1:
	print(sub[0])
elif len(sub) == 2:
	print(gcd(sub[0],sub[1]))
else:
	p = gcd(sub[0], sub[1])
	for i in range(2,len(sub)):
		p = gcd(p,sub[i])
	print(p)
import numpy as np

N, M = map(int, input().split())
ans_list = np.zeros(N-1, dtype=int)
AB = []
flag = 0
ans_num_1 = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
    if 1 in ab:
        for j in ab:
            if j != 1:
                ans_num_1.append(j)
                ans_list[j-2] = 1
        AB.remove(ab)
if 0 not in ans_list:
    flag = 1
    print("Yes")
# print(ans_list)
while(flag != 1):
    if flag == 0:
        for ab in AB:
            for ans_num in ans_num_1:
                if ans_num in ab:
                    for j in ab:
                        if ans_num != j:
                            ans_list[j-2] = ans_num
                    AB.remove(ab)
            
        if 0 not in ans_list:
            flag = 1
            print("Yes")
if flag == 1:
    for ans in ans_list:
        print(ans)

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
AB = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
# print(AB)

graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a-1].append(b)
    graph[b-1].append(a)
# print(graph) -> [[], [2], [1, 3, 4], [2, 4], [3, 2]]

que = deque([1])
ans = [0 for _ in range(N)]

while que:
    x = deque.popleft(que)
    for i in graph[x-1]:
        if ans[i-1] != 0:
            continue
        ans[i-1] = x
        que.append(i)
for a in ans[1:]:
    if a == 0:
        print('No')
        break
else:
    print('Yes')
    print('\n'.join(map(str, ans[1:])))
import numpy
N = int(input())
ls = input().split()
Mul = numpy.prod(ls)
if Mul < 10**18:
  print(Mul)
else:
  print("-1")

### FIXED CODE ###

N = int(input())
ls = list(map(int,input().split()))
mul = 1
if 0 in ls:
    print(0)
else:
    for i in range(N):
        mul *= ls[i]
        if mul > 10**18:
            print(-1)
            quit()
    print(mul)
import numpy as np
N=map(int,input().split())
p=list(map,input().split())
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if a.count(0)>0:
  print(0)
else:
  ans=a[0]
  flag=0
  for i in range(1,N):
    ans*=a[i]
    if ans>10**18:
      flag+=1
      print(-1)
      break
  if flag==0:
    print(ans)
total = 500 * int(input())
line = int(input())
if total >= line:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

k, x = map(int, input().split())
if (500 * k) >= x:
    print('Yes')
else:
    print('No')
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
from math import gcd
# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

# from operator import mul
# from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random
# import time


def main():
    n = int(input().strip())
    temp = 1
    for i in range(1, n + 1):
        temp *= i
        temp = temp % (10**9 + 7)
    print(temp)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

from __future__ import print_function

import sys
input = sys.stdin.readline

def main():
    n = int(input().strip())
    temp = 1
    for i in range(1, n + 1):
        temp *= i
        temp = temp % (10**9 + 7)
    print(temp)
    return


if __name__ == '__main__':
    main()
def main():
    N = int(input())
    A=[int(input()) for x in range(N)]

    A.sort()
    s = 0
    e = N - 1
    L = A[0]
    R = A[e]
    ret1 = R - L
    while True:
        ss = s + 1
        ee = e + 1

        b = max(abs(L - A[ss]), abs(R - A[ss])) > max(abs(L - A[ee]), abs(R - A[ee]))

        if b:
            s += 1
            if abs(L - A[s]) < abs(R - A[s]):
                ret1 += abs(R - A[s])
                R = A[s]
            else:
                ret1 += abs(L - A[s])
                L = A[s]
        else:
            e -= 1
            if s == e: break
            if abs(L - A[e]) < abs(R - A[e]):
                ret1 += abs(R - A[e])
                R = A[e]
            else:
                ret1 += abs(L - A[e])
                L = A[e]
        if s == e: break

    # 出力
    print("{}".format(ret1))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A=[int(input()) for x in range(N)]

    A.sort()
    s = 0
    e = N - 1
    L = A[0]
    R = A[e]
    ret1 = R - L
    while True:
        ss = s + 1
        ee = e - 1

        b = max(abs(L - A[ss]), abs(R - A[ss])) > max(abs(L - A[ee]), abs(R - A[ee]))

        if b:
            s += 1
            if abs(L - A[s]) < abs(R - A[s]):
                ret1 += abs(R - A[s])
                R = A[s]
            else:
                ret1 += abs(L - A[s])
                L = A[s]
        else:
            e -= 1
            if s == e: break
            if abs(L - A[e]) < abs(R - A[e]):
                ret1 += abs(R - A[e])
                R = A[e]
            else:
                ret1 += abs(L - A[e])
                L = A[e]
        if s == e: break

    # 出力
    print("{}".format(ret1))


if __name__ == '__main__':
    main()
n = int(input())
if n[-1] == 3:
  print("bon")
elif n[-1] == 0 or  n[-1] == 1 or  n[-1] == 6 or  n[-1] == 8:
  print("pon")
else:
  print("hon")

### FIXED CODE ###

n = input()
m = int(n[-1])
if m == 3:
  print("bon")
elif m == 0 or m == 1 or m == 6 or m == 8:
  print("pon")
else:
  print("hon")
# -*- coding:utf-8 -*-
import sys
print("hi")

def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym:
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]
sys.setrecursionlimit(10000000)
tile = [[0 for i in range(1)] for j in range(1)]
while True:
	counter+=1
	line = input()
	if ' ' in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)] for j in range(M)]
	if N is 0 and M is 0:
		break
	else:
		tile[counter-2] = list(line)
	if (counter-1)==M:
		solve()
		counter = 0

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
import fraction
from functools import reduce

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

n = int(input())
a= [int(i) for i in input().split()]

print(gcd(*a))


### FIXED CODE ###

import fractions
 
def gcd_1(a):
    p = fractions.gcd(a[0],a[1])
    if len(a) > 2:
        for i in range(2,len(a)):
            p = gcd_1([p,a[i]])
    else:
        p = fractions.gcd(a[0],a[1])
 
    return p
 
n = int(input())
a = [int(i) for i in input().split()]
 
print(gcd_1(a))
#!/usr/bin/env python

# input
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
k = [t[i][0] for i in range(m)]
s = [t[i][1:] for i in range(m)]

# calc
# bit full search
ans = 0 
for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[a+1]
        if tmp%2 != p[j]%2:
            ok = False
            break
    if ok: 
        print('sw =', sw) 
        ans += 1

print(ans)


### FIXED CODE ###

#!/usr/bin/env python

# input
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
k = [t[i][0] for i in range(m)]
s = [t[i][1:] for i in range(m)]

# calc
# bit full search
ans = 0 
for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
    if ok: 
        # print('sw =', sw)
        ans += 1

print(ans)
A = map(int, input().split())
A = sorted(A)

cost = 0
for i in range(len(A - 1)):
  cost += A[i + 1] - A[i]
  
print(cost)

### FIXED CODE ###

A = sorted(map(int, input().split()))

cost = 0
for i in range(len(A) - 1):
  cost += A[i + 1] - A[i]

print(cost)
A, B = map(long, raw_input().split())
ans = 0
for i in range(B, A-1, -1):
    ans ^= i
    if ((B - B >> 1) == i):
        print(ans)
        exit()
    # print(ans, i)
print(ans)


### FIXED CODE ###

A, B = map(int, input().split())
ans = 0
cnt = 0
def f(arg):
    ans = 0
    if arg < 0:
        return 0
    for pos in range(1, 41):
        # ループする数
        loop = 1 << pos
        # cnt = sum([int((n & v) / v) for n in range(arg+1)])
        cnt = int((arg + 1) / loop) * (loop >> 1)
        cnt += max(0, (arg + 1) % (loop) - (loop >> 1))
        ans += cnt%2 * (loop>>1)
        # print(arg, pos, loop, cnt, ans)
        if loop > arg:
            break
    return ans
print(f(A-1)^f(B))
inp = input().split()

input().split() == "2 5" == ["2", "5",]

A = int(inp[0])
B = int(inp[1])
C = int(inp[3])

if A + B + C >= 22:
	print("bust")
else:
	print("win")

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())
if 1 <= a1 <= 13 and 1 <= a2 <= 13 and 1 <= a3 <= 13:
    if a1 + a2 + a3 >= 22:
        print('bust')
    else:
        print('win')
s=int(input())
for i in s:
    ans+=int(i)
if ans%9==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=str(input())
ans=0
for i in s:
    ans+=int(i)
if ans%9==0:
    print("Yes")
else:
    print("No")
#ABC133 C

L,R = map(int,input().split())
A = []
if R - L > 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            A.append((i*j)%2019)

print(min(A))

### FIXED CODE ###

#ABC133 C

L,R = map(int,input().split())
A = []
if R - L > 2019:
    print(0)
elif 2 <= R - L and R - L <= 2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            A.append((i*j)%2019)
    print(min(A))
elif R - L == 1:
    print((R*L)%2019)
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
      else:
        List.append(0)
    print(List)
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    X = 0
    Y = 0
    hh = 0
    for i in range(0, 101):
        for j in range(0, 101):
            H =  []
            s = 0
            for k in range(N):
                if h[k] > 0:
                    s += h[k]
                    H.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if len(H) > 1 and len(list(set(H))) == 1:
                X, Y, hh = i, j, H[-1]
            elif len(H) == 1 and H[0] == s:
                X, Y, hh = i, j, H[0]

    print(X, Y, hh)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()
data = list(map(int,input().split()))
a = data[0]
b = data[1]
c = data[2]
d = data[3]

print(min(a,b)+min(c,d))

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c,d))
h, a = map(int, input())

print(h//a + h%a)


### FIXED CODE ###

h, a = map(int, input().split())

if h%a != 0:
    print(h//a + 1)
else:
    print(h//a)
N = int(input())
A = [int(i) for i in input().split()]
for i in input().split():
  if A[i] % 2 == 0:
    A[i] /= 2
  else:
    print(int(A[i]))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)
from collections import defaultdict

n, m = [int(i) for i in raw_input().split()]

parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

print max(f)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n, m = [int(i) for i in raw_input().split()]
parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if i < 0 or i >= len(f):
        return 0

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)
# -*- coding: utf-8 -*-

def solve():
    R, G, B, N = map(int, input().split())
    dp = [[0 for __ in range(8)] for _ in range(N+1)]
    for n in range(1,N+1):
        if n == R:
            dp[R][4] += 1
        if n == G:
            dp[G][2] += 1
        if n == B:
            dp[B][1] += 1

        dp[n][1] += dp[n-B][1]
        dp[n][2] += dp[n-G][2]
        dp[n][3] += (dp[n-G][1] + dp[n-G][3] + dp[n-B][2] + dp[n-B][3])//2
        dp[n][4] += dp[n-R][4]
        dp[n][5] += (dp[n-R][1] + dp[n-R][5] + dp[n-B][4] + dp[n-B][5])//2
        dp[n][6] += (dp[n-R][2] + dp[n-R][6] + dp[n-G][4] + dp[n-G][6])//2
        dp[n][7] += (dp[n-R][3] + dp[n-R][7] + dp[n-G][5] + dp[n-G][7] + dp[n-B][6] + dp[n-B][7])//3
    return str(sum(dp[N]))

if __name__ == '__main__':
    print(solve())



### FIXED CODE ###

# -*- coding: utf-8 -*-

def solve():
    R, G, B, N = map(int, input().split())
    dp = [[0 for __ in range(8)] for _ in range(6002)]
    for n in range(1,N+1):
        if n == R:
            dp[R][4] += 1
        if n == G:
            dp[G][2] += 1
        if n == B:
            dp[B][1] += 1

        dp[n][1] += dp[n-B][1]
        dp[n][2] += dp[n-G][2]
        dp[n][3] += (dp[n-G][1] + dp[n-G][3] + dp[n-B][2] + dp[n-B][3])//2
        dp[n][4] += dp[n-R][4]
        dp[n][5] += (dp[n-R][1] + dp[n-R][5] + dp[n-B][4] + dp[n-B][5])//2
        dp[n][6] += (dp[n-R][2] + dp[n-R][6] + dp[n-G][4] + dp[n-G][6])//2
        dp[n][7] += (dp[n-R][3] + dp[n-R][7] + dp[n-G][5] + dp[n-G][7] + dp[n-B][6] + dp[n-B][7])//3
    return str(sum(dp[N]))

if __name__ == '__main__':
    print(solve())