Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while 1:
    t, d, l = map(int, raw_input().split())
    rest = ans = 0
    for i in xrange(t):
        x = int(raw_input())
        if l <= x:
            rest = d
        elif rest:
            rest -= 1
        if rest and i < t-1:
            ans += 1
    print ans

Fixed submission:
while 1:
    t, d, l = map(int, raw_input().split())
    if t == d == l == 0:
        break
    rest = ans = 0
    for i in xrange(t):
        x = int(raw_input())
        if l <= x:
            rest = d
        elif rest:
            rest -= 1
        if rest and i < t-1:
            ans += 1
    print ans
Buggy python submission (verdict: Runtime Error):
N, C = map(int, input().split())
events = []
for i in range(N):
    events.append(list(map(int, input().split())))

dp = [[0]*201 for i in range(C+1)]
for j in range(C+1):
    for k in range(-1000, 1001):
        if k != 0:
            dp[j][k] = -10**18
for a, b, c in events:
    for j in range(C-c, -1, -1):
        for k in range(-1000, 1001):
            if k + (b-a) >= -100:
                dp[j+c][k+b-a] = max(dp[j+c][k+b-a], dp[j][k] + a)
            if k + (a-b) <= 100:
                dp[j+c][k+a-b] = max(dp[j+c][k+a-b], dp[j][k] + b)
ans = 0
for j in range(C+1):
    for k in range(-1000, 1001):
        ans = max(ans, min(dp[j][k] + k, dp[j][k]))
print(ans)

Fixed submission:
N, C = map(int, input().split())
events = []
for i in range(N):
    events.append(list(map(int, input().split())))

def solve():
    L = 250
    dp = [[-10**18]*(L+1) for i in range(C+1)]
    for j in range(C+1):
        dp[j][0] = 0
    for a, b, c in events:
        for j in range(C-c, -1, -1):
            for k in range(L+1):
                if k + (b-a) <= 0:
                    dp[j+c][a-k-b] = max(dp[j+c][a-k-b], dp[j][k]+k+b)
                else:
                    dp[j+c][k+b-a] = max(dp[j+c][k+b-a], dp[j][k]+a)
                if k + (a-b) <= L:
                    dp[j+c][k+a-b] = max(dp[j+c][k+a-b], dp[j][k]+b)
    ans = 0
    for j in range(C+1):
        ans = max(ans, max(dp[j]))
    return ans
print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
events = []
for i in range(N):
    events.append(list(map(int, input().split())))

dp = [[0]*2001 for i in range(C+1)]
for j in range(C+1):
    for k in range(-1000, 1001):
        if k != 0:
            dp[j][k] = -10**18
for a, b, c in events:
    for j in range(C-c, -1, -1):
        for k in range(-1000, 1001):
            if k + (b-a) >= -100:
                dp[j+c][k+b-a] = max(dp[j+c][k+b-a], dp[j][k] + a)
            if k + (a-b) <= 100:
                dp[j+c][k+a-b] = max(dp[j+c][k+a-b], dp[j][k] + b)
ans = 0
for j in range(C+1):
    for k in range(-1000, 1001):
        ans = max(ans, min(dp[j][k] + k, dp[j][k]))
print(ans)

Fixed submission:
N, C = map(int, input().split())
events = []
for i in range(N):
    events.append(list(map(int, input().split())))

def solve():
    L = 250
    dp = [[-10**18]*(L+1) for i in range(C+1)]
    for j in range(C+1):
        dp[j][0] = 0
    for a, b, c in events:
        for j in range(C-c, -1, -1):
            for k in range(L+1):
                if k + (b-a) <= 0:
                    dp[j+c][a-k-b] = max(dp[j+c][a-k-b], dp[j][k]+k+b)
                else:
                    dp[j+c][k+b-a] = max(dp[j+c][k+b-a], dp[j][k]+a)
                if k + (a-b) <= L:
                    dp[j+c][k+a-b] = max(dp[j+c][k+a-b], dp[j][k]+b)
    ans = 0
    for j in range(C+1):
        ans = max(ans, max(dp[j]))
    return ans
print(solve())
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
H, W, T, Q = map(int, input().split())
que = []
state = [[0]*W for i in range(H)]
data1 = [[0]*(W+1) for i in range(H+1)]
data2 = [[0]*(W+1) for i in range(H+1)]
def get(data, h, w):
    s = 0
    while h:
        w0 = w
        el = data[h]
        while w0:
            s += el[w0]
            w0 -= w0 & -w0
        h -= h & -h
    return s
def add(data, h, w, x):
    while h <= H:
        w0 = w
        el = data[h]
        while w0 <= W:
            el[w0] += x
            w0 += w0 & -w0
        h += h & -h

for q in range(Q):
    t, c, *ps = map(int, input().split())
    while que and que[0][0] <= t:
        _, h0, w0 = heappop(que)
        add(data1, h0, w0, -1)
        add(data2, h0, w0, 1)
        state[h0][w0] = 2
    if c == 0:
        h0, w0 = ps
        state[h0][w0] = 1
        add(data1, h0, w0, 1)
        heappush(que, (t + T, h0, w0))
    elif c == 1:
        h0, w0 = ps
        if state[h0][w0] == 2:
            add(data2, h0, w0, -1)
            state[h0][w0] = 0
    else:
        h0, w0, h1, w1 = ps
        result1 = get(data1, h1, w1) - get(data1, h1, w0-1) - get(data1, h0-1, w1) + get(data1, h0-1, w0-1)
        result2 = get(data2, h1, w1) - get(data2, h1, w0-1) - get(data2, h0-1, w1) + get(data2, h0-1, w0-1)
        print(result2, result1)

Fixed submission:
from heapq import heappush, heappop
H, W, T, Q = map(int, input().split())
que = []
state = [[0]*(W+1) for i in range(H+1)]
data1 = [[0]*(W+1) for i in range(H+1)]
data2 = [[0]*(W+1) for i in range(H+1)]
def get(data, h, w):
    s = 0
    while h:
        w0 = w
        el = data[h]
        while w0:
            s += el[w0]
            w0 -= w0 & -w0
        h -= h & -h
    return s
def add(data, h, w, x):
    while h <= H:
        w0 = w
        el = data[h]
        while w0 <= W:
            el[w0] += x
            w0 += w0 & -w0
        h += h & -h

for q in range(Q):
    t, c, *ps = map(int, input().split())
    while que and que[0][0] <= t:
        _, h0, w0 = heappop(que)
        add(data1, h0, w0, -1)
        add(data2, h0, w0, 1)
        state[h0][w0] = 2
    if c == 0:
        h0, w0 = ps
        state[h0][w0] = 1
        add(data1, h0, w0, 1)
        heappush(que, (t + T, h0, w0))
    elif c == 1:
        h0, w0 = ps
        if state[h0][w0] == 2:
            add(data2, h0, w0, -1)
            state[h0][w0] = 0
    else:
        h0, w0, h1, w1 = ps
        result1 = get(data1, h1, w1) - get(data1, h1, w0-1) - get(data1, h0-1, w1) + get(data1, h0-1, w0-1)
        result2 = get(data2, h1, w1) - get(data2, h1, w0-1) - get(data2, h0-1, w1) + get(data2, h0-1, w0-1)
        print(result2, result1)
Buggy python submission (verdict: Time Limit Exceeded):
def insertionSort(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

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

cnt = 0
G = []
for i in range(100):
    if n < 1 + 3*i:
        break
    G.append(1 + 3*i)
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt)
print(*A, sep='\n')

Fixed submission:
def insertionSort(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

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

cnt = 0
G = [1]
for i in range(99):
    if n < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt)
print(*A, sep='\n')
Buggy python submission (verdict: Runtime Error):
from math import sqrt
q3 = sqrt(3)
fmt = "%.8f %.8f"
def koch(x0, y0, x1, y1, c):
    xp = (x0*2 + x1) / 3
    yp = (y0*2 + y1) / 3

    xq = (x0 + x1*2) / 3
    yq = (y0 + y1*2) / 3

    dx = (x1 - x0) / 6
    dy = (y1 - y0) / 6

    xr = xp + (dx - dy * q3)
    yr = yp + (dx * q3 + dy)

    if c == n-1:
        return (fmt % (x0, y0), fmt % (xp, yp), fmt % (xr, yr), fmt % (xq, yq))
    return koch(x0, y0, xp, yp, c+1) + koch(xp, yp, xr, yr, c+1) + koch(xr, yr, xq, yq, c+1) + koch(xq, yq, x1, y1, c+1)
n = int(input())
print(*koch(0, 0, 100, 0, 0)+(fmt % (100, 0),), sep='\n')

Fixed submission:
from math import sqrt
q3 = sqrt(3)
fmt = "%.8f %.8f"
def koch(x0, y0, x1, y1, c):
    if c == n:
        return (fmt % (x0, y0),)
    xp = (x0*2 + x1) / 3
    yp = (y0*2 + y1) / 3

    xq = (x0 + x1*2) / 3
    yq = (y0 + y1*2) / 3

    dx = (x1 - x0) / 6
    dy = (y1 - y0) / 6

    xr = xp + (dx - dy * q3)
    yr = yp + (dx * q3 + dy)

    return koch(x0, y0, xp, yp, c+1) + koch(xp, yp, xr, yr, c+1) + koch(xr, yr, xq, yq, c+1) + koch(xq, yq, x1, y1, c+1)
n = int(input())
print(*koch(0, 0, 100, 0, 0)+(fmt % (100, 0),), sep='\n')
Buggy python submission (verdict: Runtime Error):
n = input()
ps = [map(int, raw_input().split()) for i in xrange(n)]
def intersection(p1, p2, q1, q2):
    dx0 = p2[0] - p1[0]
    dy0 = p2[1] - p1[1]
    dx1 = q2[0] - q1[0]
    dy1 = q2[1] - q1[1]
    a = dy0*dx1; b = dy1*dx0; c = dx0*dx1; d = dy0*dy1
    if a == b: return None
    x = (a*p1[0] - b*q1[0] + c*(q1[1] - p1[1])) / float(a - b)
    y = (c*p1[1] - a*q1[1] + d*(q1[0] - p1[0])) / float(b - a)
    return x, y
def cross(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
def calc_area(ps):
    return abs(sum(ps[i][0]*ps[i-1][1] - ps[i][1]*ps[i-1][0] for i in xrange(n))) / 2.
for t in xrange(input()):
    vs = []
    x1, y1, x2, y2 = map(int, raw_input().split())
    p1 = (x1, y1); p2 = (x2, y2)
    for i in xrange(n):
        q1 = ps[i-1]; q2 = ps[i]
        if cross(p1, p2, q1) * cross(p1, p2, q2) <= 0:
            r = intersection(p1, p2, q1, q2)
            if r is not None:
                vs.append(r)
        if cross(p1, p2, q2) >= 0:
            vs.append(q2)
    print "%.09f" % calc_area(vs)

Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def cross_point(p0, p1, q0, q1):
    x0, y0 = p0; x1, y1 = p1
    x2, y2 = q0; x3, y3 = q1
    dx0 = x1 - x0; dy0 = y1 - y0
    dx1 = x3 - x2; dy1 = y3 - y2
    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if -EPS < sm < EPS:
        return None
    return x0 + s*dx0/sm, y0 + s*dy0/sm
EPS = 1e-9
def convex_cut(P, line):
    q0, q1 = line
    N = len(P)
    Q = []
    for i in range(N):
        p0 = P[i-1]; p1 = P[i]
        cv0 = cross3(q0, q1, p0)
        cv1 = cross3(q0, q1, p1)
        if cv0 * cv1 < EPS:
            v = cross_point(q0, q1, p0, p1)
            if v is not None:
                Q.append(v)
        if cv1 > -EPS:
            Q.append(p1)
    return Q
def polygon_area(P):
    s = 0
    N = len(P)
    for i in range(N):
        p0 = P[i-1]; p1 = P[i]
        s += p0[0]*p1[1] - p0[1]*p1[0]
    return abs(s) / 2
def solve():
    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]
    Q = int(readline())
    for i in range(Q):
        x0, y0, x1, y1 = map(int, readline().split())
        P0 = convex_cut(P, ((x0, y0), (x1, y1)))
        write("%.16f\n" % polygon_area(P0))
solve()
Buggy python submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
memo = [-1] * (n+1)
def dfs(rest):
    if memo[rest] != -1:
        return memo[rest]
    if rest == 0:
        return 0
    res = n+1
    for i in xrange(m):
        if c[i] <= rest:
            res = min(res, 1 + dfs(rest - c[i]))
    memo[rest] = res
    return res
print dfs(n)

Fixed submission:
n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
dp = [n+1] * (n+1)
dp[n] = 0
for rest in xrange(n, 0, -1):
    for i in xrange(m):
        if c[i] <= rest:
            dp[rest - c[i]] = min(dp[rest - c[i]], 1 + dp[rest])
print dp[0]
Buggy python submission (verdict: Runtime Error):
from bisect import *
n = input()
dp = [n+1]*(n+1)
dp[0] = -1
for i in xrange(n):
    a = input()
    idx = bisect(dp, a-1)
    dp[idx] = min(a, dp[idx])
print bisect(dp, n)-1

Fixed submission:
from bisect import *
import sys

def solve(N, A):
    INF = 10**10

    dp = [INF]*(N+1)
    dp[0] = -1
    for a in A:
        idx = bisect(dp, a-1)
        dp[idx] = min(a, dp[idx])
    return max(i for i in range(N+1) if dp[i] < INF)

N, *A = map(int, sys.stdin.read().split())
sys.stdout.write("%d\n" % solve(N, A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
*H, = map(int, input().split())
st = [(0, -1)]
ans = 0
for i in range(N):
    h = H[i]
    base = i
    while h <= st[-1][0]:
        h0, j = st.pop()
        ans = max(ans, (i-j)*h0)
        base = j
    st.append((h, base))
while st:
    h0, j = st.pop()
    ans = max(ans, (N-j)*h0)
print(ans)

Fixed submission:
N = int(input())
*H, = map(int, input().split())
st = [(0, -1)]
ans = 0
for i in range(N):
    h = H[i]
    base = i
    while st and h <= st[-1][0]:
        h0, j = st.pop()
        ans = max(ans, (i-j)*h0)
        base = j
    st.append((h, base))
while st:
    h0, j = st.pop()
    ans = max(ans, (N-j)*h0)
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
V, E, r = map(int, raw_input().split())
g = [[] for i in xrange(V)]
for i in xrange(E):
    s, t, d = map(int, raw_input().split())
    g[s].append((t, d))

INF = 10**10
dist = [INF]*V
que = [(0,r)]
dist[r] = 0
while que:
    c, v = heappop(que)
    if dist[v] < c:
        continue
    for t, cost in g[v]:
        if dist[v] + cost < dist[t]:
            dist[t] = dist[v] + cost
            heappush(que, (t, dist[t]))
for i in xrange(V):
    print dist[i] if dist[i]<INF else "INF"

Fixed submission:
class RadixHeap:
    __slots__ = ["data", "last", "siz", "used"]

    # (max_key - min_key) <= C
    def __init__(self, N, C):
        self.data = [[] for i in range(C.bit_length() + 1)]
        self.last = self.siz = 0
        self.used = [0]*N

    def push(self, x, key):
        #assert self.last <= x
        self.siz += 1
        self.data[(x ^ self.last).bit_length()].append((x, key))

    def pop(self):
        data = self.data
        used = self.used
        #assert self.siz > 0
        if not data[0]:
            i = 1
            while not data[i]:
                i += 1
            d = data[i]
            new_last, new_key = min(d)
            used[new_key] = 1
            for val in d:
                x, key = val
                if used[key]:
                    self.siz -= 1
                    continue
                data[(x ^ new_last).bit_length()].append(val)
            self.last = new_last
            data[i] = []
        else:
            new_last, new_key = data[0].pop()
            used[new_key] = 1
            self.siz -= 1
        return new_last, new_key

    def __len__(self):
        return self.siz

import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, M, s = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, readline().split())
    G[a].append((b, c))

INF = 10**18
def dijkstra(N, G, s):
    que = RadixHeap(N, 10**9 + 1)

    dist = [INF]*N
    dist[s] = 0
    que.push(0, s)
    while que:
        cost, v = que.pop()
        if dist[v] < cost:
            continue
        for w, c in G[v]:
            if cost + c < dist[w]:
                dist[w] = r = cost + c
                que.push(r, w)
    return dist

dist = dijkstra(N, G, s)
for c in dist:
    write("INF\n" if c == INF else "%d\n" % c)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = input()

C = [None]*n
P = [None]*n
for i in xrange(n):
    ipt = map(int, raw_input().split())
    C[i] = ipt[1:]
    for c in C[i]:
        P[c] = i
LEV = (n+1).bit_length()
parent = [[None]*(LEV + 1) for i in xrange(n)]
for i in xrange(n):
    parent[i][0] = P[i]
for k in xrange(1, LEV):
    for i in xrange(n):
        if parent[i][k] is None:
            parent[i][k+1] = None
        else:
            parent[i][k+1] = parent[parent[i][k]][k]
depth = [None]*n
deq = deque()
deq.append(0)
depth[0] = 0
while deq:
    v = deq.popleft()
    for c in C[v]:
        deq.append(c)
        depth[c] = depth[v] + 1

q = input()
for t in xrange(q):
    u, v = map(int, raw_input().split())
    if not depth[u] < depth[v]:
        u, v = v, u
    for k in xrange(LEV+1):
        if ((depth[v] - depth[u]) >> k) & 1:
            v = parent[v][k]
    if u == v:
        print u
        continue

    for k in xrange(LEV, -1, -1):
        if parent[u][k] != parent[v][k]:
            u = parent[u][k]
            v = parent[v][k]
    print parent[u][0]

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
G = [None]*N
for v in range(N):
    k, *G[v] = map(int, readline().split())

S = []

FS = [0]*N
depth = [0]*N

*it, = map(iter, G)
P = [-1]*N

stk = [0]
depth[0] = 0
FS[0] = 0
while stk:
    v = stk[-1]
    p = P[v]
    S.append(v)

    w = next(it[v], -1)
    while w != -1:
        if w != p:
            P[w] = v
            depth[w] = len(stk)
            FS[w] = len(S)
            stk.append(w)
            break
        w = next(it[v], -1)
    else:
        stk.pop()

L = len(S)
lg = [0]*(L + 1)
for i in range(2, L+1):
    lg[i] = lg[i >> 1] + 1
st = [None]*(lg[L] + 1)
st0 = st[0] = S
b = 1
for i in range(lg[L]):
    st0 = st[i+1] = [p if depth[p] <= depth[q] else q for p, q in zip(st0, st0[b:])]
    b <<= 1

def query(u, v):
    x = FS[u]; y = FS[v]
    if x > y:
        x, y = y, x
    l = lg[y - x + 1]
    px = st[l][x]; py = st[l][y - (1 << l) + 1]
    return px if depth[px] <= depth[py] else py

Q = int(readline())
ans = []
for q in range(Q):
    u, v = map(int, readline().split())
    ans.append(query(u, v))
write("\n".join(map(str, ans)))
write("\n")
Buggy python submission (verdict: Runtime Error):
pi = 3.1415926535897
r = int(input())
print(pi*r**2, 2*pi*r)


Fixed submission:
pi = 3.1415926535897
r = float(input())
print(pi*r**2, 2*pi*r)
Buggy python submission (verdict: Runtime Error):
S = [s.strip().replace("/","//") for s in open(0).readlines()][:-1]
print(*map(eval, S), sep='\n')


Fixed submission:
ans = []
for s in open(0).readlines():
    if "?" in s:
        break
    ans.append(eval(s.strip().replace("/", "//")))
print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
for i in xrange(1,10):
    for j in xrange(1,10):
        print('%sx%s=%s'%(i,j,i*j))

Fixed submission:
for i in xrange(1,10):
    for j in xrange(1,10):
        print '%sx%s=%s'%(i,j,i*j)
Buggy python submission (verdict: Runtime Error):
import math
while True:
    a,b = map(int,raw_input().split())
    print int(math.log10(a + b) + 1)

Fixed submission:
import math
while True:
    try:
        a,b = map(int,raw_input().split())
        print int(math.log10(a + b) + 1)
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
while True:
    a,b,c,d,e,f = map(int,raw_input().split())
    x = 0.; y = 0.
    delta = abs(a*e-b*d)
    x = float((e*c-b*f)/delta)
    y = float((a*f-d*c)/delta)

    print "%.3f %.3f" % (x,y)
    

Fixed submission:
while True:
    try:
        a,b,c,d,e,f = map(float,raw_input().split())
        delta =a*e-b*d
        x = (e*c-b*f)/delta
        y = (a*f-d*c)/delta
        if abs(x)<1e-3:
            x=0
        if abs(y)<1e-3:
            y=0
        #print str('%.3f' % x) + " " + str('%.3f' % y)
        print "%.3f %.3f" % (x,y)
    except EOFError:
        break
Buggy python submission (verdict: Time Limit Exceeded):
def euclid(m,n):
    while m%n>0:
        r=m%n
        m,n=n,r
    else:
        return n

def isprime_euclid2(N):

    if N==1:
        return False
    elif N==2:
        return True
    elif N>=3:
        euclid_list=[]
        for k in range(1,int(round(math.sqrt(N)))+1):
            euclid_list.append(euclid(N,k))
        temp=set(euclid_list)
        if len(temp)==1:
            return True
        else:
            return False   
        
import math
while True:
    n = int(raw_input())
    ans = 0
    for k in range(1,n+1):
        if isprime_euclid2(k):
            ans +=1
    print ans
    

Fixed submission:
def prime_table(n):
  list = [True for _ in xrange(n + 1)]
  i = 2
  while i * i <= n:
    if list[i]:
      j = i + i
      while j <= n:
        list[j] = False
        j += i
    i += 1

  table = [i for i in xrange(n + 1) if list[i] and i >= 2]
  return table

table = prime_table(999999)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
        
    m = 0
    for i in table:
        if i<=n:
            m+=1
        else:
            break
    print m
Buggy python submission (verdict: Runtime Error):
while True:
    w = int(raw_input())
    n = int(raw_input())
    ans = []
    ans = [j for j in range(1,w+1)]
    for k in range(n):
        a,b = map(int,(raw_input().split(",")))
        ans[a-1],ans[b-1] = ans[b-1],ans[a-1]
    for item in ans:
        print item

Fixed submission:
while True:
    try:
        w = int(raw_input())
        n = int(raw_input())
        ans = [j for j in range(1,w+1)]
        for k in range(n):
            a,b = map(int,(raw_input().split(",")))
            ans[a-1],ans[b-1] = ans[b-1],ans[a-1]
        for item in ans:
            print item
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
while True:
    try:
        ls = []
        dic = {}# {'your' : [appeared,len]}
        
        ls = raw_input().split()
        for k in range(len(ls)):
            if ls[k] not in dic.keys():
                dic[ls[k]] = []
                dic[ls[k]].append(1)
                dic[ls[k]].append(len(ls[k]))
            else:
                dic[ls[k]][0] += 1
        
        a=max(dic) # value[0]
        b=max(dic.items(), key=lambda x: x[1][1])[0]
        print "%s %s" % (a,b)
    except EOFError:
        break

Fixed submission:

wordlist = []
wordlist = raw_input().split()
dic = {}       
longest = ['',0]  
m = 0
for word in wordlist:    
    # mode
    if word not in dic:
        dic[word] = 1
    else:
        dic[word] += 1
    
    # word_length    
    if m == 0:
        longest[0] = word
        longest[1] = len(word)
        m += 1
    else:
        if len(word) > longest[1]:
            longest[0] = word
            longest[1] = len(word)

mode_key = sorted(dic.items(),key = lambda x:x[1],reverse=True)[0][0]                   
print '%s %s' % (mode_key,longest[0])

Buggy python submission (verdict: Runtime Error):
while True:
    try:
        ls = []
        dic = {}# {'your' : [appeared,len]}
        
        ls = raw_input().split()
        for k in range(len(ls)):
            if ls[k] not in dic.keys():
                dic[ls[k]] = []
                dic[ls[k]].append(1)
                dic[ls[k]].append(len(ls[k]))
            else:
                dic[ls[k]][0] += 1
        
        a=max(dic) # value[0]
        b=max(dic.items(), key=lambda x: x[1][1])[0]
        print "%s %s" % (a,b)
    except EOFError:
        break

Fixed submission:

wordlist = []
wordlist = raw_input().split()
dic = {}       
longest = ['',0]  
m = 0
for word in wordlist:    
    # mode
    if word not in dic:
        dic[word] = 1
    else:
        dic[word] += 1
    
    # word_length    
    if m == 0:
        longest[0] = word
        longest[1] = len(word)
        m += 1
    else:
        if len(word) > longest[1]:
            longest[0] = word
            longest[1] = len(word)

mode_key = sorted(dic.items(),key = lambda x:x[1],reverse=True)[0][0]                   
print '%s %s' % (mode_key,longest[0])
Buggy python submission (verdict: Runtime Error):
ls = []
while True:
    try:
        data = map(float,raw_input().split())
        ls.append(data)
    except EOFError:
        break
ls.sort()
ans = ls[-1]-ls[0]
print ans
    

Fixed submission:
ls = []
while True:
    try:
        data = float(raw_input())
        ls.append(data)
    except EOFError:
        break
        
print max(ls)-min(ls)

Buggy python submission (verdict: Runtime Error):
ls = []
while True:
    try:
        data = float(raw_input().split())
        ls.append(data)
    except EOFError:
        break
ls.sort()
ans = ls[-1]-ls[0]
print ans

Fixed submission:
ls = []
while True:
    try:
        data = float(raw_input())
        ls.append(data)
    except EOFError:
        break
        
print max(ls)-min(ls)