Harryxun/stf_run huggingface dataset:
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
using namespace std;

const int MAX_N = 1000;
const int MAX_M = 20000;

int n, H;
int w[MAX_N], v[MAX_N];
// dp[i+1][j]: i番目までの品物から重さの総和がj以下となるように選んだ時の,
// 価値の総和の最大値
int dp[MAX_N + 1][MAX_M + 1];

int main() {
    cin >> H;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < n+1; i++) {
        for (int j = 0; j <= MAX_M+1; j++) {
            dp[i][j] = 100000000;
        }
    }
  for (int i = 0; i < n+1; i++) {
            dp[i][0] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= MAX_M; j++) {
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-w[i]]+v[i]);
        }
    }
    int ans = 100000000;
  for (int i=H; i<MAX_M+1; i++){
  	ans = min(ans, dp[n][i]);
  }

    cout << ans << '\n';

    return 0;
}

### FIXED CODE ###

H,N = map(int,input().split())
AB = []
 
for i in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])
INF = 10**15
dp = [[INF]*(2*10**4+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
 
for i in range(N):
    for j in range(1,2*10**4+1):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j-AB[i][0]]+AB[i][1])
        
ans = float('inf')
for i in range(H,2*10**4+1):
    ans = min(ans,dp[N][i])
print(ans)
S = input().split()

Flag = True

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  Flag = False
  
if Flag == False:
  print("Bad")
else:
  print("Good")

### FIXED CODE ###

S = int(input())

Flag = True

if (S//1000) == ((S%1000)//100) or ((S%1000)//100) == ((S%100)//10) or ((S%100)//10) == ((S%10)//1):
  Flag = False
  
if Flag == False:
  print("Bad")
else:
  print("Good")
#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappush,heappop

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  heappush(q,(s-x,1,x)) # xで死ぬ
  heappush(q,(t-x,0,x)) # xで死ななくなる

for i in range(Q):
  d = int(input())
  heappush(q,(d,2,i))
answer = [-1]*Q

se = []
remove_task = []

while q:
  a,c,b = heappop(q)
  if not c:
    heappush(remove_task,b)
  elif c&1:
    heappush(se,b)
  else:
    while se:
      x = se[0]
      y = remove_task[0]
      if x == y:
        se.pop()
        remove_task.pop()
        continue
      else:
        answer[b] = x

print('\n'.join(map(str,answer)))


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  q.append((s-x,1,x)) # xで死ぬ
  q.append((t-x,0,x)) # xで死ななくなる

for i in range(Q):
  d = int(input())
  q.append((d,2,i))
answer = [-1]*Q

se = set() # 引っかかってる場所

q.sort()

min_se = 10**18
flag = False # min_seが正しい

for a,c,b in q:
  if not c:
    se.remove(b)
    if min_se == b:
      flag = False
  elif c&1:
    se.add(b)
    if b < min_se:
      min_se = b
      flag = True
  else:
    if se:
      if not flag:
        min_se = min(se)
        flag = True
      answer[b] = min_se

print('\n'.join(map(str,answer)))
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = (k-a) // (a-b)

#print(cnt)

if k > a:

    print(-1)

else:
    if ((k-a) % (a-b) == 0):

        print(1 + cnt * 2)

    else:

        print(1 + (cnt + 1) * 2)

    


### FIXED CODE ###

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = a - b

rate = a

if rate >= k:
    
    print(1)
    
elif cnt==0:

    print(-1)
else:
    
    if (k-rate) % cnt == 0:
        
        num = (k-rate) // cnt 
        
        print(1+ num*2)
    
    else:
        
        num = ((k-rate) // cnt) + 1
        
        if num>=1 :
        
            print(num*2+1)
        
        else:
            
            print(-1)
import math
import os
import random
import re
import sys
from collections import defaultdict

def count(n, h):
	count = 0
	if len(h) < 1:
		return count
	max = h[0]
	for i in h:
		if i >= max:
			max = i 
			count += 1

	return count

if __name__ == '__main__':
	n = int(input())
    h = list(map(int, input().rstrip().split()))
    print(count(n, h))

### FIXED CODE ###

import math
import os
import random
import re
import sys
from collections import defaultdict

# sys.stdin = open('input.in', 'r')
# sys.stdout = open('output.out', 'w') 

def count(n, h):
	count = 0
	if len(h) < 1:
		return count
	max = h[0]
	for i in h:
		if i >= max:
			max = i 
			count += 1

	return count

if __name__ == '__main__':
	n = int(input())
	h = list(map(int, input().rstrip().split()))
	print(count(n, h))
a,b,c=list(input().split())
A=int(a*b/2)
ptint(A)


### FIXED CODE ###

a=list(input().split())
b=int(a[0])
c=int(a[1])
d=int(c*b/2)
print(d)
n,q=map(int,input().split())
ki=[[] for i in range(n+1)]
#ki[0]="null"

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

scores=[0 for i in range(n+1)]
#scores[0]="null"
for i in range(q):
    p,x=map(int,input().split())
    scores[p]+=x


ans=[0 for i in range(n+1)]
#ans[0]="null"
point=0

ed=[]

def tansa(n,point):
    global ed
    point+=scores[n]
    ed.append(n)
    for p in ki[n]:
        if not p in ed:
            try:
                tansa(p,point)
            except:
                return 0
    else:
        ans[n]=point
        
tansa(1,0)

ans=ans[1:]
ans=[str(i) for i in ans]
print(" ".join(ans))

### FIXED CODE ###

n,q=map(int,input().split())
L=[[] for i in range(n+1)]
S=[0 for i in range(n+1)]
V=[0 for i in range(n+1)]

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

for _ in range(q):
    p,x=map(int,input().split())
    S[p]+=x


que=[1]
head=0
V[1]=1
while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex]==0:
            V[nex]=1
            que.append(nex)
            S[nex]+=S[now]

print(" ".join([str(i) for i in S[1:]]))
ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)
a,b,c,d = map(int,input().split())

if a <c:
  

    if b-c>=0 :
       print ("Yes")
    else:
       print("No")
        
else:
    if b-c>=0 :
       print ("No")
    else:
       print("Yes")

### FIXED CODE ###

K = int(input())



for i in range(K):

  print("ACL", end='')
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        if Y == 10000 * x + 5000 * y + 1000 * (N - x - y):
            results = [x, y, (N - x - y)]
            print(results)
            exit()

### FIXED CODE ###

N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)
n = print()
a = list(map(int, input().sprit()))
print(a.reverse())

### FIXED CODE ###

n = int(input())
array = list(input().split())
array.reverse()
 
for i in range(n - 1):
    print(array[i] + " ", end = "")

print (array[n - 1])
def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)

### FIXED CODE ###

from fractions import gcd

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

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]
AB.sort()

X = AB[:N]
Y = AB[N:]

if any(x[0] == y[0] for x, y in zip(X, Y)):
    print('No')
    exit()

ans = [-1] * N
swap = []

for (_, i, sx), (_, j, sy) in zip(X, Y):
    if sx == sy:
        swap.append((min(i, j), max(i, j)))
    else:
        if sx == 0:
            ans[i] = B[j]
        else:
            ans[j] = B[i]

if len(swap) != len(set(swap)):
    1 / 0

print('No')



### FIXED CODE ###

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

AB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]
AB.sort()

X = AB[:N]
Y = AB[N:]

if any(x[0] == y[0] for x, y in zip(X, Y)):
    print('No')
    exit()

swapA = []
swapB = []
ans = [-1] * N

for (_, i, sx), (_, j, sy) in zip(X, Y):
    if sx == sy == 0:
        swapA.append((i, j))
    elif sx == sy == 1:
        swapB.append((i, j))
    else:
        if sx == 0:
            ans[i] = B[j]
        else:
            ans[j] = B[i]

for (i, j), (x, y) in zip(swapA, swapB):
    ans[i] = B[x]
    ans[j] = B[y]

    if A[i] == ans[i] or A[j] == ans[j]:
        ans[i], ans[j] = ans[j], ans[i]

print('Yes')
print(*ans)
N, M = map(int, input().split())
l = []
for i in range(M):
  x = list(map(int, input().split()))
  l.append(x)
print(l)
m = []
n = [[1]]

for j in range(M):
  for i in range(M):
    for k in range(len(n[j])):
      if l[i][0] == n[j][k] or l[i][1] == n[j][k]:
        if l[i][0] == n[j][k]:
          m.append(l[i][1])
        else:
          m.append(l[i][0])
        l[i] = [0, 0]
  n.append(m)
  m = []
  print(n)

for i in range(M -1):
  

### FIXED CODE ###

import queue

N, M = map(int, input().split())
parent = [-1] * N # -1なら未訪問
adj = [[] for _ in range(N)] # 隣接リスト作成
for i in range(M):
  a, b = map(int, input().split())
  adj[a-1].append(b)
  adj[b-1].append(a)
q = queue.Queue() # 自分の部屋、親の部屋
q.put([1, 0]) # 1の親は0
while not q.empty():
  x, y = q.get()
  if parent[x-1] != -1: # もし自分の部屋が訪問済みなら
    continue
  parent[x-1] = y # 自分の部屋の親yを指定
  for i in adj[x-1]:
    if parent[i-1] == -1:
      q.put([i, x])
print('Yes')
for j in parent[1:]:
  print(j)
W,H,x,y,r = map(int, raw_input().split())
if r <= x <= W-r and r <= y <= H-r:
    print ('Yes')
else:
    print ('No')

### FIXED CODE ###

W,H,x,y,r = map(int, input().split())
if r <= x <= W-r and r <= y <= H-r:
    print ('Yes')
else:
    print ('No')
S = input()
A = S.split()

for i in A:
    if A[i]=A[i+1]:
        print('Bad')
    else:
        print('Good')


### FIXED CODE ###

S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')
$ cat atcorder_142_C.py
N = int(input())
s = raw_input().split()
h = [0]*N

for i in range(N):
    h[i] = int(s[i])
    h[i] = (h[i], i+1)

#print h
h.sort()
#print h

for i in range(N-1):
    print h[i][1],

print h[N-1][1]


### FIXED CODE ###

N = int(input())
s = raw_input().split()
h = [0]*N

for i in range(N):
    h[i] = int(s[i])
    h[i] = (h[i], i+1)

#print h
h.sort()
#print h

for i in range(N-1):
    print h[i][1],

print h[N-1][1]
a,b,k=map(int,input())

cnt = 0
for i in range(1, max(a,b)+1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break


### FIXED CODE ###

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

cnt = 0
for i in range(max(a,b)+1, 0, -1):
    if (a % i == 0) and (b % i == 0):
        cnt += 1
    if cnt == k:
        print(i)
        break
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
                a = False
                break
    if not a:
        break
if a ==True:
    print('Yes')
else:
    print('No')



### FIXED CODE ###

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
 
flag = False
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if (j-1 >= 0 and s[i][j-1] == '.') and (j+1 < W and s[i][j+1] == '.') and (i-1 >= 0 and s[i-1][j] == '.') and (i+1 < H and s[i+1][j] == '.'):
                print('No')
                flag = True
                break
    if flag:
        break
else:
    print('Yes')
ABC = import()
list_ABC= list(ABC)

A_ = list_ABC[1] + list_ABC[2]
B_ = list_ABC[2] + list_ABC[0]
C_ = list_ABC[0] + list_ABC[1]

if A_>list_ABC[0] and B_>list_ABC[1] and C_>list_ABC[2]:
    print('Yes')
else:
    print('No')    

### FIXED CODE ###

ABC = input().split()
list_ABC= list(ABC)

if list_ABC[0] == list_ABC[1] and list_ABC[0] == list_ABC[2]:
    print('Yes')
else:
    print('No')
p = [1] * 1000001
for i in range(2, 1001):
    if p[i] == 0:
        continue
    for j in range(2, 1000001/i):
        p[i*j] = 0

t = int(raw_input())
for i in range(t):
    n = int(raw_input())
    res = n * (n-1) / 2 + 2
    for j in range(2, n+1):
        if p[j] == 1:
            res -= (n / j - 1) * (j - 1)
    print res

### FIXED CODE ###

count = range(1000001) 
for i in xrange(2, 500001):
    for n in xrange(i*2, 1000001, i):
        count[n] -= (count[i] - 1) 
 
count[1] = 2
for i in xrange(2, 1000001):
    count[i] += count[i-1]

t = int(raw_input())
for i in xrange(t):
    n = int(raw_input())
    print count[n] - n + 1
N, K = map(int, input().split())

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

# print(N, K)
# print(A_list)

keiro = [1]
visit_town = [0]*N

town = 1
c = 1
while True:
    visit_town[town - 1] = c
    c += 1
    town = A_list[town - 1]
    # print('town', town)

    if len(keiro) > 1 and visit_town[town-1] != 0:
        break
    keiro.append(town)

# print(keiro)
# print(visit_town)
# print(town)


first_visit = keiro[:visit_town[A_list[keiro[-1]-1]-1]-1]
loop_visit = keiro[visit_town[A_list[keiro[-1]-1]-1]-1:]

# print(first_visit)
# print(loop_visit)

if K <= len(first_visit):
    print(first_visit[k - 1])
else:
    l = K - len(first_visit)
    # print(l)
    c = (l+1) % len(loop_visit)
    # print(c)
    print(loop_visit[c-1])

# print(keiro[len(first_visit) + (K - len(first_visit)) % len(loop_visit)])


### FIXED CODE ###

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

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

# print(N, K)
# print(A_list)

keiro = [1]
visit_town = [0]*N

town = 1
c = 1
while True:
    visit_town[town - 1] = c
    c += 1
    town = A_list[town - 1]
    # print('town', town)

    if len(keiro) > 1 and visit_town[town-1] != 0:
        break
    keiro.append(town)

# print(keiro)
# print(visit_town)
# print(town)


first_visit = keiro[:visit_town[A_list[keiro[-1]-1]-1]-1]
loop_visit = keiro[visit_town[A_list[keiro[-1]-1]-1]-1:]

# print(first_visit)
# print(loop_visit)

if K <= len(first_visit)-1:
    print(first_visit[K])
else:
    l = K - len(first_visit)
    # print(l)
    c = (l) % len(loop_visit)
    # print(c)
    print(loop_visit[c])

# print(keiro[len(first_visit) + (K - len(first_visit)) % len(loop_visit)])
from collections import defaultdict

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

g = defaultdict(list)
done = [0] * (N+1)
memo = [0] * (N+1)
for x, y in xy:
    g[x].append(y)

def dp(v):
    max_len = 0
    if done[v] == 1:
        return memo[v]
    else:
        for to in g[v]:
            max_len = max(max_len, dp(to)+1)
        done[v] = 1
        memo[v] = max_len
        return max_len

ans = 0
for v in range(1, N+1):
    ans = max(ans, dp(v))
print(ans)

### FIXED CODE ###

from collections import defaultdict, deque

def topological_sort(vertex:list, edge:list):
    graph = {i: [] for i in vertex}
    for i, j in edge:
        graph[i].append(j)
        
    inp_cnt = defaultdict(int)
    outs = defaultdict(list)
    for inp, out in edge:
        inp_cnt[out] += 1
        outs[inp].append(out)

    result = []
    queue = deque([i for i in vertex if inp_cnt[i]==0])
    while queue:
        v = queue.popleft()
        result.append(v)
        for v2 in outs[v]:
            inp_cnt[v2] -= 1
            if inp_cnt[v2] == 0:
                queue.append(v2)
    return result

N, M = map(int, input().split())
vertex = list(range(1, N+1))
edge = [list(map(int, input().split())) for _ in range(M)]
graph = {i: [] for i in vertex}
for i, j in edge:
    graph[i].append(j)

sorted_vertecies = topological_sort(vertex, edge)
dp = [0] * (N+1)
for i in sorted_vertecies:
    ends = graph[i]
    for j in ends:
        dp[j] = max(dp[j], dp[i] + 1)
print(max(dp))
#bin/usr/env python3

n, x = map(int,input().split())
length = input().split()

total_len = 0
for i in range(n):
    total_len += int(length[i])
    if total_len > x:
        print(i+1)
        break
    if i = n-1:
        print(n+1)





### FIXED CODE ###

#bin/usr/env python3

n, x = map(int,input().split())
length = input().split()

total_len = 0
for i in range(n):
    total_len += int(length[i])
    if total_len > x:
        print(i+1)
        break
    if i == n-1:
        print(n+1)
print('Yes' if (sorted(input()) == sorted(input()) else 'No'))


### FIXED CODE ###

S = input()
T = input() * 2
for i in range(len(S)):
    for j in range(len(S)):
        s, e = [i+j, i+j+len(S)]
        if (T[s:e] == S):
            print('Yes')
            exit()
print('No')
a, b = map(int, input().split())
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print("even")
else:
  print("odd")

### FIXED CODE ###

x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')
n = int(input())
array = []
for i in range(1,n+1):
    for j in range(1,n//i+1):
        array.append(abs(i-j) + n - i*j)
print(min(array))

### FIXED CODE ###

N,K = map(int,input().split())
num = 0
dicta = {}
for i in range(N):
    a,b = map(int,input().split())
    if a not in dicta:
        dicta[a] = b
    else:
        dicta[a] += b

dicts = sorted(dicta.items(), key = lambda x:x[0])
for i,v in dicts:
    num += v
    if num >= K:
        print(i)
        break
import math
A,B,C,D = list(map(int,input().split()))
dis = B - A + 1
CD = C*D//math.gcd(C,D)
perCfromA = (A-1)//C
perDfromA = (A-1)//D
perCDfromA = (A-1)//CD
perCfromB = B//C
perDfromB = B//D
perCDfromB = B//CD
warikire = (perCfromB + perDfromB -perCDfromB) - (perCfromA + perDfromA -perCDfromA)
warikirenai = dis -warikire
print(warikirenai)

### FIXED CODE ###

import fractions
A,B,C,D = list(map(int,input().split()))
dis = B - A + 1

CD = C*D//(fractions.gcd(C,D))
#print(CD)
perCfromA = (A-1)//C
perDfromA = (A-1)//D
perCDfromA = (A-1)//(CD)


perCfromB = B//C
perDfromB = B//D
perCDfromB = B//(CD)

#print(perCfromA,perDfromA,perCDfromA,perCfromB,perDfromB,perCDfromB)
warikire = (perCfromB + perDfromB -perCDfromB) - (perCfromA + perDfromA -perCDfromA)
warikirenai = dis -warikire
print(warikirenai)
while True:
    (x, y) = (int(i) for i in input().split())
    if x = 0 and y = 0:
        break
    elif x <= y:
        print(x, y)
    elif x > y:
        print(y, x)

### FIXED CODE ###

while True:
    (x, y) = (int(i) for i in input().split())
    if x == 0 and y == 0:
        break
    elif x <= y:
        print(x, y)
    else:
        print(y, x)
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    L, R = map(int, input().split())

    R_r = R%2019
    if (R - L) > R_r :
        print(0)
    else:
        L_r = L%2019
        ans = L_r*(L_r+1)%2019
        for l in range(L_r, R_r):
            for r in range(l+1, R_r+1):
                ans = min(ans, l*r%2019)
        print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","c",main)

### FIXED CODE ###

#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())

    print(min(A*N, B))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","a",main)
import sys
N = int(input())
for i in range(int(N/4)):
    amount = (i + 1) * 4
    for j in range(int(N/7)):
        amount += 7
        if(amount == N):
            print('Yes')
            sys.exit()
print('No')


### FIXED CODE ###

string = input()
array = string.split(' ')
N = int(array[0])
K = int(array[1])
if N % K == 0:
    print(0)
else:
    print(1)
xs=input()
xi=int(xs)
xs=list(xs)
fx=sum(xs)
print("Yes" if xi%fx==0 else "No")

### FIXED CODE ###

N=int(input())
def digitsum(N) :
  s = str(N)
  array = list(map(int, list(s)))
  T = sum(array) 
  return T

U = digitsum(N)

if N % U ==0 :
  print("Yes")
else:
  print("No")
A,B = map(int,input().split())
  
if A*B%2 == 0:
    print("Even")
else:
  pritn("False")

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2 ==0:
    print('Even')
else:
    print('Odd')
r,d,x0 = map(int,input().split())

xlist = []

xlist.append(r*x0-d)

for i in range(9):
    xlist.append(r*xlist[i]-d)
    map(int,xlist)
    print(xlist[i])




### FIXED CODE ###


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

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print(int(ans))