Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecusionlimit(100000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
print(d)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(sys.getrecursionlimit()*100)
n = int(input())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
a = []
def f(i, p):
    a.append(i)
    if i == n:
        return True
    for j in g[i]:
        if j != p:
            if f(j, i):
                return True
    a.pop()
f(1,0)
m = (len(a)+1) // 2
def h(i, j, p):
    if i == j:
        return 1
    return 1 + sum(h(k, j, i) for k in g[i] if k != p)
if h(1, a[m], 0) > h(n, a[m-1], 0):
    print("Fennec")
else:
    print("Snuke")


Fixed submission:
import sys
sys.setrecursionlimit(sys.getrecursionlimit()*1000)
n = int(input())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
a = []
def f(i, p):
    a.append(i)
    if i == n:
        return True
    for j in g[i]:
        if j != p:
            if f(j, i):
                return True
    a.pop()
f(1,0)
m = (len(a)+1) // 2
def h(i, j, p):
    if i == j:
        return 1
    return 1 + sum(h(k, j, i) for k in g[i] if k != p)
if h(1, a[m], 0) > h(n, a[m-1], 0):
    print("Fennec")
else:
    print("Snuke")

Buggy python submission (verdict: Runtime Error):
n = int(input())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
a = []
def f(i, p):
    a.append(i)
    if i == n:
        return True
    for j in g[i]:
        if j != p:
            if f(j, i):
                return True
    a.pop()
f(1,0)
m = (len(a)+1) // 2
def h(i, j, p):
    if i == j:
        return 1
    return 1 + sum(h(k, j, i) for k in g[i] if k != p)
if h(1, a[m], 0) > h(n, a[m-1], 0):
    print("Fennec")
else:
    print("Snuke")

Fixed submission:
import sys
sys.setrecursionlimit(sys.getrecursionlimit()*1000)
n = int(input())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
a = []
def f(i, p):
    a.append(i)
    if i == n:
        return True
    for j in g[i]:
        if j != p:
            if f(j, i):
                return True
    a.pop()
f(1,0)
m = (len(a)+1) // 2
def h(i, j, p):
    if i == j:
        return 1
    return 1 + sum(h(k, j, i) for k in g[i] if k != p)
if h(1, a[m], 0) > h(n, a[m-1], 0):
    print("Fennec")
else:
    print("Snuke")
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
s=[input() for _ in range(n)]
a=[map(int,input().split()) for _ in range(q)]
for k in range(q):
    x1,y1,x2,y2=a[k]
    v=e=0
    for i in range(x1-1,x2):
        for j in range(y1-1,y2):
            if s[i][j]=='1':
                v+=1
                if i!=x2-1 and s[i+1][j]=='1':
                    e+=1
                if j!=y2-1 and s[i][j+1]=='1':
                    e+=1
    print(v-e)

Fixed submission:
n,m,q=map(int,input().split())
s,v,el,eu=([[0]*(m+2) for _ in range(n+2)] for _ in range(4))
for i in range(1,n+1):
    s[i][1:m+1]=map(int,input())
    for j in range(1,m+1):
        v[i][j]=v[i][j-1]+s[i][j]
        el[i][j]=el[i][j-1]+s[i][j]*s[i][j-1]
        eu[i][j]=eu[i][j-1]+s[i][j]*s[i-1][j]
for i in range(2,n+1):
    for j in range(1,m+1):
        v[i][j]+=v[i-1][j]
        el[i][j]+=el[i-1][j]
        eu[i][j]+=eu[i-1][j]
for _ in range(q):
    x1,y1,x2,y2=map(int,input().split())
    print(v[x2][y2]-v[x1-1][y2]-v[x2][y1-1]+v[x1-1][y1-1]
            -(el[x2][y2]-el[x1-1][y2]-el[x2][y1]+el[x1-1][y1])
            -(eu[x2][y2]-eu[x1][y2]-eu[x2][y1-1]+eu[x1][y1-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
e=[tuple(map(int,input().split())) for _ in range(m)]
d=[0]+[-float('inf')]*(n-1)
for _ in range(n-1):
    for a,b,c in e:
        d[b-1]=max(d[b-1],d[a-1]+c)
r=d[n-1]
for _ in range(n-1):
    for a,b,c in e:
        d[b-1]=max(d[b-1],d[a-1]+c)
if d[n-1]==r:
    print(r)
else:
    print('inf')

Fixed submission:
n,m=map(int,input().split())
e=[tuple(map(int,input().split())) for _ in range(m)]
d=[0]+[-float('inf')]*(n-1)
for _ in range(n-1):
    for a,b,c in e:
        d[b-1]=max(d[b-1],d[a-1]+c)
r=d[n-1]
for _ in range(n-1):
    for a,b,c in e:
        d[b-1]=max(d[b-1],d[a-1]+c)
if d[n-1]==r:
    print(r)
else:
    print('inf')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, list(input().split())))
h = list(map(int, list(input().split())))
h = [0] + h

dp = [0x3f3f3f3f for _ in range(N+1)]
dp[1] = 0
for i in range(1, N+1):
    for j in range(1, K+1):
        if j > i:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
print(dp[N])

Fixed submission:
N, K = list(map(int, list(input().split())))
h = list(map(int, list(input().split())))
h = [0] + h

dp = [0x3f3f3f3f for _ in range(N+1)]
dp[1] = 0
for i in range(1, N+1):
    for j in range(1, K+1):
        if j > i:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))

import sys

if 0 in A:
    print(0)
    sys.exit(0)

ans = 1
for i in range(len(A)):
    ans *= A[i]
if ans > int(1e18):
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())

A = list(map(int, input().split()))

import sys

if 0 in A:
    print(0)
    sys.exit(0)

ans = 1
for i in range(len(A)):
    ans *= A[i]
    if (ans > int(1e18)):
        print(-1)
        sys.exit(0)
if ans > int(1e18):
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import numpy as np


# In[ ]:


N, K, Q = map(int, input().split())
As = [int(input()) for i in range(Q)]
"""
6 3 4
3
1
3
2
"""


# In[11]:


points = np.array([K]*N)
args = np.arange(1, N+1)


# In[13]:


for i in range(Q):
    #points[args!= int(input())] -= 1
    points[args != As[i]] -= 1


# In[14]:


#print(points)


# In[16]:


for b in points >= 1:
    if b:
        print('Yes')
    else:
        print('No')


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import numpy as np


# In[ ]:


N, K, Q = map(int, input().split())
As = [int(input()) for i in range(Q)]
"""
6 3 4
3
1
3
2
"""


# In[17]:


#points = np.array([K]*N)
points = np.array([0]*N)
args = np.arange(1, N+1)


# In[18]:


for i in range(Q):
    #points[args!= int(input())] -= 1
    points[As[i]-1] += 1


# In[22]:


points = points-Q+K


# In[23]:


for b in points >= 1:
    if b:
        print('Yes')
    else:
        print('No')


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[69]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.sort(np.array(list(map(int, input().split()))))[::-1]
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[70]:


As


# In[71]:


#As[0] = As[0] // 2
#arg = 
arg = 0
argrange = 0
As[arg] = As[arg] // 2
for i in range(1, M):
    argrange = max(arg + 1, argrange)
    arg = np.argmax(As[:argrange+1])
    #print(arg)
    As[arg] = As[arg] // 2
    #As[:i+1] = np.sort(As[:i+1])[::-1]
    #As[0] = As[0] // 2


# In[72]:


#print(As)
print(sum(As))


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


# import copy
#import numpy as np
import heapq

N, M = map(int, input().split())

def int_minus(s):
    return -int(s)

As = list(map(int_minus, input().split()))
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[10]:


heapq.heapify(As)


# In[17]:


for i in range(M):
    mx = heapq.heappop(As)
    heapq.heappush(As, -(-mx//2))


# In[19]:


#print(As)
print(-sum(As))


# In[ ]:

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[69]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.sort(np.array(list(map(int, input().split()))))[::-1]
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[70]:


As


# In[71]:


#As[0] = As[0] // 2
#arg = 0
As[0] = As[0] // 2
for i in range(1, M):
    arg = np.argmax(As[:i+1])
    #print(arg)
    As[arg] = As[arg] // 2
    #As[:i+1] = np.sort(As[:i+1])[::-1]
    #As[0] = As[0] // 2


# In[72]:


#print(As)
print(sum(As))


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


# import copy
#import numpy as np
import heapq

N, M = map(int, input().split())

def int_minus(s):
    return -int(s)

As = list(map(int_minus, input().split()))
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[10]:


heapq.heapify(As)


# In[17]:


for i in range(M):
    mx = heapq.heappop(As)
    heapq.heappush(As, -(-mx//2))


# In[19]:


#print(As)
print(-sum(As))


# In[ ]:

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[54]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.array(sorted(list(map(int, input().split())), reverse=True))
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[56]:


As[:9] = As[:9]


# In[57]:


As[0] = As[0] // 2
for i in range(1, M):
    As[:i+1] = np.sort(As[:i+1])[::-1]
    As[0] = As[0] // 2


# In[39]:


#print(As)
print(sum(As))


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


# import copy
#import numpy as np
import heapq

N, M = map(int, input().split())

def int_minus(s):
    return -int(s)

As = list(map(int_minus, input().split()))
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[10]:


heapq.heapify(As)


# In[17]:


for i in range(M):
    mx = heapq.heappop(As)
    heapq.heappush(As, -(-mx//2))


# In[19]:


#print(As)
print(-sum(As))


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[34]:


import numpy as np
N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[41]:


dp = np.zeros((N+1, N+1), dtype=np.uint32)


# In[43]:


max_cont = 0
for i in range(N)[::-1]:
    for j in range(i+1, N)[::-1]:
        if S[i] == S[j]:
            dp[i,j] = min(dp[i+1, j+1]+1, j-i)
            max_cont = max(max_cont, dp[i, j])
        else:
            continue


# In[44]:


print(max_cont)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[49]:


#import numpy as np
N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[54]:


i = 0
j = 1
max_cont = 0

while j < N:
    if S[i:j] in S[j:]:
        max_cont = max(max_cont, len(S[i:j]))
        j += 1
    else:
        i += 1
    if i == j:
        i += 1
        j += 2


# In[55]:


print(max_cont)


# In[ ]:

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[20]:


N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[29]:


dp = [[0]*(N+1) for i in range(N+1)]


# In[30]:


max_cont = 0
for i in range(N)[::-1]:
    for j in range(i+1, N)[::-1]:
        if S[i] == S[j]:
            dp[i][j] = min(dp[i+1][j+1]+1, j-i)
            max_cont = max(max_cont, dp[i][j])
        else:
            continue


# In[31]:


print(max_cont)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[49]:


#import numpy as np
N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[54]:


i = 0
j = 1
max_cont = 0

while j < N:
    if S[i:j] in S[j:]:
        max_cont = max(max_cont, len(S[i:j]))
        j += 1
    else:
        i += 1
    if i == j:
        i += 1
        j += 2


# In[55]:


print(max_cont)


# In[ ]:

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[20]:


N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[25]:


dp = [[0]*(N+1) for i in range(N+1)]


# In[26]:


max_cont = 0
for i in range(N)[::-1]:
    for j in range(N)[::-1]:
        if i < j:
            if S[i] == S[j]:
                dp[i][j] = min(dp[i+1][j+1]+1, j-i)
                max_cont = max(max_cont, dp[i][j])
            else:
                continue
        else:
            continue


# In[27]:


print(max_cont)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[49]:


#import numpy as np
N = int(input())
S = input()
"""
5
ababa
2

13
strangeorange
5
"""


# In[54]:


i = 0
j = 1
max_cont = 0

while j < N:
    if S[i:j] in S[j:]:
        max_cont = max(max_cont, len(S[i:j]))
        j += 1
    else:
        i += 1
    if i == j:
        i += 1
        j += 2


# In[55]:


print(max_cont)


# In[ ]:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


A, B, C = map(int, input().split())


# In[ ]:


ans = int(C-(A-B))
if ans < 0:
    print(0)
else:
    print(ans)



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


a = int(input())
s = input()


# In[ ]:


if a >= 3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[64]:


import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])
"""
4 6
#..#..
.....#
....#.
#.#...
"""


# In[72]:


field = np.ones((H, W))
field[S=='#'] = 0
lm, rm, um, dm = (field.copy() for _ in [0]*4)
#print(field)


# In[73]:


#np.where()
for i in range(1, H):
    um[i] = (um[i-1]+1) * field[i]
    dm[-1-i] = (dm[-i]+1) * field[i]
    
for i in range(1, W):
    lm[:, i] = (lm[:, i-1]+1) * field[:, i]
    rm[:, -1-i] = (rm[:, -i]+1) * field[:, i]


# In[75]:


#print(um)
#print(dm)
#print(lm)
#print(rm)
print(int(np.max(um+dm+lm+rm)-3))


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


P, Q, R = map(int, input().split())


# In[3]:


t = [P, Q, R]
print(sum(t)-max(t))


# In[ ]:

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[27]:


import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])
"""
4 6
#..#..
.....#
....#.
#.#...
"""


# In[51]:


row_beam = np.zeros((H, W))
col_beam = np.zeros((H, W))
sh, sw = np.where(S=='#')


# In[52]:


#np.where()
for i in range(H):
    #print(i)
    #print(row_beam)
    row = S[i]
    #sharp_pos = np.where(row=='#')[0]
    sharp_pos = sw[sh==i]
    #print(sharp_pos)
    if len(sharp_pos) == 0:
        row_beam[i] = W
    else:
        s = 0
        for sp in sharp_pos:
            contin = sp-s
            row_beam[i, s:sp] = contin
            s = sp+1
        if s != W:
            row_beam[i, s:W] = W-s
            
for i in range(W):
    #print(i)
    #print(col_beam)
    col = S[:,i]
    #sharp_pos = np.where(col=='#')[0]
    sharp_pos = sh[sw==i]
    #print(sharp_pos)
    if len(sharp_pos) == 0:
        col_beam[:, i] = H
    else:
        s = 0
        for sp in sharp_pos:
            contin = sp-s
            col_beam[s:sp, i] = contin
            s = sp+1
        if s != W:
            col_beam[s:H, i] = H-s


# In[53]:


print(int(np.max(row_beam+col_beam-1)))


# In[54]:


#print(row_beam)
#print(col_beam)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


P, Q, R = map(int, input().split())


# In[3]:


t = [P, Q, R]
print(sum(t)-max(t))


# In[ ]:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
#input = sys.stdin.readline
A, B = map(int, input().split())


# In[ ]:


if A <=5:
    print(0)
el



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


import sys
#input = sys.stdin.readline
A, B = map(int, input().split())


# In[7]:


if A <=5:
    print(0)
elif A <= 12:
    print(int(B/2))
else:
    print(B)


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
#input = sys.stdin.readline
N, M = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(M)]


# In[9]:


union = set(range(1, N+1))
for i in range(M):
    union = union & set(range(lr[i][0], lr[i][1]+1))
print(len(union))


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[15]:


import sys
input = sys.stdin.readline
N, M = map(int, input().split())


# In[ ]:


"""
4 2
1 3
2 4
"""


# In[19]:


l_ = 0
r_ = N
for i in range(M):
    l, r = map(int, input().split())
    l_ = max(l_, l)
    r_ = min(r_, r)


# In[21]:


#print(l_, r_)
ids = r_-l_+1
if ids < 0:
    print(0)
else:
    print(ids)


# In[ ]:
Buggy python submission (verdict: Runtime Error):

# coding: utf-8

# In[1]:

import sys
import math
#input = sys.stdin.readline
N = int(input())


# In[5]:

sum_ = 0
#print(math.sqrt(N))
#print(int(math.sqrt(N)))
for i in range(1, int(math.sqrt(N+0.5))+1):
    if N%i == 0:
        #print(i)
        #print(N/i-1)
        sum_ += N/i-1
print(int(sum_))


# In[ ]:





Fixed submission:

# coding: utf-8

# In[ ]:

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
#A = list(map(int, input().split()))


# In[ ]:

print(N-K+1)
Buggy python submission (verdict: Runtime Error):

# coding: utf-8

# In[1]:

import sys
#input = sys.stdin.readline
N = int(input())


# In[3]:

import numpy as np


# In[9]:

a = np.arange(1, N//2)
nN = np.ones(N//2-1)*N
print(np.sum((nN/a-1)[(nN/a-1)%1==0]))


# In[ ]:





Fixed submission:

# coding: utf-8

# In[10]:

import sys
#import math
#input = sys.stdin.readline
N = int(input())


# In[13]:

sum_ = 0
#print(math.sqrt(N))
#print(int(math.sqrt(N)))
#print(int(N**0.5))
rn = N**0.5
if rn%1 == 0:
    rn -= 1
for i in range(1, int(rn)+1):
    if N%i == 0 and i < N//i-1:
        #print(i)
        #print(N/i-1)
        sum_ += N/i-1
print(int(sum_))


# In[ ]:

Buggy python submission (verdict: Runtime Error):

# coding: utf-8

# In[1]:

import sys
input = sys.stdin.readline
N = int(input())


# In[2]:

import numpy as np


# In[9]:

#sum_ = 0
a = np.arange(1, N//2)
print(np.sum(N/a[(N/a-1)%1==0]-1))
#print(a)
#print(np.sum(a[N//a==N%a]))
#print(a)
#for m in range(1, (N-2)//2):
#    if (N-m)%m==0:
#        print(m)
#        sum_ += (N-m)/m
#print(sum_)


# In[ ]:





Fixed submission:

# coding: utf-8

# In[10]:

import sys
#import math
#input = sys.stdin.readline
N = int(input())


# In[13]:

sum_ = 0
#print(math.sqrt(N))
#print(int(math.sqrt(N)))
#print(int(N**0.5))
rn = N**0.5
if rn%1 == 0:
    rn -= 1
for i in range(1, int(rn)+1):
    if N%i == 0 and i < N//i-1:
        #print(i)
        #print(N/i-1)
        sum_ += N/i-1
print(int(sum_))


# In[ ]:

Buggy python submission (verdict: Runtime Error):

# coding: utf-8

# In[17]:

import sys
#input = sys.stdin.readline
N = int(input())


# In[3]:

import numpy as np


# In[ ]:

sum_ = 0
a = np.arange(1, N)
#print(a)
print(np.sum(a[N//a==N%a]))
#print(a)
#for m in range(1, (N-2)//2):
#    if (N-m)%m==0:
#        print(m)
#        sum_ += (N-m)/m
#print(sum_)


# In[ ]:





Fixed submission:

# coding: utf-8

# In[10]:

import sys
#import math
#input = sys.stdin.readline
N = int(input())


# In[13]:

sum_ = 0
#print(math.sqrt(N))
#print(int(math.sqrt(N)))
#print(int(N**0.5))
rn = N**0.5
if rn%1 == 0:
    rn -= 1
for i in range(1, int(rn)+1):
    if N%i == 0 and i < N//i-1:
        #print(i)
        #print(N/i-1)
        sum_ += N/i-1
print(int(sum_))


# In[ ]: