Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(n)]
b=[int(input())for _ in range(m)]
[print(sum([j*k for j,k in zip(a[i],b]))for i in range(n)]
~                                                       


### FIXED CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[int(input())for _ in range(m)]
[print(sum([j*k for j,k in zip(a[i],b)]))for i in range(n)]
import math
import heapq
N, D, A = map(int, input().split())

M = []
for i in range(N):
    X, H = map(int, input().split())
    M.append((X, H))
M.sort(key=lambda x: x[0])


hq = []
heapq.heapify(hq)  # リストhqのheap化
ans = 0
B = 0
dx = M[0][0]+2*D
dd = math.ceil(M[0][1]/A)*A
for i, (x, h) in enumerate(M):
    while x > dx:
        B -= dd
        if B == 0:
            break
        dx, dd = heapq.heappop(hq)
    if h > B:
        t = math.ceil((h-B)/A)
        ans += t
        B += t*A
        if i != 0:
            heapq.heappush(hq, (x+2*D, t*A))
        if len(hq) == 1:
            dx = x+2*D
            dd = t*A


print(ans)


### FIXED CODE ###

import math
N, D, A = map(int, input().split())

M = []
for i in range(N):
    X, H = map(int, input().split())
    M.append((X, H))
M.sort(key=lambda x: x[0])

d = []
i = 0

ans = 0
B = 0
for X, H in M:
    while i != len(d) and X > d[i][0]:
        B -= d[i][1]
        i += 1
    if H > B:
        t = math.ceil((H-B)/A)
        ans += t
        B += t*A
        d.append((X+2*D, t*A))


print(ans)
n=int(input())
lst=[]
for i in range(n)
 lst.extend(str(input()))
 
 
list_uniq=[]
for j in lst
 if list_uniq.count(j)==0:
    list_uniq.extend(j)
 else:
    pass
 print(len(list_uniq))

### FIXED CODE ###

n=int(input())
lst={}
for i in range(n):
  lst[input()]=1
print(len(lst))
target = input()
text = input()
text = input()
text = input()
text = input()
text = input()
text2 = text.replace('\n',' ')
sentenceList = text2.split()
count = 0
for word in sentenceList:
 if(word.lower() == target):
  count+=1
print(count)


### FIXED CODE ###

target = input()
total_text = ""
while True:
 text = input()
 if(text=="END_OF_TEXT"):
  break
 total_text+=" "
 total_text+=text
#text2 = text.replace('\n',' ')
sentenceList = total_text.split()
count = 0
for word in sentenceList:
 if(word.lower() == target):
  count+=1
print(count)
x = int(input())
y = x ** 3
print(y

### FIXED CODE ###

x =int(input())
y = x**3
print(y)
def comb(n,r):
    return math.factorial(n)/(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))

### FIXED CODE ###

import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))
N,K=input().split()
N,K=[int(N),int(K)]
 
minimum=N
while N < =minimum:
  N=abs(N-K)
  minimum=N
  
  
print(minimum)

### FIXED CODE ###

N,K=input().split()
N,K=[int(N),int(K)]

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)
n=int(input())
total=0
for i in range(1,n+1,2):
  ans=0
  for j in range(1,i+1):
    if i%j==0:
      ans+=1
  if ans==8:
    total+=1
print(total)


### FIXED CODE ###

a,b=map(int,input().split())
print((a-1)*(b-1))
n=input()
print':'.join(map(str,[n/3600,n%3600/60,n%60]))

### FIXED CODE ###

import sys
S = int(sys.stdin.readline())
h = int(S / 60 / 60)
m = int(S % 3600 / 60)
s = S % 60
print("%d:%d:%d" % (h, m, s))
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b=map(int,input().split())

print(-(-a//(2b+1)))

### FIXED CODE ###

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

print(-((-a)//(2*b+1)))
(x, y) = map(int, input().split())
print x * y, 2 * (x + y)

### FIXED CODE ###

(x, y) = map(int, raw_input().split())
print x * y, 2 * (x + y)
from sys import stdin
 
input_list = []
for line in stdin:
  input_list.append(line.rstrip('\n'))
 
if input_list[0] == input_list[1][:len(input_list[0])]:
  print('Yes')
else:
  print('No)

### FIXED CODE ###

from sys import stdin
 
input_list = []
for line in stdin:
  input_list.append(line.rstrip('\n'))
 
if input_list[0] == input_list[1][:len(input_list[0])]:
  print('Yes')
else:
  print('No')
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin
 
def main():
    N = map(int, input().split())
    A = [int(x) for x in input.split()]
    cnt = 0
    while True:
        for i in range(N):
            A[i] /= 2
            if A[i] % 2 == 1:
                break
        cnt += 1
    print(cnt)
 
input = lambda: stdin.readline().rstrip()
main()

### FIXED CODE ###

from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    cnt = 0
    while True:
        loop = True
        for i in range(N):
            if A[i] % 2 == 1:
                loop = False
                break
            A[i] /= 2
        if not loop:
            break
        cnt += 1
    print(cnt)

input = lambda: stdin.readline().rstrip()
main()
import sys
from collections import deque

prime = []

for i in range(2,1001):
    det = 0
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            det = -1
            break
    if det == 0:
        prime.append(i)

N = int(input())
A = list(map(int,input().split()))
B = []###Aのうち1ではないもの
det = False###Aが1を含んでいたか否か

for i in range(N):
    if A[i] == 1:
        det = True
    else:
        B.append(A[i])

if len(B) <= len(prime):

    m = 1

    for p in prime:
        count = 0
        for b in B:
            if b%p==0:
                count += 1
        m = max(m,count)
        if m >= 2:
            break
    
    if m == 1:
        print('pairwise coprime')
        sys.exit(1)

if det:
    print('setwise coprime')

else:
    pp = prime[:]
    
    for b in B:
        pp_ = []
        for p in pp:
            if b%p == 0:
                pp_.append(p)
        pp = pp_[:]


        if pp == []:
            print('setwise coprime')
            sys.exit(1)
    
    print('not coprime')
                

### FIXED CODE ###

import math

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

A_max = max(A)

D = [i for i in range(1+A_max)]

for i in range(2,1+int(A_max**(1/2))):
    if D[i] == i:
        for j in range(2,1+A_max//i):
            D[i*j] = i

prime = {}

for i in range(2,1+A_max):
    if D[i] == i:
        prime[i] = 0

for a in A:
    X = []
    aa = a
    while aa > 1:
        X.append(D[aa])
        aa //= D[aa]
    
    X = set(X)

    for x in X:
        prime[x] += 1

if all([v<=1 for v in prime.values()]):
    print('pairwise coprime')

else:
    g = A[0]
    for i in range(1,N):
        g = math.gcd(g,A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
    if i==N:
      print(sum(A))
      exit()
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))
def factorization(n):
    arr = []
    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])

    return arr
N = int(input())
ans = 0
if N != 1:
    fact_list = factorization(N)
    for _, i in fact_list:
        j = 1
        while i >= j:
            ans += 1
            i = i - j
            j += 1
            
print(ans)


### FIXED CODE ###

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
N = int(input())
ans = 0
if N != 1:
    fact_list = factorization(N)
    for _, i in fact_list:
        j = 1
        while i >= j:
            ans += 1
            i = i - j
            j += 1
            
print(ans)
import math

n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))
    
for i in s:
    i.sort()

s.sort()

tmp = 'a'
total = 0
for i in s:
    if i == tmp:
        cnt += 1
    elif cnt >= 2:
        total += math.factorial(cnt)*math.factorial(cnt-2)/2
        cnt = 1
    tmp = i

print(int(total)

### FIXED CODE ###

n = int(input())
ss = ["".join(sorted(list(input()))) for _ in range(n)]
ss.sort()

ans = 0
cnt = 0
tmp = ss.pop(0)
for s in ss:
    if tmp == s:
        cnt+=1
    elif cnt > 0:
        tmp = s
        ans+=((cnt+1) * cnt // 2)
        cnt = 0
    else:
        tmp = s
        cnt = 0
print(ans + ((cnt+1) * cnt // 2))
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
 
dp = [0] * 10000
dp[0] = 1
if 1 not in a:
    dp[1] = 1
    
for i in range(2, n + 1):
    if  (i - 1) not in a:
        dp[i] = dp[i] + dp[i - 1]
    if (i - 2) not in a:
        dp[i] = dp[i] + dp[i - 2]
 
    dp[i] %= 1000000007    
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
issafe = [True] * (n +1)
for _ in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * (n + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if  issafe[i - 1]:
        dp[i] = dp[i] + dp[i - 1]
    if issafe[i -  2]:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])
from sys import stdin
a = stdin.readline().rstrip()
#print(a.upper())    # 読み込んだ文字を大文字に変換
pi = 3.14159265
r = 2*pi*a
print(r)

### FIXED CODE ###

from sys import stdin
a = stdin.readline().rstrip()
#print(a.upper())    # 読み込んだ文字を大文字に変換
a = int(a)
pi = 3.14159265
r = 2*pi*a
print(r)
import numpy as np

n, m = input().split()
n = int(n)
m = int(m)

# a[i] = 0 の床は踏めない
a = np.ones(n+1, dtype=np.bool)
for _ in range(m):
    a[int(input())] = 0

mod = 1e9 + 7

# pos[i]はi段目まで登る場合の数
pos = np.zeros(n+1)
pos[0] = 1
for i in range(n):
    if i == n - 1:
        pos[i+1] += pos[i]
    else:
        if a[i+1]:
            pos[i+1] += pos[i]
        if a[i+2]:
            pos[i+2] += pos[i]

print(int(pos[n] % mod))

### FIXED CODE ###

import numpy as np

n, m = input().split()
n = int(n)
m = int(m)

# a[i] = 0 の床は踏めない
a = np.ones(n+1, dtype=np.bool)
for _ in range(m):
    a[int(input())] = 0

mod = 1e9 + 7

# pos[i]はi段目まで登る場合の数
pos = np.zeros(n+1)
pos[0] = 1
for i in range(n-1):
    if a[i+1]:
        pos[i+1] += pos[i]
        pos[i+1] %= mod
    if a[i+2]:
        pos[i+2] += pos[i]
        pos[i+2] %= mod

pos[n] += pos[n-1]

print(int(pos[n] % mod))
import numpy as np
import scipy.sparse.csgraph as sg

H, W = [int(a) for a in input().split()]
ss = []
for _ in range(H):
    ss.append(input())

g = np.zeros((H*W,H*W))

v_edges = [((i,j), (i,j+1)) for i in range(H) for j in range(W-1) if ss[i][j] == "." and ss[i][j+1] == "."]
h_edges = [((i,j), (i+1,j)) for i in range(H-1) for j in range(W) if ss[i][j] == "." and ss[i+1][j] == "."]

for (si,sj), (di,dj) in v_edges + h_edges:
    g[si*W+sj][di*W+dj] = 1
    g[di*W+dj][si*W+sj] = 1

r = sg.dijkstra(g)
score = r[0,H*W-1]

if np.isinf(score):
    print(-1)
    exit(1)

#print(r)
#print(ss) 

ss_ = "".join(ss)
num = len([0 for c in ss_ if c == '.'])
#print(num)
#print(score)
print("%d" % (num - (score+1)))




### FIXED CODE ###

import numpy as np
import scipy as sp
import scipy.sparse.csgraph as sg

H, W = [int(a) for a in input().split()]
ss = []
for _ in range(H):
    ss.append(input())

g = np.zeros((H*W,H*W))

v_edges = [((i,j), (i,j+1)) for i in range(H) for j in range(W-1) if ss[i][j] == "." and ss[i][j+1] == "."]
h_edges = [((i,j), (i+1,j)) for i in range(H-1) for j in range(W) if ss[i][j] == "." and ss[i+1][j] == "."]

for (si,sj), (di,dj) in v_edges + h_edges:
    g[si*W+sj][di*W+dj] = 1
    g[di*W+dj][si*W+sj] = 1

r = sg.dijkstra(g, indices=[0,H*W-1])
score = r[0,H*W-1]

if sp.isinf(score):
    print(-1)
    exit(0)
else:
    #print(r)
    #print(ss) 

    ss_ = "".join(ss)
    num = len([0 for c in ss_ if c == '.'])
    #print(num)
    #print(score)
    print("%d" % (num - (score+1)))
s = input()
t = input()

s = [x for x in s[::-1]]
t = [x for x in t[::-1]]    

for i in range(len(s)-len(t)):
  flg = False
  cnt = 0
  for j in range(len(t)):
    if s[i+j] == '?':
      cnt += 1
      continue
    if s[i+j] == t[j]:
      flg = True
    else:
      flg = False
      break
  if flg or cnt == len(t):
    s[i:i+len(t)] = t
    flg = True
    break

if not flg:
    print('UNRESTORABLE')
    exit()

ans = ''
s = [x for x in s[::-1]]
for i in range(len(s)):
  if s[i] == '?':
    s[i] = 'a'
  ans += s[i]
print(ans)


### FIXED CODE ###

s = input()
t = input()

if len(s) < len(t):
    print('UNRESTORABLE')
    exit()

s = [x for x in s[::-1]]
t = [x for x in t[::-1]]    

for i in range(len(s)-len(t)+1):
  flg = False
  cnt = 0
  for j in range(len(t)):
    if s[i+j] == '?':
      cnt += 1
      continue
    if s[i+j] == t[j]:
      flg = True
    else:
      flg = False
      break
  if flg or cnt == len(t):
    s[i:i+len(t)] = t
    flg = True
    break

if not flg:
    print('UNRESTORABLE')
    exit()

ans = ''
s = [x for x in s[::-1]]
for i in range(len(s)):
  if s[i] == '?':
    s[i] = 'a'
  ans += s[i]
print(ans)
S = input()
n = len(S)
a = [0]*(n+1)
l = [0]*2019
t = pow(10, n-1)

a[0] = int(S)
l[a[0]%2019] += 1

for i in range(n):
    a[i+1] = a[i] - int(S[i])*t
    l[a[i+1]%2019] += 1
    t = t // 10

print(sum(map(lambda x: x*(x-1)//2, l)))


### FIXED CODE ###

S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
b = input()
 
if  "A"==b
    print("T")
elif "C"==b
    print("G")
elif "T"==b
    print("A")
else:
    print("C")

### FIXED CODE ###

S = input()
count = 0
num = 0


for i in S:
    if i=="A" or i=="C" or i=="G" or i=="T":
         count = count + 1
         if count >= num:
             num = count
    else:
        count = 0

print(num)
r = int(input())
import numpy

print(math.pi*2*r)

### FIXED CODE ###

r = int(input())

import math

print(math.pi*2*r)
s = input()
t = s[0]
p = 1
i = 1
while i < len(s):
    if s[i] == t:
        i += 2
    else:
        i += 1
    t = s[i-1]
    p += 1

print(p)

### FIXED CODE ###

s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i <= 1:
    print(p+i)
else:
    if s[i-1] == s[i-2]:
        print(p+1)
    else:
        print(p+2)
# Hello World program in Python
import math
def lcm(a, b):
    return (a*b) //math.gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x) % mod
for x in A:
    ans = (ans + l/x) % mod
print(ans)

### FIXED CODE ###

def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)

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

N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007

for x in A:
    l = lcm(l, x)

for x in A:
    ans = ans + l//x
print(ans % mod)
tmp=input().sprit(" ")
a = int(tmp[0])
b = int(tmp[1])

if a = b:
    print (a*2)
else:
    print (max(a,b)*2-1)


### FIXED CODE ###

tmp=input().split(" ")
a = int(tmp[0])
b = int(tmp[1])

if a == b:
    print (a*2)
else:
    print (max(a,b)*2-1)
n = int( raw_input( ) )
eles = []
for i in range( n ):
	op = raw_input( ).split( " " )
	if "insert" == op[0]:
		eles.insert( 0, op[1] )
	elif "delete" == op[0]:
		for val in eles:
			if op[1] == val:
				eles.pop( i )
	elif "deleteFirst" == op[0] :
		del eles[0]
	elif "deleteLast" == op[0]:
		eles.pop( )

print( " ".join( eles ) )

### FIXED CODE ###

import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )
a,b=map(int,input().split())
a=min(1,a)
b=min(1,b)
z=aa.count(0)
if b==1 and a<=0:
  print('Zero')
elif b==0:
  print('Zero')
elif (b-a)%2==0 and b<0:
  print("Negative")
else:
  print("Positive")

### FIXED CODE ###

a,b=map(int,input().split())
a=min(1,a)
b=min(1,b)
if b==1 and a<=0:
  print('Zero')
elif b==0:
  print('Zero')
elif (b-a)%2==0 and b<0:
  print("Negative")
else:
  print("Positive")
from collections import defaultdict
from operator import sub

def main():
    N = int(input())
    balls = [tuple(map(int,input().split())) for _ in range(N)]
    d = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            d[tuple(map(sub, balls[i], balls[j]))] += 1
    try:
        mmax = max(d.values())
    except:
        print(100)
	mmax = int(N - mmax)
    try:
        print(mmax)
    except:
        print(100)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
from operator import sub

def main():
    N = int(input())
    balls = [tuple(map(int,input().split())) for _ in range(N)]
    d = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            d[tuple(map(sub, balls[i], balls[j]))] += 1
    try:
        mmax = N - max(d.values(), default=0)
        print(mmax)
    except ValueError:
        print(100)

if __name__ == '__main__':
    main()
n,m=map(int,input().split())
l=list(map(int,input().split())
s=sum(l)
if n<=s:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l)
if n<=s:
  print("Yes")
else:
  print("No")
def ss():
    N,Q = list(map(int,input().split()))
    s = input()
    lis=[0]*N
     
    count = 0
    for i in range(1,len(s)):
        if s[i-1] == 'A' and s[i] == 'C':
            count +=1
        lis[i]+=count
    for i in range(Q):
        l,r = list(map(int,input().split()))
        print(lis[r-1]-lis[l-1])

ss()


### FIXED CODE ###

import re
 
N,Q = list(map(int,input().split()))
s = input()
lis=[0]
 
count = 0
for i in range(1,len(s)):
    if s[i-1] == 'A' and s[i] == 'C':
        count +=1
    lis.append(count)
for i in range(Q):
    l,r = list(map(int,input().split()))
    print(lis[r-1]-lis[l-1])
N = int(input())
H =list(map(int, input().split()))
count = []
count_tmp = 0
if N == 0:
  print(0)
else:
	for i in range(N-1):
    	if H[i] >= H[i+1]:
        	count_tmp += 1
        	if i == N-2:
            	count.append(count_tmp)
    	else:
        	count.append(count_tmp)
        	count_tmp = 0
	print(max(count))

### FIXED CODE ###

N = int(input())
H =list(map(int, input().split()))
count = []
count_tmp = 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H[i] >= H[i+1]:
            count_tmp += 1
            if i == N-2:
                count.append(count_tmp)
        else:
            count.append(count_tmp)
            count_tmp = 0
    print(max(count))
# ABC109D - Make Them Even (WA)
def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(int, input().split())) for _ in range(H))
    ans = []
    # assume a single stroke
    for i in range(H):
        if i % 2 == 0:
            for j in range(W):
                if (i, j) == (H - 1, W - 1):
                    continue
                if A[i][j] % 2:
                    A[i][j] -= 1
                    if j + 1 != W:
                        A[i][j + 1] += 1
                        ans += [(i, j, i, j + 1)]
                    else:
                        A[i + 1][j] += 1
                        ans += [(i, j, i + 1, j)]
        else:
            for j in range(W, -1, -1):
                if (i, j) == (H - 1, W - 1):
                    continue
                if A[i][j] % 2:
                    A[i][j] -= 1
                    if j != 0:
                        A[i][j - 1] += 1
                        ans += [(i, j, i, j - 1)]
                    else:
                        A[i + 1][j] += 1
                        ans += [(i, j, i + 1, j)]
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC109D - Make Them Even
import sys
input = sys.stdin.readline


def main():
    H, W = tuple(map(int, input().rstrip().split()))
    A = list(
        list(map(lambda x: int(x) % 2, input().rstrip().split())) for _ in range(H)
    )
    ans = []
    # move left to right
    for i in range(H):
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += [(i + 1, j + 1, i + 1, j + 2)]
    # move up to down
    for i in range(H - 1):
        if A[i][W - 1]:
            A[i][W - 1] ^= 1
            A[i + 1][W - 1] ^= 1
            ans += [(i + 1, W, i + 2, W)]
    print(len(ans))
    for i in ans:
        print(*i)


if __name__ == "__main__":
    main()
n,l=map(int,input().split())
c=0
m=100000
for i in range(1,n+1):
  c+=l+i-1
  m=min(m,abs(l+i-1))
if l<0 and a-n<=0:
  print(c+d)
else:
  print(c-d)

### FIXED CODE ###

n,l=map(int,input().split())
c=0
m=100000
for i in range(1,n+1):
  c+=l+i-1
  m=min(m,abs(l+i-1))
if l<0 and l-n<=0:
  print(c+m)
else:
  print(c-m)
#!/usr/bin/env python3
import numpy as np

def main():
    N, K = map(int, input().split())
    A = np.array(input().split(),dtype=int)
    I = np.arange(N)# 電球番号を保持
    for i in range(K):
        B = np.zeros(N+1, int)
        # ユニバーサル関数(ufunc)を利用して一度に処理
        np.add.at(B, np.maximum(0,I-A),1)
        np.add.at(B, np.minimum(N,I+A+1),-1)
        A = B.cumsum()[:-1]
        if np.all(A == N):
            break
    print(*A)

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mina = min(A)
    for i in range(K):
        B = [0]*N
        for j in range(N):
            if j-A[j] >= 0:
                B[j-A[j]] += 1
            else:
                B[0] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
        A = list(accumulate(B[:]))
        mina = mina*2+1
        if mina >= N and A[0] == A[-1] == N:
            break
    print(*A)

if __name__ == "__main__":
    main()
X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            break
            if K%2 == i%2:
                print(List[i])
            else:
                print(List[i+1])
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D
        print(List[K-1])
                

### FIXED CODE ###

X,K,D = map(int,input().split())

t = abs(X) // D
s = abs(X) % D

if abs(X) > K*D:
    print(abs(X) - K*D)
elif t%2 == K%2:
    print(s)
else:
    print(D-s)