Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Matrix Vector Multiplication

Write a program which reads a $ n \times m$ matrix $A$  and a $m \times 1$ vector $b$, and prints their product $Ab$.

  A column vector with m elements is represented by the following equation.

\[
  b = \left(
    \begin{array}{c}
      b_1  \\
      b_2  \\
      : \\ 
      b_m \\ 
    \end{array}
  \right)
\]

  A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.

\[
  A = \left(
    \begin{array}{cccc}
      a_{11} & a_{12} & ... & a_{1m} \\
      a_{21} & a_{22} & ... & a_{2m} \\
       :    &   :   &  :  &  : \\
      a_{n1} & a_{n2} & ... & a_{nm} \\
    \end{array}
  \right)
\]

  $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$  $j = 1, 2, ..., m$).

The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula:

\[
c_i = \sum_{j=1}^m a_{ij}b_j  = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m
\]

Input

  In the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.

Output

  The output consists of $n$ lines. Print $c_i$ in a line.

Constraints

$1 \leq n, m \leq 100$

$0 \leq b_i, a_{ij} \leq 1000$

Sample Input

3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

Sample Output

5
6
9



Sample input:
3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0


Sample output:
5
6
9

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
matrix = []
for num in range(n):
    matrix.append([int(y) for y in input().split()])
colum = []
for num in range(m):
    colum.append(int(input()))
for i in range(n):
    a = 0
    for j in range(m):
        product = matrix[i][j] * colum[j]
        a += product
    print(a)

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())
array = [[int(i) for i in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]
for i in range(n):
    ans = 0
    for i2 in range(m):
        ans += array[i][i2]*b[i2]
    print(ans)

Submission status: Accepted

Solution code:
m,n = map(int,input().split())
matrix_1 = []
matrix_2 = []
matrix_new = []

for i in range(m):
    x = list(map(int,input().split()))
    matrix_1.append(x)

for j in range(n):
    y = int(input())
    matrix_2.append(y)

c=0
while c<m:
    element = 0
    for j in range(n):
        element += matrix_1[c][j]*matrix_2[j]
    matrix_new.append(element)
    c+=1

for p in range(len(matrix_new)):
    print(matrix_new[p])

Submission status: Accepted

Solution code:
[n, m] = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]

d = [sum([a[i][j]*b[j] for j in range(m)]) for i in range(n)]
for i in range(n):
    print(d[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os


def input_to_list():
    return list(map(int, input().split()))

H, W = input_to_list()
M = []
for i in range(H):
    M.append(input_to_list())

v = []
for i in range(W):
    v.append(int(input()))

# M x v
for i in range(H):
    all = 0
    for j in range(W):
        all += M[i][j] * v[j]
    print(all)

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split()))
a = []
b = []
result = []
row_sum = 0

for i in range(n):
    l = list(map(int, input().split()))
    a.append(l)

for i in range(m):
    b.append(int(input()))

for row in a:
    for i,num in enumerate(row):
        row_sum += num * b[i]
    print(row_sum)
    row_sum = 0

Submission status: Accepted

Solution code:
n,m = [int(i) for i in input().split()]
a = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	a[i] = [int(j) for j in input().split()]
b = [0 for i in range(m)]
for i in range(m):
	b[i] = int(input())
for i in range(n):
	sum = 0
	for j in range(m):
		sum += a[i][j] * b[j]
	print(sum)

Submission status: Accepted

Solution code:
# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

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

A = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))

b = [[0] for i in range(m)]
for i in range(m):
    b[i][0] = int(input())

c = [[0] for i in range(n)]            #A??b
for i in range(n):
    for j in range(m):
        c[i][0] += A[i][j] * b[j][0]

for i in range(n):
    print(c[i][0])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())

a_list = []
b_list = []
c_list = []

for a in range(n):
    a_list.append(list(map(int,input().split())))

for b in range(m):
    b_list.append(int(input()))

for c in range(n):
    c_list.append([])
    for d in range(m):
        c_list[c].append((a_list[c][d] * b_list[d]))

c_list = list(map(sum,c_list))

for c in c_list:
    print(c)

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

def func():
    try:
        (n,m) = tuple( [ int(num) for num in input().rstrip().split(" ") ] )
        matrix = [ [int(num) for num in input().rstrip().split(" ")] for i in range(n) ]
        vector = [ int( input().rstrip() ) for i in range(m) ]
    except:
        return inputError()

    result = [ sum( [ matrix[j][i]*vector[i] for i in range(m) ] ) for j in range(n)  ] #????????¨??????????????????

    for num in result:
        print(num)
    
def inputError():
    print("input error")
    return -1

func()

Submission status: Accepted

Solution code:
#!/usr/bin/env python

#get dimensions
n, m = input().split()
n = int(n)
m = int(m)

nmmatrix = []
mvector = []
result = []

#make matrix
for x in range(n):
    row = input()
    rowSplit = row.split()
    for y in range(len(rowSplit)):
        rowSplit[y] = int(rowSplit[y])
    nmmatrix.append(rowSplit)

#makevector
for x in range(m):
    mvector.append(int(input()))

#multiplication
for x in range(n):
    value = 0
    for y in range(m):
        value += nmmatrix[x][y]*mvector[y]
    result.append(value)
    
#print result
for x in result:
    print(x)

Submission status: Accepted

Solution code:
def func(amat, bmat, nm):
    for i in range(nm[0]):
        ans = 0
        for j in range(nm[1]):
            ans += amat[i][j] * bmat[j][0]
        print(ans)


if __name__ == '__main__':
    nm = input().split(' ')
    nm = [int(i) for i in nm]
    amat = [[0 for i in range(nm[1])] for j in range(nm[0])]
    bmat = [[0] for i in range(nm[1])]

    for i in range(nm[0]):
        a = input().split(' ')
        for j in range(nm[1]):
            amat[i][j] = int(a[j])

    for i in range(nm[1]):
        b = int(input())
        bmat[i][0] = b

    func(amat, bmat, nm)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split(" ")]

a =[ [int(i) for i in input().split(" ")] for _ in range(n) ]
b =[]
for i in range(m):
    b.append( int(input()) )


for x in range(n):
    result = 0
    for y in range(m):
        result += a[x][y] * b[y]
    print(result)

Submission status: Accepted

Solution code:
r, c = map(int, input().split())
a, b, ans = [], [], []
for i in range(r):
    a.append([int(x) for x in input().split()])
for i in range(c):
    b.append(int(input()))
for i in range(r):
    tmp = 0
    for j in range(c):
        tmp += a[i][j] * b[j]
    ans.append(tmp)
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
N ,M= input().split()
a=[]
N=int(N)
M=int(M)
for i in range(N):
    a.append(list(map(int,input().split())))
b=[int(input()) for i in range(M)]
x=[0 for i in range(N)]
for i in range(N):
    for j in range(M):
        x[i]+=a[i][j]*b[j]
print("\n".join(map(str,x)))

Submission status: Accepted

Solution code:
from operator import mul

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

A = []
B = []

for i in range(n):
    A.append(list(map(int, input().split(' '))))

for j in range(m):
    B.append(int(input()))

for a in A:
    print(sum(map(mul, a, B)))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
AL = []
for i in range(n):
 ALI = list(map(int, input().split()))
 AL.append(ALI)

BL = []
for i in range(m):
 BL.append(int(input()))

for i  in AL:
 Ci = 0
 for (j, ai) in enumerate(i):
  Ci += ai * BL[j]
 print(Ci)

Submission status: Accepted

Solution code:
a = [[0 for i in range(100)] for j in range(100)]
b = [0 for i in range(100)]
n, m = map(int, input().split())
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
    d = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = d[j]

b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j] * b[j]
    print(c)

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())

a = []
for i in range(n):
    a.append(map(int, raw_input().split()))
b = []
for j in range(m):
    b.append(int(raw_input()))

ans = []
for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += a[i][j] * b[j]
    ans.append(tmp)

print "\n".join(map(str, ans))

Submission status: Accepted

Solution code:
#coding:utf-8

n, m =[int(i) for i in input().rstrip().split(" ")]

a =[]
b =[]
#a
for i in range(n):
    d = [int(j) for j in input().rstrip().split(" ")]
    a.append(d)
#b
for i in range(m):
    b.append(int(input().rstrip()))

for i in range(n):
    ai = list(a[i])
    c = [j*k for j,k in zip(ai,b)]
    print(sum(c))

Submission status: Accepted

Solution code:
s = input().split(" ")
n = int(s[0])
m = int(s[1])
a = [["" for i in range(m)]for j in range(n)]
b = []
c = []
for i in range(n):
    s = input().split(" ")
    for j in range(m):
        a[i][j] = int(s[j])
for i in range(m):
    b.append(int(input()))
for i in range(n):
    seki = 0
    for j in range(m):
        seki += a[i][j] * b[j]
    c.append(seki)
for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    a.append([int(j) for j in input().split()])
for i in range(m):
    b.append(int(input()))
for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    print(s)

Submission status: Accepted

Solution code:
A = []
B = []
n, m = [int(i) for i in input().split(' ')]

for i in range(n):
	A.append([int(j) for j in input().split(' ')])
for j in range(m):
	B.append(int(input()))

c = 0
for i in range(n):
	for j in range(m):
		c += A[i][j] * B[j]
	print(c)
	c = 0

Submission status: Accepted

Solution code:
H, W= map(int, input().split())
A=[]
b=[]
ans=[0 for i in range(H)]
for i in range(H):
    A.append(list(map(int, input().split())))
for j in range(W):
    b.append(int(input()))
for i in range(H):
    for j in range(W):
        ans[i]+=A[i][j]*b[j]
    print(ans[i])

Submission status: Accepted

Solution code:
rows, cols = [int(x) for x in input().split()]
matrix = []
vector = []
for i in range(rows):
    matrix.append([int(x) for x in input().split()])
for i in range(cols):
    vector.append(int(input()))

for row in matrix:
    result = 0
    for x, y in zip(row, vector):
        result += x*y
    print(result)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [int(input()) for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
def vp(va, vb, i, m):
    return sum([
        va[i][j] * vb[j]
        for j in range(m)
    ])


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

A = []
b = []

for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    b.append(int(input()))

for i in range(n):
    print(vp(A, b, i, m))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

# ?????°??¨?????°???????????????
inp = input().split(" ")
n = int(inp[0])
m = int(inp[1])

# n*m ??????????????????
ArrA = []
for i in range(n):
    l = list(map(int,input().split(" ")))
    ArrA.append(l)

# m*1 ??????????????????
ArrB = []
for i in range(m):
    ArrB.append(int(input()))

# ArrA * ArrB
for i in range(n):
    x = 0
    for j in range(m):
        x += ArrA[i][j] * ArrB[j]
    print(str(x))

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
vec = []
for i in range(n):
    vec.append([int(j) for j in input().split()])
c = []
for i in range(m):
    c.append(int(input()))
for i in range(n):
    sum = 0
    for j in range(m):
        sum += vec[i][j]*c[j]
    print(sum)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
A = []
V = []
B = []
for i in range(n):
    A.append(list(map(int, input().split())))
for j in range(m):
    V.append([int(input())])
for i in range(n):
    B.append([0])
    for j in range(m):
            B[i][0] += A[i][j] * V[j][0]
for i in range(n):
    print(B[i][0])

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split(" ")))
A = [[0 for _ in range(m)] for _ in range(n)]
b = [0 for _ in range(m)]

for i in range(n):
    A_line = list(map(int, input().split(" ")))
    for j, a in enumerate(A_line):
        A[i][j] += a
        
for j in range(m):
    b[j] = int(input())
    
for i in range(n):
    ans = 0
    for j in range(m):
        ans += A[i][j] * b[j]
    print (ans)

Submission status: Accepted

Solution code:
h,w= [int(i) for i in input().split()]
x=[[int(0)for i in range(w)]for j in range(h)]
z=[int(0 ) for i in range(w)]
for i in range(h):
    y=[int(k) for k in input().split()]
    for s in range(w):
        x[i][s]=y[s]
for s in range(w):
    z[s]=int(input())
for i in range(h):
    count=0
    for s in range(w):
        count=count+x[i][s]*z[s]
    print(count)

Submission status: Accepted

Solution code:
n,m = [int(s) for s in input().split(' ')]
A,b,c = [],[],[]
[A.append([int(s) for s in input().split(' ')]) for i in range(n)]
[b.append(int(input())) for i in range(m)]

for Ai in A:
	ci = []
	for aij,bj in zip(Ai,b):
		ci.append(aij * bj)
	c.append(sum(ci))

[print(ci) for ci in c]

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))

A = [list(map(int, input().split())) for i in range(n)]
bt = [int(input()) for i in range(m)]

for i in range(n):
    print(sum([x * y for (x, y) in zip(A[i], bt)]))

Submission status: Accepted

Solution code:
n,m = map(int,(input().split()))
a = []
b=[]
c=[]
for i in range(n):
    k = [int(i) for i in input().split()]
    a.append(k)
for i in range(m):
    x = int(input())
    b.append(x)


for j in range(len(a)):
    c.append(0)
    for k in range(len(a[j])):
        c[j] += a[j][k]*b[k]


for j in c:
    print (j)

Submission status: Accepted

Solution code:
n,m=list(map(int,input().split()))
mA=[list(map(int,input().split())) for i in range(n)]
mB=[int(input())  for j in range(m)]

for ma in mA:
    print(sum([a*b for a, b in zip(ma,mB)]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[] for _ in range(n)]

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

b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())

for i in range(n):
  c = 0

  for j in range(m):
    c += a[i][j]*b[j]

  print(c)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
b=[list(map(int,input().split())) for i in range(n)]
c =[int(input()) for j in range(m)]
[print(sum([d*e for d,e in zip(b[i],c)])) for i in range(n)]

Submission status: Accepted

Solution code:
A,B = list(map(int, input().split()))

list_A = []
list_B = []

for i in range(A):
    a = list(map(int, input().split()))
    list_A.append(a)

for i in range(B):
    b = int(input())
    list_B.append(b)

for i in list_A:
    output = []
    for (y,z) in zip(i,list_B):
        op = y*z
        output.append(op)
    sum_op = sum(output)
    print(sum_op)

Submission status: Accepted

Solution code:
A = []
b = []

row, col = (int(x) for x in input().split())

for i in range(row):
    A.append([int(x) for x in input().split()])

for i in range(col):
    b.append(int(input()))

for i in range(row):
    print(sum(A[i][j]*b[j] for j in range(col)))

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
a, b, result = list(), list(), list()
for _ in range(n):
    a.append(map(int, raw_input().split()))
for _ in range(m):
    b.append(int(raw_input()))
for i in range(n):
    temp = 0
    for j in range(m):
        temp += a[i][j] * b[j]
    result.append(temp)
for i in result:
    print(i)

Submission status: Accepted

Solution code:
i,j=map(int,input().split())
matrix=[list(map(int,input().split())) for _ in range(i)]
vector=[int(input()) for _ in range(j)]
for x in range(i):
    print(sum([v * m for v,m in zip(vector,matrix[x])]))

Submission status: Accepted

Solution code:
A = []
b = []
n, m = map(int,input().split())
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for s in range(m):
        c += A[i][s] * b[s]
    print(c)

Submission status: Accepted

Solution code:
x=[]
z=[]
A,b=map(int,input().split())
for i in range(0,A):
 a=list(map(int,input().split()))
 x.append(a)
for s in range(0,b):
    q=int(input())
    z.append(q)
    
for i in range(A):
  l=0
  for s in range(b):
    l += x[i][s]*z[s]
  print(l)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [[int(e) for e in input().split()] for i in range(n)]
b = []
for i in range(m):
    e = int(input())
    b.append(e)
for i in range(n):
    p = 0
    for j in range(m):
        p += A[i][j] * b[j]
    print(p)

Submission status: Accepted

Solution code:
A = []
b = []
row = 0
col = 0
row, col = map(int, raw_input().split())
A = [[0 for i in range(col)] for j in range(row)]

for i in range(row):
    r = map(int, raw_input().split())
    for index, j in enumerate(r):
        A[i][index] = j

for i in range(col):
    b.append(int(raw_input()))

for i in A: 
    ret = 0 
    for j,k in zip(i,b):
        ret += j*k
    print ret

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
z=[]
x=[]
for i in range(n):
    a+=[[int(i) for i in input().split()]]
for i in range(m):
    b+=[[int(i) for i in input().split()]]
for i in range(n):
    for j in range(m):
        z+=[a[i][j]*b[j][0]]
    x+=[sum(z)]
    z=[]
for i in range(n):
    print(x[i])

Submission status: Accepted

Solution code:
# Aizu Problem ITP_1_6_D: Matrix Vector Multiplication
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


n, m = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for __ in range(n)]
V = [int(input()) for _ in range(m)]

for row in range(n):
    print(sum([A[row][k] * V[k] for k in range(m)]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
kakeru = [list(map(int,input().split())) for _ in range(n)]
kakerareru = [int(input()) for _ in range(m)]
for a in range(n):
    kotae = 0
    for b in range(m):
        kotae += kakeru[a][b]*kakerareru[b]
    print(kotae)

Submission status: Accepted

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

matrix = []

for i in range(n):
    row = []
    A = input().split()
    for a in A:
        row.append(int(a))

    matrix.append(row)

column = []
for i in range(m):
    column.append(int(input()))

for i in range(n):
    sum_list = []
    for j in range(m):
        sum_list.append(column[j]*matrix[i][j])
    print(sum(sum_list))

Submission status: Accepted

Solution code:
box_a = []
box_b = []
tate, yoko = map(int, input().split())
[box_a.append( list(map(int, input().split())) ) for i in range(tate)]
[box_b.append( int(input()) ) for i in range(yoko)]

for i in range(tate):
    stuck = []
    [stuck.append(box_a[i][j]*box_b[j]) for j in range(yoko)]
    #print("DBG:: i={0} box_a={1} - box_b={2}".format(i, box_a, box_b))
    print(sum(stuck))

Submission status: Accepted

Solution code:
n,m = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(m):
    b[i] = int(input())
for i in range(n):
        for j in range(m):
            c[i] += a[i][j] * b[j]
print('\n'.join(map(str,c)))

Submission status: Accepted

Solution code:
a1 = [input().split()]
m = int(a1[0][0])
n = int(a1[0][1])
a2 = [input().split() for i in range(m)]
a3 = [input().split() for i in range(n)]
i = 0
while i < m:
    sum = 0
    j = 0
    while j < n:
        s = int(a2[i][j]) * int(a3[j][0])
        sum += s
        j += 1
    print(sum)
    i += 1

Submission status: Accepted

Solution code:
i, j = map(int, input().split())
a = []
b = []
result = []
for _ in range(i):
	a.append(list(map(int, input().split())))
for _ in range(j):
	b.append(int(input()))
for x in range(i):
	sum = 0
	for y in range(j):
		sum += a[x][y]*b[y]
	result.append(sum)
print (*result, sep="\n")

Submission status: Accepted

Solution code:
Ia = input().split()
n = int(Ia[0])
m = int(Ia[1])

a = [[0 for midx in range(m)] for nidx in range(n)]
for nidx in range(n):
    A = input().split()
    for midx in range(m):
        a[nidx][midx] = int(A[midx])

b = m * [0]
for bidx in range(m):
    b[bidx] = int(input())

c = n * [0]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

B = []
for j in range(m):
    B.append(int(input()))

for k in range(n):
    x = 0
    for l in range(m):
        x += A[k][l] * B[l]
    print(x)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
A_Matrix = []
B_Matrix = []
output_list = []
tmp = 0
for i in range(n):
        A_Matrix.append([int(j) for j in input().split()])
for i in range(m):
    B_Matrix.append(int(input()))

for i in range(n):
    for j in range(m):
        tmp += A_Matrix[i][j] * B_Matrix[j]
    output_list.append(tmp)
    tmp = 0
for i in range(n):
    print(output_list[i])

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))

mat = [list(map(int, input().split())) for _ in range(n)]
vec = [int(input()) for _ in range(m)]

for v in mat:
    print(sum(a * b for a, b in zip(v, vec)))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())

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

matrix_b = [int(input()) for i in range(m)]

for i in range(n):
    answer = sum([matrix_a[i][j] * matrix_b[j] for j in range(m)])
    print(answer)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a,b=[],[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    x=0
    for j in range(m):
        x+=a[i][j]*b[j]
    print(x)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[int(input()) for _ in range(m)]
for _ in range(n):
    print(sum(a[_][i]*b[i] for i in range(m)))

Submission status: Accepted

Solution code:
N, M=map(int, input().split())
mat = [[0 for m in range(M)]for n in range(N)]
vec = [0 for m in range(M)]

for n in range(N):
  mat[n] = list(map(int , input().split()))
for m in range(M):
  vec[m] = int(input())

c = 0
for n in range(N):
 for m in range(M):
  c += mat[n][m] * vec[m]
 print(c)
 c = 0

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[int(n) for n in input().split()] for i in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])

Submission status: Accepted

Solution code:
# (c) midandfeed
n, m = [int(x) for x in input().split()]
a = []
b = []
for _ in range(n):
	z = [int(x) for x in input().split()]
	a.append(z)
	
for _ in range(m):
	b.append(int(input()))
	
for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j]*b[j]
	print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A, B = [list(map(int, input().split())) for r in range(n)], [list(map(int, input().split())) for r in range(m)]
for i in range(n):
    Ci = 0
    for j in range(m):
        Ci += A[i][j] * B[j][0]
    print(Ci)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[v for v in list(map(int, input().split()))] for i in range(n)]
b = [int(input()) for i in range(m)]
c = [sum([a[i][j] * b[j] for j in range(m)]) for i in range(n)]
print('\n'.join(map(str, c)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[v for v in list(map(int, input().split()))] for i in range(n)]
b = [int(input()) for j in range(m)]
for i in range(n):
    print(sum([a[i][j] * b[j] for j in range(m)]))

Submission status: Accepted

Solution code:
n, m = map(int,raw_input().split())
matrix = []
for i in range(n):
    matrix.append(map(int,raw_input().split()))
 
vector = []
for i in range(m):
    vector.append(int(raw_input()))
 
for row in range(n):
    sum = 0
    for col in range(m):
        sum += vector[col] * matrix[row][col]
    print sum

Submission status: Accepted

Solution code:
m1 = []
m2 = []
n, m = [int(s) for s in input().split()]
for i in range(n):
    m1.append([int(s) for s in input().split()])

for i in range(m):
    m2.append(int(input()))

for ma in m1:
    print(sum(map(lambda m, n: m * n, ma, m2)))

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    
    A = []
    for _ in range(n):
        A.append(list(map(int, input().split())))

    b = []
    for _ in range(m):
        b.append(int(input()))

    for x in range(n):
        ans = 0
        for y in range(m):
            hoge = A[x][y] * b[y]
            ans += hoge
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
array_data = map(int, raw_input().split())
n = array_data[0]
m = array_data[1]

A = []
for i in range(n):
	partial_A = map(int, raw_input().split())
	A.append(partial_A)

b = []
for i in range(m):
	partial_b = int(raw_input())
	b.append(partial_b)

ans = []
for i in range(n):
	partial_ans = 0
	for j in range(m):
		partial_ans += A[i][j] * b[j]
	ans.append(partial_ans)

for i in range(len(ans)):
	print ans[i]

Submission status: Accepted

Solution code:
def main():

    n, m = map(int, (input().split()))
    a = [list(map(int, list(input().split()))) for item in range(n)]
    b = [int(input()) for item in range(m)]

    c = [sum(a_im * b_m for (a_im, b_m) in zip(a_i, b)) for a_i in a]
    for c_i in c:
        print(c_i)


main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

c = []

for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += A[i][j] * b[j]
    c.append(tmp)

for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = [0] * m
for i in range(m):
    b[i] = int(input())

c = [0] * n
for i in range(n):
    for j in range(m):
        c[i] += A[i][j] * b[j]
    print(c[i])

Submission status: Accepted

Solution code:
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = [0] * m
for i in range(m):
    b[i] = int(input())

from operator import mul
for i in range(n):
    print(sum(map(mul, A[i], b)))

Submission status: Accepted

Solution code:
import sys

def main():
    lines = sys.stdin.readlines()

    A = []
    B = []
    C = []
    n = 0
    m = 0
    for i, line in enumerate(lines):
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if i == 0:
            n = int(elems[0])
            m = int(elems[1])
        elif 0 < i and i < n + 1:
            A.append([int(e) for e in elems])
        elif n < i:
            B.append([int(elems[0])])
    c = []
    for i in range(0, n):
        num = 0
        for index, e in enumerate(A[i]):
            num += e * B[index][0]
        c.append(num)

    for i in range(0, n):
        print c[i]

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*-coding:utf-8

import fileinput
import math

def main():

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

    A = [[0 for i2 in range(n)] for i1 in range(m)]

    for i in range(m):
        tokens = list(map(int, input().split()))
        for j in range(n):
            A[i][j] = tokens[j]

    b = []
    for i in range(n):
        line = input()
        b.append(int(line))

    for i in range(m):
        sum = 0
        for j in range(n):
            sum += (A[i][j] * b[j])

        print(sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input().split()
n=int(s[0])
m=int(s[1])
a=[[0 for j in range(m)]for i in range(n)]
b=[0 for j in range(m)]
for i in range(n):
    t=input().split()
    for j in range(m):
        a[i][j]=int(t[j])
for j in range(m):
    b[j]=int(input())
c=[0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i]+=a[i][j]*b[j]
    print("{0}".format(c[i]))

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
A = [[0]*b for i in range(a)]
B = [0] * b

for i in range(a):
    A[i] = list(map(int,input().split()))

for i in range(b):
    B[i] = int(input())

for i in range(a):
    s=0
    for j in range(b):
        s+=A[i][j]*B[j]
    print(s)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    matrix = [
        list(map(int, input().split()))
        for _ in range(n)
    ]
    vector = [
        int(input())
        for _ in range(m)
    ]

    for v in matrix:
        res = sum(x * y for x, y in zip(v, vector))
        print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
A=[list(map(int, input().split())) for _ in range (n)]
b=[int(input()) for _ in range (m)]
for _ in range (n):
 print(sum(A[_][i] * b[i] for i in range(m)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

mat_A = []
vec_b = []

for j in range(n):
    mat_A.append(list(map(int, input().split())))
for i in range(m):
    vec_b.append(int(input()))

for j in range(n):
    tmp = 0
    for i in range(m):
        tmp += mat_A[j][i] * vec_b[i]
    print(tmp)