Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os

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


def circumscribed_circle(x1, y1, x2, y2, x3, y3):
    d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
    px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
    py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
    A = .5 * abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y1 - y1))
    a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
    r = a * b * c / (4 * A)
    return px, py, r

          
N = int(input())
for k in range(N):
    x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
    px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
    print("%.3f %.3f %.3f" % (px, py, r))

Fixed submission:
# Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os

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


def circumscribed_circle(x1, y1, x2, y2, x3, y3):
    d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
    px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
    py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
    a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
    s = (a + b + c) / 2
    A = math.sqrt(s * (s - a) * (s - b) * (s - c))
    r = a * b * c / (4 * A)
    return px, py, r

          
N = int(input())
for k in range(N):
    x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
    px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
    print("%.3f %.3f %.3f" % (px, py, r))
Buggy python submission (verdict: Runtime Error):
# Aizu Problem 0076: Treasure Hunt II
#
import sys, math, os

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


positions = {0: [0, 0], 1: [1, 1]}
direction = 135 * math.pi / 180
x, y = 1, 1
for step in range(2, 10):
    x += math.cos(direction)
    y += math.sin(direction)
    positions[step] = [x, y]
    direction = math.atan2(x, -y)

while True:
    n = int(input())
    if n == -1:
        break
    print("%.2f" % positions[n-1][0])
    print("%.2f" % positions[n-1][1])
    

Fixed submission:
# Aizu Problem 0076: Treasure Hunt II
#
import sys, math, os

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


positions = {0: [0, 0], 1: [1, 1]}
direction = 135 * math.pi / 180
x, y = 1, 1
for step in range(2, 1001):
    x += math.cos(direction)
    y += math.sin(direction)
    positions[step] = [x, y]
    direction = math.atan2(x, -y)

while True:
    n = int(input())
    if n == -1:
        break
    print("%.2f" % positions[n-1][0])
    print("%.2f" % positions[n-1][1])
Buggy python submission (verdict: Time Limit Exceeded):
# Aizu Problem 0080: Third Root
#
import sys, math, os

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


def third_root(q):
    x = q / 2
    while abs(x**3 - q) > 1e-8:
        x = x - (x**3 - q) / (3 * x**2)
    return x


for line in sys.stdin:
    n = int(line)
    if n == -1:
        break
    print("%.6f" % third_root(n))

Fixed submission:
# Aizu Problem 0080: Third Root
#
import sys, math, os

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


def third_root(q):
    x = q / 2
    while abs(x**3 - q) >= 1e-5 * q:
        x = x - (x**3 - q) / (3 * x**2)
    return x


for line in sys.stdin:
    n = int(line)
    if n == -1:
        break
    print("%f" % third_root(n))
Buggy python submission (verdict: Runtime Error):
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy

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


code = {1: "afkpuz", 2: "ablqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}

def pocket_pager(string):
    if len(string) % 2 == 1:
        return "NA"
    res = ""
    for k in range(len(string) // 2):
        i = int(string[2*k])
        j = int(string[2*k+1])
        res += code[j][i-1]
    return res


for line in sys.stdin:
    print(pocket_pager(line.strip()))

Fixed submission:
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy

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


code = {1: "afkpuz", 2: "bglqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}

def pocket_pager(string):
    if len(string) % 2 == 1:
        return "NA"
    res = ""
    for k in range(len(string) // 2):
        i = int(string[2*k])
        j = int(string[2*k+1])
        if not 1 <= i <= 6 or not 1 <= j <= 5:
            return "NA"
        res += code[j][i-1]
    return res


for line in sys.stdin:
    print(pocket_pager(line.strip()))
Buggy python submission (verdict: Runtime Error):
# Aizu Problem 00150: Twin Prime
#
import sys, math, os, bisect

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


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10000)

while True:
    n = int(input())
    if n == 0:
        break
    idx = bisect.bisect_left(primes, n)
    while True:
        #if idx == len(primes):
        #    idx -= 1
        if primes[idx] >= n:
            idx -= 1
        if primes[idx] - primes[idx - 1] == 2:
            print(primes[idx - 1], primes[idx])
            break
        idx -= 1

Fixed submission:
# Aizu Problem 00150: Twin Prime
#
import sys, math, os, bisect

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


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10050)

while True:
    n = int(input())
    if n == 0:
        break
    idx = bisect.bisect_left(primes, n)
    while True:
        #if idx == len(primes):
        #    idx -= 1
        if primes[idx] > n:
            idx -= 1
        if primes[idx] - primes[idx - 1] == 2:
            print(primes[idx - 1], primes[idx])
            break
        idx -= 1
Buggy python submission (verdict: Time Limit Exceeded):
# Aizu Problem 0223: Stray Twins

import sys, math, os, bisect
from queue import Queue

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


def stray_twins(W, H, grid, tx, ty, kx, ky):
    moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    Q = Queue()
    Q.put((tx, ty, kx, ky, 0))
    visited = set()
    while not Q.empty():
        tx, ty, kx, ky, t = Q.get()
        visited.add((tx, ty, kx, ky))
        if t >= 100:
            return "NA"
        if tx == kx and ty == ky:
            return t
        for dy, dx in moves:
            dtx = max(0, min(tx + dx, W - 1))
            dty = max(0, min(ty + dy, H - 1))
            dkx = max(0, min(kx - dx, W - 1))
            dky = max(0, min(ky - dy, H - 1))
            if grid[dty][dtx] == 1:
                dtx, dty = tx, ty
            if grid[dky][dkx] == 1:
                dkx, dky = kx, ky
            if (dtx, dty, dkx, dky) not in visited:
                Q.put((dtx, dty, dkx, dky, t + 1))
    
while True:
    W, H = map(int, input().split())
    if W == H == 0:
        break
    tx, ty = [int(_) - 1 for _ in input().split()]
    kx, ky = [int(_) - 1 for _ in input().split()]
    grid = [[int(_) for _ in input().split()] for __ in range(H)]
    print(stray_twins(W, H, grid, tx, ty, kx, ky))

Fixed submission:
from Queue import Queue
mv=((-1,0),(1,0),(0,-1),(0,1))
while True:
    X,Y=map(int,raw_input().split())
    if X==Y==0:break
    tx,ty=map(int,raw_input().split())
    kx,ky=map(int,raw_input().split())
    tx,ty,kx,ky=tx-1,ty-1,kx-1,ky-1
    D=[map(int,raw_input().split()) for i in range(Y)]
    Q=Queue()
    Q.put((tx,ty,kx,ky,0))
    visited=set()
    visited.add((tx,ty,kx,ky))
    while not Q.empty():
        tx,ty,kx,ky,t=Q.get()
        if t>=100:
            print "NA"
            break
        if tx==kx and ty==ky:
            print t
            break
        for i in range(4):
            dtx,dty=tx+mv[i][0],ty+mv[i][1]
            dkx,dky=kx-mv[i][0],ky-mv[i][1]
            if dtx<0 or dtx>=X or dty<0 or dty>=Y:
                dtx,dty=tx,ty
            if dkx<0 or dkx>=X or dky<0 or dky>=Y:
                dkx,dky=kx,ky
            if D[dty][dtx]==1:
                dtx,dty=tx,ty
            if D[dky][dkx]==1:
                dkx,dky=kx,ky
            if (dtx,dty,dkx,dky) not in visited:
                visited.add((dtx,dty,dkx,dky))
                Q.put((dtx,dty,dkx,dky,t+1))
    else:
        print "NA"
Buggy python submission (verdict: Time Limit Exceeded):
# Aizu Problem 0270: Modular Query

import sys, math, os, datetime

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


N, Q = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
for q in range(Q):
    m = int(input())
    print(max([a % m for a in A]))

Fixed submission:
N,Q=map(int,raw_input().split())
c=map(int,raw_input().split())
 
mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
     
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
         
for i in range(Q):
    q=int(raw_input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print ans
Buggy python submission (verdict: Runtime Error):
# Aizu Problem ITP_1_4_B: Circle
#
import sys, math, os

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

pi = math.pi
r = int(input())
print("%.6f %.6f" % (pi * r**2, 2 * pi * r))

Fixed submission:
# Aizu Problem ITP_1_4_B: Circle
#
import sys, math, os

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

pi = math.pi
r = float(input())
print("%.6f %.6f" % (pi * r**2, 2 * pi * r))
Buggy python submission (verdict: Runtime Error):
# Aizu Problem ITP_1_5_D: Structured Programming
#
import sys, math, os

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

res = []


def CHECK_NUM(n, i):
    x = i
    if x % 3 == 0:
        res.append(i)
    else:
        while True:
            if x % 10 == 3:
                res.append(i)
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i <= n:
        CHECK_NUM(n, i)
        
        
def call(n):
    CHECK_NUM(n, 1)
    

n = int(input())
call(n)
print(' ' + ' '.join([str(r) for r in res]))

Fixed submission:
# Aizu Problem ITP_1_5_D: Structured Programming
#
import sys, math, os

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

res = []


def CHECK_NUM2(n, i):
    x = i
    if x % 3 == 0:
        res.append(i)
    else:
        while True:
            if x % 10 == 3:
                res.append(i)
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i <= n:
        CHECK_NUM(n, i)
        
def CHECK_NUM(n, i):
    while True:
        x = i
        if x % 3 == 0:
            res.append(i)
        else:
            while True:
                if x % 10 == 3:
                    res.append(i)
                    break
                x //= 10
                if x == 0:
                    break
        i += 1
        if i > n:
            break
        
def call(n):
    CHECK_NUM(n, 1)
    

n = int(input())
#n=1000
call(n)
print(' ' + ' '.join([str(r) for r in res]))
Buggy python submission (verdict: Runtime Error):
nums  = int(input())
array = [int(n) for n in input().split()]

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
        array[j+1] = v
        print array

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

if __name__ == '__main__':
    print(" ".join(map(str, A)))
    for i in range(1, N):
        target_num = A[i]
        j = i - 1
        while j >= 0 and A[j] > target_num:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = target_num
        print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
nums  = int(input())
array = list(map(int, input().split()))

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print array

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

if __name__ == '__main__':
    print(" ".join(map(str, A)))
    for i in range(1, N):
        target_num = A[i]
        j = i - 1
        while j >= 0 and A[j] > target_num:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = target_num
        print(" ".join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    print(" ".join(A))
    for i in range(1, N):
        target_num = A[i]
        for j in range(i):
            if A[j] > target_num:
                tmp_idx = i
                while j < tmp_idx:
                    A[tmp_idx] = A[tmp_idx-1]
                    tmp_idx -= 1
                A[j] = target_num
                break
        print(" ".join(A))


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

if __name__ == '__main__':
    print(" ".join(map(str, A)))
    for i in range(1, N):
        target_num = A[i]
        j = i - 1
        while j >= 0 and A[j] > target_num:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = target_num
        print(" ".join(map(str, A)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    cnt = 0
    for i in range(N):
        for j in range(N-1, i, -1):
            if j > 0 and A[j-1] > A[j]:
                A[j-1], A[j] = A[j], A[j-1]
                cnt += 1
    print(" ".join(map(str, A)))
    pritn(cnt)


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

if __name__ == '__main__':
    flg = True
    cnt = 0
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if A[j] < A[j-1]:
                    A[j], A[j-1] = A[j-1], A[j]
                    cnt += 1
                    flg = True
    print(" ".join(map(str, A)))
    print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(input().split())

A = []
A1 = []
A2 = []
for i in a:
    A.append(list(i))
    A1.append(list(i))
    A2.append(list(i))

# check stable or not
def is_stable(A3):
    for i in range( 1, n ):
        if int(A3[i-1][1]) == int(A3[i][1]):
            sm = i-1
            bg = i
            for j in range( n ):
                if ( A[j][0] == A3[sm][0]) & ( A[j][1] == A3[sm][1]):
                    t1 = j
                if ( A[j][0] == A3[bg][0]) & ( A[j][1] == A3[bg][1]):
                    t2 = j
            print(t1)
            print(t2)
            if t1 > t2:
                return "Not stable"
    return "Stable"

# bubble
for i in range( n ):
    for j in range( n-1, i, -1 ):
        if int(A1[j][1]) < int(A1[j-1][1]):
            t = A1[j-1]
            A1[j-1] = A1[j]
            A1[j] = t

s = is_stable(A1)
print(" ".join(A1))
print(s)


# selection
for i in range( n ):
    minj = i
    for j in range( i+1, n ):
        if int(A2[j][1]) < int(A2[minj][1]):
            minj = j
    if minj != i:
        t = A2[i]
        A2[i] = A2[minj]
        A2[minj] = t

s = is_stable(A2)
print(" ".join(A2))
print(s)

Fixed submission:
import copy

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

def is_stable(sorted_list):
    for i in range(len(sorted_list)-1):
        if sorted_list[i][1] == sorted_list[i+1][1]:
            for j in range(len(A)):
                if A[j] == sorted_list[i]:
                    smaller_idx = j
                if A[j] == sorted_list[i+1]:
                    larger_idx = j
            if smaller_idx > larger_idx:
                return False
    return True

def print_stable_or_not(is_stable):
    if is_stable:
        print("Stable")
    else:
        print("Not stable")

def bubble_sort(A1):
    flg = True
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if int(A1[j-1][1]) > int(A1[j][1]):
                    A1[j-1], A1[j] = A1[j], A1[j-1]
                    flg = True
    print(" ".join(A1))
    print_stable_or_not(is_stable(A1))

def insertion_sort(A2):
    for i in range(N-1):
        min_idx = i
        for j in range(i+1, N):
            if int(A2[min_idx][1]) > int(A2[j][1]):
                min_idx = j
        if min_idx != i:
            A2[i], A2[min_idx] = A2[min_idx], A2[i]
    print(" ".join(A2))
    print_stable_or_not(is_stable(A2))

if __name__ == '__main__':
    A1 = copy.deepcopy(A)
    A2 = copy.deepcopy(A)
    bubble_sort(A1)
    insertion_sort(A2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    divide_cnt = 0
    diffs = []
    quotient = N
    while True:
        quotient = quotient // 2
        if quotient == 1:
            break
        diffs.append(quotient)
        divide_cnt += 1
    diffs.append(1)
    divide_cnt += 1
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(divide_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)



Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    diffs = []
    h = 1
    while h <= N:
        diffs.append(h)
        h = h*3 + 1
    diffs.reverse()
    diffs_cnt = len(diffs)
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(diffs_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().strip().split())

A = []
D = {}
for l in range(N):
    n, t = input().strip().split()
    D[n] = int(t)
    A.append(n)

print(A)
T = 0
d = 0
while True:
    n = A.pop(0)
    if D[n] > Q:
        D[n] -= Q
        T += Q
        A.append(n)
    else:
        T += D[n]
        print(str(n) + ' ' + atr(T))
        d += 1
        if d == N:
            break

Fixed submission:
N, qms = map(int, input().split())

raw_proc = [input() for i in range(N)]
queue = [{} for i in range(N+1)]
limit = N+1
for i in range(N):
    name, time = raw_proc[i].split()
    time = int(time)
    queue[i] = {"name": name, "time": time}

def enque(tail, p):
    queue[tail] = p
    tail = (tail+1) % limit
    return tail

def deque(head):
    proc = queue[head]
    head = (head+1) % limit
    return proc, head


if __name__ == '__main__':
    head = 0
    tail = N
    total_time = 0
    while head != tail:
        p, head = deque(head)
        t = min(qms, p["time"])
        p["time"] = p["time"] - t
        total_time += t
        if p["time"] > 0:
            tail = enque(tail, p)
        else:
            print("{} {}".format(p["name"], total_time))

Buggy python submission (verdict: Runtime Error):
process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]


if __name__ == '__main__':
    procs = []
    for row in raw_procs:
        name, time = row.split()
        procs.push = {
            "name": name,
            "time": int(time),
        }

    total_time = 0
    current_proc = 0
    while len(procs) > 0:
        if procs[current_proc]["time"] > 100:
            procs[current_proc]["time"] = procs[current_proc]["time"] - qms
            total_time += qms
            if current_proc == len(procs)-1:
                current_proc = 0
            else:
                current_proc += 1
        else:
            total_time += procs[current_proc]["time"]
            print("{} {}".format(procs[current_proc]["name"], total_time))
            del procs[current_proc]
            if current_proc >= len(procs)-1:
                current_proc = 0


Fixed submission:
N, qms = map(int, input().split())

raw_proc = [input() for i in range(N)]
queue = [{} for i in range(N+1)]
limit = N+1
for i in range(N):
    name, time = raw_proc[i].split()
    time = int(time)
    queue[i] = {"name": name, "time": time}

def enque(tail, p):
    queue[tail] = p
    tail = (tail+1) % limit
    return tail

def deque(head):
    proc = queue[head]
    head = (head+1) % limit
    return proc, head


if __name__ == '__main__':
    head = 0
    tail = N
    total_time = 0
    while head != tail:
        p, head = deque(head)
        t = min(qms, p["time"])
        p["time"] = p["time"] - t
        total_time += t
        if p["time"] > 0:
            tail = enque(tail, p)
        else:
            print("{} {}".format(p["name"], total_time))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input()))
Q = int(input())
T = list(map(int, input()))

match_count = 0
for i in T:
    for j in S:
        if i == j:
            match_count += 1
            break

print(str(match_count))



Fixed submission:
n = int(input())
S = set([int(i) for i in input().split()])
q = int(input())
T = set([int(i) for i in input().split()])
print(len( S & T ))