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: Wrong Answer

Solution code:
def main():

    m, n = tuple(map(int, input().split()))
    a = [[0 for j in range(n)] for i in range(m)]
    b = [0 for j in range(n)]
    c = [0 for i in range(m)]

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

    for j in range(n):
        b[j] = int(input())

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#データ入力
rowNum, columnNum = map(int, input().split())
inMat = [[0] * columnNum for i in range(columnNum)]
inColumnVec = [[0] for i in range(columnNum)]
for row in range(rowNum):
    inMat[row] = [int(i) for i in input().split()]
for column in range(columnNum):
    inColumnVec[column] = int(input())

timesAns = [[0] for i in range(rowNum)]

#行列計算
for row in range(rowNum):
    timesAns[row] = 0
    for column in range(rowNum):
        timesAns[row] = timesAns[row] + inMat[row][column] * inColumnVec[column]

for row in range(rowNum):
    print(timesAns[row])

Submission status: Wrong Answer

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

a = [0] * n
b = [0] * m

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

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
n_l = []
ans = [0, 0, 0]

for _ in range(n):
    l = list(map(int, input().split()))
    n_l.append(l)
for x in range(m):
    p = int(input())
    n_l[:0] *= p
for i in n_l:
    print(sum(i))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
n_l = []
ans = [0, 0, 0]

for _ in range(n):
    l = list(map(int, input().split()))
    n_l.append(l)
for x in range(m):
    p = int(input())
    n_l[:x] *= p
for i in n_l:
    print(sum(i))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
n_l = []
ans = [0, 0, 0]

for _ in range(n):
    l = list(map(int, input().split()))
    n_l.append(l)
for x in range(m):
    p = int(input())
    for o in range(n):
        n_l[o] *= p
for i in n_l:
    print(sum(i))

Submission status: Wrong Answer

Solution code:
#ITP1_6_D
n,m=map(int,input().split())
A=[[0 for j in range(m)]for i in range(n)]
B=[[0 for j in range(1)]for i in range(m)]
C=[[0 for j in range(1)]for i in range(n)]
for i in range(n):
  A1,A2,A3,A4=map(int,input().split())
  A[i][0]=A1
  A[i][1]=A2
  A[i][2]=A3
  A[i][3]=A4
for i in range(m):
  B[i][0]=int(input())
S=int(0)
for j in range(n):
  for i in range(m):
    S=S+(A[j][i]*B[i][0])
  C[j][0]=S
  S=0
for i in range(n):
  print(C[j][0])

Submission status: Wrong Answer

Solution code:
a = [[0]*4 for i in range(3)]
b = [0]*4

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

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

for i in c:
    print(i)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

n =  [[] for i in range(N)]

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

m = [ 0 for k in range(M)]

for k in range(M):
    m[k] = int(input())

for x in range(N):
    for y in range(M):
        a = n[x][y] * m[y]
    print(a)

Submission status: Wrong Answer

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

A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])
    
b = []
for mc in range(m):
    b.append(int(input()))
    
product = []
for nc in range(n):
    total = 0
    for mc in range(m):
        total += A[nc][mc] * b[mc]

    product.append(total)
    
[print(p) for p in product]

Submission status: Wrong Answer

Solution code:
(n,m) = [int(i) for i in 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()))

print(A)
print(b)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, raw_input().split());
i = 0
ar = [0] * n
vc = [0] * m
while i < n:
    ar[i] = map(int, raw_input().split());
    i += 1
i = 0
while i < m:
    vc[i] = input();
    i += 1
for el in ar:
    ans = 0
    for el2, el3 in zip(vc, el):
        ans += el2 * el3
    print

Submission status: Wrong Answer

Solution code:
n,m = map(int,raw_input().split())
a = []
b = []

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#a???A?????????,b???A??????
a,b=map(int,input().split())
A=[]
B=[]
for i in range(a):
	A.append([int(j) for j in input().split()])

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

print(A)
print(B)

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

Submission status: Wrong Answer

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

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

print(A)
print(B)

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

Submission status: Wrong Answer

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

ret = []
for i in range(n):
    ret.append(sum(A[i][j] * B[j] for j in range(m)))
print('\n'.join(map(str, ret)))

Submission status: Wrong Answer

Solution code:
n,m=map(int,raw_input().split())
a=[]
b=[]
c=0

for i in range(n):
	a.append(map(int,raw_input().split()))
		
for i in range(m):
	b.append(input())

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

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
A = [[0 for w in range(m)] for h in range(n)]
B = [0 for h in range(m)]
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: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
A = [[0 for w in range(m)] for h in range(n)]
B = [0 for h in range(m)]
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: Wrong Answer

Solution code:
A=map(int,raw_input().split(" "))
vec=A[0]
col=A[1]

def zero(n):
	zerolist=list()
	for i in range(n):
		zerolist+=[0]
	return(zerolist)
A=list()
for i in range(vec):
	A+=[zero(col)]

print A

for i in range(vec):
	k=map(int,raw_input().split(" "))
	for j in range(col):
		A[i][j]=k[j]

#ok

v=zero(col)

for i in range(col):
	v[i]=int(raw_input())

k=0
for i in range(vec):
	for j in range(col):
		k+=A[i][j]*v[j]
	print k
	k=0

Submission status: Wrong Answer

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)]
c = []

for i in range(n):
    bi = b[i]
    for y in A[i]:
        bi += y
    c.append(bi)

print(*[ci for ci in c], sep = "\n")

Submission status: Wrong Answer

Solution code:
x, y = [int(i) for i in input().split()]
date = [[int(i) for i in input().split()]for i in range(1,x+1)]
date2 =[int(input())for i in range(1,y+1)]
date3 =[]
for k in range(x):
    print(date[k])
print(date2)
for a in range(0,x):
    for b in range(0,y):
        date3 += [date2[b]*date[a][b]]
for h in range(0,len(date3)-1):
    print(date3[h])

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))


print(matrix)
print()
print(vector)

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
    
vector = []
for mi in range(m):
    vector.append(int(input()))
    
print(matrix)
print()
print(vector)

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a)for a in input().split()])

vector = []
for mi  in range(m):
    vector.append(int(input()))

for i in range(len(matrix)):

    sum = 0
    for j in range(len(matrix[i])):

        sum += matrix[i][j] * vector[j]

Submission status: Wrong Answer

Solution code:
a = []; b = []; c = []
n, m = map(int, input().split())

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

for j in range(m):
	col = int(input())
	b.append(col)

for k in range(n):
	temp = 0
	for l in range(m):
		temp += a[k][l] * b[l] 
	c.append(temp)

print(c)

Submission status: Wrong Answer

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

print(matrix)
print()
print(vector)

for ni in range(n):
    sum = 0
    for mi in range(n):
        sum += matrix[ni][mi]* vector[mi]
    print(sum)

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))

for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

print(matrix)
print()
print(vector)

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

print(matrix)
print()
print(vector)

Submission status: Wrong Answer

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))



for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]


print(sum)

Submission status: Wrong Answer

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

vector = []
for mi in range(m):
    vector.append(int(input()))


print(matrix)
print()
print(vector)

Submission status: Wrong Answer

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

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

for i in range(n):
 c = 0
 for s in range(m):
  c += M1[i][s] + M2[s]
 print(c)

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
sum_li = []
for i in range(nums[0]):
    line = list(map(int, input().split()))
    sum_li.append(sum(line))
for i in range(nums[0]):
    n = int(input())
    sum_li[i] += n
input()
for i in range(nums[0]): print(sum_li[i])

Submission status: Wrong Answer

Solution code:
[n, m] = [int(x) for x in raw_input().split()]
A = [[0] * m for x in range(n)]
B = [0] * m

counter = 0
while counter < n:
    A[counter] = [int(x) for x in raw_input().split()]
    counter += 1

counter = 0
while counter < n:
    B[counter] = int(raw_input())
    counter += 1

counter = 0
while counter < n:
    result = 0
    for j in range(m):
        result += A[counter][j] * B[j]
    print(result)
    counter += 1

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(col)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

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

Submission status: Wrong Answer

Solution code:
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(row)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

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

Submission status: Wrong Answer

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

Mat = []

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

print(Mat)
b = []

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

c = [0 for k in range(n)]

for l in range(n):
	for l2 in range(m):
		c[l] += (Mat[l][l2] * b[l2])
	print(c[l])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = [[0 for i in range(m)] for j in range(n)]

Submission status: Wrong Answer

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):
    a_tmp = list(map(int,input().split()))

Submission status: Wrong Answer

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(n):
    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[c]))

c_list = list(map(sum,c_list))

for c in c_list:
    print(c)

Submission status: Wrong Answer

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( [i*j for i in matrix[k] for j in vector] ) for k in range(n) ]  #matrix??¨vector?????????
    
    for num in result:
        print(num)
    
def inputError():
    print("input error")
    return -1

func()

Submission status: Wrong Answer

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: Wrong Answer

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)]
for i in range(m):
    print(x)

Submission status: Wrong Answer

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
print(a2)
print(a3)
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: Wrong Answer

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

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


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

print(B)

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

Submission status: Wrong Answer

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

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


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

print(B)

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [[int(n) for n in input().split()] for i in range(n)]
print(a)
b = []
for i in range(m):
    b.append(int(input()))
print(b)
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: Wrong Answer

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

Submission status: Wrong Answer

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)]
print(sum([a[i][j] * b[j] for j in range(m)]) for i in range(n))

Submission status: Wrong Answer

Solution code:
data = list(map(int, list(input().split())))
row = data[0]
column = data[1]
matrix = [[0 for i in range(column)] for j in range(row)]
vector = [[0] for k in range(column)]
vector_multi = [[0] for l in range(row)]

for i in range(row):
    data_row = list(map(int, list(input().split())))
    print(data_row)
    for j in range(column):
        matrix[i][j] = data_row[j]

for i in range(column):
    vector[i] = int(input())

for i in range(row): 
    element = 0
    for j in range(column):
        element += matrix[i][j] * vector[j]
    vector_multi[i][0] = element

for i in vector_multi:
    print(i[0])

Submission status: Wrong Answer

Solution code:
n,m = map(int,raw_input().split())
for i in range(0,n):
    if i == 0:
        matrix = [map(int,raw_input().split())]
    else:
        matrix.append(map(int,raw_input().split()))
for j in range(0,m):
    if j == 0:
        vec = map(int,raw_input())
    else:
        vec.extend(map(int,raw_input()))
mul = []
for k in range(0,n):
    num_sum=0
    for l in range(0,m):
        num_sum += matrix[k][l] * vec[l]
    print num_sum

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
print(n,m)
A = [[0 for i in range(m)] for j in range(n)]
#B = [[0 for i in range(1)] for j in range(m)]
B = [0 for i in range(m)]
C = [[0 for i in range(1)] for j in range(n)]
print(A)
print(B)
print(C)
A = [[i for i in input().split()] for j in range(n)]
B = [input() for i in range(m)]
print(A)
print(B)

Submission status: Wrong Answer

Solution code:
vec1 = []
vec2 = []

n, m = map(int, input().split())
for x in range(1, n+1):
    vec1.append(list(map(int, input().split())))

for y in range(m):
    vec2.append(int(input()))

for j, z in zip(vec1, vec2):
    print(sum(j)+z)

Submission status: Wrong Answer

Solution code:
from itertools import zip_longest

vec1 = []
vec2 = []

n, m = map(int, input().split())
for x in range(1, n+1):
    vec1.append(list(map(int, input().split())))

for y in range(m):
    vec2.append(int(input()))

for j, z in zip_longest(vec1, vec2):
    if j is None:
        print(z)
    elif z is None:
        print(sum(j))
    else:
        print(sum(j)+z)

Submission status: Wrong Answer

Solution code:
n,m= map(int,input().split())
A_line =[]
row=[]

for i in range(n):
    line = [int(i) for i in input().split()]
    A_line.append(line)
for i in range(m):
    row += [int(i) for i in input()]
for i in range(n):
    c=0
    for j in range(m):
        c += A_line[i][j]*row[j]
    print(c)

Submission status: Wrong Answer

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

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

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

for i in range(n[0]):
    for j in range(n[1]):
        ab_sum += a[i][j] * b[j]
    print(ab_sum)

Submission status: Wrong Answer

Solution code:
n,m = tuple(int(i) for i in input().split())
A = [[int(j) for j in input().split()] for k in range(n)]
b = [int(l) for p in range(m) for l in input()]
R = [sum([A[p][q] * b[q] for q in range(m)]) for p in range(n)]
for r in R:
    print(str(r))

Submission status: Wrong Answer

Solution code:
n,m = tuple(int(i) for i in input().split())
A = [[int(j) for j in input().split()] for k in range(n)]
b = [int(input()) for p in range(m)]
print(b)
R = [sum([A[p][q] * b[q] for q in range(m)]) for p in range(n)]

for r in R:
    print(str(r))

Submission status: Wrong Answer

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

#receive vecter a(n*m)
i=0
A=[]
while i<n:
    a=input().split()
    for p in a:
        A.append(int(p))
    i+=1

#receive vecter b(m*1)
I=0
B=[]
while I<m:
    b=int(input())
    B.append(b)
    I+=1

#Ci=ai1b1+ai2b2+...+aimbm
#C[i]=a[m*(i)+1]*b[1]+a[m*(i)+2]*b[2]+...a[m*(i)+m]*b[m]
q=0
C=[]
while q<n:
    Q=0
    cq=0
    while Q<m:
        cq+=A[m*q+Q]*B[Q]
        Q+=1
    C.append(cq)
    q+=1

print(C)

Submission status: Wrong Answer

Solution code:
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 i in range(n):
    c = sum(a[i]) + b[i]
    print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import sys

n, m = input().strip().split(" ")
n = int(n) ;m = int(m)

c = n

a = []
for line in sys.stdin :
    a.append(line)
    c -= 1
    if c == 0 :
        break

c = m

b = []
for line in sys.stdin :
    b.append(line)
    c -= 1
    if c == 0 :
        break

for i in range(0, len(a)) :
    a[i] = a[i].strip().split(" ")
    for j in range(0, len(a[i])) :
        a[i][j] = int(a[i][j])

for i in range(0, len(b)) :
    b[i] = int(b[i].strip())

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

Submission status: Accepted

Solution code:
def read_a(n, m):
    A = []
    for _ in range(0, n):
        A.append([int(x) for x in input().split()])

    return A

def read_b(m):
    B = []
    for _ in range(0, m):
        B.append(int(input()))

    return B

def multiply(A, B):
    C = []
    for a in A:
        C.append(sum(map(lambda x, y:x*y, a, B)))

    return C

def main():
    n, m = [int(x) for x in input().split()]

    A = read_a(n, m)
    B = read_b(m)
    C = multiply(A, B)

    print("\n".join([str(x) for x in C]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():

    m, n = tuple(map(int, input().split()))
    a = [[0 for j in range(n)] for i in range(m)]
    b = [0 for j in range(n)]
    c = [0 for i in range(m)]

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

    for j in range(n):
        b[j] = int(input())

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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys


def main():
    n, m = map(int, sys.stdin.readline().split())
    matrix = []
    for i in range(n):
        matrix.append(list(map(int, sys.stdin.readline().split())))
    vector = []
    for i in range(m):
        vector.append(int(sys.stdin.readline()))
    product = [0] * n
    for i in range(n):
        for j in range(m):
            product[i] += matrix[i][j] * vector[j]
    for i in product:
        print(i)
    return


if __name__ == '__main__':
    main()

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 j in range(m)]
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:
A_element = []
B_element = []
C_element = []
ele_num = [int(x) for x in input().split()]
for i in range(ele_num[0]):
    C_element.append(0)
for i in range(ele_num[0]):
    element = [int(x) for x in input().split()]
    A_element.append(element)

for i in range(ele_num[1]):
    element = int(input())
    B_element.append(element)

for i in range(ele_num[0]):
    for j in range(ele_num[1]):
        C_element[i] =C_element[i] + (A_element[i][j] * B_element[j])

for out in C_element:
    print(out)

Submission status: Accepted

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

ans = [sum([a[j][i] * b[i] for i in range(m)]) for j in range(n)]
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import sys

# 標準入力からデータを読み込む
def read_data():
    n, m = [int(i) for i in sys.stdin.readline().strip().split(' ')]
    matrix = []
    for _ in range(n):
        matrix.append([int(num) for num in sys.stdin.readline().strip().split(' ')])

    vector = []
    for _ in range(m):
        vector.append(int(sys.stdin.readline().strip()))

    return matrix, vector

# 行列xベクトルの計算
def multiple(matrix, vector):
    n = len(matrix)
    m = len(vector)
    ans = []

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

        ans.append(sum)

    return ans

# メイン関数
def main():
    matrix, vector = read_data()
    ans = multiple(matrix, vector)
    for i in ans:
        print(i)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
x = []
y = []
z = []

for i in range(a[0]):
    b = input().split()
    for j in range(a[1]):
        b[j] = int(b[j])
    x.append(b)
    z.append(0)
for i in range(a[1]):
    c = int(input())
    y.append(c)  
for i in range(a[0]):
    for j in range(a[1]):
        z[i] += x[i][j]*y[j]
for i in z:
    print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
n, m = map(int, input().split())
matrixA = []
vectorB = []

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

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


for i in range(n):
    num = 0
    for j in range(m):
        num += matrixA[i][j] * vectorB[j]
    print(num)

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):
    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 = []
for _ in range(n):
    a.append(list(map(int, input().split())))
b = []
for _ in range(m):
    b.append(int(input()))
c = []
for i in range(n):
    c.append(sum([a[i][j] * b[j] for j in range(m)]))
for i in c:
    print(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 i in range(m):
    b.append(int(input()))

for i, ai in enumerate(a):
    cnt = 0
    for j, bj in enumerate(b):
       cnt += ai[j] * bj
    print(cnt)

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)]

for i, ai in enumerate(a):
    cnt = 0
    for j, bj in enumerate(b):
       cnt += ai[j] * bj
    print(cnt)

Submission status: Accepted

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

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

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

for ai in a:
    cnt = 0
    for j, bj in enumerate(b):
        cnt += ai[j] * bj
    print(cnt)