Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
P = [0 for i in range(M)]
Y = [0 for i in range(M)]
country = [[] for i in range(N+1)]
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    heapq.heappush(country[P[i]], Y[i])
cs = [[] for i in range(N+1)]
for i in range(N+1):
    cs[i] = [heapq.heappop(country[i]) for j in range(len(country[i]))]

for i in range(M):
    num = cs[P[i]].index(Y[i]) + 1
    line = str(P[i]).zfill(6) + str(num).zfill(6)
    print(line)


Fixed submission:
import heapq
N, M = map(int, input().split())
P = [0 for i in range(M)]
Y = [0 for i in range(M)]
country = [[] for i in range(N+1)]
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    heapq.heappush(country[P[i]], (Y[i],i))
cs = [0 for i in range(M)]
for i in range(N+1):
    ran = len(country[i])
    for j in range(ran):
        year, num = heapq.heappop(country[i])
        cs[num] = str(j+1).zfill(6)

for i in range(M):
    line = str(P[i]).zfill(6) + cs[i]
    print(line)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
P = [0 for i in range(M)]
Y = [0 for i in range(M)]
country = [[] for i in range(N+1)]
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    country[P[i]].append(Y[i])

for i in range(N+1):
    country[i].sort()

for i in range(M):
    num = country[P[i]].index(Y[i]) + 1
    line = str(P[i]).zfill(6) + str(num).zfill(6)
    print(line)

Fixed submission:
import heapq
N, M = map(int, input().split())
P = [0 for i in range(M)]
Y = [0 for i in range(M)]
country = [[] for i in range(N+1)]
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    heapq.heappush(country[P[i]], (Y[i],i))
cs = [0 for i in range(M)]
for i in range(N+1):
    ran = len(country[i])
    for j in range(ran):
        year, num = heapq.heappop(country[i])
        cs[num] = str(j+1).zfill(6)

for i in range(M):
    line = str(P[i]).zfill(6) + cs[i]
    print(line)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
i = int(np.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])
else:
    print('No')


Fixed submission:
import numpy
N = int(input())
i = int(numpy.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    k = 1
    for now in range(0, i+1):
        for now2 in range(now+1, i+1):
            S[now].append(k)
            S[now2].append(k)
            k += 1
    for j in range(i+1):
        print(i, end = ' ')
        values = map(str, S[j])
        print(' '.join(values))
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
mport math
N = int(input())
i = int(math.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])
else:
    print('No')


Fixed submission:
import numpy
N = int(input())
i = int(numpy.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    k = 1
    for now in range(0, i+1):
        for now2 in range(now+1, i+1):
            S[now].append(k)
            S[now2].append(k)
            k += 1
    for j in range(i+1):
        print(i, end = ' ')
        values = map(str, S[j])
        print(' '.join(values))
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())
flag = False
for i in range(1,N):
    if i * (i+1) == 2 * N:
        flag = True
        print('Yes')
        break
if not flag:
    print('No')
else:
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])


Fixed submission:
import numpy
N = int(input())
i = int(numpy.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    k = 1
    for now in range(0, i+1):
        for now2 in range(now+1, i+1):
            S[now].append(k)
            S[now2].append(k)
            k += 1
    for j in range(i+1):
        print(i, end = ' ')
        values = map(str, S[j])
        print(' '.join(values))
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, L, T = map(int, input().split())
X = [0 for i in range(N)]
ant = [[] for i in range(2)]
E = [0 for i in range(N)]
for i in range(N):
    X[i], w = map(int, input().split())
    ant[w-1].append(i)
    if w == 1:
        end = X[i] + T
        end = end % L
    if w == 2:
        end = X[i]-T
        end = end % L
        if end < 0:
            end += L
    E[i] = end
len0 = len(ant[0])
len1 = len(ant[1])
TA = []
for m in range(len0):
    for n in range(len1):
        Y0 = ant[0][m]
        Y1 = ant[1][n]
        sa = X[Y1] - X[Y0]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        while gikan < T:
            heapq.heappush(TA,(gikan, Y0, Y1))
            gikan += L / 2.0
lastant = [i for i in range(N)]

for i in range(len(TA)):
    time, Y0, Y1 = heapq.heappop(TA)
    a = lastant[Y0]
    b = lastant[Y1]
    lastant[Y0] = b
    lastant[Y1] = a

result = [0 for i in range(N)]
for i in range(N):
    result[lastant[i]] = E[i]
for i in range(N):
    print(result[i])


Fixed submission:
N, L, T = map(int, input().split())
X = [0 for i in range(N)]
W = [0 for i in range(N)]
E = [0 for i in range(N)]
count = 0
for i in range(N):
    X[i], W[i] = map(int, input().split())
    if W[i] == 1:
        end = X[i] + T
        end = end % L
    if W[i] == 2:
        end = X[i]-T
        end = end % L
        if end < 0:
            end += L
    E[i] = end
    shu = L / 2.0
    if i > 0 and W[i] == 2 and  W[0] == 1:
        sa = X[i] -X[0]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count += (T - gikan ) // shu + 1
        if (T - gikan) % shu == 0:
            count -= 1

    if i > 0 and W[i] == 1 and  W[0] == 2:
        sa = X[0] -X[i]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count -= (T - gikan ) // shu + 1

#print(E)
count = count % N
if count < 0:
    count += N
count = int(count)
#print(count)
basho = E[0]
E.sort()
ind = E.index(basho)
result = [0 for i in range(N)]
for i in range(N):
    newind = ind + i
    if newind >= N :
        newind -= N
    result[count] = E[newind]
    count += 1
    if count >= N:
        count -= N

for i in range(N):
    print(result[i])
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as f

def nCr(n, r):
    return int(f(n) / (f(r) * f(n-r)))
    
N = int(input())
lisA = list(map(int, input().split()))

lisB = [0]
m = 0
for e in lisA:
    m += e
    lisB.append(m)

lisRed = [nCr(lisB.count(e), 2) for e in set(lisB) if lisB.count(e) > 1]
ans = sum(lisRed)

print(ans)


Fixed submission:
from collections import defaultdict as dd
from math import factorial as f

def nCr(n, r):
    return int(f(n) / (f(r) * f(n-r)))
    
N = int(input())
lisA = list(map(int, input().split()))

lisB = [0]
m = 0
for e in lisA:
    m += e
    lisB.append(m)

d = dd(int)

for e in lisB:
    d[e] += 1

ans = 0
for e in d.values():
    if e > 1:
        ans += nCr(e,2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
import numpy as np
N = int(input())
lisS = [list(map(ord, list(input()))) for _ in range(N)]
arS = np.array(lisS)

arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i, j in product(range(N),range(N)):
    ar = arExt[i:i+N, j:j+N]
    cnt += ((ar - ar.T) == 0).all()

print(cnt)



Fixed submission:
import numpy as np

N = int(input())
lisS = [list(map(ord, list(input()))) for _ in range(N)]
arS = np.array(lisS)
arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i in range(N):
    ar = arExt[i:i+N, 0:N]
    cnt += N * (ar == ar.T).all()

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
import numpy as np
N = int(input())
lisS = [list(input()) for _ in range(N)]
arS = np.array(lisS)
arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i, j in product(range(N),range(N)):
    ar = arExt[i:i+N, j:j+N]
    cnt += (ar == ar.T).all()

print(cnt)



Fixed submission:
import numpy as np

N = int(input())
lisS = [list(map(ord, list(input()))) for _ in range(N)]
arS = np.array(lisS)
arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i in range(N):
    ar = arExt[i:i+N, 0:N]
    cnt += N * (ar == ar.T).all()

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
ap = [e + 1 for e in a]
am = [e - 1 for e in a]

b = sorted(a + ap + am)

cmax = 0

pre = b.pop(0)

while True:
    smc = 1
    while True:
        if len(b) == 0:
            print(cmax)
            import sys
            sys.exit()

        cur = b.pop(0)
        if cur == pre:
            smc += 1
        else:
            cmax = max(smc, cmax)
            pre = cur
            break



Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ap = [e + 1 for e in a]
am = [e - 1 for e in a]

table = [0 for _ in range(10**5 + 2)]
for e in a:
    table[e + 1] += 1
    table[(e+1) + 1] += 1
    table[(e-1) + 1] += 1
print(max(table))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
ap = [e + 1 for e in a]
am = [e - 1 for e in a]

b = a + ap + am

cnt = [b.count(e) for e in set(b)]

print(max(cnt))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ap = [e + 1 for e in a]
am = [e - 1 for e in a]

table = [0 for _ in range(10**5 + 2)]
for e in a:
    table[e + 1] += 1
    table[(e+1) + 1] += 1
    table[(e-1) + 1] += 1
print(max(table))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
A = list(map(int, input().split()))
A = sorted([e for e in A if A.count(e) > 1], reverse = True)

c = None
for a in A:
    if A.count(a) >= 2:
        if c is not None:
            print(c * a)
            sys.exit()
    c = a
    A.remove(a)
    A.remove(a)
print(0)


Fixed submission:
import sys

N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

mstack = []
stack = [0]
for a in A:
    if a == stack[-1]:
        mstack.append(a)
        stack.pop()
        if len(mstack) >= 2:
            print(mstack[-1] * mstack[-2])
            sys.exit()
    else:
        stack.append(a)
print(0)

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

N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

c = None

for a in A:
    if A.count(a) >= 2:
        if c is not None:
            print(c * a)
            sys.exit()
        c = a
        A.remove(a)
        A.remove(a)
print(0)


Fixed submission:
import sys

N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

mstack = []
stack = [0]
for a in A:
    if a == stack[-1]:
        mstack.append(a)
        stack.pop()
        if len(mstack) >= 2:
            print(mstack[-1] * mstack[-2])
            sys.exit()
    else:
        stack.append(a)
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()

b = []

for e in a:
    b.append(e)
    b = b[::-1]
ans = ' '.join(b)
print(ans)


Fixed submission:
n = int(input())
a = input().split()

b = []
c = []
for i in range(len(a)):
    if (i+1) % 2 !=  0:
        b.append(a[i])
    else:
        c.append(a[i])
if (i + 1) % 2 != 0:
    d = " ".join(reversed(b)) + " " + " ".join(c)
else:
    d = " ".join(reversed(c)) + " " + " ".join(b)

print(d)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * (10**5 + 1)
if a[0] == 1 or a[1]  == 2:
    print(-1)
ch[1] = numB
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1


Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * (10**5 + 1)
numB = 1
ch[1] = numB
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * 10**5
ch[1] = 1

if a[0] == 1 or a[1]  == 2:
    print(-1)

numB = 1
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1


Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * (10**5 + 1)
numB = 1
ch[1] = numB
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, L, T = map(int, input().split())
X = []
W = []
ant = [i for i in range(N)]
for i in range(N):
    xi, wi = map(int, input().split())
    X.append(xi)
    W.append(wi)

npX = np.array(X).astype(np.float)
npW = np.array(W).astype(np.float)
npW[npW == 2] = -1

def swap(ant, i, j):
    tmp = ant[i]
    ant[i] = ant[j]
    ant[j] = tmp
    return ant

ans = (npX + npW * T) % L

T %= L
if T > L - T:
    T = L - T
    npW *= -1
t = 0
while t < T:
    t += 0.5
    npX = (npX + npW * 0.5) % L
    colision = set([e for e in set(npX) if np.sum(npX == e) == 2])
    if len(colision) != 0:
        for e in colision:
            i, j = np.where(npX == e)[0].tolist()
            swap(ant, i, j)

for i in range(N):
    print(int(ans[ant.index(i)]))



Fixed submission:
N = int(input())
A = list(map(int, input().split()))

sign = 0
c = 0
for i in range(1,len(A)):
    dif = A[i] - A[i-1]
    if dif * sign < 0:
        c += 1
        sign = 0
        continue
    if dif != 0:
        sign = dif
print(c+1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(M):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)


Fixed submission:
A, B = map(int, input().split())
print((A + B) % 24)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(N):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)


Fixed submission:
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(M):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(N):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 2 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)


Fixed submission:
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(M):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)
Buggy python submission (verdict: Runtime Error):
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

N = int(input())
if N = 1:
    print(1)
else:
    table = prime_decomposition(N)
    digN = len(str(N))
    digMaxEle = len(str(table[-1]))
    if digN / 2  < digMaxEle:
        print(digMaxEle)
    else:
        print(digN//2 + digN%2)


Fixed submission:
N = int(input())

def count_digit(N):
    return(len(str(N)))

ans = count_digit(N)

A = 1
while (A * A <= N):
    if N%A != 0: pass
    else:
        B = N//A
        curDig = max(count_digit(A), count_digit(B))
    ans = min(ans, curDig)
    A += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

N = int(input())
table = prime_decomposition(N)
digN = len(str(N))
digMaxEle = len(str(table[-1]))
if digN / 2  < digMaxEle:
    print(digMaxEle)
else:
    print(digN//2 + digN%2)


Fixed submission:
N = int(input())

def count_digit(N):
    return(len(str(N)))

ans = count_digit(N)

A = 1
while (A * A <= N):
    if N%A != 0: pass
    else:
        B = N//A
        curDig = max(count_digit(A), count_digit(B))
    ans = min(ans, curDig)
    A += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_card = list(map(int, input().split()))
count = 0
for x in set(list_card):
    count += list_card.count(x) - 1
print(N - (count + count%2))

Fixed submission:
N = int(input())
list_card = list(map(int, input().split()))
##count = 0
##for x in set(list_card):
##    count += list_card.count(x) - 1
M = N - len(set(list_card))
print(N - (M + M%2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
x = 0
max_x = 0
for c in S:
    if c == 'I': x += 1
    else: x -= 1
    max_x = max(max_x, x)
print(max_x)


Fixed submission:
A, B, C, D = map(int, input().split())
print(max(A*B,C*D))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K, S = map(int, input().split())
list_ans = [(x,y,z) for x, y, z in itertools.product([w for w in range(K + 1)], repeat = 3) if ((x + y + z) == S)]
print(len(list_ans))



Fixed submission:
K, S = map(int, input().split())

c = 0
for x in range(S//3 + 1):
    for y in range(x, (S-x)//2 + 1):
        z = S - (x + y)
        if z <= K:
            l = len(set((x,y,z)))
            if l == 1: c += 1
            elif l == 2: c += 3
            else: c += 6
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
c = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i + j + k) == S:
                c += 1

print(c)


Fixed submission:
K,S = map(int,input().split())
c = 0

for i in range(K+1):
    for j in range(K+1):
            if 0<=(S-i-j)<=K:
                c += 1

print(c)
Buggy python submission (verdict: Runtime Error):
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
a(H)
print(ans)

Fixed submission:
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)

Buggy python submission (verdict: Runtime Error):

def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)



H = int(input())
dic = {}
dic[1] = 1
ans = 1
a(H)
print(ans)



Fixed submission:
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def a(H):
    global ans
    if H <= 1:
        ans = ans + 1
    else:
        ans = ans + 1
        a(H // 2)
        a(H//2)


H = int(input())
ans = 0
a(H)
print(ans)



Fixed submission:
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)