Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  7 18:47:41 2020

@author: naoki
"""
import sys
import copy
def func():
    N, M = map(int, input().split())
    uvs = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
    S, T = map(lambda x:int(x)-1, input().split())
    
    roots = [[] for _ in range(N)]
    
    for uv in uvs:
        roots[uv[0]].append(uv[1])
    
    costs = [-10000]*(N)
    
    from collections import deque
    
    todo = deque([S])
    costs[S] = 0
    todo_set = set([S])
    
    for i in range(10):
    #while len(todo)>0:
        checking = todo.popleft()
        next_targets = deque([checking])
        for i in range(3):
            purposes = set()
            while len(next_targets) > 0:
                now = next_targets.pop()
                for root in roots[now]:
                    purposes.add(root)
            next_targets = purposes.copy()
        for next_target in next_targets:
            if costs[next_target] < 0 and next_target not in todo_set:
                costs[next_target] = costs[checking]+1
                todo.append(next_target)
                todo_set.add(next_target)
                if next_target == T:
                    print(costs[next_target])
                    sys.exit()
    print(-1)
if __name__ == "__main__":
    func()

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  7 18:47:41 2020

@author: naoki
"""
import sys
import copy
def func():
    N, M = map(int, input().split())
    uvs = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
    S, T = map(lambda x:int(x)-1, input().split())
    
    roots = [[] for _ in range(N)]
    
    for uv in uvs:
        roots[uv[0]].append(uv[1])
    
    costs = [-10000]*(N)
    
    from collections import deque
    
    todo = deque([S])
    costs[S] = 0
    todo_set = set([S])
    
    layers = [set() for _ in range(3)]
    
    while len(todo)>0:
        checking = todo.popleft()
        next_targets = deque([checking])
        for i in range(3):
            purposes = set()
            while len(next_targets) > 0:
                now = next_targets.pop()
                for root in roots[now]:
                    if root not in layers[i]:
                        layers[i].add(root)
                        purposes.add(root)
            next_targets = purposes.copy()
        for next_target in next_targets:
            if costs[next_target] < 0 and next_target not in todo_set:
                costs[next_target] = costs[checking]+1
                todo.append(next_target)
                todo_set.add(next_target)
                if next_target == T:
                    print(costs[next_target])
                    sys.exit()
    print(-1)
if __name__ == "__main__":
    func()
n=int(input())
l=list(map(int,input().split()))
l.sort()
sum=1#個数
if l[0]==l[1]:
  sum=0
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j] % l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
dp=[0]*(10**6+1)
for i in a:
  dp[i]+=1
for i in range(1,10**6+1):
  if dp[i]:
    for  j in range(2*i,10**6+1,i):
      dp[j]=0
print(dp.count(1))
N = int(input())
H = list(map(int,input().split()))

count_list = []
count = 0

for i in range(N-1):
  if  H[i] >= H[i+1]:
    count += 1
  else:
    count_list.append(count)
    count = 0
else:
  count_list.apend(count)

print(max(count_list))

### FIXED CODE ###

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

count_list = []
count = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    count_list.append(count)
    count = 0
else:
  count_list.append(count)
    
print(max(count_list))
import numpy as np
import sys
L,R = map(int,input().split())
a = np.zeros(R-L+1,dtype="int64")
b = 2019
if R - L >= 2018:
  print("0")
  sys.exit()
else:
  for i in range (0,R-L+1):
    d = (L + i) % 2019
    a[i] = d
  for i in range (0,R-L+1):
    for j in range (i+1,R-L+1):
      x = (a[i] * a[j]) % 2019
      b = min(b,x)
print(b)

### FIXED CODE ###

L, R = map(int,input().split())
b = 2018
if R - L >= 2019:
  print(0)
else:
  L = L % 2019
  R = R % 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      if b > (i * j) % 2019:
        b = (i * j) % 2019
  print(b)
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def gcd_multi(nums):
    if len(nums) == 0:
        return 0
    if len(nums) == 1:
        return nums[0]

    ret = math.gcd(nums.pop(), nums.pop())
    while len(nums) > 0:
        ret = math.gcd(ret, nums.pop())
    return ret


def solve(inputs):
    monsters = string_to_int(inputs[0])
    return gcd_multi(monsters)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


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

    if a > b:
        return gcd(b, a % b)
    else:
        return gcd(a, b % a)


def gcd_multi(nums):
    if len(nums) == 0:
        return 0
    if len(nums) == 1:
        return nums[0]

    ret = gcd(nums.pop(), nums.pop())
    while len(nums) > 0:
        ret = gcd(ret, nums.pop())
    return ret


def solve(inputs):
    monsters = string_to_int(inputs[0])
    return gcd_multi(monsters)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)
import math

[a,b,h,m] = [int(x) for x in input().split(" ")]

short = (h*60+m)/(12*60)*360
long = (m)/(60)*360
theta = min(abs(long-short),abs(360-abs(short-long)))

print(math.sqrt(a*2+b*2+a*b*math.cos(theta)))

### FIXED CODE ###

import math
 
[a, b, h, m] = [int(x) for x in input().split(" ")]
short = ((h) * 60 + m) / (12 * 60) * 360
long = (m) / (60) * 360
theta = abs(long - short)
inte = math.cos(math.radians(theta))
print(math.sqrt(a ** 2 + b ** 2- 2*a * b * inte))
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op = '+':
        print(a + b)
    elif op = '-':
        print(a - b)
    elif op = '*'
        print(a * b)
    elif op = '/':
        print(a // b)
    else:
        break

### FIXED CODE ###

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math

prime_flag = [True] * (small + 1)
limit  = int(math.sqrt(small))
for i in range(2, limit + 2):
    if not prime_flag[i]:
        continue
    for j in range(i + i, small + 1, i):
        prime_flag[j] = False

primes = [i for i, _ in enumerate(prime_flag) if prime_flag[i]][2:]
cd = [p for p in primes if (small % p == 0) and (big % p == 0)]

print(len(cd) + 1)


### FIXED CODE ###

a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    # divisorsを使い回せるようにする。
    #   - 二度生成した場合にかかる時間が許容できない場合
    #   - エラトステネスの篩などで素数テーブルを既に持っている場合
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        # divisorsを引数で与えた場合のみ起こりうる
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))

print(len(small_factors.intersection(big_factors)) + 1)
# -*- coding:utf-8 -*-
import math

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(math.gcd(A,B)))+1)

### FIXED CODE ###

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

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if fractions.gcd(A,B) == 1:
    print(1)
else:
    print(len(factorization(fractions.gcd(A,B)))+1)
s = input()

i = 0
while(True):
    if ("01" in s ) :
        s = s.replace("01","",1) 
        i += 1
    elif "10" in s:
        s = s.replace("10","",1)
        i += 1
    else:
        break
    print(s)
print(i*2)

### FIXED CODE ###

s = input()

num_0 = s.count("0")
num_1 = s.count("1")
if num_0 < num_1:
    print(num_0*2)
else:
    print(num_1*2)
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if sort_p[0]!=0:
        print(x)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        #print(ans)
        small=x-ans
        big=x+ans
        #print(p)
        #print(small,big)
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)




### FIXED CODE ###

x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)
import math
a,b,c,d=map(int,input().split())
e=(c*d)//math.gcd(c, d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))

### FIXED CODE ###

from fractions import gcd
a,b,c,d=map(int,input().split())
e=(c*d)//gcd(c, d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=is_prime[1]=0
for i in range(2,int(n**0.5)*1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

### FIXED CODE ###

Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')
N = int(input())
L = input().split()
L.sort()
c = 0
for a in range(N):
    if a == 0:
        c = c + float(L[0])/pow(2, N - 1)
    else:
        c = c + float(L[a])/pow(2, N - a)
print(c)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
N = input()
A = input().split(",")
count = 0

while True:
    roop = False
    for i in range(0, int(N)):
        if int(int(A[i])) % 2 != 0:
            roop = True
            break
        A[i] = int(A[i]) / 2
    if roop:
        break
    count+=1


print(count)

        

  

### FIXED CODE ###

N = int(input())
A = input().split()


count = 0
while True:
    flag = True
    for i in range(N):
        Ai = int(A[i])
        if Ai % 2 != 0:
            flag = False
            break
        A[i] = Ai / 2
        
    if flag == False:
        break
    count += 1

print(count)
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)

### FIXED CODE ###

import math
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)
k, n, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
import numpy as np
points = np.array([k]*n)

for i in range(q):
    winner = a[i]
    points -= np.array([1]*n)
    points[a[i]] += 1

for i in points:
    if i <= 0:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

points = [k - q]*n
for i in range(q):
    points[a[i]-1] += 1
for i in range(n):
    if points[i] <= 0:
        print("No")
    else:
        print("Yes")
N, K = map(int, input().split())
c = 0
n = 1
for i in range(K):
  Lists = list(int(input()))
  List = list(map(int, input().split()))
for I in range(N):
  if n in List:
    n = n+1
  else:
    c = c+1
    n = n+1
print(c)

### FIXED CODE ###

def resolve():
    N, K = map(int, input().split())
    A = []
    for i in range(K):
        d = int(input())
        a = list(map(int, input().split()))
        A.extend(a)
    print(N - len(set(A)))
resolve()
S = input()
if S[0] == S[1] and S[2] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[2] and S[1] == S[4] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and len(set(S)) == 2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()
if S[0] == S[1] and S[2] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and len(set(S)) == 2:
    print('Yes')
else:
    print('No')
N, K = [int(i) for i in input()]
print(0) if N % K == 0 else print(1)

### FIXED CODE ###

N, K = [int(i) for i in input().split()]
print(0) if N % K == 0 else print(1)
import math
N = int(input())

if N % 2 != 0:
    print(0)
else:
    n = N // 10
    ans = n
    for i in range(1,int(math.log(n, 5) + 1)):
        ans += n // (5 ** i)
    print(ans)

### FIXED CODE ###

import math
N = int(input())

if N % 2 != 0 or N <= 8:
    print(0)
else:
    n = N // 10
    ans = n
    for i in range(1,int(math.log(n, 5) + 1)):
        ans += n // (5 ** i)
    print(ans)
N = int(input())
S = [input() for i in range(N)]
m_count = 0
m_str = []

for i in range(N):
    if S.count(S[i]) > m_count:
        m_str = [S[i]]
        m_count = S.count(S[i])
    elif S.count(S[i]) == m_count:
        m_str.append(S[i])

m_str = list(set(m_str))
m_str.sort()

print(m_str[i] for i in len(m_str))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
judge = 1
while 0 in A:
    A.remove(0)

A_ = list(set(A))
A_.sort()
for i in range(len(A_) - 1):
    if A_[i+1] == A_[i]+2:
        judge = 1
    else:
        judge = 0

if len(set(A)) == len(A)/2 and judge:
    print((2 ** (len(A) // 2)) % (10**9 +7))
else:
    print(0)
INF = 10000000

h, n = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]

maxA = max(AB[:][0])

dp = [INF for i in range(h+maxA)]
dp[0] = 0

for i in range(1, h+maxA):
    for j in range(n):
        a, b = AB[j][0], AB[j][1]
        dp[i] = min(dp[i], dp[i-a] + b)

ans = min(dp[h:])

print(ans)


### FIXED CODE ###

INF = 1000000000

h, n = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]

maxA = max(AB, key=lambda x: x[0])[0]

dp = [INF for i in range(h+maxA)]
dp[0] = 0

for i in range(1, h+maxA):
    dp[i] = min(dp[i-a] + b for a, b in AB)

print(min(dp[h:]))
input (x)
x**3


### FIXED CODE ###

x = input()
x = int(x)
print(x**3)
import sys
while 1
    H,W = sys.stdin.readline().split()
    if H == 0 and W == 0:
        break
    print(('#' * W + '\n')*H)

### FIXED CODE ###

import sys
while 1:
    H,W = map(int,sys.stdin.readline().split())
    if H == W == 0:
        break
    print(('#'*W + '\n')*H)
import math

r=int(raw_input())
s=float(r)*r*math.pi
l=float(r)*2*math.pi
print  s,l

### FIXED CODE ###

import math

r=float(raw_input())
s=r*r*math.pi
l=2*r*math.pi

print  "{0:.6f}".format(s),"{0:.6f}".format(l)
import math

A,B=[int(x) for x in input().rstrip().split()]

print(A*B//(math.gcd(A,B)))

### FIXED CODE ###

a,b=[int(x) for x in input().rstrip().split()]

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)

    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
def lcm(m,n):
    return int(m*n/gcd(m,n))
print(lcm(a,b))
inp = raw_input().split("\r\n")
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = [[0] * 10 for i in range(10)]
for i in xrange(10):
    for j, a in enumerate(map(int,inp[i + 1].split(" "))):
        Cij[i][j] = a
        #print a,
    #print

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [[n, 0, Nmm,n]]
    while len(rourt) > 0:
        rl = len(rourt)
        new_rourt = []
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                if i != r[0]:
                    nm = r[1] + Cij[r[0]][i]
                    if nm < Nmm:
                        """if Mml[i] != None:
                            Mml[n] = nm + Mml[i]
                            return nm + Mml[i]"""
                        if i == 1:
                            #print r
                            Nmm = nm
                        new_rourt.append([i, nm, nm + Cij[i][1]] + r[3:] + [i] )
        rourt = new_rourt
    Mml[n] = Nmm
    return Nmm


NumberList = [0] * 10
for Ai in inp[11:]:
    #print Ai
    for A in Ai.split(" "):
        if A != "-1" and A != "":
            NumberList[int(A)] += 1

ans = 0
for i, n in enumerate(NumberList):
    if n > 0:
        ans += sloveMm(i) * n
        #print "AA",i,":",Cij[i][1],">>",Mml[i],"*", n
#print Mml
#print NumberList
print ans



### FIXED CODE ###


inp = []
inp.append(raw_input())
for i in xrange(10 + int(inp[0].split(" ")[0])):
    inp.append(raw_input())
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = [[0] * 10 for i in range(10)]
for i in xrange(10):
    for j, a in enumerate(map(int,inp[i + 1].split(" "))):
        Cij[i][j] = a
        #print a,
    #print

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [[n, 0, Nmm,n]]
    while len(rourt) > 0:
        rl = len(rourt)
        new_rourt = []
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                if i != r[0]:
                    nm = r[1] + Cij[r[0]][i]
                    if nm < Nmm:
                        """if Mml[i] != None:
                            Mml[n] = nm + Mml[i]
                            return nm + Mml[i]"""
                        if i == 1:
                            #print r
                            Nmm = nm
                        new_rourt.append([i, nm, nm + Cij[i][1]] + r[3:] + [i] )
        rourt = new_rourt
    Mml[n] = Nmm
    return Nmm


NumberList = [0] * 10
for Ai in inp[11:]:
    #print Ai
    for A in Ai.split(" "):
        if A != "-1" and A != "":
            NumberList[int(A)] += 1

ans = 0
for i, n in enumerate(NumberList):
    if n > 0:
        ans += sloveMm(i) * n
        #print "AA",i,":",Cij[i][1],">>",Mml[i],"*", n
#print Mml
#print NumberList
print ans
import heapq


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

idx_dict = {}
for i in range(n):
    idx_dict[i] = i+1

ans = [A[i]+A[i] for i in range(n)]
candidates = [[-(A[i]+A[i+1]), i] for i in range(n-1)]
heapq.heapify(candidates)

for i in range(m//2):
    num, idx = heapq.heappop(candidates)
    ans.append(-num)
    ans.append(-num)
    idx_dict[idx] += 1
    new_pair = idx_dict[idx]
    if new_pair >= n:
        continue
    candidate = A[idx] + A[new_pair]
    heapq.heappush(candidates, [-candidate, idx])

ans.sort(reverse=True)
print(sum(ans[:m]))

### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
cumsumA = []

total = 0
for a in A:
    total += a
    cumsumA.append(total)
cumsumA.append(0)

l = 0
r = 10 ** 6
while l + 1 < r:
    num = (l+r)//2
    pair_idx = n-1
    count = 0
    for a in A:
        while a + A[pair_idx] < num and pair_idx >= 0:
            pair_idx -= 1

        count += pair_idx+1

    if count < m:
        r = num
        continue
    elif count >= m:
        l = num


ans = 0
count = 0
num = l
pair_idx = n-1
for a in A:
    while a + A[pair_idx] < num and pair_idx >= 0:
        pair_idx -= 1

    count += pair_idx+1
    ans += cumsumA[pair_idx] + a*(pair_idx+1)

diff = count - m
ans -= num * diff
print(ans)
n = int(input())
x =list(map(int,input().split()))
def step(i,cost):
    if i>=(n-1):
        return abs(x[-1]-cost)
    return min(step(i+1,x[i])+abs(cost-x[i]),step(i+2,x[i])+abs(cost-x[i]))
cost = x[0]
print(step(0,cost))


### FIXED CODE ###

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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])
N,M = map(int,input().split())
K=[]
ans=0
for _ in range(N):
  K+=[input().split()]
S=set(K)
for s in S:
  if K.count(s)==N:
    ans+=1
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
K=[]
ans=0
for _ in range(N):
  K+=input().split()[1:]
S=set(K)
for s in S:
  if K.count(s)==N:
    ans+=1
print(ans)
n=int(input())
if s[-1]==2 and s[-1]==4 and s[-1]==5 and s[-1]==7 and s[-1]==9:
    print('hon')
elif s[-1]==0 and s[-1]==1 and s[-1]==6 and s[-1]==8
    print('pon')
else:
    print('bon')


### FIXED CODE ###

s=input()
if s[-1]=='3':
  print('bon')
elif s[-1] in ['0','1','6','8']:
  print('pon')
else:
  print('hon')
A,B,C,D = [int(i) for i in input().split()]
import math
l= C * D / math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(int(s))


### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
cd = lcm(c, d)
print(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))
H,W,K=map(int,input().split())
F=[input() for _ in range(H)]
ans=0
for i in range(2**H):
 for j in range(2**W):
  cnt=0
  for ii in range(H):
   for jj in range(W):
    if i>>ii%2==0 or j>>jj%2==0 or F[ii][jj]==".":
     continue
    cnt+=1
  if cnt==K:
  ans+=1
print(ans)

### FIXED CODE ###

H,W,K=map(int,input().split())
F=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    cnt=0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
          continue
        cnt+=1
    if cnt==K:
      ans+=1
print(ans)