Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


def dfs(i: int):
    if visited[i]:
        return

    visited[i] = True

    for k in range(n):
        if graph[i][k] == 1:
            dfs(k)


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    ab = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    graph = [[0 for __ in range(m)] for _ in range(m)]

    for a, b in ab:
        graph[a][b] = 1
        graph[b][a] = 1

    count = 0

    for a, b in ab:
        visited = [False for _ in range(n)]

        if a == 0:
            dfs(a)

            if False not in visited:
                count += 1

    print(count)


### FIXED CODE ###

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

# AtCoder Beginner Contest
# Problem C


# See:
# https://atcoder.jp/img/abc054/editorial.pdf
def dfs(v):
    all_visited = True

    if False in visited:
        all_visited = False

    if all_visited:
        return 1

    count = 0

    for i in range(n):
        if graph[v][i] == 0:
            continue

        if visited[i]:
            continue

        visited[i] = True
        count += dfs(i)
        visited[i] = False
    return count


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    graph = [[0 for __ in range(n)] for _ in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x) - 1, input().split()))
        graph[a][b] = 1
        graph[b][a] = 1

    visited = [False] * n
    visited[0] = True

    print(dfs(0))
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

"""
pairCounter=0
for i in range(N):
  for j in range(N -i -1):
    if A[j+i +1] < 1:
      continue
    if A[i] < 1:
      break
    wa = A[i] + A[j+i +1]
    for b in range(9):
      if 2**b & wa == wa:
        A[i]=-1
        A[j+i +1]=-1
        pairCounter+=1
        break
"""

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

print(pairCounter)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c=collections.Counter(A)

pairCounter=0

beki=29
nibeki=2**beki

for i in range(N):
  target = A[i]
  if c[target] < 1:
    continue
  c[target]-= 1

  while (nibeki > target):
    beki-=1
    nibeki=2**beki

  pair = nibeki * 2 - target
  if pair in c.keys() and c[pair] > 0:
    c[pair]-= 1
    pairCounter+=1

print(pairCounter)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return int((a * b) / gcd(a, b))


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""


### FIXED CODE ###

def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


def lcm(a, b):
    tmp = gcd(a, b)
    return (a//tmp) * b


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
_sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    _sum = lcm(_sum, t[i])
    # print(sum)
print(_sum)
A,B = input()
C = A * B
print(C);

### FIXED CODE ###

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

print(a*b)
N = int(input())
MOD = 10**9 + 7
tree = [[] for i in range(N+1)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree[b].append(a)

# 頂点1をルートにして各頂点より下にある部分木の頂点数を求めていく
root, par = 1, 0
sizes = [0] * (N+1)
order = [[root, par]]
def calc_nums(node, par):
  global sizes
  global order
  if sizes[node] > 0:
    return sizes[node]
  children = tree[node]
  res = 1
  for child in children:
    if child == par:
      continue
    order.append([child, node])
    res += calc_nums(child, node)
  sizes[node] = res
  return res

calc_nums(root, par)

# 2の累乗を事前に計算しておく
prod2 = [1]
for i in range(N):
  prod2.append(prod2[-1] * 2 % MOD)

# 各頂点について、その頂点が穴あき度としてカウントされる状況を独立に計算する
demo = 0 # 分子
div = prod2[N] # 分母
base = prod2[N-1] - 1
for node, par in order:
  children = tree[node]
  num = base
  num_par = N - 1
  for child in children:
    if child == par:
      continue
    s = sizes[child]
    num_par -= s
    num -= prod2[s] - 1 
  num -= prod2[num_par] - 1
  demo += num
    
ans = demo * pow(div, MOD-2, MOD) % MOD
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
MOD = 10**9 + 7
tree = [[] for i in range(N+1)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree[b].append(a)

# 頂点1をルートにして各頂点より下にある部分木の頂点数を求めていく
root, par = 1, 0
sizes = [0] * (N+1)
order = [[root, par]]
def calc_nums(node, par):
  global sizes
  global order
  if sizes[node] > 0:
    return sizes[node]
  children = tree[node]
  res = 1
  for child in children:
    if child == par:
      continue
    order.append([child, node])
    res += calc_nums(child, node)
  sizes[node] = res
  return res

_ = calc_nums(root, par)

# 2の累乗を事前に計算しておく
prod2 = [1]
for i in range(N):
  prod2.append(prod2[-1] * 2 % MOD)

# 各頂点について、その頂点が穴あき度としてカウントされる状況を独立に計算する
demo = 0 # 分子
div = prod2[N] # 分母
base = prod2[N-1] - 1
for node, par in order:
  children = tree[node]
  num = base
  num_par = N - 1
  for child in children:
    if child == par:
      continue
    s = sizes[child]
    num_par -= s
    num -= prod2[s] - 1 
  num -= prod2[num_par] - 1
  demo += num
    
ans = demo * pow(div, MOD-2, MOD) % MOD
print(ans)
import math
n,x=map(int,input().split())
pl=sorted(list(map(int,input().split()))+[x])
ans=abs(pl[1]-pl[0])
if len(pl)>1:
    for i in range(len(pl)-2):
        ans=math.gcd(ans,abs(pl[i+2]-pl[i+1]))
print(ans)

### FIXED CODE ###

import fractions
n,x=map(int,input().split())
pl=sorted(list(map(int,input().split()))+[x])
ans=abs(pl[1]-pl[0])
if len(pl)>1:
    for i in range(len(pl)-2):
        ans=fractions.gcd(ans,abs(pl[i+2]-pl[i+1]))
print(ans)
#B- Frog 2

def solution(nums):
    if not nums:return 0
    INF = float('-inf')
    n = len(nums[0])

    def dp(pre,cur,total = set([0,1,2])):
        if cur == n:
            return 0
        take = total - set([pre])
        res = INF
        for x in take:
            cand =  nums[x][cur] + dp(x,cur+1)
            if cand > res:
                res = cand
        return res
    return dp(-1,0)

N = int(input())
nums = [[],[],[]]
for _ in range(N):    
    a,b,c = list(map(int,input().split()))
    nums[0].append(a)
    nums[1].append(b)
    nums[2].append(c)
res = solution(nums)
print(res)


### FIXED CODE ###


#B- Frog 2

def solution(nums):
    n = len(nums)
    dp = [0,0,0]
    for day in range(n):
        new_dp = [0,0,0]
        for i in range(3):
            for j in range(3):
                if i!=j:
                    new_dp[i] = max(new_dp[i] , dp[j]+ nums[day][i] )
        dp = new_dp
    return max(dp[0],dp[1],dp[2])

N = int(input())
nums = []
for _ in range(N):    
    day = list(map(int,input().split()))
    nums.append(day)
res = solution(nums)
print(res)
N = int(input())
for i in range(26):
    for j in range(15):
        if 4*i + 7*j == N
        print("Yes")
        exit()
print("No")

### FIXED CODE ###

N = int(input())
for i in range(26):
    for j in range(15):
        if 4*i + 7*j == N:
            print("Yes")
            exit()
print("No")
x = int(input())
y = int(input())
if x == y:
    print(y)
else:
    print(y - x + 1)

### FIXED CODE ###

n,a=map(int , input().split())
print(n-a+1)
a, b, k = map(int, input().split())
divs = []

for i in range(1, max(int(max(a, b)), 2)):
    if a % i == 0:
        if b % i == 0:
            divs.append(i)
print(divs[-k])

### FIXED CODE ###

a, b, k = map(int, input().split())

for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
a, b = map(int, input().split())
print(int(a / b), a % b, "{0:.5f}"format(a / b))

### FIXED CODE ###

a, b = map(int, input().split())
print(a // b, a % b, "{0:f}".format(a / b))
from bisect import bisect_right
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

shop = []
shop_a0 = []

for i in range(n):
    a, b = map(int, input().split())
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [t+1]*30
dp[0] = 0

for i in range(n):
    for j in range(30):
        dp[j] = min(dp[j], dp[j-1] + 1 +
                    shop[i][0]*(dp[j-1]+1) + shop[i][1])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(n+1):
    if t - dp[i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[i]) + i)

print(ans)


### FIXED CODE ###

from bisect import bisect_right
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


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

shop = []
shop_a0 = []

for i in range(n):
    a, b = map(int, input().split())
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

INF = 10**10
# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[INF for _ in range(31)] for __ in range(n+1)]
dp[0][0] = 0

m = min(n+1, 30)

for i in range(n):
    for j in range(m):
        if (shop[i][0]+1)*(dp[i][j]+1) + shop[i][1] > t:
            dp[i+1][j+1] = dp[i][j+1]
        else:
            dp[i+1][j+1] = min(dp[i][j+1], (shop[i][0]+1)
                               * (dp[i][j]+1) + shop[i][1])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(m):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

print(ans)
H,M = map(int,input().split())
if H == 1 and M == 1:
    print(1)
else :
    print(round(H*M/2)

### FIXED CODE ###

import math
H,M = map(int,input().split())
if H == 1 or M ==1 :
    print(1)
else :
    print(math.ceil((H*M)/2))
N, M = (int(x) for x in input().split())

xyz = [list(map(int, input().split())) for _ in range(M)]

# 魔法実行回数
magic_act_num = 0

known = [False for x in range(N)]
judge = 0
index = 0
for x, y, _ in xyz:
    x = x-1
    y = y-1
    if known[x] and known[y]:
        continue;

    # zは気にしなくてよい
    if known[x]:
        if known[y] is False:
            known[y] = True
            judge += 1
    else:
        if known[y]:
            known[x] = True
            judge += 1
        else:
            known[x] = True
            known[y] = True
            judge += 2
            magic_act_num += 1
    i = 0
    for a, b, _ in xyz:
        if i <= index:
            continue
        a = a - 1;
        b = b - 1;
        if known[a] is x and known[b] is y:
            continue
        if known[a] is y and known[b] is x:
            continue
        if known[a] is x:
            if known[b] is not y:
                known[b] = True
        if known[a] is y:
            if known[b] is not x:
                known[b] = True
        if known[b] is x:
            if known[a] is not y:
                known[a] = True
        if known[b] is y:
            if known[a] is not x:
                known[a] = True
        i++
    index++

magic_act_num += (N-judge)

print(magic_act_num)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.p[ry] = rx

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set()
    for i in range(N):
        rlist.add(u.root(i))

    print(len(rlist))

if __name__ == '__main__':
    main()
x = [int(i) for i in input().split()]
x.pop(0)

M = max(x)
m = min(x)
s = sum(x)

print(m,M,s)

### FIXED CODE ###

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

M = max(x)
m = min(x)
s = sum(x)

print("{0} {1} {2}".format(m,M,s))
n=iny(input())
a=set(list(input().split())
if len(a)==3:
    print("Three")
else:
    print("Four")

### FIXED CODE ###

n=int(input())
a=set(list(input().split()))
if len(a)==3:
    print("Three")
else:
    print("Four")
n = int(input())
h = list(map(int, input().split()))

if h[0]>h[1]: h[0] -= 1
for i in range(1,n-1):
  if h[i]>h[i-1] and h[i]>h[i+1]:
    h[i] -= 1
    
if h == sorted(h):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

flag = True
for i in range(n-1,0,-1):
  if h[i]>=h[i-1]:
    continue
  elif h[i-1]-h[i]==1:
    h[i-1] -= 1
  else:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')
a,b,c=input().split()
print("Yes" if sum(a==b,b==c,c==a)==1 else "No")

### FIXED CODE ###

a,b,c=input().split()
print("YNeos"[sum((a==b,b==c,c==a))!=1::2])
import fanctions
A, B, C, D = map(int, input().split())
CD = C*D/fanctions.gcd(C, D)

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))


### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())
CD = int((C*D)/fractions.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))
import numpy as np
def f(n, a):
    index, count = np.unique(a, return_counts=True)
    mx = max(count)
    for s in index[count == mx]:
        print(s)
    print(mx)

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = input()
f(n, a)


### FIXED CODE ###

d = {}
max_value = 1
n = int(input())
for i in range(n):
    t = input()
    if t in d.keys():
        d[t] += 1
        if d[t] > max_value:
            max_value = d[t]
    else:
        d.setdefault(t, 1)
#print(f"d = {d}")
#print(f"max_value = {max_value}")
#print(f"d.keys() = {d.keys()}")
#print(f"d.values() = {d.values()}")
d = sorted(d.items())
#print(d)
for k, v in d:
    if v == max_value:
        print(k)
N,K,Q = map(int,input().split(" "))
a=[]
a2={}

for i in range(Q):
  a.append(input())
  
for i in range(N):
  a2[i+1] = a.count(str(i+1))

for i in range(N):
  if a2[i+1] >= Q-K+1:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a = ["Sunny","Cloudy","Rainy"]

def f():
  S = input() 
  return a[(a.index(S) + 1) % 3]

print(f())
H, W, M = map(int, input().split())

hs = [0] * H
ws = [0] * W
checked = set()

for i in range(M):
    r,c = map(int, input().split())
    r -= 1
    c -= 1

    hs[r] += 1
    ws[c] += 1
    checked.add((r, c))

mh, mw = 0, 0
for i in range(H):
    mh = max(mh, hs[i])
    mw = max(mw, ws[i])

max_h_list = []
max_w_list = []
    
for i in range(H):
    if hs[i] == mh: max_h_list.append(i)    
for i in range(W):
    if ws[i] == mw: max_w_list.append(i)

ans = mh + mw

for i in max_h_list:
    for j in max_w_list:
        if (i,j) not in checked:
            print(ans)
            exit()
print(ans-1)  

### FIXED CODE ###

H, W, M = map(int, input().split())

hs = [0] * H
ws = [0] * W
checked = set()

for i in range(M):
    r,c = map(int, input().split())
    r -= 1
    c -= 1

    hs[r] += 1
    ws[c] += 1
    checked.add((r, c))

mh, mw = 0, 0
for i in range(H):
    mh = max(mh, hs[i])
for j in range(W):
    mw = max(mw, ws[j])

max_h_list = []
max_w_list = []
    
for i in range(H):
    if hs[i] == mh: max_h_list.append(i)    
for j in range(W):
    if ws[j] == mw: max_w_list.append(j)

ans = mh + mw

for i in max_h_list:
    for j in max_w_list:
        if (i,j) not in checked:
            print(ans)
            exit()
print(ans-1)
import operator

def snuke_fest(top_arr, middle_arr, bottom_arr):
    sorted_arrs = list(sorted(arr) for arr in (top_arr, middle_arr, bottom_arr))
    del top_arr
    del middle_arr
    del bottom_arr
    pointers = [0] * 3
    ended = [False] * 3
    min_posi = [None] * len(sorted_arrs[0]) * 3
    min_posi_pointer = 0
    while not all(ended):
        nums = [0] * 3
        mins = [10**9] * 3
        for i in range(3):
            if not ended[i]:
                mins[-(i+1)] = sorted_arrs[i][pointers[i]]
        min_index, min_val = min(enumerate(mins), key = operator.itemgetter(1))
        min_index = 2 - min_index
        pointers[min_index] += 1
        min_posi[min_posi_pointer] = min_index
        min_posi_pointer += 1
        if pointers[min_index] == len(sorted_arrs[0]):
            ended[min_index] = True
    del sorted_arrs
    del pointers
    count = 0
    count_arr = [0, 0, 0]
    count_one_two = 0
    for i in range(len(min_posi)):
        count_arr[min_posi[-(i+1)]] += 1
        if min_posi[-(i+1)] == 1:
            count_one_two += count_arr[2]
        elif min_posi[-(i+1)] == 0:
            count += count_one_two
    return count


if __name__ == "__main__":
    _ = input()
    top_arr = [int(i) for i in input().split(" ")]
    middle_arr = [int(i) for i in input().split(" ")]
    bottom_arr = [int(i) for i in input().split(" ")]
    print(snuke_fest(top_arr, middle_arr, bottom_arr))

### FIXED CODE ###


import operator

def snuke_fest(top_arr, middle_arr, bottom_arr):
    sorted_arrs = list(sorted(arr) for arr in (top_arr, middle_arr, bottom_arr))
    del top_arr
    del middle_arr
    del bottom_arr
    pointers = [0] * 3
    ended = [False] * 3
    min_posi = [None] * len(sorted_arrs[0]) * 3
    min_posi_pointer = 0
    try:
        while not all(ended):
            nums = [0] * 3
            mins = [10**9] * 3
            for i in range(3):
                if not ended[i]:
                    mins[-(i+1)] = sorted_arrs[i][pointers[i]]
            min_index, min_val = min(enumerate(mins), key = operator.itemgetter(1))
            min_index = 2 - min_index
            pointers[min_index] += 1
            min_posi[min_posi_pointer] = min_index
            min_posi_pointer += 1
            if pointers[min_index] == len(sorted_arrs[0]):
                ended[min_index] = True
    except Exception as e:
        return 0
    del sorted_arrs
    del pointers
    count = 0
    count_arr = [0, 0, 0]
    count_one_two = 0
    for i in range(len(min_posi)):
        count_arr[min_posi[-(i+1)]] += 1

        if min_posi[-(i+1)] == 1:
            count_one_two += count_arr[2]
        elif min_posi[-(i+1)] == 0:
            count += count_one_two
    return count


if __name__ == "__main__":
    # run_test(find_even, test_pair)
    _ = input()
    top_arr = [int(i) for i in input().split(" ")]
    middle_arr = [int(i) for i in input().split(" ")]
    bottom_arr = [int(i) for i in input().split(" ")]
    print(snuke_fest(top_arr, middle_arr, bottom_arr))
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(N, 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(M, 2)))

c3 = c1 + c2
print(c3)

### FIXED CODE ###

import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)
3
apple
orange
apple

### FIXED CODE ###

import collections

N = int(input())
S = list(input() for _ in range(N))

setS = set(S)

print(len(setS))
a, b, c, k = map(int, input().split())

ans = []

a_list = list(range(a + 1))
b_list = list(range(b + 1))

for l in a_list:
    for m in b_list:
        ans.append(l - (k - l - m))

print(max(ans))


### FIXED CODE ###

a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif a < k <= a+b:
    print(a)
elif a+b < k:
    print(a - (k-a-b))
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限
N, M = map(int, input().split())
A = [[0]* N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    A[a-1][b] = 1
    A[b-1][a] = 1
visited=[0]*N
ans = 0
def DFS(x):
    if not 0 in visited:
        return 1
    for i in range(N):
        if not 1 in A[x][i]:
            return
        if visited[x] == 1:
            return
        visited[x] = 1
        ans += DFS(i)
    return ans
print(DFS(0))

### FIXED CODE ###


import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
k, n = map(int, input().split())
list_a = list(map(int, input().split()))
 
x = 0
longest = 0
for a in list_a:
  if a - x > longest:
    longest = a - x
    x = a - x
if longest < a[0] + (k - a[n-1]):
  longest = a[0] + (k - a[n-1])
print(k-longest)

### FIXED CODE ###

k, n = map(int, input().split())
list_a = list(map(int, input().split()))
 
x = 0
longest = 0
for a in list_a:
  if a - x > longest:
    longest = a - x
  x = a
if longest < list_a[0] + (k - list_a[n-1]):
  longest = list_a[0] + (k - list_a[n-1])
print(k-longest)
K, X = map(int, input().split())
wealth = 500 * K
if K >= X:
  print('Yes")
else:
  print('No')

### FIXED CODE ###

K, X = map(int, input().split())
wealth = 500 * K
if wealth >= X:
    print('Yes')
else:
    print('No')
a, b=map(str, input().split())
if a is "H"
    if b is "H"
        print("H")
    else:
        print("D")
else:
    if b is "H"
        print("D")
    else:
        print("H")


### FIXED CODE ###

a, b=map(str, input().split())
if a is 'H':
    if b is 'H':
        print('H')
    else:
        print('D')
else:
    if b is 'H':
        print('D')
    else:
        print('H')
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)


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