Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
H, W, M = map(int, input().split())
 

for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))
 
MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
 
H, W, M = map(int, input().split())
 
X = [0] * W
Y = [0] * H
Map = []
 
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))
 
MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ans = 0
for i in range(1,N+1):
    j = N//i
    ans += int(i*j*(j+1)/2)

print(ans)

Fixed submission:
N=int(input())

ans = 0
for i in range(1,N+1):
    j = N//i
    ans += i*j*(j+1)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        for j in xrange(v, N):
            a[j] += i
            b[j] -= i
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def go(a, x, y):
    if a[x][y] != '#':
        return []
    r = [(x, y)]
    while True:
        for tx, ty in ((x+1, y), (x, y+1)):
            if 0 <= tx < len(a) and 0 <= ty < len(a[0]) and a[tx][ty] == '#':
                x = tx
                y = ty
                break
        else:
            break
        r.append((x,y))
    return r


def main():
    R, C = srl(int)
    a = []
    for _ in xrange(R):
        a.append(rl())
    b = go(a, 0, 0)
    if not b or b[-1] != (R-1, C-1):
        print "Impossible"
        return
    s = sum(x.count('#') for x in a)
    print "Impossible" if s != len(b) else "Possible"

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        for j in xrange(v, N):
            a[j] += i
            b[j] -= i
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    inc = [0] * (N+1)
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        inc[v] += i
    s = 0
    for i in xrange(N):
        s += inc[i]
        a[i] += s
        b[i] -= s
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        for j in xrange(v, N):
            a[j] += i
            b[j] -= i
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    inc = [0] * (N+1)
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        inc[v] += i
    s = 0
    for i in xrange(N):
        s += inc[i]
        a[i] += s
        b[i] -= s
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import networkx as nx

R, C = [int(x) for x in input().split()]
grid = [list(input()) for r in range(R)]


def pack(r, c):
    return r * C + c


graph = nx.Graph()
for r in range(R - 1):
    for c in range(C - 1):
        if grid[r][c] == grid[r + 1][c] == ".":
            graph.add_edge(pack(r, c), pack(r + 1, c))
        if grid[r][c] == grid[r][c + 1] == ".":
            graph.add_edge(pack(r, c), pack(r, c + 1))

matching = nx.bipartite.maximum_matching(graph)

count = 0
for u, v in matching.items():
    if u > v:
        assert matching[v] == u
        r1, c1 = divmod(u, C)
        r2, c2 = divmod(v, C)
        if r1 == r2:
            if c1 > c2:
                c1, c2 = c2, c1
            grid[r1][c1], grid[r2][c2] = ">", "<"
        elif c1 == c2:
            if r1 > r2:
                r1, r2 = r2, r1
            grid[r1][c1] = "v"
            grid[r2][c2] = "^"
        count += 1

print(count)
for row in grid:
    print("".join(row))



Fixed submission:
import networkx as nx

R, C = [int(x) for x in input().split()]
grid = [list(input()) for r in range(R)]


def pack(r, c):
    return r * C + c


graph = nx.Graph()
top_nodes = set()  # top half of the bipartite graph
for r in range(R):
    for c in range(C):
        if r + 1 < R and grid[r][c] == grid[r + 1][c] == ".":
            u, v = pack(r, c), pack(r + 1, c)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)
        if c + 1 < C and grid[r][c] == grid[r][c + 1] == ".":
            u, v = pack(r, c), pack(r, c + 1)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)


matching = nx.bipartite.maximum_matching(graph, top_nodes=top_nodes)

count = 0
for u, v in matching.items():
    if u > v:
        assert matching[v] == u
        r1, c1 = divmod(u, C)
        r2, c2 = divmod(v, C)
        if r1 == r2:
            if c1 > c2:
                c1, c2 = c2, c1
            grid[r1][c1], grid[r2][c2] = ">", "<"
        elif c1 == c2:
            if r1 > r2:
                r1, r2 = r2, r1
            grid[r1][c1] = "v"
            grid[r2][c2] = "^"
        count += 1

print(count)
for row in grid:
    print("".join(row))
Buggy python submission (verdict: Runtime Error):

import networkx as nx

import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, D = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for i in range(N)]


graph = nx.DiGraph()


# a_i = 0 means choose x, a_i = 1 means choose y
# Store i for a_i==0 and i+N for a_i==1
for i, (x1, y1) in enumerate(XY):
    for j in range(N):
        if i != j:
            x2, y2 = XY[j]
            if abs(x1 - x2) < D:
                # a_i==0 => a_j==1
                graph.add_edge(i, j + N)
            if abs(x1 - y2) < D:
                # a_i==0 => a_j==0
                graph.add_edge(i, j)
            if abs(y1 - x2) < D:
                # a_i==1 => a_j==1
                graph.add_edge(i + N, j + N)
            if abs(y1 - y2) < D:
                # a_i==1 => a_j==0
                graph.add_edge(i + N, j)


SCC = nx.algorithms.components.strongly_connected_components(graph)
assignment = {}
for comp in SCC:
    for x in comp:
        if (x < N and x + N in comp) or (x >= N and x - N in comp):
            print("No")
            exit()
        if x not in assignment:
            assignment[x] = True
            assignment[(x + N) % (2 * N)] = False
print("Yes")
for i in range(N):
    print(XY[i][0] if assignment[i] else XY[i][1])


Fixed submission:
import networkx as nx

import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, D = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for i in range(N)]

graph = nx.DiGraph()
for i in range(2 * N):
    graph.add_node(i)

# f_i = 0 means choose x for flag i, f_i = 1 means choose y
# Node i is (f_i==0), node (i+N) is (f_i==1)
for i, (x1, y1) in enumerate(XY):
    for j in range(N):
        if i != j:
            x2, y2 = XY[j]
            if abs(x1 - x2) < D:
                # f_i==0 => f_j==1
                graph.add_edge(i, j + N)
            if abs(x1 - y2) < D:
                # f_i==0 => f_j==0
                graph.add_edge(i, j)
            if abs(y1 - x2) < D:
                # f_i==1 => f_j==1
                graph.add_edge(i + N, j + N)
            if abs(y1 - y2) < D:
                # f_i==1 => f_j==0
                graph.add_edge(i + N, j)


SCC = nx.algorithms.components.strongly_connected_components(graph)
assignment = {}
for comp in SCC:
    for x in comp:
        if (x < N and x + N in comp) or (x >= N and x - N in comp):
            print("No")
            exit()
        if x not in assignment:
            assignment[x] = True
            assignment[(x + N) % (2 * N)] = False

print("Yes")
for i in range(N):
    print(XY[i][0] if assignment[i] else XY[i][1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
n_data = {i: A.count(i) for i in range(1, 10 ** 5 + 1)}
ans = sum(A)
for _ in range(Q):
  b, c = map(int, input().split())
  ans += (c - b) * n_data[b]
  n_data[c] += n_data[b]
  n_data[b] = 0
  print(ans)

Fixed submission:
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
n_data = Counter(A)
ans = sum(A)
for _ in range(Q):
  b, c = map(int, input().split())
  ans += (c - b) * n_data[b]
  n_data[c] += n_data[b]
  n_data[b] = 0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
n_data = {i: A.count(i) for i in range(1, 10 ** 5 + 1)}
for _ in range(Q):
  b, c = map(int, input().split())
  n_data[c] += n_data[b]
  n_data[b] = 0
  print(sum([k * v for k, v in n_data.items()]))

Fixed submission:
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
n_data = Counter(A)
ans = sum(A)
for _ in range(Q):
  b, c = map(int, input().split())
  ans += (c - b) * n_data[b]
  n_data[c] += n_data[b]
  n_data[b] = 0
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * pow(26, -1, mod)) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

Fixed submission:
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
div = pow(26, -1, mod)
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * div) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i)) % mod
  comb_i = (comb_i * 25) % mod
  comb_i = (comb_i * pow(i, -1, mod)) % mod
  comb_i = (comb_i * pow(26, -1, mod)) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

Fixed submission:
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
div = pow(26, -1, mod)
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * div) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = ((comb_i * (N - 1 + i) * 25) * pow(i, -1, mod) * pow(26, -1, mod)) % mod
  ans += comb_i
  
print(ans % mod)

Fixed submission:
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
div = pow(26, -1, mod)
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * div) % mod
  ans = (ans + comb_i) % mod
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
comb_i = 26 ** K
ans = comb_i
for i in range(1, K + 1):
  comb_i *= (N + i - 1) * 25
  comb_i //= i * 26
  ans += comb_i
  
print(ans % mod)

Fixed submission:
K = int(input())
N = len(input())

mod = 10 ** 9 + 7
div = pow(26, -1, mod)
comb_i = pow(26, K, mod)
ans = comb_i
for i in range(1, K + 1):
  comb_i = (comb_i * (N - 1 + i) * pow(i, -1, mod)) % mod
  comb_i = (comb_i * 25 * div) % mod
  ans = (ans + comb_i) % mod
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Fixed submission:
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
ans = 1
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Fixed submission:
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
ans = 1
A = list(map(int, input().split()))
if 0 in A:
  ans = 0
else:
  for a in A:
    ans *= a
ans = -1 if ans > 10 ** 18 else ans
print(ans)

Fixed submission:
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
ans = 1
A = map(int, input().split())
for a in A:
  ans *= a
ans = -1 if ans > 10 ** 18 else ans
print(ans)

Fixed submission:
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
ans = 1
for _ in range(N):
  a = int(input())
  ans *= a
ans = -1 if ans > 10 ** 18 else ans
print(ans)

Fixed submission:
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
print((A * B) // 1)

Fixed submission:
import decimal
A, B = map(decimal.Decimal, input().split())
print(int(A*B))
Buggy python submission (verdict: Runtime Error):
A, B = map(lambda x: int(x) - 1, input().split())

if B == 0:
  ans == 0
elif B % A == 0:
  ans = B // A
else:
  ans = B // A + 1
  
print(ans)

Fixed submission:
A, B = map(lambda x: int(x) - 1, input().split())

if B == 0:
  ans = 0
elif B % A == 0:
  ans = B // A
else:
  ans = B // A + 1
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(lambda x: 2 * int(x), input().split())

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(mounts))

Fixed submission:
N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

all_mount = sum(A)
mounts = []
for i in range(N):
  mount = all_mount
  for j in range(0, N-1, 2):
    mount -= 2 * A[(i+j+1)%N]
  mounts.append(mount)
    
print(" ".join(map(str,mounts)))

Fixed submission:
N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

all_mount = sum(A)
mounts = []
for i in range(N):
  mount = all_mount
  for j in range(0, N, 2):
    mount -= 2 * A[(i+j)%N]
  mounts.append(abs(mount))
    
print(" ".join(map(str,mounts)))

Fixed submission:
N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def cmb(n, r):
  if n == r:
    return 1
  return math.factorial(n % (10**9+7)) // math.factorial((n-r) % (10**+7)) // math.factorial(r % (10**9+7))

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

for i in range(K):
  C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  print(C)

Fixed submission:
import math

def cmb(n, r):
  if n == r:
    return 1
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

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

for i in range(K):
  if (N-K+1) < i + 1:
    print(0)
  else:
  	C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  	print(C)

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

def cmb(n, r):
  if r == 0 or n == r:
    return 1
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

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

for i in range(K):
  C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  print(C)

Fixed submission:
import math

def cmb(n, r):
  if n == r:
    return 1
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

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

for i in range(K):
  if (N-K+1) < i + 1:
    print(0)
  else:
  	C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  	print(C)
Buggy python submission (verdict: Runtime Error):
n = raw_input()

n.translate(str.maketrans({'1': '9', '9': '1'}))
print n

Fixed submission:
n = input()

print(n.translate(str.maketrans({'1': '9', '9': '1'})))
Buggy python submission (verdict: Runtime Error):
s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w)):
  result += s[i * w]
  
if w != 1:
  result += s[i * w + w]
print result

Fixed submission:
s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w)):
  result += s[i * w]
  
if len(s) % w != 0:
  result += s[-(len(s) % w)]
print result

Buggy python submission (verdict: Runtime Error):
s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w) + 1):
  result += s[i * w]

print result

Fixed submission:
s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w)):
  result += s[i * w]
  
if len(s) % w != 0:
  result += s[-(len(s) % w)]
print result
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
if N %= 2 == 0:
  print N
else:
  print N * 2

Fixed submission:
N = int(raw_input())
if N % 2 == 0:
  print N
else:
  print N * 2
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
a = map(int, raw_input().split())
number = 0

for i in xrange(n):
  while a[n] % 2 == 0:
    number += 1
    a[n] /= 2
    
print number

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
number = 0

for i in xrange(n):
  while a[i] % 2 == 0:
    number += 1
    a[i] /= 2
    
print number
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9+7


def inv(x):
    return pow(x, mod - 2, mod)


r1, c1, r2, c2 = map(int, input().split())
fact, inv_fact = [1, 1], [1, 1]
for i in range(2, r2+c2+3):
    fact.append(fact[-1] * i % mod)
    inv_fact.append(inv(fact[-1]))


def nCr(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n-r] % mod


def path_sum_sum(r, c):
    return ((r + 2) * nCr(c+r+2, r+2) % mod + mod - c - 1) * inv(c + 1) % mod


ans = (path_sum_sum(r2, c2) + mod - path_sum_sum(r2, c1-1) +
       mod - path_sum_sum(r1-1, c2) + path_sum_sum(r1-1, c1-1))
print(ans % mod)


Fixed submission:
mod = 10 ** 9+7


def inv(x):
    return pow(x, mod - 2, mod)


r1, c1, r2, c2 = map(int, input().split())
fact, inv_fact = [1, 1], [1, 1]
for i in range(2, r2+c2+3):
    fact.append(fact[-1] * i % mod)
    inv_fact.append(inv(fact[-1]))


def nCr(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n-r] % mod


def path_sum_sum(r, c):
    return ((r + 2) * nCr(c+r+2, r+2) % mod + mod - c - 1) * inv(c + 1) % mod


ans = (path_sum_sum(r2, c2) + mod - path_sum_sum(r2, c1-1) +
       mod - path_sum_sum(r1-1, c2) + path_sum_sum(r1-1, c1-1))
print(ans % mod)