Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
class queue:
    head = tail = None
    size = 0
    def enqueue(self, x):
        if self.is_empty():
            self.head = self.tail = (x, None)
        else:
            self.tail[1] = (x, None)
            self.tail = self.tail[1]
        self.size += 1

    def dequeue(self):
        if not self.is_empty():
            self.head = self.head[1]
            self.size -=1

    def is_empty(self):
        return self.size == 0

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

s = queue()
t = list()
process = 0
for i in range(n):
    name, time = map(str, input().split())
    s.enqueue([name, int(time)])

while s.is_empty():
    diff = s[0][1] - q
    if diff <= 0:
        process += s[0][1]
        t.append([s[0][0], process])
        s.dequeue()
    else:
        process += q
        s.enqueue([s[0][0], diff])
        s.dequeue()
for i in t:
    print(i[0], i[1])

Fixed submission:
class Node:
    elm = None
    nxt = None

    def __init__(self, elm, nxt):
        self.elm = elm
        self.nxt = nxt


class MyQueue:
    head = tail = None
    size = 0

    def enqueue(self, x):
        if self.is_empty():
            self.head = self.tail = Node(x, None)
        else:
            self.tail.nxt = Node(x, None)
            self.tail = self.tail.nxt
        self.size += 1

    def dequeue(self):
        n = self.head
        if not self.is_empty():
            self.head = self.head.nxt
            self.size -= 1
        return n.elm

    def is_empty(self):
        return self.size == 0

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

s = MyQueue()
result = list()
process = 0

for i in range(n):
    name, time = map(str, input().split())
    s.enqueue([name, int(time)])

while not s.is_empty():

    e = s.dequeue()
    diff = e[1] - q
    if diff <= 0:
        process += e[1]
        result.append([e[0], process])
    else:
        process += q
        s.enqueue([e[0], diff])
for i in result:
    print(i[0], i[1])
Buggy python submission (verdict: Runtime Error):
import math
nums = list(map(int , input().split())
a = nums[0]
b = nums[1]
print(a // b)
print(a % b)
print(float(a / b))

Fixed submission:
nums = list(map(int , input().split()))
a = nums[0]
b = nums[1]
print(a // b , end = " ")
print(a % b , end = " ")
print("{0:.5f}".format((a / b)))
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())

print("{0:5f}".format(r**2*math.pi) , end = " ")
print("{0:5f}".format(2*r*math.pi))

Fixed submission:
import math
r = float(input())

print("{0:5f}".format(r**2*math.pi) , end = " ")
print("{0:5f}".format(2*r*math.pi))
Buggy python submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
print(math.gcd(x, y))

Fixed submission:
x, y = map(int, input().split())
a = max(x, y)
b = min(x, y)

while a%b != 0:
    temp = a
    a = b
    b = temp%b

print(b)

Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
n = min(x, y)

for i in range(1, n+1):
    if x%i==0 and y%i==0:
        gcd = i

print(gcd)

Fixed submission:
x, y = map(int, input().split())
a = max(x, y)
b = min(x, y)

while a%b != 0:
    temp = a
    a = b
    b = temp%b

print(b)

Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
a = max(x, y)
b = min(x, y)
if a%b==0:
    gcd = b
else:
    for i in range(1, a%b+1):
        if b%i==0 and (a%b)%i==0:
            gcd = i

print(gcd)

Fixed submission:
x, y = map(int, input().split())
a = max(x, y)
b = min(x, y)

while a%b != 0:
    temp = a
    a = b
    b = temp%b

print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

for a in A:
    for i in range(2, a//2+1):
        if a%i == 0:
            n -= 1
            break

print(n)

Fixed submission:
import sys
import math

def isprime(n):
    if n == 2:
        return 1
    if n < 2 or n % 2 == 0:
        return 0

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return 0
        i += 2
    return 1

n = int(input())
p = 0
for i in map(int, sys.stdin.readlines()):
    p += isprime(i)

print(p)

Buggy python submission (verdict: Runtime Error):
import sys
import math

def isprime(n):
    ans = 1
    for i in range(2, n):
        x = i
        y = n % i
        if math.gcd(x, y) != 1:
            ans = 0
            break
    return ans


n = int(input())
p = 0
for i in map(int, sys.stdin.readlines()):
    p += isprime(i)

print(p)

Fixed submission:
import sys
import math

def isprime(n):
    if n == 2:
        return 1
    if n < 2 or n % 2 == 0:
        return 0

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return 0
        i += 2
    return 1

n = int(input())
p = 0
for i in map(int, sys.stdin.readlines()):
    p += isprime(i)

print(p)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = [0 for _ in range(n)]
for i in range(n):
    R[i] = int(input())

m = -float('inf')
for i in range(n-1):
    for j in range(i+1, n):
        if R[j]-R[i] > m:
            m = R[j]-R[i]

print(m)

Fixed submission:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = [0 for _ in range(n)]
for i in range(n):
    R[i] = int(input())

m = -float('inf')
for i in range(n-1):
    for j in range(i+1, n):
        if R[j]-R[i] > m:
            m = R[j]-R[i]

print(m)

Fixed submission:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = []
P = []

R.append(int(input()))
for i in range(1, n):
    r = int(input())
    P.append(r-min(R))
    R.append(r)

P.sort()
print(P[-1])

Fixed submission:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = []
P = []

p = float('-inf')
R.append(int(input()))
for i in range(1, n):
    r = int(input())
    if r-min(R) > p:
        p = r-min(R)
    R.append(r)

print(p)

Fixed submission:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = []
P = []

p = float('-inf')
R.append(int(input()))
for i in range(1, n):
    r = int(input())
    m = min(R)
    if r-m > p:
        p = r-m
    R.append(r)

print(p)

Fixed submission:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)
Buggy python submission (verdict: Runtime Error):
def insertion_sort(A ,N, g):
	grobal cnt
	for i in range(g, N):
		v = A[i]
		j = i - g
		while j>=0 and A[j]>v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
			A[j+g] = v


def shell_sort(A, N):
	grobal cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G


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

shell_sort(A, N)
print(cnt)
for a in A:
	print(a)



Fixed submission:
def insertion_sort(A ,N, g):
	global cnt
	for i in range(g, N):
		v = A[i]
		j = i - g
		while j>=0 and A[j]>v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
			A[j+g] = v


def shell_sort(A, N):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G


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

shell_sort(A, N)
print(cnt)
for a in A:
	print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
C = [input() for i in range(n)]

A = []
for c in C:
	if c == 'deleteFirst':
		A.pop(0)
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.pop(A.index(q))
	elif 'insert' in c:
		q = int(c[7:])
		A.insert(0, q)

print(' '.join(map(str, A)))


Fixed submission:
from collections import deque

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

A = deque([])
for c in C:
	if c == 'deleteFirst':
		A.popleft()
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q)

print(' '.join(map(str, A)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(int, input().split())
q = int(input())
T = list(int, input().split())

cnt = 0
for t in T:
	if s in S:
		cnt += 1

print(cnt)


Fixed submission:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if t in S:
		cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if s in S:
		cnt += 1

print(cnt)


Fixed submission:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if t in S:
		cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if t in S:
		cnt += 1

print(cnt)


Fixed submission:
from bisect import bisect_left

def index(A, x):
	i = bisect_left(A, x)
	if i != len(A) and A[i] == x:
		return i
	else:
		return -1


n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if index(S, t)>=0:
		cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
import math

x1, y1, x2, y2 = map(int, input().split())
distance = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print(distance)

Fixed submission:
import math

x1, y1, x2, y2 = map(float, input().split())
distance = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print(distance)

Buggy python submission (verdict: Runtime Error):
import math

x1, y1, x2, y2 = map(int, input().split())

Fixed submission:
import math

x1, y1, x2, y2 = map(float, input().split())
distance = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print(distance)
Buggy python submission (verdict: Runtime Error):
x = input()
x = x**3
print(x)

Fixed submission:
x = int(input())
x = x**3
print(x)
Buggy python submission (verdict: Runtime Error):
import math

r = int(input())

s = "{0:.6f}".format(r*r*math.pi)
l = "{0:.6f}".format(2*r*math.pi)

print(str(s) + " " + str(l))

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
import math

r = int(input())

s = r*r*math.pi
l = 2*r*math.pi

print(str(s) + " " + str(l))

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
r = int(input())

s = r*r*math.pi
l = 2*r*math.pi

print(str(s) + " " + str(l))

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
import math

r = int(input())

s = r*r*math.pi()
l = 2*r*math.pi()

print(str(s) + " " + str(l))

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
import math

r = int(input())

s = r * r * math.pi
l = 2 * r * math.pi

print(s, end = " ")
print(l)

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
r = int(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979

print(s, end = " ")
print(l)

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
r = int(input())
 
s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
r = int(input())

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
i = input()
 
r = int(i)
s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Buggy python submission (verdict: Runtime Error):
r = input()

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)

Fixed submission:
r = float(input())

s = r * r * 3.14159265358979
l = 2 * r * 3.14159265358979
 
print(s, end = " ")
print(l)
Buggy python submission (verdict: Runtime Error):
# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

import numpy as np
n, m = map(int, input().split())

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

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

c = A.dot(b)            #A??b

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

Fixed submission:
# 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])

Buggy python submission (verdict: Runtime Error):
# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

import numpy as np
n, m = map(int, input().split())

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

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

c = np.matrix([[0] for i in range(n)])            #A??b

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

Fixed submission:
# 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])
Buggy python submission (verdict: Runtime Error):
array = input()

char = ["" for _ in range(len(array))]
for i in range(len(array)):
    char[i] = array[i:i+1]

alp = [0 for _ in range(26)]
for j in range(len(array)):
    for i in range(26):
        if char[j] == chr(i+ord("A")) or c == chr(i+ord("a")):
            alp[i] += 1

for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), alp[i]))

Fixed submission:
import sys

count = [0 for _ in range(26)]

for line in sys.stdin:
    array = line
    char = ["" for _ in range(len(array))]
    for i in range(len(array)):
        char[i] = array[i:i+1]
    for c in char:
        for i in range(26):
            if c == chr(i+ord("A")) or c == chr(i+ord("a")):
                count[i] += 1


for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), count[i]))

Buggy python submission (verdict: Runtime Error):
import sys

array = []
for line in sys.stdin:
    array.append(line)

char = ["" for _ in range(len(array))]
for i in range(len(array)):
    char[i] = array[i:i+1]

count = [0 for _ in range(26)]
for c in char:
    for i in range(26):
        if c == chr(i+ord("A")) or c == chr(i+ord("a")):
            count[i] += 1

for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), alp[i]))

Fixed submission:
import sys

count = [0 for _ in range(26)]

for line in sys.stdin:
    array = line
    char = ["" for _ in range(len(array))]
    for i in range(len(array)):
        char[i] = array[i:i+1]
    for c in char:
        for i in range(26):
            if c == chr(i+ord("A")) or c == chr(i+ord("a")):
                count[i] += 1


for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), count[i]))

Buggy python submission (verdict: Runtime Error):
import sys

array = ""
for line in sys.stdin:
    array += line

char = ["" for _ in range(len(array))]
for i in range(len(array)):
    char[i] = array[i:i+1]

count = [0 for _ in range(26)]
for c in char:
    for i in range(26):
        if c == chr(i+ord("A")) or c == chr(i+ord("a")):
            count[i] += 1

for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), alp[i]))

Fixed submission:
import sys

count = [0 for _ in range(26)]

for line in sys.stdin:
    array = line
    char = ["" for _ in range(len(array))]
    for i in range(len(array)):
        char[i] = array[i:i+1]
    for c in char:
        for i in range(26):
            if c == chr(i+ord("A")) or c == chr(i+ord("a")):
                count[i] += 1


for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), count[i]))
Buggy python submission (verdict: Runtime Error):
def check(s, p):
    if s == p:
        return 1
    else:
        return 0

word = input().lower()
print(word)
count = 0
while 1:
    array = input().lower()
    if array == "END_OF_TEXT":
        break

    print(array)
    for i in range(len(array)-len(word)+1):
        if array[i:i+len(word)] == word:
            count += 1

print(count)

Fixed submission:
word = input().lower()
count = 0
while 1:
    array = input().split()
    if array[0] == "END_OF_TEXT":
        break

    for a in array:
        if a.lower() == word:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

score_taro, score_hanako = 0, 0
for _ in range(n):
    card_taro, card_hanako = input().split()

    if card_taro == card_hanako:            # DRAW
        score_taro += 1
        score_hanako += 1
        #print("draw")#
        continue
    for i in range(n):
        if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):         # TARO WIN
            score_taro += 3
            #print("taro win")#
            break
        if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):         # HANAKO WIN
            score_hanako += 3
            #print("hanako win")#
            break
        if ord(card_taro[i:i+1]) == ord(card_hanako[i:i+1]):        # NEXT CHAR
            continue

print("{0} {1}".format(score_taro, score_hanako))

Fixed submission:
n = int(input())

score_taro, score_hanako = 0, 0
for _ in range(n):
    card_taro, card_hanako = input().split()

    point_taro = 0
    point_hanako = 0
    if card_taro == card_hanako:
        score_taro += 1
        score_hanako += 1
        continue
    for i in range(min(len(card_taro), len(card_hanako))):
        if len(card_taro) > len(card_hanako):
            point_taro = 3
        elif len(card_taro) < len(card_hanako):
            point_hanako = 3
        if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):
            point_taro = 3
            point_hanako = 0
            break
        if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):
            point_taro = 0
            point_hanako = 3
            break
    score_taro += point_taro
    score_hanako += point_hanako
print("{0} {1}".format(score_taro, score_hanako))
Buggy python submission (verdict: Runtime Error):
#3.4

N = int(input())
a = list(map(int, input().split()))

swapCount = 0
for i in range(0, N):
    minIndex = 1
    for j in range(i + 1, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIdex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)

        

Fixed submission:
#3.4

N = int(input())
a = list(map(int, input().split()))

swapCount = 0
for i in range(0, N):
    minIndex = i
    for j in range(i, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIndex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)

Buggy python submission (verdict: Runtime Error):
#3.4

N = int(input())
a = list(map(int, input().split()))

swapCount = 0
for i in range(0, N):
    minIndex = 1
    for j in range(0, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIdex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)

        

Fixed submission:
#3.4

N = int(input())
a = list(map(int, input().split()))

swapCount = 0
for i in range(0, N):
    minIndex = i
    for j in range(i, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIndex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)