Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    """
    道を全部張った後に最小全域木を求めれば良いー＞プリム
    """
    N = int(input())
    city = {}
    for i in range(N):
        x, y = map(int, input().split())
        city[i] = x * 10**10 + y
    unvisited = set([i for i in range(1, N)])
    ans = 0
    q = []
    # qに頂点0から延びる道を追加
    for i in range(1, N):
        x0, y0 = city[0] // 10**10, city[0] % 10**10
        x, y = city[i] // 10**10, city[i] % 10**10
        cost = min(abs(x - x0), abs(y - y0))
        heappush(q, (cost, i))
    while q:
        cost, v = heappop(q)
        if v not in unvisited: continue
        ans += cost
        unvisited.remove(v)
        if not unvisited: break
        for u in unvisited:
            xv, yv = city[v] // 10**10, city[v] % 10**10
            xu, yu = city[u] // 10**10, city[u] % 10**10
            cost = min(abs(xv - xu), abs(yv - yu))
            heappush(q, (cost, u))
    print(ans)





if __name__ == "__main__":
    main()


Fixed submission:
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    """
    道を全部張った後に最小全域木を求めれば良いー＞プリム
    """
    N = int(input())
    city_x = defaultdict(list)
    city_y = defaultdict(list)
    indexes_x = set()
    indexes_y = set()
    for v in range(N):
        x, y = map(int, input().split())
        city_x[x].append(v)
        city_y[y].append(v)
        indexes_x.add(x)
        indexes_y.add(y)
    indexes_x = list(indexes_x)
    indexes_y = list(indexes_y)
    indexes_x.sort()
    indexes_y.sort()

    # 必要な道のみに間引く
    repn = [[] for _ in range(N)]
    pre_x = -1
    for x in indexes_x:
        pre_v = city_x[x][0]
        for i, v in enumerate(city_x[x]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_x != -1:
            repn[city_x[pre_x][0]].append((x - pre_x, pre_v))
            repn[pre_v].append((x - pre_x, city_x[pre_x][0]))
        pre_x = x
    pre_y = -1
    for y in indexes_y:
        pre_v = city_y[y][0]
        for i, v in enumerate(city_y[y]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_y != -1:
            repn[city_y[pre_y][0]].append((y - pre_y, pre_v))
            repn[pre_v].append((y - pre_y, city_y[pre_y][0]))
        pre_y = y
    # for i in range(N): print(repn[i])

    # プリム
    unvisited = set([i for i in range(1, N)])
    ans = 0
    q = []
    for cost, v in repn[0]: heappush(q, (cost, v))
    while q:
        cost, v = heappop(q)
        if v not in unvisited: continue
        ans += cost
        unvisited.remove(v)
        if not unvisited: break
        for next_cost, u in repn[v]:
            if u not in unvisited: continue
            heappush(q, (next_cost, u))
    print(ans)





if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    ok = [i for i in range(10) if i not in D]
    N = str(N)
    l = len(N)
    if {i for i in range(int(N[0]), 10)} <= D:
        if ok[0] == 0:
            ans = ok[1] * 10 ** l
            print(ans)
    else:
        ans = 0
        for c in N:
            ans *= 10
            idx = bisect_left(ok, int(c))
            ans += ok[idx]
        print(ans)




if __name__ == "__main__":
    main()


Fixed submission:
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    while True:
        check = True
        for c in str(N):
            if int(c) in D:
                check = False
        if check:
            print(N)
            return
        N += 1


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(10**5)

def main():
    H, W, A, B = map(int, input().split())
    ans = 0
    for i in range(1, H - A + 1):
        ans += comb(i + B - 2, i - 1) * comb(H - i + W - B - 1, H - i)
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(10**6)

def main():
    H, W, A, B = map(int, input().split())
    ans = 0
    for i in range(1, H - A + 1):
        ans += comb(i + B - 2, i - 1) * comb(H - i + W - B - 1, H - i)
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
  n = int(input())
  pirnt(n**3)
  
main()

Fixed submission:
def main():
  n = int(input())
  print(n**3)
  
main()
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
A = list(map(int, input().split()))
m = max(A)
c = [0] * (m+1)
for i in A:
  c[i] += 1

pairwise = True
for i in range(2,m+1,1):
  cnt = 0
  for j in range(i,m+1,i):
    cnt += c[j]
  if cnt > 1:
    pairwise = False
if pairwise:
  print("pairwise coprime")
  exit()

g = 0
for i in range(N):
  g = math.gcd(g,A[i])
if g == 1:
  print("setwise coprime")
  exit()
print("not coprime")

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
m = max(A)
c = [0] * (m+1)
for i in A:
  c[i] += 1

pairwise = True
for i in range(2,m+1,1):
  cnt = 0
  for j in range(i,m+1,i):
    cnt += c[j]
  if cnt > 1:
    pairwise = False
if pairwise:
  print("pairwise coprime")
  exit()

g = 0
for i in range(N):
  g = math.gcd(g,A[i])
if g == 1:
  print("setwise coprime")
  exit()
print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

di = [-1,0,1,0]
dj = [0,-1,0,1]

H,W = map(int, input().split())
si,sj = map(int, input().split())
ti,tj = map(int, input().split())
si -= 1
sj -= 1
ti -= 1
tj -= 1
inf = 10**9
s = list()
for i in range(H):
  s.append(input())

dist = [[inf]*W for i in range(H)]
q = deque()
dist[si][sj] = 0
q.append([si,sj])

while len(q) > 0:
  tmp = q.popleft()
  i = tmp[0]
  j = tmp[1]
  d = dist[i][j]
  if dist[i][j] != d:
    continue
  for v in range(4):
    ni = i + di[v]
    nj = j + dj[v]
    if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
      continue
    if s[ni][nj] == "#":
      continue
    if dist[ni][nj] <= d:
      continue
    dist[ni][nj] = d
    q.appendleft([ni,nj])
  
  for ei in range(-2,3,1):
    for ej in range(-2,3,1):
      ni = i+ei
      nj = j+ej
      if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
        continue
      if s[ni][nj] == "#":
        continue
      if dist[ni][nj] <= d+1:
        continue
      dist[ni][nj] = d + 1
      q.append([ni,nj])
      
ans = dist[ti][tj]
if ans == inf:
  ans = -1
print(ans)


Fixed submission:
from collections import deque

di = [-1,0,1,0]
dj = [0,-1,0,1]

H,W = map(int, input().split())
si,sj = map(int, input().split())
ti,tj = map(int, input().split())
si -= 1
sj -= 1
ti -= 1
tj -= 1
inf = 10**9
s = list()
for i in range(H):
  s.append(input())

dist = [[inf]*W for i in range(H)]
q = deque()
dist[si][sj] = 0
q.append([si,sj])

while len(q) > 0:
  tmp = q.popleft()
  i = tmp[0]
  j = tmp[1]
  d = dist[i][j]
  if dist[i][j] != d:
    continue
  for v in range(4):
    ni = i + di[v]
    nj = j + dj[v]
    if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
      continue
    if s[ni][nj] == "#":
      continue
    if dist[ni][nj] <= d:
      continue
    dist[ni][nj] = d
    q.appendleft([ni,nj])
  
  for ei in range(-2,3,1):
    for ej in range(-2,3,1):
      ni = i+ei
      nj = j+ej
      if (ni < 0) or (ni >= H) or (nj < 0) or (nj >= W):
        continue
      if s[ni][nj] == "#":
        continue
      if dist[ni][nj] <= d+1:
        continue
      dist[ni][nj] = d + 1
      q.append([ni,nj])
      
ans = dist[ti][tj]
if ans == inf:
  ans = -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M = map(int,input().split())

hs = [0] * H
ws = [0] * W
s = list()
for i in range(M):
  h,w = map(int, input().split())
  hs[h-1] += 1
  ws[w-1] += 1
  s.append([h-1,w-1])
  
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])
  
i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)

ans = mh + mw
for i in i_s:
  for j in j_s:
    if [i,j] in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

Fixed submission:
H,W,M = map(int,input().split())
hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  r,c = map(int,input().split())
  r -= 1
  c -= 1
  hs[r] += 1
  ws[c] += 1
  s.add((r,c))
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])

i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
hNum = [0]*H
wNum = [0]*W
bom = [[0] * W for i in range(H)]
for i in range(M):
  h,w = map(int, input().split())
  bom[h-1][w-1] = 1
  hNum[h-1] += 1
  wNum[w-1] += 1

hmax = max(hNum)
wmax = max(wNum)
ans = hmax + wmax
if bom[hNum.index(hmax)][wNum.index(wmax)] == 1:
  ans -= 1

print(ans)

Fixed submission:
H,W,M = map(int,input().split())
hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  r,c = map(int,input().split())
  r -= 1
  c -= 1
  hs[r] += 1
  ws[c] += 1
  s.add((r,c))
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])

i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
hNum = [0]*H
wNum = [0]*W
bom = [[0] * W for i in range(H)]
for i in range(M):
  h,w = map(int, input().split())
  bom[h-1][w-1] = 1
  hNum[h-1] += 1
  wNum[w-1] += 1

ans = 0
for i in range(H):
  for j in range(W):
    if bom[i][j] == 1:
      ans = max(ans, hNum[i]+wNum[j]-1)
    else:
      ans = max(ans, hNum[i]+wNum[j])

print(ans)

Fixed submission:
H,W,M = map(int,input().split())
hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  r,c = map(int,input().split())
  r -= 1
  c -= 1
  hs[r] += 1
  ws[c] += 1
  s.add((r,c))
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])

i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
1000000000000000 1000000000000000 1000000000000000

Fixed submission:
X,K,D = map(int, input().split())
absX = abs(X)
ans = 0
if absX//D > K:
  ans = absX - D*K
else:
  if (absX//D)%2 == (K%2):
    ans = absX%D
  else:
    posX = absX%D+D
    negX = abs(absX%D-D)
    if posX < negX:
      ans = posX
    else:
      ans = negX
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
PList = list(map(int, input().split()))
CList = list(map(int, input().split()))

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  l = 0
  while(1):
    x = PList[x]-1
    s.append(CList[x])
    l += 1
    total += CList[x]
    if x == si:
      break
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)
    

Fixed submission:
N,K = map(int, input().split())
PList = list(map(int, input().split()))
CList = list(map(int, input().split()))

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  l = 0
  while(1):
    x = PList[x]-1
    s.append(CList[x])
    l += 1
    total += CList[x]
    if x == si:
      break
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)

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

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  while(1):
    x = PList[x]-1
    s.append(CList[x])
    total += CList[x]
    if x == si:
      break
  l = len(s)
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)
    

Fixed submission:
N,K = map(int, input().split())
PList = list(map(int, input().split()))
CList = list(map(int, input().split()))

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  l = 0
  while(1):
    x = PList[x]-1
    s.append(CList[x])
    l += 1
    total += CList[x]
    if x == si:
      break
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
PList = list(map(int, input().split()))
CList = list(map(int, input().split()))
for i in range(N):
  PList[i] -= 1

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  while(1):
    x = PList[x]
    s.append(CList[x])
    total += CList[x]
    if x == si:
      break
  l = len(s)
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)
    

Fixed submission:
N,K = map(int, input().split())
PList = list(map(int, input().split()))
CList = list(map(int, input().split()))

ans = -1*(10**18)
for si in range(N):
  x = si
  s = list()
  total = 0
  l = 0
  while(1):
    x = PList[x]-1
    s.append(CList[x])
    l += 1
    total += CList[x]
    if x == si:
      break
  t = 0
  for i in range(l):
    t += s[i]
    if i+1 > K:
      break
    now = t
    if total > 0:
      e = (K-i-1)//l
      now += total*e
    ans = max(ans, now)  
print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//L
else:
  L = 9*K
  
t = 1
ans = -1
for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L
print(ans)

Fixed submission:
K = int(input())

if K%7 == 0:
  L = 9*K/7
else:
  L = 9*K
s = 1

for i in range(1, 9*(10**6)+1):
  s = s*10%L
  if s == 1:
    print(i)
    exit()

print("-1")

Buggy python submission (verdict: Runtime Error):
K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//L
else:
  L = 9*K
  
t = 1
ans = 0
for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L
print(ans)

Fixed submission:
K = int(input())

if K%7 == 0:
  L = 9*K/7
else:
  L = 9*K
s = 1

for i in range(1, 9*(10**6)+1):
  s = s*10%L
  if s == 1:
    print(i)
    exit()

print("-1")
Buggy python submission (verdict: Runtime Error):
N = int(input())
AList = list(map(int, input().split()))
Q = int(input())
dp = [0]*(10**5)
total = 0
for i in AList:
  dp[i] += 1
  total += i
  
for i in range(Q):
  B,C = map(int, input().split())
  bNum = dp[B]
  dp[B] = 0
  dp[C] += bNum
  cNum = dp[C]
  total = total - B*bNum + C*bNum
  print(total)

Fixed submission:
N = int(input())
AList = list(map(int, input().split()))
Q = int(input())
dp = [0]*(10**5+1)
total = 0
for i in AList:
  dp[i] += 1
  total += i
  
for i in range(Q):
  B,C = map(int, input().split())
  bNum = dp[B]
  dp[B] = 0
  dp[C] += bNum
  cNum = dp[C]
  total = total - B*bNum + C*bNum
  print(total)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul
N = int(input())
numList = list(map(int, input().split()))
ans = reduce(mul, numList)
print(ans) if ans <= 10**18 else print("-1")

Fixed submission:
import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numList = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= numList[i]
  if ans == 0:
    break
print(ans) if ans <= 10**18 else print("-1")

Fixed submission:
import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(float, input().split())
ans = Decimal(A)*Decimal(B)
print(int(ans))

Fixed submission:
from decimal import Decimal
A,B = input().split()
print(int(int(A)*Decimal(B)))
Buggy python submission (verdict: Time Limit Exceeded):
def prime_factorization(N):
  n = int(N**0.5)
  primeList = [i if i != 1 else 2 for i in range(1, n, 2) ]
  for data in primeList:
    primeList = [x for x in primeList if (x == data or x%data != 0)]
  return primeList
 
N = int(input())
ans = 0
 
primeList = prime_factorization(N)

for p in primeList:
  e = 1
  while N % p == 0:
    if N % p ** e == 0:
      N //= p ** e
      e += 1
      ans += 1
    else:
      N = N / p
    
print(ans)

Fixed submission:
N = int(input())
 
def prime_factorization(N):
  n = int(N**0.5)+1
  numList = [i if i != 1 else 2 for i in range(1, n, 2) ]
  primeList = [2]
  ansDict = {}
  idx = 0
  for data in numList:
    for x in primeList:
      if (data%x != 0 or x == 2):
        count = 0
        while N%data == 0:
          count += 1
          N //= data
        if count > 0:
          ansDict[data] = count
        if N == 1:
          return ansDict
        if x != 2:
          primeList.append(data)
        break
  if N != 1:
    ansDict[N] = 1
  
  return ansDict 

if N <= 1:
  print(0)
  exit()
  
ansDict = prime_factorization(N)
ansCount = 0
for p,v in ansDict.items():
  e = 1
  while e <= v:
    ansCount += 1
    v -= e 
    e += 1  

print(ansCount)
Buggy python submission (verdict: Runtime Error):
N = int(input())
listA = [0] * N
listB = [0] * N
idx = 0
for i in range(N):
  listA[idx],listB[idx] = map(int, input().split())
  idx += 1

medianA = 0
medianB = 0
ans = 0
if N%2 == 0:
  medianA = statistics.median(listA)
  medianB = statistics.median(listB)
  ans = (medianB - medianA) * 2 + 1
else:
  medianA = statistics.median(listA)
  medianB = statistics.median(listB)
  ans = medianB - medianA + 1

print(int(ans))

Fixed submission:
import statistics
import math

N = int(input())
listA = [0] * N
listB = [0] * N
idx = 0
for i in range(N):
  listA[idx],listB[idx] = map(int, input().split())
  idx += 1

medianA = 0
medianB = 0
ans = 0
if N%2 == 0:
  medianA = statistics.median(listA)
  medianB = statistics.median(listB)
  ans = (medianB - medianA) * 2 + 1
else:
  medianA = statistics.median(listA)
  medianB = statistics.median(listB)
  ans = medianB - medianA + 1

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
A=0
B=0
while(True):
  while(True):
    if (A**5) - (B**5) == X:
      print("{} {}".format(A,B))
      exit()
    elif ((-1*A)**5) - (B**5) == X:
      print("{} {}".format(-1*A,B))
      exit()
    elif (A**5) - ((-1*B)**5) == X:
      print("{} {}".format(A,-1*B))
      exit()   
    elif ((-1*A)**5) - ((-1*B)**5) == X:
      print("{} {}".format(-1*A,-1*B))
      exit()
    else:
      B += 1
  A += 1

Fixed submission:
X = int(input())
for A in range(130):
  for B in range(130):
    if (A**5) - (B**5) == X:
      print("{} {}".format(A,B))
      exit()
    elif ((-1*A)**5) - (B**5) == X:
      print("{} {}".format(-1*A,B))
      exit()
    elif (A**5) - ((-1*B)**5) == X:
      print("{} {}".format(A,-1*B))
      exit()   
    elif ((-1*A)**5) - ((-1*B)**5) == X:
      print("{} {}".format(-1*A,-1*B))
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
hList = list(map(int, input().split()))
count = 0
nList = [ i + hList[i] for i in range(len(hList))]

for i in range(N):
  tmpVal = i - hList[i]
  count += nList.count(tmpVal)

print(count)

Fixed submission:
import collections

N = int(input())
hList = list(map(int, input().split()))
count = 0
n_p = collections.Counter([ i + hList[i] for i in range(len(hList))])

for i in range(N):
  if i - hList[i] > 0:
    count += n_p.get(i - hList[i], 0)

print(count)

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

for i in range(N):
  for j in range(i+1,N):
    if (j-i) == (hList[i]+hList[j]):
      count += 1
print(count)

Fixed submission:
import collections

N = int(input())
hList = list(map(int, input().split()))
count = 0
n_p = collections.Counter([ i + hList[i] for i in range(len(hList))])

for i in range(N):
  if i - hList[i] > 0:
    count += n_p.get(i - hList[i], 0)

print(count)

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

for i in range(N):
  for j in range(i,N):
    if (j-i) == (hList[i]+hList[j]):
      count += 1
print(count)

Fixed submission:
import collections

N = int(input())
hList = list(map(int, input().split()))
count = 0
n_p = collections.Counter([ i + hList[i] for i in range(len(hList))])

for i in range(N):
  if i - hList[i] > 0:
    count += n_p.get(i - hList[i], 0)

print(count)