Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

h = {}
for c in "MARCH":
    h[c] = 0

n = int(input())
for i in range(n):
    s = input().strip()
    h[s[0]] += 1
#print(h)

import itertools
ans = 0
for i,j,k in itertools.combinations("MARCH", 3):
    ans += h[i]*h[j]*h[k]
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline

n = int(input())
a = [0]*5
for i in range(n):
    s = input().strip()
    c = s[0]
    if c == "M":
        a[0] += 1
    elif c == "A":
        a[1] += 1
    elif c == "R":
        a[2] += 1
    elif c == "C":
        a[3] += 1
    elif c == "H":
        a[4] += 1
#print(a)

ans = 0
for i in range(0, len(a)-2):
    for j in range(i+1, len(a)):
        for k in range(j+1, len(a)):
#            print(i,j,k, a[i]*a[j]*a[k])
            ans += a[i]*a[j]*a[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


def main():
    H, W, D = map(int, input().split())
    A = []
    d = [0]*(H*W)
    for h in range(H):
        a = list(map(int, input().split()))
        A.append(a)
        for i, x in enumerate(a):
            d[x-1] = h*W + i
    Q = int(input())
    for q in range(Q):
        ans = 0
        l, r = map(int, input().split())
        while l != r:
            ans += abs(d[l-1]//W - d[l+D-1]//W) + abs(d[l-1]%W - d[l+D-1]%W)
            l += D
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    H, W, D = map(int, input().split())
    A = []
    d = [0]*(H*W)
    for h in range(H):
        a = list(map(int, input().split()))
        A.append(a)
        for i, x in enumerate(a):
            d[x-1] = h*W + i
    mp = [0]*(H*W)
    for i in range(H*W):
        if i >= D:
            mp[i] = mp[i-D] + abs(d[i]//W - d[i-D]//W) + abs(d[i]%W - d[i-D]%W)
    Q = int(input())
    for q in range(Q):
        ans = 0
        l, r = map(int, input().split())
        print(mp[r-1] - mp[l-1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    C = []
    S = []
    F = []
    for _ in range(N-1):
        c,s,f = map(int,input().split())
        C.append(c)
        S.append(s)
        F.append(f)
    
    for i in range(N-1):
        t = 0
        for j in range(i,N-1):
            wait = 0
            if t <= S[j]:
                wait = S[j] - t
            else:
                x = S[j]
                while x < t:
                    x += F[j]
                wait = x - t
            t += wait + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline
import math

def main():
    N = int(input())
    C = []
    S = []
    F = []
    for _ in range(N-1):
        c,s,f = map(int,input().split())
        C.append(c)
        S.append(s)
        F.append(f)
    
    for i in range(N-1):
        t = 0
        for j in range(i,N-1):
            k = max(0, math.ceil((t - S[j])/F[j]))
            t = S[j] + k*F[j] + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import fractions
input=sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

ans = 0
k = 0
for i in a:
    for j in b:
        if j <= i:
            continue
        for k in range(len(c)):
            if j < c[k]:
                ans += (n - k)
                break
print(ans)


Fixed submission:
import sys
import fractions
import bisect
input=sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

ans = 0
k = 0
for j in b:
    ai = bisect.bisect_left(a, j)
    ci = n - bisect.bisect_right(c, j)
    ans += ai * ci
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = []
for i in range(N):
    x = int(input())
    if x in a:
        a.remove(x)
    else:
        a.append(x)
print(len(a))


Fixed submission:
N = int(input())

a = {}
for i in range(N):
    x = input()
    if x in a:
        del a[x]
    else:
        a[x] = 0
print(len(a))
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import collections

input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = collections.defaultdict(int)
    for a in A:
        d[a] += 1
    for k,v in list(d.items()):
        if v < 2:
            d.pop(k)
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)
    if len(d) >= 1 and d[0][1] >= 4:
        print(d[0][0]**2)
    elif len(d) >= 2:
        print(d[0][0]*d[1][0])
    else:
        print(0)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = collections.defaultdict(int)
    for a in A:
        d[a] += 1
    for k,v in list(d.items()):
        if v < 2:
            d.pop(k)
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)
    if len(d) >= 1 and d[0][1] >= 4:
        print(d[0][0]**2)
    elif len(d) >= 2:
        print(d[0][0]*d[1][0])
    else:
        print(0)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

# 頂点 s からの最短距離を求める (存在しないときはinf) O(|w|log|n|)
# n: 頂点数, w: 辺の数, cost[u][v]: 辺uvのコスト (cost が dict の場合 cost[(u,v)] など適宜)
# 前提条件: u < v
def dijkstra(s,n,w,cost):
    d = [float("inf")] * n # s からの距離
    d[s] = 0
    used = [False] * n # 使用済みの頂点か
    
    while True:
        v = -1
        # 未使用の頂点のうち、最小の距離のものを探す
        for i in range(n):
            if used[i]:
                continue
            if v == -1 or d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
               
        for j in range(n):
            e = (min(v,j), max(v,j))
            c = cost[e] if e in cost else float("inf")
            # cost が list のときは普通に c = cost[v][j] などとする
            d[j] = min(d[j], d[v] + c)
    return d

def main():
    N = int(input())
    E = dict()
    for _ in range(N-1):
        a,b,c = map(int, input().split())
        a0 = min(a,b)-1
        b0 = max(a,b)-1
        E[(a0, b0)] = c
    Q,K = map(int, input().split())
    D = dijkstra(K-1, N, N-1, E)
    for _ in range(Q):
        x,y = map(int, input().split())
        print(D[x-1] + D[y-1])

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

# 頂点 s からの最短距離を求める (存在しないときはinf)
# n: 頂点数, edge[i]: 頂点 i からの [cost, dst] の list (heapq のため cost が先)
# O(|E|log|V|)
import heapq
def dijkstra(s,n,edge):
    d = [float("inf")] * n # s からの距離
    d[s] = 0
    q = [] # 頂点への距離を管理する。ヒープにする
    for e in edge[s]:
        heapq.heappush(q, e)
    
    while q:
        minedge = heapq.heappop(q)
        v = minedge[1]
        if d[v] < minedge[0]:
            continue # 最小のもの以降はスルー
        d[v] = minedge[0]
        for e in edge[v]:
            heapq.heappush(q, [e[0]+d[v], e[1]])

    return d

def main():
    N = int(input())
    edge = [[] for i in range(N)]
    # edge[i] : 頂点 i から出る経路の [重み,行先] の配列
    for _ in range(N-1):
        a,b,c = map(int, input().split())
        edge[a-1].append([c,b-1])
        edge[b-1].append([c,a-1])

    Q,K = map(int, input().split())
    D = dijkstra(K-1, N, edge)

    for _ in range(Q):
        x,y = map(int, input().split())
        print(D[x-1] + D[y-1])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
import collections

def main():
    N,M = map(int, input().split())
    A = []
    for _ in range(M):
        A.append(list(map(int, input().split())))
    X1 = []
    for a in A:
        if a[0] == 1:
            X1.append(a)
    X2 = []
    for a in A:
        if a[1] == N:
            X2.append(a)
    for x1 in X1:
        for x2 in X2:
            if x1[1] == x2[0]:
                print("POSSIBLE")
                return
    print("IMPOSSIBLE")

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    N,M = map(int, input().split())
    A = []
    for _ in range(M):
        A.append(list(map(int, input().split())))
    p1 = set()
    for a in A:
        if a[0] == 1:
            p1.add(a[1])
    for a in A:
        if a[1] == N and a[0] in p1:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
    import sys
    input = sys.stdin.readline


    def main():
        N, M = map(int, input().split())
        mod = (10**9)+7
        if abs(N-M) >= 2:
            print(0)
        else:
            ans = 1
            for n in range(1, N+1):
                ans = ans * n % mod
            for m in range(1, M+1):
                ans = ans * m % mod
            if N == M:
                ans = ans * 2 % mod
            print(ans)


    if __name__ == '__main__':
        main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    mod = (10**9)+7
    if abs(N-M) >= 2:
        print(0)
    else:
        ans = 1
        for n in range(1, N+1):
            ans = ans * n % mod
        for m in range(1, M+1):
            ans = ans * m % mod
        if N == M:
            ans = ans * 2 % mod
        print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = A.copy()
    mi = -1
    for j in range(2):
        A = tmp.copy()
        s = 0
        n = 0
        if j == 0: # 偶数番目までの和が正 ⇒ A[0] を負にする
            if A[0] > 0:
                n += abs(A[0] +1)
                A[0] = -1
        else:   # 奇数番目までの和が正 ⇒ A[0] を正にする
            if A[0] < 0:
                n += abs(A[0] -1)
                A[0] = 1
        s = A[0]
#        print(A)
        for i in range(1,N):
            if s * (s+A[i]) >= 0:
                if s < 0:
                    n += abs(-s+1 -A[i])
                    A[i] = -s+1
                else:
                    n += abs(-s-1 -A[i])
                    A[i] = -s-1
            s += A[i]
        if mi == -1:
            mi = n
        else:
            mi = min(mi, n)
    print(mi)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline
#input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = A.copy()
    mi = -1
    for j in range(2):
        A = tmp.copy()
        s = 0
        n = 0
        if j == 0: # 偶数番目までの和が正 ⇒ A[0] を負にする
            if A[0] >= 0:
                n += abs(A[0] +1)
                A[0] = -1
        else:   # 奇数番目までの和が正 ⇒ A[0] を正にする
            if A[0] <= 0:
                n += abs(A[0] -1)
                A[0] = 1
        s = A[0]
#        print(A)
        for i in range(1,N):
            if s * (s+A[i]) >= 0:
                if s < 0:
                    n += abs(-s+1 -A[i])
                    A[i] = -s+1
                else:
                    n += abs(-s-1 -A[i])
                    A[i] = -s-1
            s += A[i]
        if mi == -1:
            mi = n
        else:
            mi = min(mi, n)
    print(mi)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        x = min(K+1, S-i+1)
        for j in range(x):
            y = min(K+1, S-i-j+1)
            for k in range(y):
                if i+j+k == S:
                    n += 1
    print(n)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j >= 0 and S-i-j <= K:
                n += 1
    print(n)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
import itertools

def main():
    K,S = map(int, input().split())
    c = itertools.product([i for i in range(K+1)], repeat=3)
    n = 0
    for i in c:
        if sum(i) == S:
            n += 1
    print(n)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j >= 0 and S-i-j <= K:
                n += 1
    print(n)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
import itertools

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        if i + 2*K < S:
            continue
        for j in range(K+1):
            if i+j +K < S:
                continue
            for k in range(K+1):
                if i+j+k == S:
                    n += 1
    print(n)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    K,S = map(int, input().split())
    n = 0
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j >= 0 and S-i-j <= K:
                n += 1
    print(n)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

def main():
    X = input().strip()

    for i in range(9,-1,-1): # 注: 長さは根拠なし
        # "S..ST..T"
        s = "S"*(2**i) + "T"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
        # "ST..ST"
        s = "ST"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
    print(len(X))

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    X = input().strip()
    A = []
    for c in X:
        if len(A) > 0 and A[-1] == "S" and c == "T":
            A.pop()
        else:
            A.append(c)
    print(len(A))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

def main():
    X = input().strip()
    while 1:
        si = X.find("ST")
        if si == -1:
            break
        sc = 1
        for i in range(si-1,-1,-1):
            if X[i] != "S":
                break
            sc += 1
        tc = 1
        for i in range(si+2,len(X)):
            if X[i] != "T":
                break
            tc += 1
        c = min(sc,tc)
        X = X[:max(0,si-c+1)] + X[min(len(X),si+c+1):]
    print(len(X))

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    X = input().strip()
    A = []
    for c in X:
        if len(A) > 0 and A[-1] == "S" and c == "T":
            A.pop()
        else:
            A.append(c)
    print(len(A))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))

    M = max(X)*N
    dp = [[[0 for k in range(M+1)] for j in range(N+1)] for i in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(M):
                if dp[i][j][k]:
                    dp[i+1][j][k] += dp[i][j][k]
                    dp[i+1][j+1][k+X[i]] += dp[i][j][k]
    ans = 0
    for j in range(1, N+1):
        ans += dp[N][j][A*j]
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))

    M = max(max(X), A)*N
    dp = [[[0 for k in range(M+1)] for j in range(N+1)] for i in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(M):
                if dp[i][j][k]:
                    dp[i+1][j][k] += dp[i][j][k]
                    dp[i+1][j+1][k+X[i]] += dp[i][j][k]
    ans = 0
    for j in range(1, N+1):
        ans += dp[N][j][A*j]
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

def main():
    a,b = map(int,input().split())
    if a<=0 and 0<=b:
        print("Zero")
        return
    else:
        n = 0
        for i in range(a,b+1):
            if i<0:
                n += 1
        if n%2 == 1:
            print("Negative")
            return
        print("Positive")

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input=sys.stdin.readline

def main():
    a,b = map(int,input().split())
    if a<=0 and 0<=b:
        print("Zero")
        return
    elif a<0 and b<0:
        if (b-a)%2 == 0:
            print("Negative")
            return
    print("Positive")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input.split()))
 
def solve(N, A):
	if not A or A[0] != 1:
      print(-1)
      return
 
    prev = 1
    rt = 1
    for a in A[1:]:
        if a > prev * 2:
          print(-1)
          return
        rt += (prev * 2 - a) % (prev * 2)
        prev = a

    print(rt)
    
solve(N, A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input.split()))
 
def solve(N, A):
  if not A or A[0] != 1:
    print(-1)
    return
 
  prev = 1
  rt = 1
  for a in A[1:]:
    if a > prev * 2:
      print(-1)
      return
    rt += (prev * 2 - a) % (prev * 2)
    prev = a
 
  print(rt)
 
solve(N, A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)

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

def solve(N, A):
  if not A or A[0] != 1:
    print(-1)
    return

  prev = 1
  rt = 1
  for a in A[1:]:
    if a > prev * 2:
      print(-1)
      return
    rt += (prev * 2 - a) % (prev * 2)
    prev = a

  print(rt)

solve(N, A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)
Buggy python submission (verdict: Runtime Error):
s = int(input())
if s == 'SAT':
    print(1)
if s == 'FRI':
    print(2)
if s == 'THU':
    print(3)
if s == 'WED':
    print(4)
if s == 'TUE':
    print(5)
if s == 'MON':
    print(6)
if s == 'SUN':
    print(7)

Fixed submission:
s = input()
if s == 'SAT':
    print(1)
if s == 'FRI':
    print(2)
if s == 'THU':
    print(3)
if s == 'WED':
    print(4)
if s == 'TUE':
    print(5)
if s == 'MON':
    print(6)
if s == 'SUN':
    print(7)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s) + 1
lft = 0
rgt = 0
l = []
for i in range(n):
    for j in reversed(range(i)):
        if s[j] == '<':
            lft += 1
        else:
            break
    for j in range(i, n-1):
        if s[j] == '>':
            rgt += 1
        else:
            break
    l.append(max(lft, rgt))
    lft = 0
    rgt = 0
print(sum(l))

Fixed submission:
s = input()
n = len(s) + 1
a = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = max(a[i-1], a[i]+1)
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s) + 1
lft = 0
rgt = 0
l = []
for i in range(n):
    for j in reversed(range(i)):
        if s[j] == '<':
            lft += 1
        else:
            break
    for j in range(i, n-1):
        if s[j] == '>':
            rgt += 1
        else:
            break
    l.append(max(lft, rgt))
    lft = 0
    rgt = 0
print(sum(l))

Fixed submission:
s = input()
n = len(s) + 1
a = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        a[i+1] = a[i] + 1
for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = max(a[i-1], a[i]+1)
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ln = []
for k in range(1,n+1):
    if n % k == 0:
        ln.append(k)
if not n**0.5 % 1 == 0:
    i = ln[len(ln) // 2 - 1]
    j = ln[len(ln) // 2]
    ans = i + j -2
else:
    ans = int(2*n**0.5)-2
print(ans)

Fixed submission:
n = int(input())
ln = []
for k in range(1,(int(n**0.5))+1):
    if n % k == 0:
        ln.append(k)
if not n**0.5 % 1 == 0:
    for k in reversed(range(0, len(ln))):
        ln.append(n // ln[k])
else:
    for k in reversed(range(0, len(ln)-1)):
        ln.append(n // ln[k])
if not n**0.5 % 1 == 0:
    i = ln[len(ln) // 2 - 1]
    j = ln[len(ln) // 2]
    ans = i + j -2
else:
    ans = int(2*n**0.5)-2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(2,n):
    for j in range(2,n):
        l.append(i*j)
if n not in l:
    ans = n-1
else:
    lf = []
    for k in range(1, n+1):
        if n % k == 0:
            lf.append(k)
        i = lf[len(lf) // 2 - 1]
        j = lf[len(lf) // 2]
        ans = i + j - 2
print(ans)

Fixed submission:
n = int(input())
ln = []
for k in range(1,(int(n**0.5))+1):
    if n % k == 0:
        ln.append(k)
if not n**0.5 % 1 == 0:
    for k in reversed(range(0, len(ln))):
        ln.append(n // ln[k])
else:
    for k in reversed(range(0, len(ln)-1)):
        ln.append(n // ln[k])
if not n**0.5 % 1 == 0:
    i = ln[len(ln) // 2 - 1]
    j = ln[len(ln) // 2]
    ans = i + j -2
else:
    ans = int(2*n**0.5)-2
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)

Fixed submission:
def main():
 A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()

Buggy python submission (verdict: Runtime Error):
def main():
A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()

Fixed submission:
def main():
 A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()

Buggy python submission (verdict: Runtime Error):
def main():
A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print("0")
  
mail()

Fixed submission:
def main():
 A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print("0")

Fixed submission:
def main():
 A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()