Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().stlip())

if a*b<=81:
  print(a*b)
else:
	print(-1)


Fixed submission:
A, B = map(int, input().split())
if 0 <= A <= 9 and 0 <= B <= 9:
    print(A*B)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().stlip)

if a*b<=81:
  print(a*b)
else:
	print(-1)

Fixed submission:
A, B = map(int, input().split())
if 0 <= A <= 9 and 0 <= B <= 9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int(input())))

ans=0
s=sum(l)

for i in range(n):

    ans+=l[i]*(s-l[i])

print(ans/2)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))

ans=0
s=sum(l)

for i in range(n):

    ans+=l[i]*(s-l[i])

print(int(ans/2))
Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0
for i range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0
 
for i range(1,n+1):
  
  if (i%2==1):
    x+=1
    
print(x/n)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0
 
for i range(1,n+1):
  if i%2==1:
    x+=1
    
print(x/n)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0

for i range (1,n+1):
  
  if i%2==1:
    x+=1
    
print(x/n)
    

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)
Buggy python submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
h = list(map(int,input()))

cnt = 0
for i in h:
    if i >= k:
        cnt+=1

print(cnt)

Fixed submission:
n,k=map(int,input().split())

h = list(map(int,input().split()))
ans=0
for i in range(n):

    if(h[i] >=k):
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

ans = ""

if(S=="Sunny")
	print("Cloudy")
else if(S=="Rainy")
	print("Sunny")
else
	print("Rainy")


Fixed submission:
S = input()

ans = ""

if S=="Sunny":
	print("Cloudy")
elif S=="Rainy":
	print("Sunny")
else:
	print("Rainy")

Buggy python submission (verdict: Runtime Error):
S = input()

ans = ""

if(S="Sunny")
	print("Cloudy")
else if(S="Rainy")
	print("Sunny")
else
	print("Rainy")

Fixed submission:
S = input()

ans = ""

if S=="Sunny":
	print("Cloudy")
elif S=="Rainy":
	print("Sunny")
else:
	print("Rainy")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(n)]
c = [int(input()) for i in range(n-1)]

ans = sum(b)
for i in range(1,n):
    if a[i]-1==a[i-1]:
        ans+=c[i-1]
print(ans)

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

m=0
for i in range(n-1):
  if a[i+1]==a[i]+1:
    m=m+c[a[i]-1]

print(sum(b)+m)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(n)]
c = [int(input()) for i in range(n)]

ans = sum(b)
for i in range(1,n):
    if a[i]-1==a[i-1]:
        ans+=c[i-1]
print(ans)

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

m=0
for i in range(n-1):
  if a[i+1]==a[i]+1:
    m=m+c[a[i]-1]

print(sum(b)+m)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
i=0
if b!=1:



    while True:
        if a + (a-1)*i < b:
            i+=1
        else :
            break

print(i)

Fixed submission:
S = input()
T = input()
ans=0
for i in range (3):
	if(S[i] == T[i]):
  		ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

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

s=0
for x in a:
    s+=1/x
ans=1/s

print(ans)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")

Buggy python submission (verdict: Runtime Error):
a = int(input)
s = input()

if(a>=3200):
    print(s)
else:
    print("red")

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

if (a+b)%2 == 0:
    print(int((a+b)/2))
else:
    print("

Fixed submission:
a,b = map(int, input().split())

if (a+b)%2 == 0:
    print(int((a+b)/2))
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

if (a+b)%2 == 0:
    print((a+b)/2)
else
    print("IMPOSSIBLE")

Fixed submission:
a,b = map(int, input().split())

if (a+b)%2 == 0:
    print(int((a+b)/2))
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a = int(input())
print(3*r**2)

Fixed submission:
r = int(input())

print(3*r*r)
Buggy python submission (verdict: Time Limit Exceeded):

n= int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    a_n = a[:i]+a[i+1:]
    print(max(a_n))
    
    

Fixed submission:

n= int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a,reverse=True)

for i in range(n):
    ans = a_s[0]
    if a[i]==a_s[0]:
        ans = a_s[1]
    
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n= int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    a_n = copy.copy(a)
    a_n.pop(i)
    print(max(a_n))

Fixed submission:

n= int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a,reverse=True)

for i in range(n):
    ans = a_s[0]
    if a[i]==a_s[0]:
        ans = a_s[1]
    
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n= int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    a_n = copy.copy(a)
    a_n.pop(i)
    print(max(a_n))

Fixed submission:

n= int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a,reverse=True)

for i in range(n):
    ans = a_s[0]
    if a[i]==a_s[0]:
        ans = a_s[1]
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S[0]==S[1]||S[1]==S[2]||S[2]==S[3]||S[3]==S[4]:
  print("bad")
else:
  print("good")

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
if a >=13:
    print(b)
elif 6 <= a <= 12:
    print(b//2)
else:
    print(0)

Fixed submission:
a,b=map(int,input().split())

if a>=13:
    print(b)
elif 12 >= a >= 6:
    print(b//2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A = [int(input()) for i in range(5)]
time = 0
l = []
for i in A:
    if i%10 == 0:
        time+=i
    else:
        time+=(i//10+1)*10
        l.append(i%10)

print(time-(10-min(l)))
    


Fixed submission:
A = [int(input()) for i in range(5)]
count=0 
max_i=0
for i in A:
    if i%10!=0:
        max_i = max(max_i,10-i%10)
        count += i//10*10+10
    else:
        count += i
print(count-max_i)

Buggy python submission (verdict: Runtime Error):
A = [int(input()) for i in range(5)]
time = 0
l = []
for i in A:
    if i%10 == 0:
        time+=i
    else:
        time+=(i//10+1)*10
        l.append(i%10)

print(time-(10-min(l)))
    

Fixed submission:
A = [int(input()) for i in range(5)]
count=0 
max_i=0
for i in A:
    if i%10!=0:
        max_i = max(max_i,10-i%10)
        count += i//10*10+10
    else:
        count += i
print(count-max_i)
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
n_l = []
for i in range(n):
    l = list(map(int,input().split()))
    for j in range(l[0]):
        n_l.append(l[j+1])
    
cnt = 0
for i in range(1,m+1):
    if n_l.count(i) == n:
        cnt += 1

print(cnt)

Fixed submission:
a,b = list(map(int,input().split()))
print(a+b if b%a == 0 else b-a)
Buggy python submission (verdict: Runtime Error):
s = input()
n = ""
for i in s:
  if i == "9":
    n+=1
  else:
    n+=9
print(n)

Fixed submission:
s = input()
n = ""
for i in s:
  if i == "9":
    n+="1"
  else:
    n+="9"
print(n)
Buggy python submission (verdict: Runtime Error):
n = input()
n.sort(reverse=True)
print(int(n[0]+n[0]+n[0]))

Fixed submission:
n = int(input())

for i in range(1000):
    if str(n)[0] == str(n)[1] ==str(n)[2]:
        print(n)
        exit()
    else:
        n+=1
Buggy python submission (verdict: Runtime Error):
n = int(input())

if 104 >= n:
    print(0)
else:
    ans = 0
    for i in range(105,n+1):
        if i%2 == 0:
            continue
        cnt=0
        for j in range(1,i+1):
            if i%j == 0:
                cnt+=1
            
        if cnt == 8:
            ans+=1

print(ans)

Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
    if i%2 == 0:
        continue
    cnt=0
    for j in range(1,i+1):
        if i%j == 0:
            cnt+=1
        
    if cnt == 8:
        ans+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

if 104 >= n:
    print(0)
else:
    ans = 0
    for i in range(105,n+1):
        cnt=0
        for j in range(1,i+1):
            if i%j == 0:
                cnt+=1
            
        if cnt == 8:
            ans+=1

print(ans)

Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
    if i%2 == 0:
        continue
    cnt=0
    for j in range(1,i+1):
        if i%j == 0:
            cnt+=1
        
    if cnt == 8:
        ans+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

if 104 >= n:
    print(0)
else:
    ans = 0
    for i in range(105,201):
        cnt=0
        for j in range(1,i+1):
            if i%j == 0:
                cnt+=1
            
        if cnt == 8:
            ans +=1

print(ans)
            

Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
    if i%2 == 0:
        continue
    cnt=0
    for j in range(1,i+1):
        if i%j == 0:
            cnt+=1
        
    if cnt == 8:
        ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

ans = 0

for i in range(10000):
    for j in range(n):
        ans += i%a[j]

    max_ans = max(max_ans,ans)

print(max_ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)-len(a)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = list(map(int,input()))
if a < b:
    print(a-1)
else:
    print(a)

Fixed submission:
a,b = list(map(int,input().split()))
if a > b:
    print(a-1)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
a,b,c = list(input())
ans = int(b+c)
if ans%4 == 0:
  print("YES")
else:
  print("NO")


Fixed submission:
a,b,c = list(input().split())
ans = int(b+c)
if ans%4 == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,t = input().split()

if a == "H":
  print(b)
else:
  if t == "D":
    print("H")
  else:
    print("D")


Fixed submission:
a,t = input().split()

if a == "H":
  print(t)
else:
  if t == "D":
    print("H")
  else:
    print("D")

Buggy python submission (verdict: Runtime Error):
a,t = input().split()

if a == "H":
  print(b)
else:
  if b == "D":
    print("H")
  else:
    print("D")

Fixed submission:
a,t = input().split()

if a == "H":
  print(t)
else:
  if t == "D":
    print("H")
  else:
    print("D")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 1
for i in range(1,n+1):
    ans=ans*i%(1e9+7)

print(int(ans)

Fixed submission:
n = int(input())
ans = 1
for i in range(1,n+1):
    ans=ans*i%(1e9+7)

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
for i in range(1,n+1):
    p*=i

print(p%(10**9+7))


Fixed submission:
n = int(input())
ans = 1
for i in range(1,n+1):
    ans=ans*i%(1e9+7)

print(int(ans))
Buggy python submission (verdict: Runtime Error):
x , n = map(int , input().split())
if n != 0:
    p = list(map(int , input().split()))

ans = x

for i in range(100):
    tmp1 = x - i
    tmp2 = x + i
    if not tmp1 in p:
        ans = tmp1
        break
    elif not tmp2 in p:
        ans = tmp2
        break

print(ans)

Fixed submission:
x , n = map(int , input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int , input().split()))

ans = x

for i in range(101):
    tmp1 = x - i
    tmp2 = x + i
    if not tmp1 in p:
        ans = tmp1
        break
    elif not tmp2 in p:
        ans = tmp2
        break

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

ans = 1

for i in range(n):
    ans *= A[i]

if ans > 10**18:
    print("-1")
elif 0 in A:
    print("0")
else:
    print(ans)

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

ans = 1

if 0 in A:
    print("0")
    exit()

for i in range(n):
    ans *= A[i]
    if ans > 10**18:
        print("-1")
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import collections

n = int(input())

if n == 1:
    print("0")
    exit()

ans = 0

factor = []
tmp = n
for i in range(2 , int(-(-n**0.5//1))+1):
    if tmp % i == 0:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp //= i
        factor.append([i , cnt])

if tmp != 1:
    factor.append([tmp , 1])
if factor == []:
    factor.append([n , 1])
        
s = collections.Counter(factor)


s = list(s.values())

for i in s:
    j = 1
    while True:
        i -= j
        if i < 0:
            break
        j += 1
        ans += 1

print(ans)

Fixed submission:
n = int(input())

if n == 1:
    print("0")
    exit()

ans = 0

factor = []
tmp = n
for i in range(2 , int(-(-n**0.5//1))+1):
    if tmp % i == 0:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp //= i
        factor.append(cnt)

if tmp != 1:
    factor.append(1)
if factor == []:
    factor.append(1)

for i in factor:
    j = 1
    while True:
        i -= j
        if i < 0:
            break
        j += 1
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a , b , n = map(int , input().split())

ans = 0

for i in range(1 , n+1):
    ans_p = (a*i//b) - a * (i//b)
    if ans_p >= ans:
        ans = ans_p

print(ans)

Fixed submission:
import math

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

if n < b:
    print(math.floor(a*n/b))
else:
    print(math.floor(a*(b-1)/b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
n_list = []
for i in range(1 , n+1):
    n_list.append(i)
    if i % 3 == 0 or i % 5 == 0:
        n_list.remove(i)
print(sum(n_list))

Fixed submission:
n = int(input())
ans = 0
for i in range(1 , n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n , m = map(int , input().split())
print(cmb(n , 2) + cmb(m , 2))

Fixed submission:
n , m = map(int , input().split())
print(int(n*(n-1)/2 + m*(m-1)/2))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n , m = map(int , input().split())
print(comb(n , 2 , exact = True) + comb(m , 2 , exact = True))

Fixed submission:
n , m = map(int , input().split())
print(int(n*(n-1)/2 + m*(m-1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
n , a , b = map(int , input().split())
s = []
while n > len(s):
    for i in range(a):
        s.append("a")
    for i in range(b):
        s.append("b")
del s[n::]
print(s.count("a"))

Fixed submission:
n , a , b = map(int , input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a , rem)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(S)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Fixed submission:
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(s)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = []

for i in range(len(s)-2): #1桁目
    for j in range(i+1 , len(s)-1): #2桁目
        for k in range(j+1 , len(s)): #3桁目
            ans.append(s[i]+s[j]+s[k])

print(len(set(ans)))

Fixed submission:
n = int(input())
s = input()

ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(n):
        if s[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
    if t_index == 3:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = []

for i in range(len(s)-2): #1桁目
    for j in range(i+1 , len(s)-1): #2桁目
        for k in range(j+1 , len(s)): #3桁目
            ans.append(s[i]+s[j]+s[k])

print(len(set(ans)))

Fixed submission:
n = int(input())
s = input()

ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(n):
        if s[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
    if t_index == 3:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n , m = map(int , input().split())

k = []
s = []
ans = 0

for _ in range(m):
    a = list(map(int , input().split()))
    k.append(a[0])
    s.append(a[1:])

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

for bit in range(1<<n):
    for i in range(m):
        cnt = 0
        for sw in s[i]:
            if bit & 1<<(sw-1):
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:
        res += 1

print(res)

Fixed submission:
n , m = map(int , input().split())

k = []
s = []
ans = 0

for _ in range(m):
    a = list(map(int , input().split()))
    k.append(a[0])
    s.append(a[1:])

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

for bit in range(1<<n):
    for i in range(m):
        cnt = 0
        for sw in s[i]:
            if bit & 1<<(sw-1):
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k , s = map(int , input().split())

ans = 0

for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k == s:
                ans += 1
                
print(ans)

Fixed submission:
k , s = map(int , input().split())

ans = 0

for i in range(k+1):
    for j in range(k+1):
            if 0 <= s-i-j <= k:
                ans += 1
                
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
MOD = 998244353

def fn(n, m):
  return (m*pow(m-1, n-1, MOD))%MOD

def nCr(n, r):
    fac = 1
    finv = 1
    for i in range(r):
        fac *= n-i
        fac %= MOD
        finv *= i+1
        finv %= MOD
    return fac * pow(finv, MOD-2, MOD) % MOD

ans = fn(n, m)
for i in range(1, k+1):
  ans += nCr(n-1,i)*fn(n-i, m)
  ans %= MOD
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
MOD = 998244353

def fn(n, m):
  return (m*pow(m-1, n-1, MOD))%MOD

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, n):
  fact.append((fact[-1]*i) % MOD)
  inv.append((-inv[MOD % i] * (MOD // i) % MOD))
  factinv.append((factinv[-1] * inv[-1]) % MOD)
  
def nCr(n, r):
    return fact[n] * factinv[r] * factinv[n-r] % MOD

ans = fn(n, m)
for i in range(1, k+1):
  ans += nCr(n-1, i)*fn(n-i, m)
  ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
b = np.array([i for i in range(1, n+1)])

ans = 0
for i in range(n-1):
  ans += ((a[i+1:] + a[i]) == b[:n-1-i]).sum()
print(ans)

Fixed submission:
n = int(input())
alist = list(map(int, input().split()))

ans = 0
dic = {}
for i, a in enumerate(alist):
  if dic.get(str(i-a)) is not None:
    ans += dic[str(i-a)]
  if dic.get(str(i+a)) is not None:
    dic[str(i+a)] += 1
  else:
    dic[str(i+a)] = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, u, v = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
#print(tree)

def calc_dist(dlist, n, dist, nnode):
  for c in tree[n]:
    if c == nnode:
      continue
    dlist[c] = dist
    calc_dist(dlist, c, dist+1, n)
    
u_dist_list = [0] * N
calc_dist(u_dist_list, u-1, 1, -1)
#print(u_dist_list)

v_dist_list = [0] * N
calc_dist(v_dist_list, v-1, 1, -1)
#print(v_dist_list)

ans = 0
for i in range(N):
  if (v_dist_list[i] - u_dist_list[i]) > 0 and v_dist_list[i] > ans:
    ans = v_dist_list[i] - 1
    
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

N, u, v = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
#print(tree)

def calc_dist(dlist, n, dist, nnode):
  for c in tree[n]:
    if c == nnode:
      continue
    dlist[c] = dist
    calc_dist(dlist, c, dist+1, n)
    
u_dist_list = [0] * N
calc_dist(u_dist_list, u-1, 1, -1)
#print(u_dist_list)

v_dist_list = [0] * N
calc_dist(v_dist_list, v-1, 1, -1)
#print(v_dist_list)

ans = 0
for i in range(N):
  if (v_dist_list[i] - u_dist_list[i]) > 0 and v_dist_list[i] > ans:
    ans = v_dist_list[i] - 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()

#print(data)

dp = [0] * T
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    eatable = dp[:T-a]
    j = 0
    for i in range(a, T, 1):
      if dp[i] < eatable[j] + b:
        dp[i] = eatable[j] + b
      j += 1
print(ans)

Fixed submission:
import numpy as np

N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()
data = np.array(data)

#print(data)

dp = np.zeros(T)
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    newtable = dp[:T-a] + b
    dp[a:] = np.maximum(dp[a:], newtable)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()

#print(data)

dp = [0] * T
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    eatable = dp[:T-a]
    j = 0
    maxj = len(eatable)
    for i in range(a, T, 1):
      if dp[i] < eatable[j] + b:
        dp[i] = eatable[j] + b
      if not j==maxj:
        j += 1
print(ans)

Fixed submission:
import numpy as np

N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()
data = np.array(data)

#print(data)

dp = np.zeros(T)
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    newtable = dp[:T-a] + b
    dp[a:] = np.maximum(dp[a:], newtable)
print(int(ans))