Harryxun/stf_run huggingface dataset:
from collections import defaultdict
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
Un = UnionFind(M)
D = defaultdict(lambda: [])
for i in range(N):
    _, *L = map(int, input().split())
    for l in L:
        D[l].append(i)
for i in range(M):
    if len(D[i]) > 1:
        t = D[i]
        for d in t[1:]:
            Un.union(t[0], d)
if Un.size[Un.find(0)] == N-1:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

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


class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
Un = UnionFind(N)  # 会話できる人をつなげる
D = defaultdict(lambda: [])
for i in range(N):
    _, *L = map(lambda x: int(x)-1, input().split())
    for l in L:
        D[l].append(i)
for i in range(M):
    if len(D[i]) > 1:
        t = D[i]
        for d in t[1:]:
            Un.union(t[0], d)
if Un.size[Un.find(0)] == N:
    print("YES")
else:
    print("NO")
r=input()
x=r*r
print(x)

### FIXED CODE ###

r=int(input())

x=r*r

print(x)
N=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
ans=0
for i in range(N):
  val=B[i]
  mid_a=A[N//2-1]
  mid_c=C[N//2-1]
  if mid_a<val:
    count1=0
    for i in range(N//2,N):
      if A[i]<val:
        count1+=1
      else:
        break
    val1=N//2+count1
  else:
    count2=0
    for i in range(N//2):
      if A[i]<val:
        count2+=1
      else:
        break
    val1=count2
  if mid_c>val:
    count3=0
    for i in range(N//2):
      if C[i]<val:
        count3+=1
      else:
        break
    val2=N-count3
  else:
    for i in range(N//2,N):
      if C[i]>val:
        val2=N-i
        break
      else:
        if i==N:
          val2=0
        else:
          pass
  ans+=val1*val2
print(ans)

### FIXED CODE ###

import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
ans=0
for val in B:
  val1=bisect.bisect_left(A,val)
  val2=N-bisect.bisect_right(C,val)
  ans+=val1*val2
print(ans)
input()
slist = raw_input().split()
input()
tlist = raw_input().split()

def func(v, low, high):

    mid = (low + high)/2
    
    if mid >= len(slist):
        return False
    
    if v > slist[mid]:
        if low == high:
            return False
        return func(v, mid+1, high)
    elif v == slist[mid]:
        return True
    else:
        if low == high:
            return False
        return func(v, low, mid-1)

count = 0
for t in tlist:
    count += func(t, 0, len(slist)-1)

print count

### FIXED CODE ###

input()
slist = map(int, raw_input().split())
input()
tlist = map(int, raw_input().split())

def func(v, low, high):

    # print "l h = %d %d" % (low, high)
    if low > high:
        return 0

    mid = (low + high)/2
    
    # print "mid %d" % mid
    
    if mid >= len(slist):
        # print "test1"
        return 0
    
    if v > slist[mid]:
        if low == high:
            # print "test2"
            return 0
        # print "test3"
        return func(v, mid+1, high)
        
    elif v == slist[mid]:
        # print "test4"
        return 1
    else:
        if low == high:
            # print "test5"
            return 0

        # print "test6 %d %d" % (v, slist[mid])
        return func(v, low, mid-1)

count = 0
for t in tlist:
    count += func(t, 0, len(slist)-1)
print count
l,r,d = map(int,input.split())
print((l-r+1)//d)

### FIXED CODE ###

l,r,d = map(int,input().split())
print(r//d - (l-1)//d)
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    //nump <= numg
    int nump = 0, numg = 0;
    for(int i = 0 ; i < len; i++){
        if(s[i] == 'p')nump++;
        else if(s[i] == 'g')numg++;
    }
    cout<<(nump+numg)/2-nump;
    return 0;
}


### FIXED CODE ###

x=input()
n=int(len(x)/2)
a=0
ls=[]
def fun():
     for i in range(2):
          ls.append(i)
for i in x:
     if i=='p':
          a+=1
print(n-a)
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end+1]))


### FIXED CODE ###

# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1, -1):
    if s[i] == 'Z':
        end = i
        break
print(end + 1 - start)
S=str(input())

if 0<int(S[0]+S[1])<=12 and 0<int(S[2]+S[3])<=12:
  print('AMBIGUOUS');exit()
elif S[0]+S[1]=='00':
  print('NA');exit()
elif (S[0]+S[1]<=12 or S[2]+S[3]=='00') and int(S[0]+S[1])>12:
  print('YYMM');exit()
else:
  print('MMYY');exit()

### FIXED CODE ###

S=str(input())
A=int(S[0]+S[1])
B=int(S[2]+S[3])

if 0<A<=12 and 0<B<=12:
  print('AMBIGUOUS');exit()
elif (A>12 or A==0) and 0<B<=12:
  print('YYMM');exit()
elif 0<A<=12 and (B>12 or B==0):
  print('MMYY');exit()
else:
  print('NA');exit()
N = int(input())
A = list(map(int, input().split(' ')))

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1 or count_list[1] != 0:
        false_flag = 1
    count_ = 2
    diff = 1
while count_ < N and false_flag == 0:
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print(2 ** (N // 2))
else:
    print(0)

### FIXED CODE ###

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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    #print(count_)
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print((2 ** (N // 2) ) % 1000000007)
else:
    print(0)
N = int(raw_input())
a = raw_input()

b = a.split()
c = [0 for i in range(9)]
for i in range(N):
	b[i] = int(b[i])
	if 1 <= b[i] <=399:
		c[0] = 1
	elif 400 <= b[i] <= 799:
		c[1] = 1
	elif 800 <= b[i] <=1199:
		c[2] = 1
	elif 1200<= b[i] <= 1599:
		c[3] = 1
	elif 1600 <= b[i] <= 1999:
		c[4] = 1
	elif 2000 <= b[i] <= 2399:
		c[5] = 1
	elif 2400 <= b[i] <= 2799:
		c[6] = 1
	elif 2800 <= b[i] <= 3199:
		c[7] = 1
	else:
		c[8] += 1

max = 0
min = 0
for i in range(9):
	max = max + c[i]

min = max - c[8]
if min == 0:
	min = 1
print min, 
print max

### FIXED CODE ###

a= raw_input().split()

sum = int(a[0])*100 + int(a[1])*10 + int(a[2])

if sum%4 == 0:
	print "YES"
else:
	print "NO"
X, N = map(int, input("").split(" "))
p = list(map(int,input().split()))
p.sort()
q = [i+1 for i in range(-2*X,2*X)]

ans = 0
diff = 100

for i in q:
    if (abs(X - i) < diff and (not i in p)):
        ans = i
        diff = abs(X-i)
print(ans)


### FIXED CODE ###

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

for i in range(len(l)):
    if (l[i] == 0):
        print(i+1)
        break
h,w = map(int,input().split())
maps = []
for i in range(h):
    maps.append(list(map(int,input().split())))
for i in range(h):
    for j in range(w):
        if maps[i][j] == "snuke":
            print(chr(ord('A') + w) + str(h + 1))
            exit()

### FIXED CODE ###

h,w = map(int,input().split())
maps = []
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
    maps.append(list(map(str,input().split())))
for i in range(h):
    for j in range(w):
        if maps[i][j] == "snuke":
            print(alphabet[j]+str(i+1))
            exit()
n = int(input())
c = input().split()
c = [int(n) for n in c]

for i in range(1, n+1):
    print(c.count(i))


### FIXED CODE ###

import math
r = int(input())
r = 2*r*math.pi
print(r)
a,b,c,d=map(int,input().split())
while 1:
    c-=b
    if a<=0  or c<=0:
        break
    a -= d
    if a<=0  or c<=0:
        break
print('Yes' if a>0 else 'No')


### FIXED CODE ###

n,m=map(int,input().split())
print('unsafe' if m>=n else 'safe')
import sys
readline = sys.stdin.readline
from functools import reduce
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def calc(A):
    N = len(A)
    K = sum(1 for a in A if a % 2 == 0)
    if K & 1:
        return True
    if N-1 != K:
        return False
    A = [a-a%2 for a in A]
    g = reduce(gcd, A)
    A = [a//g for a in A]
    return not calc(A)


N = int(readline())
A = list(map(int, readline().split()))
print('First' if calc(A) else 'Second')

### FIXED CODE ###

import sys
readline = sys.stdin.readline
from functools import reduce
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def calc(A):
    N = len(A)
    if N == 1:
        return A[0]%2 == 0

    K = sum(1 for a in A if a % 2 == 0)
    if K & 1:
        return True
    if N-K != 1:
        return False
    if min(A) == 1:
        return False
    A = [a-a%2 for a in A]
    g = reduce(gcd, A)
    A = [a//g for a in A]
    return not calc(A)


N = int(readline())
A = list(map(int, readline().split()))
print('First' if calc(A) else 'Second')
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

N = int(input())
strings = [input() for i in range(N)]
ans = 0

for i in range(len(strings)):
  anagrams_index = []
  anagrams_num = 0
  for j in range(i+1, len(strings)):
    if i > len(strings) or j > len(strings):
      break
    if is_anagram(strings[i], strings[j]):
      anagrams_num += 1
      strings.pop(j)
  
  if anagrams_num == 1:
    ans +=1
  elif anagrams_num > 1:
    ans += int(math.factorial(anagrams_num+1)/math.factorial(anagrams_num)) 
print(ans) 

### FIXED CODE ###

import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)
a = input().split
b = input().split

if a[0] = b[0]:
  print("0")
else:
  print("1")

### FIXED CODE ###

a = []
b = []
a = input().split()
b = input().split()

if a[0] == b[0]:
  print("0")
else:
  print("1")
# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 2): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c+1, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d+1, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d)+1, s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        # Case: B < D < C 
        pflg = searchPlain(b-1, d, s, ".")
#        if pflg == False:
#            if s[b-2] == "." and s[b] == ".":
#                ans = "Yes"
#            else:
#                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
print(ans)


### FIXED CODE ###

# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c+1, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d+1, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d)+1, s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        # Case: B < D < C 
        pflg = searchPlain(b-1, d, s, ".")
        if pflg == False:
            ans = "No"
#            if s[b-2] == "." and s[b] == ".":
#                ans = "Yes"
#            else:
#                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
print(ans)
a, b, c, k = map(int, input().split())

if k <= a:
    sum = k * 1
elif a < k and k <= a + b:
    sum = a
elif a + b < k <= a + b + c:
    sum = a + (-1) * (k - a - b)

print(sum)


### FIXED CODE ###

s = input()
t = input()

if (s[:len(s)] == t[:len(s)]):
    print("Yes")
else:
    print("No")
X, Y, Z = input()
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split(' '))
print(Z, X, Y)
a,b,h=map(int,input().split())
print((((a+b)*h)//2)

### FIXED CODE ###

a,b,h=[int(input()) for _ in range(3)]
print(((a+b)*h)//2)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

root = [[] for _ in range(N + 1)]
result = [0] * (N + 1)

for i in range(N - 1):
    a = ab[i][0]
    b = ab[i][1]
    root[a].append(b)
    root[b].append(a)

for i in range(Q):
    p = px[i][0]
    x = px[i][1]
    result[p] += x


def dfs(now, prev):
    for next in root[now]:
        if next == prev:
            continue
        else:
            result[next] += result[now]
            dfs(next, now)


dfs(1, -1)
print(*result[1:])

### FIXED CODE ###

N, Q = map(int,input().split()) # 複数の数字を変数に格納
List_ab = [list(map(int,input().split())) for i in range(N-1)] # [[1,2],[3,4],[5,6]]
List_px = [list(map(int,input().split())) for i in range(Q)] # [[1,2],[3,4],[5,6]]

count_list = [0]*N

List_ab.sort()

for i in range(Q):
    count_list[List_px[i][0]-1] += List_px[i][1]
        
for i in range(N-1):
    count_list[List_ab[i][1]-1] += count_list[List_ab[i][0]-1]
    
print(*count_list)
import math
from decimal import *
A,B=input().strip().split()
A,B=[int(A),float(B)]
A=Decimal("A")
B=Decimal("B")
result=math.floor(A*B)
print(result)


### FIXED CODE ###

from decimal import Decimal
import math
a,b = map(Decimal,input().split())
ans = a*b
print(math.floor(ans))
import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    if len(str) > 5:
        criterion = ["a", "b", "c", "d", "e"]
    else:
        criterion = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
                     "u", "v", "w", "x", "y", "z"]
    objs = {}
    for index, s in enumerate(str):
        if s in criterion:
            for i in range(index+1,len(str)+1):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)


### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    s = sorted(list(set(str)))
    criteron = s[:k]
    objs = {}
    for index, s in enumerate(str):
        if s in criteron:
            if len(str)+1 > index + 1 + k:
                made = index + 1 + k
            else:
                made = len(str)+1
            for i in range(index+1,made):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)
N = int(input())
mod = int(10e9+7)
f = lambda n:1 if n==1 else n * f(n-1) % mod
print(f(N))

### FIXED CODE ###

N = int(input())
power = 1
for i in range(N):
    power *= i + 1
    power %= 1000000007
print(power)
w,h,x,y=map(int,input()split())
area=w*h/2
if x==w/2 and y==h/2:
  print(area, '1')
else:
  print(area, '0')

### FIXED CODE ###

w,h,x,y=map(int,input().split())
area=w*h/2
if x==w/2 and y==h/2:
  print(area, '1')
else:
  print(area, '0')
S = input()
K = int(input())
if S[0] == '1':
    print(S[1])
else:
    print(S[0])


### FIXED CODE ###

import math
S = input()
K = int(input())
M = 5 * 10 ** 15

def main():
    sum = 0
    for s in S:
        n = int(s)
        sum += (M - 1) * math.log(n)
        if sum >= math.log(K):
            print(n)
            return

def main2():
    if K <= len(S):
        for i in range(K):
            if S[i] != '1':
                print(S[i])
                return
        print('1')
        return
    else:
        for s in S:
            if s != '1':
                print(s)
                return

if __name__ == '__main__':
    main2()
a = input()
for i in range('aiueo'):
  if a == i:
    print('vowel')
    exit()
print('consonant')


### FIXED CODE ###

a = input()
for i in 'aiueo':
  if a == i:
    print('vowel')
    exit()
print('consonant')
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
      N = N - A[i] 
if N >= 0:
    print(N)
else:
    print(-1)

### FIXED CODE ###

print(int(input())*6.3)
a, b = map(int, input().split())
print(a*b)2 

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
import itertools
n = int(input())
rc = [list(map(int, input().split())) for _ in range(n)]
rc_min = rc.index(min(rc))

def calc(rc):
    total = 0
    for i, irc in enumerate(rc):
        if i ==0:
            r, c = irc
        else:
            total += r * c * irc[1]
            c = irc[1]
    return r, c, total
def reverse_calc(rc):
    total = 0
    for i, irc in enumerate(rc[::-1]):
        if i ==0:
            r, c = irc
        else:
            total += r * c * irc[0]
            r = irc[0]
    return r, c, total

total = 0
r1, c1, ret = reverse_calc(rc[:rc_min])
total += ret
r2, c2, ret =calc(rc[rc_min:])
total += ret
total += r1 * c1 * c2
print(total)

### FIXED CODE ###

def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 

def split_rc(rc):
    for i in range(1, len(rc)):
        yield rc[:i], rc[i:]

@memoize
def cost(rc):
    if len(rc) == 1:
        return 0
    return min(calc_cost(first, second) for first, second in split_rc(rc))

def calc_cost(first, second):
    return cost(first) + cost(second) + first[0][0] * first[-1][1] * second[-1][1]

n = int(input())
rc = tuple(tuple(map(int, input().split())) for _ in range(n))
print(cost(rc))
N,A,B = map(int,input().split())
print(min(S*N,B))

### FIXED CODE ###

N,A,B = map(int,input().split())
print(min(A*N,B))
import math

A,B,C = map(int, input().split())

if C%math.gcd(A, B)==0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

A,B,C = map(int, input().split())

sum=A
while sum % B != 0:
    sum = sum + A

    if sum%B==C:
        print("YES")
        break
else:
    print("NO")
n=int(input())
o=[]
for i in range(n):
    x,y=map(int,input().split())
    o.append([x,y])
p2=[]
q2=[]
for i in range(1,n):
    p2+=[int(o[i][0]-o[i-1][0])]
    q2+=[int(o[i][1]-o[i-1][1])]
p1=[int(s) for s in p2]
q1=[int(s) for s in q2]
p1=[abs(s) for s in p1]
q1=[abs(s) for s in q1]
p=min(map(int,p1))
q=min(map(int,q1))
ans=0
a=0
for i in range(n):
    for u in range(n):
        if i==u:
            break
        pd=o[i][0]-o[u][0]
        qd=o[i][1]-o[u][1]
        if pd==p and qd==q:
            a+=1
print(n-a)

### FIXED CODE ###

from collections import defaultdict
n=int(input())
o=[]
for i in range(n):
    x,y=map(int,input().split())
    o.append([x,y])
o.sort()
p2=[]
q2=[]
c=[]
if n==1:
    print(1)
else:
    for i in range(n):
        for j in range(i+1,n):
            p2=o[j][0]-o[i][0]
            q2=o[j][1]-o[i][1]
            c.append(str(p2)+" "+str(q2))
    r=defaultdict(int)
    for f in c:
        r[f]+=1
    p=list(r.values())
    q=max(p)
    print(n-q)
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break



### FIXED CODE ###

import numpy as np

N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)