CodeEff/ECCO huggingface dataset:
# Original solution
n,m = list(map(int,input().split()))

A = [[0 for q in range(m)] for w in range(n)]
B = [0 for e in range(m)]

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

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

# Optimized solution
listA = []
listB = []
Answer = []
n, m = list(map(int, input().split()))
for i in range(n):
    listA.append(list(map(int, input().split())))
for j in range(m):
    listB.append(int(eval(input())))
for k in range(n):
    result = 0
    for l in range(m):
        result += listA[k][l]*listB[l]
    Answer.append(result)
for p in range(n):
    print((Answer[p]))
# Original solution
n,m = list(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(eval(input())))
for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j]*b[j]
    print(sum)

# Optimized solution
n,m=list(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(eval(input())))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)
# Original solution
n,m = list(map(int, input().split()))

# init
A = []
b = []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    b.append(int(eval(input())))


for row in range(n):
    p = 0
    for i, j in zip(A[row], b):
        p += i * j
    print(p)

# Optimized solution
n, m = list(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(eval(input())))

for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j] * b[j]
    print(sum)
# Original solution
n, m = list(map(int, input().split()))
a = [[int(i) for i in input().split()] for j in range(n)]
b = [int(eval(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]))
    

# Optimized solution
n, m = list(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(eval(input()))
    b.append(e)
for i in range(n):
    p = 0
    for j in range(m):
        p += A[i][j] * b[j]
    print(p)
# Original solution
def f():return list(map(int,input().split()))
n,m = f()
A = [f() for _ in [0]*n]
B = [eval(input()) for _ in [0]*m]
for i in range(n):
  print(sum([A[i][j]*B[j] for j in range(m)]))

# Optimized solution
def f():return list(map(int,input().split()))
n,m = f()
A = [f() for _ in [0]*n]
B = [int(input()) for _ in [0]*m]
for i in range(n):
  print(sum([A[i][j]*B[j] for j in range(m)]))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 20 20:19:33 2017

@author: syaga
"""

if __name__ == "__main__":
    n, q = list(map(int, input().split()))
    a = []
    for i in range(n):
        b = input().split()
        b[1] = int(b[1])
        a.append(b)
    ans = []
    time = 0
    flag = 0
    while True:
        if flag == 1:
            break
        for i in range(len(a)):
            if a[i] == []:
                continue
            if a[i][1] <= q:
                time += a[i][1]
                ans.append([a[i][0], time])
                a[i] = []
                if len(ans) == len(a):
                    flag = 1
                    break
            else:
                a[i][1] -= q
                time += q
    for i in ans:
        print((" ".join(map(str, i))))

# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 20 20:19:33 2017

@author: syaga
"""

if __name__ == "__main__":
    n, q = list(map(int, input().split()))
    a = []
    for i in range(n):
        b = input().split()
        b[1] = int(b[1])
        a.append(b)
    ans = []
    time = 0
    while len(a) != 0:
        x = a.pop(0)
        if x[1] <= q:
            time += x[1]
            ans.append([x[0], time])
        else:
            x[1] -= q
            time += q
            a.append(x)
    for i in ans:
        print((" ".join(map(str, i))))
# Original solution
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t,a=0,[]
while d:
 k,v=d.popleft()
 if v>q:v-=q;t+=q;d.append([k,v])
 else:t+=v;a+=[f'{k} {t}']
print(*a,sep='\n')


# Optimized solution
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t,a=0,[]
while d:
 k,v=d.popleft()
 if v>q:v-=q;t+=q;d.append([k,v])
 else:t+=v;a+=[f'{k} {t}']
print(('\n'.join(a)))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 14:42:43 2018

@author: maezawa
"""

def print_array(g):
    ans = str(g[0])
    if len(g) > 1:
        for i in range(1,len(g)):
            ans += ' '+str(g[i]) 
    print(ans)

name=[]
time=[]
current_time = 0

n, q = list(map(int, input().split()))
for i in range(n):
    s = input().split()
    name.append(s[0])
    time.append(int(s[1]))
# =============================================================================
# print(n,q)
# print(name)
# print(time)
# =============================================================================
finished = []
fin_time = []
i=0
remain = n
while True:
    if time[i] == 0:
        i = (i+1)%n
        continue
    if time[i] <= q:
        current_time += time[i]
        finished.append(name[i])
        fin_time.append(current_time)
        time[i] = 0
        remain -= 1
        if remain == 0:
            break
    else:
        time[i] -= q
        current_time += q
        i = (i+1)%n

for i in range(n):
    print(("{} {}".format(finished[i], fin_time[i])))
        
    


# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 14:42:43 2018

@author: maezawa
"""

def print_array(g):
    ans = str(g[0])
    if len(g) > 1:
        for i in range(1,len(g)):
            ans += ' '+str(g[i]) 
    print(ans)

name=[]
time=[]
current_time = 0

n, q = list(map(int, input().split()))
for i in range(n):
    s = input().split()
    name.append(s[0])
    time.append(int(s[1]))
# =============================================================================
# print(n,q)
# print(name)
# print(time)
# =============================================================================
finished = []
fin_time = []
i=0
remain = n
while True:
    if time[i] <= q:
        current_time += time.pop(i)
        finished.append(name.pop(i))
        fin_time.append(current_time)      
        remain -= 1
        if remain == 0:
            break
        i = i%remain
    else:
        time[i] -= q
        current_time += q
        i = (i+1)%remain

for i in range(n):
    print(("{} {}".format(finished[i], fin_time[i])))
# Original solution
from collections import deque
n, q = map(int, input().split())
f = lambda a, b: (a, int(b))
dq = deque(f(*input().split()) for _ in range(n))
cnt = 0
ans = []
while dq:
    s, t = dq.popleft()
    if t <= q:
        cnt += t
        ans.append(f"{s} {cnt}")
    else:
        cnt += q
        dq.append((s, t - q))
print(*ans, sep="\n")



# Optimized solution
import sys
from collections import deque
readline = sys.stdin.readline
n, q = map(int, input().split())
f = lambda a, b: (a, int(b))
dq = deque(f(*readline().split()) for _ in range(n))
cnt = 0
ans = []
while dq:
    s, t = dq.popleft()
    if t <= q:
        cnt += t
        ans.append(f"{s} {cnt}")
    else:
        cnt += q
        dq.append((s, t - q))
print(*ans, sep="\n")
# Original solution
n, q = [ int( val ) for val in input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
	ps[i], t[i] = input( ).split( " " )


output = []
qsum = 0
while t:
	psi = ps.pop( 0 )
	ti = int( t.pop( 0 ) )
	if ti <= q:
		qsum += ti	
		output.append( psi+" "+str( qsum ) )
	else:
		t.append( ti - q )
		ps.append( psi )
		qsum += q

print(( "\n".join( output ) ))

# Optimized solution
n, q = [ int( val ) for val in input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
    ps[i], t[i] = input( ).split( " " )
 
 
output = []
qsum = 0
while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        output.append( "".join( ( psi, " ", str( qsum ) ) ) )
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q
 
print(( "\n".join( output ) ))
# Original solution
from queue import Queue

n, q = [ int( val ) for val in input( ).split( " " ) ]
names = Queue( )
times = Queue( )
for i in range( n ):
	name, time = input( ).split( " " )
	names.put( name )
	times.put( int( time ) )
 
qsum = 0
output = []
while not times.empty( ):
	name = names.get( )
	time = times.get( )
	if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q

print(( "\n".join( output ) ))

# Optimized solution
from queue import Queue
 
n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = Queue( )
for i in range( n ):
    name, time = input( ).split( " " )
    processes.put( ( name, int( time ) ) )
  
qsum = 0
output = []
while not processes.empty( ):
    process = processes.get( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.put( ( process[0], process[1]- q ) )
        qsum += q
 
print(( "\n".join( output ) ))
# Original solution
from queue import Queue
 
n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = Queue( )
for i in range( n ):
    name, time = input( ).split( " " )
    processes.put( ( name, int( time ) ) )
  
qsum = 0
output = []
while not processes.empty( ):
    process = processes.get( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.put( ( process[0], process[1]- q ) )
        qsum += q
 
print(( "\n".join( output ) ))

# Optimized solution
from collections import deque

n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = deque( )
for i in range( n ):
    name, time = input( ).split( " " )
    processes.append( ( name, int( time ) ) )
  
qsum = 0
output = []
while len( processes ):
    process = processes.popleft( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.append( ( process[0], process[1]- q ) )
        qsum += q
 
print(( "\n".join( output ) ))
# Original solution
n,q = list(map(int, input().split()))
que = [list(map(str, input().split())) for i in range(n)]
for i in range(n):que[i][1] = int(que[i][1])
mxt = sum([y for x,y in que])
t = 0
i = 0
while t < mxt:
	i %= n
	a = que[i]
	if 0 < a[1] <= q:
		t += a[1]
		que[i][1] = 0
		print(a[0],t)				
	elif q < a[1]:
		t += q
		que[i][1] = a[1] - q
	i += 1

# Optimized solution
n,q = list(map(int, input().split()))
que = [list(map(str, input().split())) for i in range(n)]
for i in range(n):que[i][1] = int(que[i][1])
mxt = sum([y for x,y in que])
t = 0
i = 0
while t < mxt:
	i %= n
	a = que[i]
	if 0 < a[1] <= q:
		t += a[1]
		que.pop(i)
		n -= 1
		print(a[0],t)				
	elif q < a[1]:
		t += q
		que[i][1] = a[1] - q
		i += 1
# Original solution
# -*- coding: utf-8 -*-
dict={}
kl=[]
n,p=list(map(int,input().split()))
for i in range(n):
    key,value=input().split()
    kl.append(key)
    dict.update({key:int(value)})
   
cnt=0
time=0
count=0
while time!=n:
    for key in kl:
        if 0<dict[key]<=p:
           	cnt+=dict[key]
           	dict[key]=0
           	#del dict[key]
           	#kl.remove(key)
           	time+=1
           	print(key,cnt)
        elif dict[key]>p:
            dict[key]-=p
            cnt+=p

# Optimized solution
# -*- coding: utf-8 -*-
dict={}
kl=[]
n,p=list(map(int,input().split()))
for i in range(n):
    key,value=input().split()
    kl.append(key)
    dict.update({key:int(value)})
   
cnt=0
time=0
while time!=n:
    for key in kl[:]:
        if 0<dict[key]<=p:
           	cnt+=dict[key]
           	dict[key]=0
           	del dict[key]
           	kl.remove(key)
           	time+=1
           	print(key,cnt)
        elif dict[key]>p:
            dict[key]-=p
            cnt+=p
# Original solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
#?????\???
#??????????????¨????§?????????¨?????¨?????????????????????????????????????????????????????????
def rrs(quantum, process):
    finished_process = []

    time_queue = Queue()
    name_queue = Queue()
    
    current_time = 0

    for name, time in process:
        time = int(time)
        time_queue.enqueue(time)
        name_queue.enqueue(name)

    while time_queue.data:
        time = time_queue.dequeue()
        name = name_queue.dequeue()
        if time <= quantum:
            current_time += time
            finished_process.append((name, current_time))
        else:
            current_time += quantum
            time_queue.enqueue(time - quantum)
            name_queue.enqueue(name)
            
    return finished_process


class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, d):
        self.data.append(d)

    def dequeue(self):
        r = self.data[0]
        self.data = self.data[1:]
        return r
    
def main():
    info = input().split()
    n_list = int(info[0])
    quantum = int(info[1])
    target_list = [tuple(input().split()) for i in range(n_list)]
    print(("\n".join([p + " " + str(t) for p,t in rrs(quantum, target_list)])))
    
if __name__ == "__main__":
    main()

# Optimized solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
#?????\???
#??????????????¨????§?????????¨?????¨?????????????????????????????????????????????????????????
def rrs(quantum, process):
    finished_process = []
    queue = Queue()
    current_time = 0

    for p in process:
       queue.enqueue(p)

    while queue.data:
        p_info = queue.dequeue()
        time = int(p_info[1])
        name = p_info[0]
        if time <= quantum:
            current_time += time
            finished_process.append((name, current_time))
        else:
            current_time += quantum
            queue.enqueue((name, time - quantum))
            
    return finished_process


class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, d):
        self.data.append(d)

    def dequeue(self):
        r = self.data[0]
        self.data = self.data[1:]
        return r
    
def main():
    info = input().split()
    n_list = int(info[0])
    quantum = int(info[1])
    target_list = [tuple(input().split()) for i in range(n_list)]
    print(("\n".join([p + " " + str(t) for p,t in rrs(quantum, target_list)])))
    
if __name__ == "__main__":
    main()
# Original solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
#?????\???
#??????????????¨????§?????????¨?????¨?????????????????????????????????????????????????????????
def rrs(quantum, process):
    finished_process = []
    queue = Queue()
    current_time = 0

    for p in process:
       queue.enqueue(p)

    while queue.data:
        p_info = queue.dequeue()
        time = int(p_info[1])
        name = p_info[0]
        if time <= quantum:
            current_time += time
            finished_process.append((name, current_time))
        else:
            current_time += quantum
            queue.enqueue((name, time - quantum))
            
    return finished_process


class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, d):
        self.data.append(d)

    def dequeue(self):
        r = self.data[0]
        self.data = self.data[1:]
        return r
    
def main():
    info = input().split()
    n_list = int(info[0])
    quantum = int(info[1])
    target_list = [tuple(input().split()) for i in range(n_list)]
    print(("\n".join([p + " " + str(t) for p,t in rrs(quantum, target_list)])))
    
if __name__ == "__main__":
    main()

# Optimized solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
#?????\???
#??????????????¨????§?????????¨?????¨?????????????????????????????????????????????????????????
def rrs(quantum, process):
    finished_process = []
    queue = Queue()
    current_time = 0
    i = 0
    while len(finished_process) < len(process):
        if i < len(process):
            p_info = process[i]
            i += 1
        else:
            p_info = queue.dequeue()
        time = int(p_info[1])
        name = p_info[0]
        
        if time <= quantum:
            current_time += time
            finished_process.append((name, current_time))
        else:
            current_time += quantum
            queue.enqueue((name, time - quantum))
            
    return finished_process


class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, d):
        self.data.append(d)

    def dequeue(self):
        r = self.data[0]
        self.data = self.data[1:]
        return r
    
def main():
    info = input().split()
    n_list = int(info[0])
    quantum = int(info[1])
    target_list = [tuple(input().split()) for i in range(n_list)]
    print(("\n".join([p + " " + str(t) for p,t in rrs(quantum, target_list)])))
    
if __name__ == "__main__":
    main()
# Original solution
from collections import deque
n, q = list(map(int,input().split()))
queue = deque([])
for i in range(n):
    queue.append(list(map(str,input().split())))

queue = deque([[x[0],int(x[1])] for x in queue]) 
end  = deque([])
time = 0

while len(queue) > 0:
    xqt = queue.popleft()
    res_time = xqt[1] - q
    if res_time <= 0:
        time = time + xqt[1]
        end.append([xqt[0],time])
    else:
        time = time + q
        xqt[1] = res_time
        queue.append(xqt)

while len(end) > 0:
    out = end.popleft()
    print(out[0], out[1])

# Optimized solution
from collections import deque
n, q = list(map(int,input().split()))
queue = deque([])
for i in range(n):
    queue.append(list(map(str,input().split())))

queue = deque([[x[0],int(x[1])] for x in queue]) 

time = 0

while len(queue) > 0:
    xqt = queue.popleft()
    res_time = xqt[1] - q
    if res_time <= 0:
        time = time + xqt[1]
        print(xqt[0], time)
    else:
        time = time + q
        xqt[1] = res_time
        queue.append(xqt)
# Original solution
import sys

def isEmpty(S):
  if len(S) == 0:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print('Error')
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print('Error')
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []

for i in range(a):
  text = input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if int(x_list_list[0][1]) > b:
    x_list_list[0][1] -= int(b)
    for j in range(flag):
      x_list_list[j][2] += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  else:
    for j in range(flag):
      x_list_list[j][2] += x_list_list[0][1]
    x_list_list[0][1] = 0
    flag -= 1
    print(x_list_list[0][0],x_list_list[0][2])
    dequeue(x_list_list)
    

# Optimized solution
import sys

def isEmpty(S):
  if len(S) == 0:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print('Error')
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print('Error')
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []

for i in range(a):
  text = input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if int(x_list_list[0][1]) > b:
    x_list_list[0][1] -= int(b)
    for j in range(flag):
      x_list_list[j][2] += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  elif int(x_list_list[0][1]) <= b:
    for j in range(flag):
      x_list_list[j][2] += x_list_list[0][1]
    x_list_list[0][1] = 0
    flag -= 1
    print(x_list_list[0][0],x_list_list[0][2])
    dequeue(x_list_list)
# Original solution
class Queue(object):
    def __init__(self, _max):
        if type(_max) != int:
            raise ValueError
        self._array = [None for i in range(0, _max)]
        self._head = 0
        self._tail = 0
        self._cnt = 0

    def enqueue(self, value):
        if self.is_full():
            raise IndexError
        self._array[self._head] = value
        self._cnt += 1
        if self._head + 1 >= len(self._array):
            self._head = 0
        else:
            self._head += 1

    def dequeue(self):
        if self.is_empty():
            raise IndexError
        value = self._array[self._tail]
        self._cnt -= 1
        if self._tail + 1 >= len(self._array):
            self._tail = 0
        else:
            self._tail += 1
        return value

    def is_empty(self):
        return self._cnt <= 0

    def is_full(self):
        return self._cnt >= len(self._array)


def round_robin(quantum, jobs):
    queue = Queue(100000)
    total = 0
    for job in jobs:
        queue.enqueue(job)

    while not queue.is_empty():
        name, time = queue.dequeue()
        if time > quantum:
            total += quantum
            queue.enqueue((name, time - quantum))
        else:
            total += time
            print(("{0} {1}".format(name, total)))


if __name__ == "__main__":
    n, quantum = input().split()
    jobs = [input().split() for i in range(0, int(n))]
    jobs = [(job[0], int(job[1])) for job in jobs]
    round_robin(int(quantum), jobs)

# Optimized solution
class Queue(object):
    def __init__(self, _max):
        if type(_max) != int:
            raise ValueError
        self._array = [None for i in range(0, _max)]
        self._head = 0
        self._tail = 0
        self._cnt = 0

    def enqueue(self, value):
        if self.is_full():
            raise IndexError
        self._array[self._head] = value
        self._cnt += 1
        if self._head + 1 >= len(self._array):
            self._head = 0
        else:
            self._head += 1

    def dequeue(self):
        if self.is_empty():
            raise IndexError
        value = self._array[self._tail]
        self._cnt -= 1
        if self._tail + 1 >= len(self._array):
            self._tail = 0
        else:
            self._tail += 1
        return value

    def is_empty(self):
        return self._cnt <= 0

    def is_full(self):
        return self._cnt >= len(self._array)


def round_robin(quantum, jobs):
    queue = Queue(len(jobs))
    total = 0
    for job in jobs:
        queue.enqueue(job)

    while not queue.is_empty():
        name, time = queue.dequeue()
        if time > quantum:
            total += quantum
            queue.enqueue((name, time - quantum))
        else:
            total += time
            print(("{0} {1}".format(name, total)))


if __name__ == "__main__":
    n, quantum = input().split()
    jobs = [input().split() for i in range(0, int(n))]
    jobs = [(job[0], int(job[1])) for job in jobs]
    round_robin(int(quantum), jobs)