Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect
def dfs(i,LIS):
    print(i)
    if a[i] > LIS[-1]:
        LIS.append(a[i])
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS.pop()
    else:
        index = bisect.bisect_left(LIS, a[i])
        x = LIS[index]
        LIS[index] = a[i]
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS[index] = x

N = int(input())
a = [0]+list(map(int,input().split()))
edges = [[] for _  in range(N+1)]
ans = [-1]*(N+1)
parent = [-1]*(N+1)
for i in range(N-1):
    u,v = map(int,input().split())
    edges[u].append(v)
    edges[v].append(u)
LIS = [a[1]]
dfs(1,LIS)
for i in ans[1:]:
    print(i)

Fixed submission:
import bisect
import sys
sys.setrecursionlimit(1<<30)
def dfs(i,LIS):
    if a[i] > LIS[-1]:
        LIS.append(a[i])
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS.pop()
    else:
        index = bisect.bisect_left(LIS, a[i])
        x = LIS[index]
        LIS[index] = a[i]
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS[index] = x

N = int(input())
a = [0]+list(map(int,input().split()))
edges = [[] for _  in range(N+1)]
ans = [-1]*(N+1)
parent = [-1]*(N+1)
for i in range(N-1):
    u,v = map(int,input().split())
    edges[u].append(v)
    edges[v].append(u)
LIS = [a[1]]
dfs(1,LIS)
for i in ans[1:]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b
for i in range(1,(n+1)//2):
    j = 0
    while j + 2*i <= n-1:
        if len(set(s[j]+s[j+i]+s[j+2*i])) == 3:
            ans -= 1
        j += 1
print(ans)

Fixed submission:
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b
for i in range(1,(n+1)//2):
    j = 0
    while j + 2*i <= n-1:
        if s[j] != s[j+i] and s[j] != s[j+2*i] and s[j+i] != s[j+2*i]:
            ans -= 1
        j += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int,input().split()))
ans = -1000000000000000
dp = [{} for _ in range(n)]
dp[0][1] = s[0]
dp[1][1] = s[1]
dp[2][1] = s[2]
for i in range(n):
    for x in dp[i].keys():
        y = dp[i][x]
        if x == n//2:
            ans = max(ans,y)
        else:
            if (n-(i+2)+1)//2 >= n//2-(x+1) and i+2 <= n-1:
                if x+1 in dp[i+2].keys():
                    dp[i+2][x+1] = max(dp[i+2][x+1],dp[i][x] + s[i+2])
                else:
                    dp[i+2][x+1] = dp[i][x] + s[i+2]
            if (n-(i+3)+1)//2 >= n//2-(x+1) and i+3 <= n-1:
                if x+1 in dp[i+3].keys():
                    dp[i+3][x+1] = max(dp[i+3][x+1],dp[i][x] + s[i+3])
                else:
                    dp[i+3][x+1] = dp[i][x] + s[i+3]
            if (n-(i+4)+1)//2 >= n//2-(x+1) and i+4 <= n-1:
                if x+1 in dp[i+4].keys():
                    dp[i+4][x+1] = max(dp[i+4][x+1],dp[i][x]+s[i+4])
                else:
                    dp[i+4][x+1] = dp[i][x]+s[i+4]
print(ans)


Fixed submission:
n = int(input())
s = list(map(int,input().split()))
ans = -1000000000000000
dp = [{} for _ in range(n)]
dp[0][1] = s[0]
dp[1][1] = s[1]
if n >= 3:
    dp[2][1] = s[2]
for i in range(n):
    for x in dp[i].keys():
        y = dp[i][x]
        if x == n//2:
            ans = max(ans,y)
        else:
            if (n-(i+2)+1)//2 >= n//2-(x+1) and i+2 <= n-1:
                if x+1 in dp[i+2].keys():
                    dp[i+2][x+1] = max(dp[i+2][x+1],dp[i][x] + s[i+2])
                else:
                    dp[i+2][x+1] = dp[i][x] + s[i+2]
            if (n-(i+3)+1)//2 >= n//2-(x+1) and i+3 <= n-1:
                if x+1 in dp[i+3].keys():
                    dp[i+3][x+1] = max(dp[i+3][x+1],dp[i][x] + s[i+3])
                else:
                    dp[i+3][x+1] = dp[i][x] + s[i+3]
            if (n-(i+4)+1)//2 >= n//2-(x+1) and i+4 <= n-1:
                if x+1 in dp[i+4].keys():
                    dp[i+4][x+1] = max(dp[i+4][x+1],dp[i][x]+s[i+4])
                else:
                    dp[i+4][x+1] = dp[i][x]+s[i+4]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(lambda x:int(x)-1,input()))
ans = 0
for i in range(n):
    if (n-1) & i == i:
        ans += a[i]
if ans % 2 == 1:
    print(1)
else:
    if a.count(1) != 0:
        print(0)
    else:
        ans = 0
        b = map(lambda x:x//2,a)
        for i in range(n):
            if (n-1) & i == i:
                ans += b[i]
        if ans % 2 == 1:
            print(2)
        else:
            print(0)

Fixed submission:
n = int(input())
a = list(map(lambda x:int(x)-1,input()))
ans = 0
for i in range(n):
    if (n-1) & i == i:
        ans += a[i]
if ans % 2 == 1:
    print(1)
else:
    if a.count(1) != 0:
        print(0)
    else:
        ans = 0
        b = list(map(lambda x:x//2,a))
        for i in range(n):
            if (n-1) & i == i:
                ans += b[i]
        if ans % 2 == 1:
            print(2)
        else:
            print(0)
Buggy python submission (verdict: Runtime Error):
n,p = map(int,input().split())
s = list(map(int,(list(input()))))

def keychange(dic,x):
    newdic = {}
    for k in dic:
        b = (k*10 + x) % p
        newdic[b] = dic[k]
    return newdic
dic = {}
count = 0
for i in range(n):
    x = s[i] % p
    dic = keychange(dic,x)
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1
    if 0 in dic:
        count += dic[0]
print(count)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
q = int(input())
for i in range(q):
    x = list(input().split())
    if x [0] == '1':
        s.reverse()
    else:
        if x[1] == '1':
            s.appendleft(x[2])
        else:
            s.append(x[2])
print("".join(s))

Fixed submission:
from collections import deque
s = deque(input())
q = int(input())
rev= 0
for i in range(q):
    x = list(input().split())
    if x [0] == '1':
        rev += 1
    else:
        if x[1] == '1':
            if rev % 2 == 0:
                s.appendleft(x[2])
            else:
                s.append(x[2])
        else:
            if rev % 2 == 0:
                s.append(x[2])
            else:
                s.appendleft(x[2])
if rev % 2 == 1:
    s.reverse()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
s = list(map(int,(list(input()))))

def keychange(dic,x):
    newdic = {}
    for k in dic:
        b = (k*10 + x) % p
        newdic[b] = dic[k]
    return newdic
dic = {}
count = 0
for i in range(n):
    x = s[i] % p
    dic = keychange(dic,x)
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1
    if 0 in dic:
        count += dic[0]
print(count)

Fixed submission:
n,p = map(int,input().split())
s = list(map(int,(list(input()))))
def keychange(dic,x):
    newdic = {}
    for k in dic:
        b = (k*10 + x) % p
        newdic[b] = dic[k]
    return newdic
count = 0
if p == 2:
    for i in range(n):
        if s[i] % 2 == 0:
            count += i+1
    print(count)
    exit()
if p == 5:
    for i in range(n):
        if s[i] % 5 == 0:
            count += i+1
    print(count)
    exit()
inv_t = [0]+[1]
for i in range(2,p):
  inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
dic = {}
memory = [1,0]
for i in range(n):
    x = s[i] % p
    memory[0] = 10*memory[0] % p
    memory[1] = (10*memory[1] + x) % p
    xinv = inv_t[memory[0]]*(x-memory[1]+p) % p
    if xinv in dic:
        dic[xinv] += 1
    else:
        dic[xinv] = 1
    zeroinv = (p-memory[1])*inv_t[memory[0]] % p
    if zeroinv in dic:
        count += dic[zeroinv]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
q = int(input())
for i in range(q):
    a,b,c = input().split()
    if a == '1':
        s[int(b)-1] = c
    else:
        b = int(b)
        c = int(c)
        print(len(set(s[b-1:c])))

Fixed submission:
def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2]
def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2
n = int(input())
s = input()
q = int(input())
d = 1
while d < n:
    d *= 2
seg = [0]*(2*d-1)
for i in range(n):
    update(i,s[i])
for i in range(q):
    type,a,b = input().split()
    if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1"))
Buggy python submission (verdict: Runtime Error):
n = int(input())
r = int(input())
if n > 9:
  print(r)
else:
  print(r+100*(10-n))

Fixed submission:
n,r = map(int,(input().split()))
if n > 9:
  print(r)
else:
  print(r+100*(10-n))
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i range(0,101):
  m_energy = 0
  for k range(n):
    m_energy += (x[k]-1)**2
  if energy < m_energy:
    m_energy = energy
print(minenergy)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(0,101):
  energy = 0
  for k range(n):
    energy += (x[k]-1)**2
  if energy < min_energy:
    min_energy = energy
print(min_energy)


Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    cons = (i+1-x[k])*(i+1-x[k])
    energy += cons
  if energy < min_energy:
    min_energy = energy
print(min_energy)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-x[k])*(i+1-x[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-x[k])*(i+1-x[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-p[k])(i+1-p[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
  if a[i] % 2 == 0 and a[i] % 3 != 0 and [i] % 5 != 0:
    print("DENIED")
    exit()
print("APPROVED")

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      
      print('DENIED')
      exit()
print('APPROVED')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = []
ans = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
for i in range(n):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i]) 

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
length = 0
word_list = []
for i in range(n):
  word = input()
  if len(word) > length:
    word_list = [word]
  if len(word) = length:
    word_list.append(word)
word_list.sort()
for k in range(len(word_list)):
  print(word_list[k])

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
length = 0
word_list = []
for i in range(n):
  word = input()
  if len(word) > length:
    word_list = [word]
  if len(word) = length:
    word.append(word_list)
word_list.sort()
for k in range(len(word_list)):
  print(word_list[k])

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())
for i in range(n):
  for k in range(i+1,n):
    if a[i] == a[k]:
      print("NO")
      exit()
print("YES")

Fixed submission:
n = int(input())
a = list(input().split())
if n == len(list(set(a))):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
h,a = map(int,input().cplit())
print(h//a+1)

Fixed submission:
h,a = map(int,input().split())
if h % a == 0:
  print(h//a)
else:
  print(h//a+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
for i in range(min(n,k)):
  a.pop(0)
print(sum(a))

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
del a[:min(n,k)]
print(sum(a))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=true)
for i in range(min(n,k)):
  pop(0)
print(sum(a))

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
del a[:min(n,k)]
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
  if min(p[0:i+1]) == p[i]:
    count += 1
print(count)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
min = n+1
for i in range(n):
  if min > p[i]:
    count += 1
    min = p[i]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
  for k in range(i):
    if p[k]<p[i]:
      break
  else:
    count += 1
print(count)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
min = n+1
for i in range(n):
  if min > p[i]:
    count += 1
    min = p[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = 1
for i in range(n):
    l = l*a[i]//gcd(l,a[i])
for i in a:
    ans = (ans + l*pow(i,mod-2,mod)) % mod
print(ans)

Fixed submission:
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = 1
for i in a:
    l = l*i//gcd(l,i)
l %= mod
for i in a:
    ans = (ans +l*pow(i,mod-2,mod)) % mod
print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int(input().split())))
ans = 0
l = 1
for i in range(n):
    l = l*a[i]//gcd(l,a[i])
for i in a:
    ans = (ans + l*pow(i,mod-2,mod)) % mod
print(ans)

Fixed submission:
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = 1
for i in a:
    l = l*i//gcd(l,i)
l %= mod
for i in a:
    ans = (ans +l*pow(i,mod-2,mod)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
l = 1
ans = 0
for i in range(n):
    l = l*a[i]//gcd(l,a[i])
for i in range(n):
    ans = (ans + l//a[i]) % mod
print(ans)

Fixed submission:
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = 1
for i in a:
    l = l*i//gcd(l,i)
l %= mod
for i in a:
    ans = (ans +l*pow(i,mod-2,mod)) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ACcount = 0
WAcount = 0
WA = []
AC = []
for i in range(n):
  WA.append(0)
  AC.append(1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "WA":
    if WA[p-1] >= 0:
      WA[p-1] += 1
  if s == "AC":
    ACcount += AC[p-1]
    AC[p-1] = 0
    if WA[p-1] >= 0:
       WAcount += WA[p-1]
       WA[p-1] = -1
print(ACcount,WAcount)

Fixed submission:
l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = input()
for i in range(25):
  if s == l[i]:
    print(l[i+1])

Buggy python submission (verdict: Runtime Error):
l = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
s = input()
for i in range(25):
  if s == l[i]:
    print(l[i+1])

Fixed submission:
l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = input()
for i in range(25):
  if s == l[i]:
    print(l[i+1])

Buggy python submission (verdict: Runtime Error):
l = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
s = input()
for i in range(25):
  if s = l[i]:
    print(l[i+1])

Fixed submission:
l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = input()
for i in range(25):
  if s == l[i]:
    print(l[i+1])
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def lcm1(x,y):
    return (x*y)//math.gcd(x,y)
def lcm2(*numbers):
    return reduce(lcm1,numbers,1)
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2,input().split()))
l = lcm2(*a)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(((m // l) + 1) // 2)

Fixed submission:
import fractions
from functools import reduce
def lcm1(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm2(*numbers):
    return reduce(lcm1,numbers,1)
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2,input().split()))
l = lcm2(*a)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(((m // l) + 1) // 2)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if　k > a+b:
  print(0,0)
elif k > a:
  print(0,a+b-k)
else:
  print(a-k,b)

Fixed submission:
a,b,k = map(int,input().split())
if k > (a+b):
  print(0,0)
elif k > a:
    print(0,a+b-k)
else:
    print(a-k,b)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if k > a:
    print(0,a+b-k)
elif　k > a+b:
  print(0,0)
else:
print(a-k,b)

Fixed submission:
a,b,k = map(int,input().split())
if k > (a+b):
  print(0,0)
elif k > a:
    print(0,a+b-k)
else:
    print(a-k,b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
    print(0)
else:
    count = 0
    n //= 2
    while n > 0:
        n//= 5
        count += n
	print(count)
        

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    count = 0
    n //= 2
    while n > 0:
        n //= 5
        count += n
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1<<30)
def dfs(x,dis):
    for y in Tree[x]:
        if parent[x] != y:
            parent[y] = x
            dis[y] = dis[x]+1
            dfs(y,dis)

N,u,v = map(int,input().split())
Tree = [[] for _ in range(N+1)]
for i in range(N-1):
    A,B = map(int,input().split())
    Tree[A].append(B)
    Tree[B].append(A)
disT = [-1]*(N+1)
disA = [-1]*(N+1)
disT[u] = 0
disA[v] = 0
parent = [-1]*(N+1)
dfs(u,disT)
parent = [-1]*(N+1)
dfs(v,disA)
ans = 0
for i in range(1,N+1):
    if disT[i] <= disA[i]:
        ans = max(ans,disA[i]-1)
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(1<<30)
def dfs(x,dis):
    for y in Tree[x]:
        if parent[x] != y:
            parent[y] = x
            dis[y] = dis[x]+1
            dfs(y,dis)

N,u,v = map(int,input().split())
Tree = [[] for _ in range(N+1)]
for i in range(N-1):
    A,B = map(int,input().split())
    Tree[A].append(B)
    Tree[B].append(A)
disT = [-1]*(N+1)
disA = [-1]*(N+1)
disT[u] = 0
disA[v] = 0
parent = [-1]*(N+1)
dfs(u,disT)
parent = [-1]*(N+1)
dfs(v,disA)
ans = 0
for i in range(1,N+1):
    if disT[i] <= disA[i]:
        ans = max(ans,disA[i]-1)
print(ans)