Buggy python submission (verdict: Runtime Error):
INPUT = list(map(int, input().split()))
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]
processes = [input().split() for _ in range(n)]


def enqueue(x):
    global processes, tail
    processes.append(0)
    processes[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(processes[i][1])

time, count = 0, 0
while count < n:
    y = processes[head][1] - quantum
    if y < 0:
        print(str(processes[head][0]) + " " + str(time + processes[head][1]))
        dequeue()
        time += y
        count += 1
    else:
        processes[head][1] -= quantum
        enqueue(processes[head])
        dequeue()

    time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
INPUT = list(map(int, input().split()))
processes = [input().split() for _ in range(n)]
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]


def enqueue(x):
    global processes, tail
    processes.append(0)
    processes[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(processes[i][1])

time, count = 0, 0
while count < n:
    y = processes[head][1] - quantum
    if y < 0:
        print(str(processes[head][0]) + " " + str(time + processes[head][1]))
        dequeue()
        time += y
        count += 1
    else:
        processes[head][1] -= quantum
        enqueue(processes[head])
        dequeue()

    time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
INPUT = list(map(int, input().split()))
processes = [input().split() for _ in range(INPUT[0])]
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]


def enqueue(x):
    global processes, tail
    processes.append(0)
    processes[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(processes[i][1])

time, count = 0, 0
while count < n:
    y = processes[head][1] - quantum
    if y < 0:
        print(str(processes[head][0]) + " " + str(time + processes[head][1]))
        dequeue()
        time += y
        count += 1
    else:
        processes[head][1] -= quantum
        enqueue(processes[head])
        dequeue()

    time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
INPUT = list(map(int, input().split()))
processes = [input() for _ in range(INPUT[0])]
for i in range(INPUT[0]):
    processes[i].split()
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]


def enqueue(x):
    global processes, tail
    processes.append(0)
    processes[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(processes[i][1])

time, count = 0, 0
while count < n:
    y = processes[head][1] - quantum
    if y < 0:
        print(str(processes[head][0]) + " " + str(time + processes[head][1]))
        dequeue()
        time += y
        count += 1
    else:
        processes[head][1] -= quantum
        enqueue(processes[head])
        dequeue()

    time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
n, quantum = [int(i) for i in input().split()]
processes = []
for i in range(n):
    processes.append(input())
for i in range(n):
    processes[i].split()
head, tail = 0, len(processes)


def enqueue(x):
    global processes, tail
    processes.append(0)
    processes[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(processes[i][1])

time, count = 0, 0
while count < n:
    y = processes[head][1] - quantum
    if y < 0:
        print(str(processes[head][0]) + " " + str(time + processes[head][1]))
        dequeue()
        time += y
        count += 1
    else:
        processes[head][1] -= quantum
        enqueue(processes[head])
        dequeue()

    time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
def parse(l):
    name, time = l.split()
    return name, int(time)


n, quantum = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
head, tail = 0, len(queue)


def enqueue(x):
    global queue, tail
    queue.append(0)
    queue[tail] = x
    tail += 1


def dequeue():
    global head
    head += 1


for i in range(n):
    int(queue[i][1])

total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y < 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum

Buggy python submission (verdict: Runtime Error):
def parse(l):
    name, time = l.split()
    return name, int(time)


n, quantum = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum



Fixed submission:
def parse(l):
    name, time = l.split()
    a = [name, int(time)]
    return a


n, quantum = map(int, input().split())
queue = []
for i in range(n):
    queue.append(parse(input()))
head = 0


def enqueue(x):
    global queue
    queue.append(x)


def dequeue():
    global head
    head += 1


total_time, count = 0, 0
while count < n:
    y = queue[head][1] - quantum
    if y <= 0:
        print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
        dequeue()
        total_time += y
        count += 1
    else:
        queue[head][1] -= quantum
        enqueue(queue[head])
        dequeue()

    total_time += quantum