Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03127 (python)

Fixed submission:
n = int(input())
list1 = list(map(int,input().split()))
import fractions as math
gcd = 10**9
for i in range(n-1):
    gcd = min(gcd,math.gcd(list1[i],list1[i+1]))
print(gcd)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
if n>=m:
  print(0)
  exit()
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)
Problem p03207 (python)

Fixed submission:
n = int(input())
list1 = [int(input()) for i in range(n) ]
list1.sort(reverse = True)
print(list1[0]//2+sum(list1[1:]))

Buggy submission (verdict: Runtime Error):
n = int(input())
list1 = [list(int(input())) for i in range(n) ]
list1.sort(reverse = True)
print(list1[0]//2+sum(list1[1:]))
Problem p03272 (python)

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

print(n-i+1)

Buggy submission (verdict: Runtime Error):
import bisect
n,k = map(int,input().split())
x = list(map(int,input().split()))
bindex = bisect.bisect_left(x,0)
mainasu = x[:bindex+1]

listr = []
for i in range(len(x)):
  if i == 0:
    listr.append(x[i])
    continue
  listr.append(listr[-1]+x[i])
ans = 10**9
for i in range(n-k+1):
  ans = min(ans,listr[i+k]-listr[i])

print(ans)

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

print(n-1+1)
Problem p03724 (python)

Fixed submission:
#AGC014-B Unplanned Queries
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
dic1 = defaultdict(int)
for i in range(m):
    a,b = map(int,readline().split())
    dic1[a] += 1
    dic1[b] += 1

for i in dic1.values():
    if not even(i):
        print("NO")
        exit()
print("YES")

Buggy submission (verdict: Runtime Error):
#AGC014-B Unplanned Queries
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
dic1 = defaultdict(int)
for i in range(n):
    a,b = map(int,readline().split())
    dic1[a] += 1
    dic1[b] += 1

for i in dic1.values():
    if not even(i):
        print("NO")
        exit()
print("YES")
Problem p02572 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
assert len(A) == N
total = 0
sum_A = sum(A)
for i,ai in enumerate(A):
  sum_A -= ai
  total += ai * sum_A
print(total % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
assert len(A) == N
total = 0
sumA = []
for i,ai in enumerate(A):
  sumA.append(sum(A[i+1]))

for i,ai in enumerate(A):
  total += ai * sumA[i]
print(total % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
total = 0
for i in range(1, N+1):
  for j in range(i, N+1):
    total += A[i] * A[j]
print(total)
Problem p02623 (python)

Fixed submission:
N , M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N): a.append(a[i] + A[i])
for i in range(M): b.append(b[i] + B[i])
ans,j=0,M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
N , M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N): a.append(a[i] + A[i])
for i in range(M): b.append(b[i] + B[i])
ans,j=0,0
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] <= K - a[i]:
    j += 1
  ans = max(ans, i+j-1)
print(ans)

Buggy submission (verdict: Runtime Error):
N , M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N): a.append(a[i] + A[i])
for i in range(M): b.append(b[i] + B[i])
ans,j=0,0
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] <= K - a[i]:
    j += 1
  ans = max(ans, i+j)
print(ans)
Problem p02659 (python)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(''.join([b for b in B if b != '.']))

print(A * B // 100)

Buggy submission (verdict: Runtime Error):
A, B = map(float, input().split())
import math

text = str(math.floor(A * B))
index = text.index('.')
if index >= 0:
  print(text[:index])
else:
  print(text)
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int, input().split())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
A = min(A, K)
B = min(K - A, B)
C = min(K - A - B, C)
assert A + B + C >= K
#print(A, B, C)
print(A - C)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
A = max(A, K)
B = max(K - A, B)
C = max(K - A - B, C)
assert A + B + C >= K
print(A - C)A, B, C, K = map(int, input().split())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
A = min(A, K)
B = min(K - A, B)
C = min(K - A - B, C)
assert A + B + C >= K
#print(A, B, C)
print(A - C)
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    sunukes[a-1] += 1
  assert len(A) == d
print(len([k for k in sunukes if k == 0]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    sunukes[a] += 1
  assert len(A) == d
print(len([k for k in sunukes if k == 0]))
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split())) #展望台iの標高
assert len(H) == N
paths = [[] for i in range(N)]
for m in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  paths[a].append(b)
  paths[b].append(a) # 展望台AからBへの道、その逆

count = 0
for a in range(N):
  for b in paths[a]:
    if H[b] >= H[a]:
      break
  else:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split())) #展望台iの標高
assert len(H) == N
paths = [[] for i in range(N)]
for m in range(M):
  a, b = map(int, input().split())
  paths[a].append(b)
  paths[b].append(a) # 展望台AからBへの道、その逆
assert len(A) == M

count = 0
for a in A:
  for b in paths[b]:
    if H[b] >= H[a]:
      break
  else:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split())) #展望台iの標高
assert len(H) == N
paths = [[] for i in range(N)]
for m in range(M)
  a, b = map(int, input().split())
  paths[a].append(b)
  paths[b].append(a) # 展望台AからBへの道、その逆
assert len(A) == M

def search(a, marks): #返り値: aから行ける展望台の高さの最大値
  peaks = []
  marks.append(a)
  for b in paths[a]:
    if b not in marks:
      peaks.append(search)
  marks.remove(a)
  if len(peaks):
    return max(H[a], max(peaks))
  return H[a]

count = 0
for a in A:
  if a == search(a, []):
    count += 1
print(count)
Problem p02707 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
assert len(A) == N - 1
count = [0 for i in range(N)]
for a in A:
  count[a-1] += 1
for n in range(N):
  print(count[n])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
assert len(A) == N - 1
count = [0 for i in range(len(A))]
for a in A:
  count[a] += 1
for n in range(N):
  print(count[n])
Problem p02547 (python)

Fixed submission:
n = int(input())
l=[]
for i in range(n):
  a,b = list(map(int,list(input().split())))
  l.append([a,b])
def fn(n,l):
  for i in range(n-2):
    if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]:
      return 'Yes'
  return 'No'  
print(fn(n,l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l=[]
for i in range(n):
  a,b = list(map(int,list(input().split())))
  l.append([a,b])
def fn(n,l):
  for i in range(n-2):
    if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] andl[i+2][0]==l[i+2][1]:
      return 'Yes'
  return 'No'  
print(fn(n,l))
Problem p02552 (python)

Fixed submission:
x = int(input())
print(x^1)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(x^1)

Buggy submission (verdict: Runtime Error):
x = int(input())
pint(x^1)

Buggy submission (verdict: Runtime Error):
x = int(input())
if x==1:
  print(0)
else:
  print(1
Problem p02753 (python)

Fixed submission:
Flag =  0 
S = input()
SA = [str(c) for c in S]
#A = list(['A','A','A'])
#B = list(['B','B','B'])
S1 = SA[0]
S2 = SA[1]
S3 = SA[2]
if(S1 == S2 == S3):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
Flag =  0 
S = input()
SA = [str(c) for c in S]
#A = list(['A','A','A'])
#B = list(['B','B','B'])
S1 = SA[1]
S2 = SA[2]
S3 = SA[3]
if(S1 == S2 == S3):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
Flag =  0 
after = ""
S = input().split()
A = list("A","A","A")
B = list("B","B","B")
if(set(S) == set(A) or set(S) ==set(B)):
    print("No")
else:
    print(print("Yes")

Buggy submission (verdict: Runtime Error):
Flag =  0 
after = ""
S = input().split()
if(all(S)):
    print("No")
else:
    print(print("Yes")
Problem p02759 (python)

Fixed submission:
N = input()
intN=int(N)
if intN%2 == 0:
    print(intN//2)
else:
    print(intN//2 +1)

Buggy submission (verdict: Runtime Error):
N = input()
if N%2 ==0:
  print(N/2)
else:
  print(N/2 + 1)

Buggy submission (verdict: Runtime Error):
N = input();
if N%2==0:
  print(N/2)
else:
  print(N/2 + 1)
Problem p02547 (python)

Fixed submission:
num = int(input())

count = 0
flag = False
for i in range(num):
    a,b = input().split()
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            flag = True
            break
    else:
        count = 0
if not flag:
    print("No")

Buggy submission (verdict: Runtime Error):
num = int(input())

count = 0
flag = False
for i in range(num):
    a,b = read().split()
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            flag = True
            break
    else:
        count = 0
if flag:
    print("No")

Buggy submission (verdict: Runtime Error):
num = int(input())

count = 0
for i in range(num):
    a,b = read().split()
    if a == b:
        count += 1
        if count >= 3:
            print(Yes)
            return()
    else:
        count = 0
print("No")
Problem p02594 (python)

Fixed submission:
import sys
for l in sys.stdin:
	if int(l) >= 30:
		print("Yes")
	else:
		print("No")

Buggy submission (verdict: Runtime Error):
import sys
a = int(sys.stdin)
if a >= 30:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
if input() >= 30:
  print("Yes")
else:
  print("Yes")
Problem p02771 (python)

Fixed submission:
import sys
 
if __name__ == '__main__':
  args = input().split()
  ret="No"
  if ((args[0] == args[1] or args[0] == args[2] or args[1] == args[2]) and (args[0] != args[1] or args[1] != args[2])):
    ret="Yes"
    
  print(ret)

Buggy submission (verdict: Runtime Error):
import sys
 
if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] or args[2] == args[3] or args[1] == args[3]):
    ret="Yes"
    
  print(ret)

Buggy submission (verdict: Runtime Error):
import sys
 
if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] | args[2] == args[3] | args[1] == args[3]):
    ret="Yes"
    
  print(ret)

Buggy submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] || args[2] == args[3] || args[1] == args[3]):
    ret="Yes"
    
  print(ret)
Problem p02793 (python)

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

#N = 10000
#A = [i*2+1 for i in range(1,N+1)]

MOD = 10**9+7

sm = 0
for x in A:
  sm += pow(x,MOD-2,MOD)
  sm %= MOD

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)
  #print(g)

an = g * sm % MOD

'''
for x in A:
  #print(g,g//x)
  an += g*pow(x,MOD-2,MOD)
  an %= MOD
  print(g,g//x,an)
'''

print(an)

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

import numpy as np

def gcd(x: int, y: int):
  if (y == 0):
    return x
  else:
    return gcd(y, x%y)

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  //print(g,g//x)
  an += g//x
  an %= MOD

print(an)
Problem p02629 (python)

Fixed submission:
n=int(input())
t=0
a=''
al='abcdefghijklmnopqrstuvwxyz'
b=[1]
c=[1]
for i in range(10):
  c.append(c[-1]*26)
  b.append(sum(c))
b.sort(reverse=True)
b.append(1)
c.sort(reverse=True)
c.append(1)
flg=0
i=0
while n>0:
  if flg ==1:
    if n >= b[i]:
      tmp=0
      while n >= b[i] and tmp <26:
        n -= c[i]
        tmp+=1
      a+=al[tmp-1]
      i+=1
    else:
      a+='a'
      i+=1
  elif n >= b[i]:
    flg=1
    tmp=0
    while n >= b[i] and tmp <26:
      n -= c[i]
      tmp+=1
    a+=al[tmp-1]
    i+=1
  else:
    i+=1
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
t=0
a=''
al='abcdefghijklmnopqrstuvwxyz'
b=[27]
c=[1]
for i in range(9):
  c.append(c[-1]*26)
  b.append(c[-1]+c[-1]*26)
c.append(c[-1]*26)
b.sort(reverse=True)
b.append(1)
b.append(1)
c.sort(reverse=True)
c.append(1)
flg=0
i=0
while n>0:
  if flg ==1:
    if n > b[i]:
      tmp=0
      while n >= b[i] and tmp <26:
        n -= c[i]
        tmp+=1
      a+=al[tmp-1]
      i+=1
    elif n!=0:
      a+='a'
      i+=1
  elif n > b[i]:
    flg=1
    tmp=0
    while n >= b[i] and tmp <26:
      n -= c[i]
      tmp+=1
    a+=al[tmp-1]
    i+=1
  else:
    i+=1
print(a)
Problem p02659 (python)

Fixed submission:
a,b=map(str,input().split())
b=b[0]+b[2]+b[3]
b=int(b)
a=int(a)*b
a//=100
print(int(a))

Buggy submission (verdict: Runtime Error):
a,b=map(str,input().split())
b=int(float(b)*100)
a=int(a)*b
a//=100
print(int(a))
Problem p02693 (python)

Fixed submission:
n = int(input())
a,b = map(int, input().split())
flg = 0
for i in range(10000):
  if n * i >= a and n * i <= b:
    flg = 1
if flg == 1:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b=map(int,input().split())
ans='NG'
for i in range(a,b+1):
  if i%k==0:
    ans='OK'
print(ans)
Problem p02873 (python)

Fixed submission:
s = input()
if s[0] == '>':
  a = [0]
else:
  a = []
flg = 1
for i in range(1,len(s)):
  if s[i] != s[i-1]:
    a.append(flg)
    flg = 1
  else:
    flg += 1
a.append(flg)
if s[-1] == '<':
  a.append(0)
ans = 0
for i in range(len(a)//2):
  if a[2*i] > a[2*i+1]:
    a[2*i+1] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
  else:
    a[2*i] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
if s[0] == '>':
  a = [0]
else:
  a = []
flg = 1
for i in range(1,len(s)):
  if s[i] != s[i-1]:
    a.append(flg)
    flg = 1
  else:
    flg += 1
if s[-1] != s[-2]:
  a.append(flg)
else:
  a.append(flg)
if s[-1] == '<':
  a.append(0)
ans = 0
for i in range(len(a)//2):
  if a[2*i] > a[2*i+1]:
    a[2*i+1] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
  else:
    a[2*i] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
print(ans)
Problem p02891 (python)

Fixed submission:
s=input()
n=int(input())
ans=0
tmp=1
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    tmp+=1
  else:
    ans+=tmp//2
    tmp=1
if tmp!=0:
  ans+=tmp//2
ans*=n
if len(s)!=1 and s[0]==s[-1]:
  top=0
  bottom=0
  for i in range(len(s)):
    if s[:i].count(s[0])==i:
      top=i
    if s[-i:].count(s[-1])==i:
      bottom=i
  if top!=len(s)-1:
    ans-=(top//2+bottom//2-(top+bottom)//2)*(n-1)
  elif len(s)%2==1:
    ans+=n//2
if len(s)==1:
  print(n//2)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
ans=0
flg=0
if len(s) == 1:
  print(-(-n//2))
else:
  for i in range(1,len(s)):
    if flg == 0 and s[i] == s[i-1]:
      flg = 1
    elif flg != 0 and s[i] == s[i-1]:
      flg += 1
    elif flg != 0:
      ans += -(-flg//2)
      flg = 0
ans += -(-flg//2)
ans *= n
if s[-1] != s[-2] and s[0] == s[-1]:
  ans += -(-n//2)
print(ans)
Problem p02762 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
uf = UnionFind(N)
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    uf.union(a[i]-1, b[i]-1)

ans = [uf.size(i) - 1 for i in range(N)]

for i in range(M):
    if uf.same(a[i]-1, b[i]-1):
        ans[a[i]-1] -= 1
        ans[b[i]-1] -= 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
uf = UnionFind(N)
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    uf.union(a[i]-1, b[i]-1)

ans = [uf.size(i) - 1 for i in range(N)]

for i in range(M):
    if uf.same(a[i]-1, b[i]-1):
        ans[a[i]-1] -= 1
        ans[b[i]-1] -= 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str, ans)))
Problem p02831 (python)

Fixed submission:
import math
A, B = map(int, input().split())



def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    if a % b == 0:
        return b
    else:
        return func(b, a % b)

# print(func(4, 6))
print(A*B//func(A,B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    elif a > b:
        return func(b, a-b)
    else:
        return a
      
# print(func(4, 6))
print(A*B//func(A,B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A,B))
Problem p02834 (python)

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

# In[21]:


N, u, v = map(int, input().split())
u = u - 1
v = v - 1


# In[22]:


eda = [[] for _ in range(N)]
for _ in range(N-1):
    A, B = map(int, input().split())
    eda[A-1].append(B-1)
    eda[B-1].append(A-1)


# In[25]:


par = [0] * N
# depth = [0] * N

stack = [v]
par[v] = -1

while stack:
    n1 = stack.pop()
    for n2 in eda[n1]:
        if n2 == par[n1]:
            continue
        par[n2] = n1
#         depth[n2] = depth[n1] + 1
        stack.append(n2)
        


# In[26]:


par


# In[27]:


dis = 0
n = u
while n != v:
    n = par[n]
    dis += 1


# In[28]:


n = u
for _ in range((dis - 1) // 2):
    n = par[n]


# In[29]:


y = (dis - 1) // 2
x = dis - y
# z = depth[n]


# In[38]:


stack = [n]
depth = [0] * N
maxd = 0

while stack:
    n1 = stack.pop()
    for n2 in eda[n1]:
        if n2 == par[n1]:
            continue
        depth[n2] = depth[n1] + 1
        maxd = max(maxd, depth[n2])
        stack.append(n2)
        


# In[41]:


z = maxd


# In[43]:


if dis % 2 == 0:
    print(y + z + 1)
else:
    print(y + z)


# In[ ]:

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

# In[1]:
import sys
sys.setrecursionlimit(10000)


N, u, v = map(int, input().split())
u = u - 1
v = v - 1


# In[2]:


eda = [[] for _ in range(N)]
for _ in range(N-1):
    A, B = map(int, input().split())
    eda[A-1].append(B-1)
    eda[B-1].append(A-1)


# In[3]:


eda


# In[ ]:





# In[4]:


def dfs(n1, n0):
    houmon[n1] = True
    par[n1] = n0
    for n2 in eda[n1]:
        if not houmon[n2]:
            dfs(n2, n1)
    


# In[5]:


houmon = [False] * N
par = [0] * N
dfs(v, v)


# In[6]:


par


# In[7]:


dis = 0
n = u
while n != v:
    n = par[n]
    dis += 1


# In[8]:


dis


# In[9]:


n = u
for _ in range((dis - 1) // 2):
    n = par[n]


# In[10]:


n


# In[11]:


def dfs2(n1):
    ret = 0
    for n2 in eda[n1]:
        if n2 == par[n1]:
            continue
        ret = max(ret, dfs2(n2) + 1)
    return ret


# In[12]:


y = (dis - 1) // 2
x = dis - y
z = dfs2(n)


# In[13]:


print(y + z + 1 if dis % 2 == 0 else y + z)

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

# In[1]:


N, u, v = map(int, input().split())
u = u - 1
v = v - 1


# In[2]:


eda = [[] for _ in range(N)]
for _ in range(N-1):
    A, B = map(int, input().split())
    eda[A-1].append(B-1)
    eda[B-1].append(A-1)


# In[3]:


eda


# In[ ]:





# In[4]:


def dfs(n1, n0):
    houmon[n1] = True
    par[n1] = n0
    for n2 in eda[n1]:
        if not houmon[n2]:
            dfs(n2, n1)
    


# In[5]:


houmon = [False] * N
par = [0] * N
dfs(v, v)


# In[6]:


par


# In[7]:


dis = 0
n = u
while n != v:
    n = par[n]
    dis += 1


# In[8]:


dis


# In[9]:


n = u
for _ in range((dis - 1) // 2):
    n = par[n]


# In[10]:


n


# In[11]:


def dfs2(n1):
    ret = 0
    for n2 in eda[n1]:
        if n2 == par[n1]:
            continue
        ret = max(ret, dfs2(n2) + 1)
    return ret


# In[12]:


y = (dis - 1) // 2
x = dis - y
z = dfs2(n)


# In[13]:


print(y + z + 1 if dis % 2 == 0 else y + z)
Problem p02659 (python)

Fixed submission:
import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])


f = str(A*B_f)
if (len(f) >= 3):
    f_i = int(f[:-2])
else:
    f_i = 0

print(A*B_i + f_i)

Buggy submission (verdict: Runtime Error):
import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])

print(A*B_i + int(str(A*B_f)[:-2]))
Problem p02682 (python)

Fixed submission:
A, B, C, K = list(map(int, input().split()))

if (A >= K):
    print(K * 1)
elif (A + B >= K):
    print(A)
else:
    print(A+(-1)*(K-A-B))

Buggy submission (verdict: Runtime Error):
A, B, C, K = list(map(int, input()))

if (A <= K):
    print(K)
elif (A + B <= K):
    print(A)
else:
    print(A+(-1)*(K-A-B))