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

Fixed submission:
import sys 
from functools import lru_cache
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
K = int(readline())
@lru_cache(None)
def f(N,K):
    if K == -1:
        return 0
    if N < 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0
    ans = 0
    q, mod = divmod(N, 10)
    ans += f(q,K) + mod * f(q,K-1) + (9-mod) * f(q-1,K-1) 
    return ans
print(f(N,K))

Buggy submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
K = int(readline())
@lru_cache(None)
def f(N,K):
    if K == -1:
        return 0
    if N < 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0
    ans = 0
    q, mod = divmod(N, 10)
    ans += f(q,K) + mod * f(q,K-1) + (9-mod) * f(q-1,K-1) 
    return ans
print(f(N,K))
Problem p02847 (python)

Fixed submission:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
SS = ['SUN','MON','TUE','WED','THU','FRI','SAT']
S = readline().decode().rstrip()
for i in range(7):
    if S == SS[i]:
        print(7-i)
        sys.exit()

Buggy submission (verdict: Runtime Error):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
N, W = map(int, readline().split())
SS = ['SUN','MON','TUE','WED','THU','FRI','SAT']
S = readline().decode().rstrip()
for i in range(7):
    if S == SS[i]:
        print(7-i)
        sys.exit()
Problem p02862 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10**9+7
X,Y = map(int,readline().split())
if X > Y:
    X,Y = Y,X
Z = X+Y
if Z % 3 == 0 and X <= Y <= 2*X:
    N = Z//3
    r = (N-(Y-X)) // 2
else:
    print(0)
    sys.exit()
f = [1]*(N+1)
for i in range(1,N+1):
    f[i] = i * f[i-1] % mod
a = pow(f[r],mod-2,mod)
b = pow(f[N-r],mod-2,mod)
ans = f[N] * a * b % mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10**9+7
X,Y = map(int,readline().split())
if X > Y:
    X,Y = Y,X
Z = X+Y
if Z % 3 == 0 and X <= Y <= 2*X:
    N = Z//3
    r = min(Y-X+1,N-Y+X-1)
else:
    print(0)
    sys.exit()
f = [1]*(N+1)
for i in range(1,N+1):
    f[i] = i * f[i-1] % mod
a = pow(f[r],mod-2,mod)
b = pow(f[N-r],mod-2,mod)
ans = f[N] * a * b % mod
print(ans)
Problem p03775 (python)

Fixed submission:
n = int(input())
ans = float('inf')
for i in range(1,int(n**0.5) + 1):
  if n % i == 0:
    ans = min(ans,len(str(n // i)))
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def make_divisors(n): #約数列挙の関数を一部改変
    lower_divisors , upper_divisors = [], [] 
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    if i == 1:
        return 1
    else:
        return upper_divisors[-1]

N = int(readline())
ans = make_divisors(N)
print(len(str(ans)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def make_divisors(n): #約数列挙の関数を一部改変
    lower_divisors , upper_divisors = [], [] 
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return upper_divisors[-1]

N = int(readline())
ans = make_divisors(N)
print(len(str(ans)))
Problem p02622 (python)

Fixed submission:
print(sum(a!=b for a,b in zip(input(),input())))

Buggy submission (verdict: Runtime Error):
print(sum(a!=b for a,b in zip(input(),input()))
Problem p02793 (python)

Fixed submission:
import sys
from fractions import gcd
from functools import reduce

MOD = 1000000007
lcm = lambda x, y: (x*y)//gcd(x,y)
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
l = reduce(lcm, a)
ans = 0
for x in a:
    ans += l//x
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
import sys
from math import gcd
from functools import reduce

MOD = 1000000007
lcm = lambda x, y: (x*y)//gcd(x,y)
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
l = reduce(lcm, a)
ans = 0
for x in a:
    ans += l//x
print(ans%MOD)
Problem p03315 (python)

Fixed submission:
s = input()
a = 0
for x in s:
    if x == '+':
        a += 1
    else:
        a -= 1

print(a)

Buggy submission (verdict: Runtime Error):
s = input()
a = 0
for x in s:
    if x == '+'
        a += 1
    else:
        a -= 1

print(a)
Problem p03617 (python)

Fixed submission:
q,h,s,d=map(int,input().split())
n=int(input())
a=min(q*4,h*2,s)
b=min(q*8,h*4,s*2,d)
print(min(a*n,a*(n%2)+b*(n//2)))

Buggy submission (verdict: Runtime Error):
q,h,s,d=map(int,input().split())
n=int(input())
a=min(q*4,h*2,s)
b=min(q*8,h*4,s*2,d)
print(min(a*n,a*(n%2)+b*(n//2))
Problem p03705 (python)

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a > b:
        print(0)
    else:
        print((b-a)*(n-2)+1)

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a > b:
        print(0)
    else:
        print((b-a)(n-2)+1)
Problem p02659 (python)

Fixed submission:
import math
import decimal

A, B = map(str, input().split())
A = int(A)
B = decimal.Decimal(B)
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(str, input().split())
A = int(A)
B = decimal.Decimal(B)
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
np.set_printoptions(suppress=True)

A, B = map(str, input().split())
A = int(A)
B = decimal.Decimal(B)
print(math.floor(A*B))
Problem p02682 (python)

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

total = 0
if K <= A:
    print(K)
else:
    total += A
    K = K - A
    if K <= B:
        print(total)
    else:
        K = K - B
        if K <= C:
            total -= K
            print(total)
        else:
            total -= C
            print(total)

Buggy submission (verdict: Runtime Error):
total = 0
if K < A:
    print(A)
else:
    total += A
    K = K - A
    if K < B:
        print(total)
    else:
        K = K - B
        if K < C:
            total -= K
            print(total)
        else:
            total -= C
            print(total)
Problem p02754 (python)

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

cnt_blue = 0
total_tmp = 0

try:
    pre_cnt = N // (A+B)
    total_tmp = pre_cnt * (A+B)
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  (pre_cnt * B)
    else:
        cnt_blue = (pre_cnt * A) + A
    print(cnt_blue)
except Exception as e:
    print(0)

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

cnt_blue = 0

# try:
pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
print(cnt_blue)
# except:
#     print(0)

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

cnt_blue = 0

# try:
pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
# print(cnt_blue)
# except:
#     print(0)

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
print(cnt_blue)

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
print(cnt_blue)

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
Problem p03631 (python)

Fixed submission:
x = input()
if x[0]==x[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x[0]==x[2]:
  print("Yes")
else:
  print("No")
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
print(len([z for x in range(k+1) for y in range(k+1) if 0<=s-x-y<=k]))

Buggy submission (verdict: Runtime Error):
s,k=map(int,input().split())
print(len([z for x in range(0,k+1) for y in range(0,k+1) if 0<=s-x-y<=k]))

Buggy submission (verdict: Runtime Error):
s,k=map(int,input().split())
print(len[z for x in range(0,k+1) for y in range(0,k+1) if 0<=s-x-y<=k])

Buggy submission (verdict: Runtime Error):
K,S = map(int,input().split())
import math
if K>=S:
  print(math.factorial(S+1))
else:
  count=0
  for i in range(0,K+1):
    for j in range(0,K+1):
      for h in range(0,K+1):
        if i+j+h==S:
          count+=1
print(count)
Problem p02915 (python)

Fixed submission:
N = int(input())
print(N**3)

Buggy submission (verdict: Runtime Error):
N = input()
print(N**3)
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N = map(int, input().split())
if N % 2 == 1:
   print((N+1)/2)
else:
    print(N/2)

Buggy submission (verdict: Runtime Error):
N=map(int, input().split())
if N % 2 == 1:
   print((N+1)/2)
else:
    print(N/2)
Problem p02753 (python)

Fixed submission:
d = list(input())

s = {i for i in d}

if len(s) == 1:
  print ("No")
else :
  print ("Yes")

Buggy submission (verdict: Runtime Error):
import math

i = [int(x) for x in input().split()]

ans = math.ceil((i[0]/ (i[2] + i[1])) ) * i[1]

print (ans)

Buggy submission (verdict: Runtime Error):
s = list(input())

d = { x for x in s}

if len(d) == 1:
  print ("NO")
else :
  print ('YES')
Problem p02754 (python)

Fixed submission:
N,A,B = map(int,input().split())
#Aが青
#Bが赤
i = N // (A+B)
b = i*A
t = N % (A+B)
if t > A:
   t = A
print(b+t)

Buggy submission (verdict: Runtime Error):
    N,A,B = map(int,input().split())
    #Aが青
    #Bが赤
    i = N // (A+B)
    b = i*A
    t = N % (A+B)

    if t > A:
        t = A

    print(b+t)
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
M=[]
for _i in range(3):
  M.append(list(map(int,input().split())))
n= int(input())
for a in range(n):
  b= int(input())
  for i in range(3):
    for j in range(3):
      if M[i][j]==b:
        M[i][j]=-1
oassiy= False
for i in range(3):
  cont=0
  for j in range(3):
    if M[i][j]==-1:
      cont+=1
  if cont==3:
    break
    oassiy=True

if not oassiy:
 for j in range(3):
  cont=0
  for i in range(3):
    if M[i][j]==-1:
      cont+=1
  if cont==3:
    break
    oassiy=True

if not oassiy:
  cont1 = cont2= 0
  for i in range(3):
    if M[i][i]==-1:
      cont1+=1
    if M[i][2-i]==-1:
      cont2+=1
if (cont1==3) or (cont2==3):
    oassiy=True

print('Yes' if oassiy else 'No')
Problem p02785 (python)

Fixed submission:
n,k = map(int,input().split())
H= list(map(int,input().split()))
if(k<n):
  H.sort()
  for i in range(k):
    H.pop()
  cont=0
  for i in range(len(H)):
    cont+= H[i]
  print(cont)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
H= list(map(int,input().split()))
H.sort()
for i in range(k):
  H.pop()
cont=0
for i in range(len(H)):
  while H[i]>0:
    H[i]-=1
    cont+=1
print(cont)
Problem p03250 (python)

Fixed submission:
A, B, C = sorted(map(int, input().split()))
print(10*C+B+A)

Buggy submission (verdict: Runtime Error):
A, B, C = sorted(map(int, input().split()))
print(10*c +a +b)
Problem p02766 (python)

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

num = 1

while N >= K:
  N = N//K 
  num = num + 1
  
print(num)

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

num = 1

if N<K:
  print(num)
else:
  N // K = N
  num = num + 1
Problem p02771 (python)

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

if A==B and B==C:
  print('No')
elif A != B and B != C and C != A:
  print('No')
else:
  print('Yes')

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

for i in li:
  if i%2 ==0:
    if i%3 != 0 and i%5 != 0:
      print('DENIED')
      break
    else:
      continue
  continue
  print('APPROVED')

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

for i in li:
  if i%2 ==0:
    if i%3 == 0 or i%5 == 0:
      a
    else:
      print('DENIED')
      break
  print('APPROVED')
Problem p02785 (python)

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

h.sort(reverse=True)

h = h[k:]

print(sum(h))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reversed=True)

h = h[k:]

print(sum(h))
Problem p03774 (python)

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

a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(M)]
d = [0 for i in range(M)]

for i in range(N):
    a[i],b[i] = map(int,input().split())

for i in range(M):
    c[i],d[i] = map(int,input().split())

for i in range(N):
    dist = []

    for j in range(M):
        tmp = abs(a[i]-c[j]) + abs(b[i]-d[j])
        dist.append(tmp)

    print(dist.index(min(dist)) + 1)

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

a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(M)]
d = [0 for i in range(M)]

for i in range(N):
    a[i],b[i] = map(int,input().split())

for i in range(M):
    c[i],d[i] = map(int,input().split())

for i in range(N):
    for j in range(M):
        dist = []
        tmp = abs(a[i]-c[i]) + abs(b[i]-d[i])
        dist.append(tmp)

    print(dist.index(min(dist)))
Problem p03804 (python)

Fixed submission:
import sys

N, M = (int(i) for i in input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    if B[0] in A[i]:
        pos = A[i].find(B[0])
        flag = 0
        for j in range(M):
            if A[i+j][pos:pos+M] == B[j]:
                pass
            else:
                flag = -1
                break
        if flag == 0:
            print("Yes")
            sys.exit()

print("No")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    if B[0] in A[i]:
        pos = A[i].find(B[j])
        flag = 0
        for j in range(M):
            if A[i+j][pos:pos+M] == B[j]:
                pass
            else:
                flag = -1
                break
        if flag = 0:
            print("Yes")

print("No")
Problem p02753 (python)

Fixed submission:
s = input()
if 'A' in s and "B" in s:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
tax1,tax2 = map(int,input().split())
tax_max1 = tax1+1 
if int(tax_max1%0.08) != 0:
    subtraction1 = int((tax_max1/0.08)) - math.ceil(tax1/0.08)
    store1 = []
    beggining1 = math.ceil(tax1/0.08)
    for num in range(subtraction1+1):
        price = beggining1 + num
        store1.append(price)
else:
    subtraction1 = int((tax_max1/0.08)-1) - math.ceil(tax1/0.08)
    store1 = []
    beggining1 = math.ceil(tax1/0.08)
    for num in range(subtraction1+1):
        price = beggining1 + num
        store1.append(price)
tax_max2 = tax2+1
subtraction2 = int((tax_max2/0.10)-1) - math.ceil(tax2/0.10)
store2 = []
beggining2 = math.ceil(tax2/0.10)
for num in range(subtraction2+1):
    price = beggining2 + num
    store2.append(price)
common = list(set(store1)&set(store2))
if len(common)>0:
    print(common[0])
else:
    print(-1)
Problem p02753 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Challenge A
"""

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Challenge A
"""

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input("give station: ")
print(i)
print(bus(i))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Challenge A
"""

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
Problem p02754 (python)

Fixed submission:
from math import floor

inp = input()
N, A, B = [int(x) for x in inp.split(" ")]

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)

Buggy submission (verdict: Runtime Error):
from math import floor

N = int(input())
A = int(input())
B = int(input())

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)
Problem p03011 (python)

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

calc_list = [P+Q, Q+R, R+P]

print(min(calc_list))

Buggy submission (verdict: Runtime Error):
L = input()
 
intL = int(L)
L10 = int(L, 2)
sum_ = 0
for a in range(L10+1):
  for b in range(L10+1):
    if ((a + b) <= L10) and ((a + b) == (a ^ b)):
      sum_+=1
 
print(sum_ % (10**9 + 7))
Problem p03041 (python)

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

s = s[:k-1] + s[k-1].lower() + s[k:]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = input()

s = s[:k] + s[k].lower() + s[k+1:]
print(s)
Problem p03835 (python)

Fixed submission:
import itertools

K, S = map(int, input().split())

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

count = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        if 0 <= (S - X - Y) and (S - X - Y) <= K:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import itertools

K, S = map(int, input().split())

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

ans = [[x,y] for x in range(2, K+1) for y in range(2, K+1) if (0<=(S-X-Y)) and ((S-X-Y)<=K)]
print(len(ans))
Problem p02915 (python)

Fixed submission:
a = int(input())
print(a ** 3)

Buggy submission (verdict: Runtime Error):
a = input()
print(a ** 3)
Problem p02753 (python)

Fixed submission:
def f():
    S = raw_input()
    return 'Yes' if len(set(S)) == 2 else 'No'

print(f())

Buggy submission (verdict: Runtime Error):
def f():
	S = input()
    for idx, s in enumerate(S):
      if s == 'A':
        a = 1
      if s == 'B':
        b = 1
      if a == 1 and b == 1:
        break
    return 'Yes' if a == 1 and b == 1 else 'No'
    
      
  
print(f())
Problem p02834 (python)

Fixed submission:
from collections import defaultdict

# def find_distances(edge_dict, node, distances):
#     for end in edge_dict[node]:
#         if distances[end] < 0:
#             distances[end] = distances[node] + 1
#             distances = find_distances(edge_dict, end, distances)

#     return distances


def find_distances(edge_dict, node, V):
    distances = [-1] * V
    stack = [(0, node)]

    while stack:
        dist, node = stack.pop()
        if distances[node] >= 0:
            continue

        distances[node] = dist
        for end in edge_dict[node]:
            stack.append((dist + 1, end))

    return distances

if __name__ == "__main__":
    V, T, A = map(int, input().split())
    T -= 1
    A -= 1
    edge_dict = defaultdict(list)

    for _ in range(V - 1):
        start, end = map(int, input().split())
        edge_dict[start - 1].append(end - 1)
        edge_dict[end - 1].append(start - 1)
    
    dist_T = [-1] * V
    dist_T[T] = 0
    dist_T = find_distances(edge_dict, T, V)

    dist_A = [-1] * V
    dist_A[A] = 0
    dist_A = find_distances(edge_dict, A, V)

    max_dist = 0
    for i in range(V):
        if dist_T[i] <= dist_A[i]:
            max_dist = max(max_dist, dist_A[i])
    
    print(max_dist - 1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict


def find_distances(edge_dict, node, distances):
    for end in edge_dict[node]:
        if distances[end] < 0:
            distances[end] = distances[node] + 1
            distances = find_distances(edge_dict, end, distances)

    return distances


if __name__ == "__main__":
    V, T, A = map(int, input().split())
    T -= 1
    A -= 1
    edge_dict = defaultdict(list)

    for _ in range(V - 1):
        start, end = map(int, input().split())
        edge_dict[start - 1].append(end - 1)
        edge_dict[end - 1].append(start - 1)
    
    dist_T = [-1] * V
    dist_T[T] = 0
    dist_T = find_distances(edge_dict, T, dist_T)

    dist_A = [-1] * V
    dist_A[A] = 0
    dist_A = find_distances(edge_dict, A, dist_A)

    max_dist = 0
    for i in range(V):
        if dist_T[i] <= dist_A[i]:
            max_dist = max(max_dist, dist_A[i])
    
    print(max_dist - 1)